update to dotclear 2.27
This commit is contained in:
parent
3dba5ba085
commit
14afb1acff
12 changed files with 95 additions and 144 deletions
|
@ -14,30 +14,25 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcAdmin;
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use dcFavorites;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Backend\Favorites;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* Improve admin class
|
||||
*
|
||||
* Add menu and dashboard icons, load Improve tasks.
|
||||
*/
|
||||
class Backend extends dcNsProcess
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->auth->isSuperAdmin();
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::BACKEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -45,23 +40,17 @@ class Backend extends dcNsProcess
|
|||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
My::name(),
|
||||
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
||||
dcPage::getPF(My::id() . '/icon.svg'),
|
||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||
dcCore::app()->auth->isSuperAdmin()
|
||||
);
|
||||
My::addBackendMenuItem();
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
|
||||
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
||||
$favs->register(
|
||||
My::id(),
|
||||
[
|
||||
'title' => My::name(),
|
||||
'url' => dcCore::app()->adminurl?->get('admin.plugin.' . My::id()),
|
||||
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||
'url' => My::manageUrl(),
|
||||
'small-icon' => My::icons(),
|
||||
'large-icon' => My::icons(),
|
||||
//'permissions' => null,
|
||||
]
|
||||
);
|
||||
|
|
|
@ -15,8 +15,8 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Backend\Notices;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
|
@ -34,19 +34,16 @@ use Exception;
|
|||
*
|
||||
* Set preference for this plugin.
|
||||
*/
|
||||
class Config extends dcNsProcess
|
||||
class Config extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->auth->isSuperAdmin();
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::CONFIG));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -54,7 +51,7 @@ class Config extends dcNsProcess
|
|||
return true;
|
||||
}
|
||||
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (is_null(dcCore::app()->blog) || !My::settings()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -63,14 +60,14 @@ class Config extends dcNsProcess
|
|||
if (!empty($_POST['disabled']) && is_array($_POST['disabled'])) {
|
||||
$pdisabled = implode(';', $_POST['disabled']);
|
||||
}
|
||||
dcCore::app()->blog->settings->get(My::id())->put('disabled', $pdisabled);
|
||||
dcCore::app()->blog->settings->get(My::id())->put('nodetails', !empty($_POST['nodetails']));
|
||||
dcCore::app()->blog->settings->get(My::id())->put('allow_distrib', !empty($_POST['allow_distrib']));
|
||||
dcCore::app()->blog->settings->get(My::id())->put('combosortby', $_POST['combosortby'] ?: 'name');
|
||||
My::settings()->put('disabled', $pdisabled);
|
||||
My::settings()->put('nodetails', !empty($_POST['nodetails']));
|
||||
My::settings()->put('allow_distrib', !empty($_POST['allow_distrib']));
|
||||
My::settings()->put('combosortby', $_POST['combosortby'] ?: 'name');
|
||||
|
||||
dcPage::addSuccessNotice(__('Configuration successfully updated'));
|
||||
Notices::addSuccessNotice(__('Configuration successfully updated'));
|
||||
|
||||
dcCore::app()->adminurl->redirect(
|
||||
dcCore::app()->admin->url->redirect(
|
||||
'admin.plugins',
|
||||
['module' => My::id(), 'conf' => 1, 'chk' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
||||
);
|
||||
|
@ -83,7 +80,7 @@ class Config extends dcNsProcess
|
|||
|
||||
public static function render(): void
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -91,8 +88,7 @@ class Config extends dcNsProcess
|
|||
return;
|
||||
}
|
||||
|
||||
$items = [];
|
||||
$settings = dcCore::app()->blog->settings->get(My::id());
|
||||
$items = [];
|
||||
|
||||
foreach (Improve::instance()->tasks->dump() as $task) {
|
||||
$items[] = (new Para())->items([
|
||||
|
@ -106,16 +102,16 @@ class Config extends dcNsProcess
|
|||
(new Fieldset())->class('fieldset')->legend(new Legend(__('List of disabled tasks')))->fields($items),
|
||||
(new Fieldset())->class('fieldset')->legend(new Legend(__('Options')))->fields([
|
||||
(new Para())->items([
|
||||
(new Checkbox('nodetails', (bool) $settings->get('nodetails')))->value('1'),
|
||||
(new Checkbox('nodetails', (bool) My::settings()?->get('nodetails')))->value('1'),
|
||||
(new Label(__('Hide details of rendered tasks'), Label::OUTSIDE_LABEL_AFTER))->class('classic')->for('nodetails'),
|
||||
]),
|
||||
(new Para())->items([
|
||||
(new Checkbox('allow_distrib', (bool) $settings->get('allow_distrib')))->value('1'),
|
||||
(new Checkbox('allow_distrib', (bool) My::settings()?->get('allow_distrib')))->value('1'),
|
||||
(new Label(__('Show dotclear distributed modules'), Label::OUTSIDE_LABEL_AFTER))->class('classic')->for('allow_distrib'),
|
||||
]),
|
||||
(new Para())->items([
|
||||
(new Label(__('Sort modules seletion by:'), Label::OUTSIDE_LABEL_BEFORE))->for('combosortby'),
|
||||
(new Select('combosortby'))->items([__('Name') => 'name', __('Id') => 'id'])->default($settings->get('combosortby')),
|
||||
(new Select('combosortby'))->items([__('Name') => 'name', __('Id') => 'id'])->default(My::settings()?->get('combosortby')),
|
||||
]),
|
||||
]),
|
||||
])->render();
|
||||
|
|
|
@ -14,7 +14,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use dcModuleDefine;
|
||||
use Dotclear\Helper\File\{
|
||||
Files,
|
||||
|
@ -50,7 +49,7 @@ class Improve
|
|||
$this->tasks = new Tasks();
|
||||
|
||||
// mark some tasks as disabled (by settings)
|
||||
$disable = explode(';', (string) dcCore::app()->blog?->settings->get(My::id())->get('disabled'));
|
||||
$disable = explode(';', (string) My::settings()?->get('disabled'));
|
||||
foreach ($disable as $id) {
|
||||
$this->tasks->get($id)?->disable();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Dotclear\Plugin\improve;
|
|||
|
||||
use dcCore;
|
||||
use dcNamespace;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
|
@ -25,7 +25,7 @@ use Exception;
|
|||
* Set default settings and version
|
||||
* and manage changes on updates.
|
||||
*/
|
||||
class Install extends dcNsProcess
|
||||
class Install extends Process
|
||||
{
|
||||
/** @var array Improve default settings */
|
||||
private static $default_settings = [[
|
||||
|
@ -37,15 +37,12 @@ class Install extends dcNsProcess
|
|||
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::INSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -65,7 +62,7 @@ class Install extends dcNsProcess
|
|||
private static function putSettings(): void
|
||||
{
|
||||
foreach (self::$default_settings as $v) {
|
||||
dcCore::app()->blog?->settings->get(My::id())->put(
|
||||
My::settings()?->put(
|
||||
$v[0],
|
||||
$v[2],
|
||||
$v[3],
|
||||
|
@ -79,11 +76,11 @@ class Install extends dcNsProcess
|
|||
/** Update improve < 0.8 : action modules settings name */
|
||||
private static function update_0_8_0(): void
|
||||
{
|
||||
if (!is_null(dcCore::app()->blog) && version_compare(dcCore::app()->getVersion(My::id()) ?? '0', '0.8', '<')) {
|
||||
foreach (dcCore::app()->blog->settings->get(My::id())->dumpGlobalSettings() as $id => $values) {
|
||||
if (!is_null(dcCore::app()->blog) && My::settings() && version_compare(dcCore::app()->getVersion(My::id()) ?? '0', '0.8', '<')) {
|
||||
foreach (My::settings()->dumpGlobalSettings() as $id => $values) {
|
||||
$newId = str_replace('ImproveAction', '', $id);
|
||||
if ($id != $newId) {
|
||||
dcCore::app()->blog->settings->get(My::id())->rename($id, strtolower($newId));
|
||||
My::settings()->rename($id, strtolower($newId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,10 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use dcAdminNotices;
|
||||
use dcThemes;
|
||||
use dcUtils;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Backend\Notices;
|
||||
use Dotclear\Core\Backend\Page;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
|
@ -32,6 +31,7 @@ use Dotclear\Helper\Html\Form\{
|
|||
Submit,
|
||||
Text
|
||||
};
|
||||
use Dotclear\Helper\Text as TText;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,7 @@ use Exception;
|
|||
* Display page and configure modules
|
||||
* and execute tasks.
|
||||
*/
|
||||
class Manage extends dcNsProcess
|
||||
class Manage extends Process
|
||||
{
|
||||
/** @var string $type Current module(s) type */
|
||||
private static string $type = 'plugin';
|
||||
|
@ -53,15 +53,12 @@ class Manage extends dcNsProcess
|
|||
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->auth->isSuperAdmin();
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::MANAGE));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -74,9 +71,9 @@ class Manage extends dcNsProcess
|
|||
|
||||
if (!empty($_POST['fix'])) {
|
||||
if (empty($_POST['actions'])) {
|
||||
dcAdminNotices::addWarningNotice(__('No tasks selected'));
|
||||
Notices::addWarningNotice(__('No tasks selected'));
|
||||
} elseif (self::$module == '-') {
|
||||
dcAdminNotices::addWarningNotice(__('No module selected'));
|
||||
Notices::addWarningNotice(__('No module selected'));
|
||||
} else {
|
||||
try {
|
||||
$time = Improve::instance()->fix(
|
||||
|
@ -87,15 +84,15 @@ class Manage extends dcNsProcess
|
|||
dcCore::app()->blog?->triggerBlog();
|
||||
|
||||
if (Improve::instance()->logs->has('error')) {
|
||||
$notice = ['type' => dcAdminNotices::NOTICE_ERROR, 'msg' => __('Fix of "%s" complete in %s secondes with errors')];
|
||||
$notice = ['type' => Notices::NOTICE_ERROR, 'msg' => __('Fix of "%s" complete in %s secondes with errors')];
|
||||
} elseif (Improve::instance()->logs->has('warning')) {
|
||||
$notice = ['type' => dcAdminNotices::NOTICE_WARNING, 'msg' => __('Fix of "%s" complete in %s secondes with warnings')];
|
||||
$notice = ['type' => Notices::NOTICE_WARNING, 'msg' => __('Fix of "%s" complete in %s secondes with warnings')];
|
||||
} elseif (Improve::instance()->logs->has('success')) {
|
||||
$notice = ['type' => dcAdminNotices::NOTICE_SUCCESS, 'msg' => __('Fix of "%s" complete in %s secondes')];
|
||||
$notice = ['type' => Notices::NOTICE_SUCCESS, 'msg' => __('Fix of "%s" complete in %s secondes')];
|
||||
} else {
|
||||
$notice = ['type' => dcAdminNotices::NOTICE_SUCCESS, 'msg' => __('Fix of "%s" complete in %s secondes without messages')];
|
||||
$notice = ['type' => Notices::NOTICE_SUCCESS, 'msg' => __('Fix of "%s" complete in %s secondes without messages')];
|
||||
}
|
||||
dcAdminNotices::addNotice($notice['type'], sprintf($notice['msg'], self::$module, $time));
|
||||
Notices::addNotice($notice['type'], sprintf($notice['msg'], self::$module, $time));
|
||||
|
||||
$done = true;
|
||||
} catch (Exception $e) {
|
||||
|
@ -106,7 +103,7 @@ class Manage extends dcNsProcess
|
|||
}
|
||||
|
||||
if ($done) {
|
||||
dcCore::app()->adminurl?->redirect('admin.plugin.' . My::id(), ['type' => self::$type, 'module' => self::$module, 'upd' => $log_id]);
|
||||
My::redirect(['type' => self::$type, 'module' => self::$module, 'upd' => $log_id]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -114,23 +111,23 @@ class Manage extends dcNsProcess
|
|||
|
||||
public static function render(): void
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
dcPage::openModule(
|
||||
Page::openModule(
|
||||
My::name(),
|
||||
dcPage::jsModuleLoad(My::id() . '/js/index.js') .
|
||||
My::jsLoad('index') .
|
||||
(self::$task === null ? '' : self::$task->header())
|
||||
);
|
||||
|
||||
echo
|
||||
dcPage::breadcrumb([
|
||||
Page::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
My::name() => '',
|
||||
empty($_REQUEST['config']) ? (self::$type == 'theme' ? __('Themes tasks') : __('Plugins tasks')) : __('Configure module') => '',
|
||||
]) .
|
||||
dcPage::notices();
|
||||
Notices::getNotices();
|
||||
|
||||
if (empty($_REQUEST['config'])) {
|
||||
self::displayActions();
|
||||
|
@ -138,19 +135,19 @@ class Manage extends dcNsProcess
|
|||
self::displayConfigurator();
|
||||
}
|
||||
|
||||
dcPage::closeModule();
|
||||
Page::closeModule();
|
||||
}
|
||||
|
||||
private static function displayConfigurator(): void
|
||||
{
|
||||
$back_url = $_REQUEST['redir'] ?? dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['type' => self::$type]);
|
||||
$back_url = $_REQUEST['redir'] ?? My::manageURL(['type' => self::$type]);
|
||||
|
||||
if (null === self::$task) {
|
||||
echo '
|
||||
<p class="warning">' . __('Unknow task') . '</p>
|
||||
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>';
|
||||
} else {
|
||||
$redir = $_REQUEST['redir'] ?? dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['type' => self::$type, 'config' => self::$task->properties->id]);
|
||||
$redir = $_REQUEST['redir'] ?? My::manageUrl(['type' => self::$type, 'config' => self::$task->properties->id]);
|
||||
$res = self::$task->configure($redir);
|
||||
|
||||
echo '
|
||||
|
@ -158,7 +155,7 @@ class Manage extends dcNsProcess
|
|||
<p><a class="back" href="' . $back_url . '">' . __('Back') . '</a></p>
|
||||
<h4>' . Html::escapeHTML(self::$task->properties->description) . '</h4>' .
|
||||
|
||||
(new Form('form-actions'))->method('post')->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))->fields([
|
||||
(new Form('form-actions'))->method('post')->action(My::manageUrl())->fields([
|
||||
empty($res) ? (new Text('p', __('Nothing to configure')))->class('message') : (new Text('', $res)),
|
||||
(new Para())->class('clear')->items([
|
||||
(new Submit(['save']))->value(__('Save')),
|
||||
|
@ -174,12 +171,13 @@ class Manage extends dcNsProcess
|
|||
private static function displayActions(): void
|
||||
{
|
||||
echo
|
||||
(new Form('improve_menu'))->method('get')->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))->fields([
|
||||
(new Form('improve_menu'))->method('get')->action(My::manageUrl())->fields([
|
||||
(new Para())->class('anchor-nav')->items([
|
||||
(new Label(__('Goto:'), Label::OUTSIDE_LABEL_BEFORE))->for('type')->class('classic'),
|
||||
(new Select('type'))->default(self::$type)->items([__('Plugins') => 'plugin', __('Themes') => 'theme']),
|
||||
(new Submit('simenu'))->value(__('Save')),
|
||||
(new Hidden('p', My::id())),
|
||||
(new Hidden('process', 'Plugin')),
|
||||
]),
|
||||
])->render();
|
||||
|
||||
|
@ -187,7 +185,7 @@ class Manage extends dcNsProcess
|
|||
if (count($combo_modules) == 1) {
|
||||
echo '<p class="message">' . __('No module to manage') . '</p>';
|
||||
} else {
|
||||
echo '<p /><form action="' . dcCore::app()->adminurl?->get('admin.plugin.' . My::id()) . '" method="post" id="form-actions">' .
|
||||
echo '<p /><form action="' . My::manageUrl() . '" method="post" id="form-actions">' .
|
||||
'<table><caption>' . __('List of available tasks') . '</caption><thead><tr>' .
|
||||
'<th colspan="2" class="first">' . __('Task') . '</td>' .
|
||||
'<th scope="col">' . __('Description') . '</td>' .
|
||||
|
@ -212,7 +210,7 @@ class Manage extends dcNsProcess
|
|||
'<td class="maximal">' . $task->properties->description . '</td>' .
|
||||
'<td class="minimal nowrap modules">' . (
|
||||
false === $task->properties->configurator ? '' :
|
||||
'<a class="module-config" href="' . dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['type' => self::$type, 'config' => $task->properties->id]) .
|
||||
'<a class="module-config" href="' . My::manageUrl(['type' => self::$type, 'config' => $task->properties->id]) .
|
||||
'" title="' . sprintf(__("Configure task '%s'"), $task->properties->name) . '">' . __('Configure') . '</a>'
|
||||
) . '</td>' .
|
||||
(DC_DEBUG ? '<td class="minimal"><span class="debug">' . $task->properties->priority . '</span></td>' : '') . /* @phpstan-ignore-line */
|
||||
|
@ -236,7 +234,7 @@ class Manage extends dcNsProcess
|
|||
'<br class="clear" />
|
||||
</form>';
|
||||
|
||||
if (!empty($_REQUEST['upd']) && !dcCore::app()->blog?->settings->get(My::id())->get('nodetails')) {
|
||||
if (!empty($_REQUEST['upd']) && !My::settings()?->get('nodetails')) {
|
||||
$logs = Improve::instance()->logs->parse((int) $_REQUEST['upd']);
|
||||
|
||||
if (!empty($logs)) {
|
||||
|
@ -289,7 +287,7 @@ class Manage extends dcNsProcess
|
|||
{
|
||||
try {
|
||||
if (!empty(self::$type)) {
|
||||
$preferences = dcCore::app()->blog?->settings->get(My::id())->get('preferences');
|
||||
$preferences = My::settings()?->get('preferences');
|
||||
if (is_string($preferences)) {
|
||||
$preferences = json_decode($preferences, true);
|
||||
if (is_array($preferences)) {
|
||||
|
@ -315,8 +313,8 @@ class Manage extends dcNsProcess
|
|||
}
|
||||
}
|
||||
}
|
||||
dcCore::app()->blog->settings->get(My::id())->put('preferences', json_encode($preferences), 'string', null, true, true);
|
||||
dcAdminNotices::addSuccessNotice(__('Configuration successfully updated'));
|
||||
My::settings()?->put('preferences', json_encode($preferences), 'string', null, true, true);
|
||||
Notices::addSuccessNotice(__('Configuration successfully updated'));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -337,16 +335,16 @@ class Manage extends dcNsProcess
|
|||
|
||||
$combo_modules = [];
|
||||
$modules = self::$type == 'plugin' ? dcCore::app()->plugins->getDefines() : dcCore::app()->themes->getDefines();
|
||||
if (dcCore::app()->blog->settings->get(My::id())->get('combosortby') == 'id') {
|
||||
if (My::settings()?->get('combosortby') === 'id') {
|
||||
uasort($modules, fn ($a, $b) => strtolower($a->getId()) <=> strtolower($b->getId()));
|
||||
} else {
|
||||
uasort($modules, fn ($a, $b) => strtolower(dcUtils::removeDiacritics($a->get('name'))) <=> strtolower(dcUtils::removeDiacritics($b->get('name'))));
|
||||
uasort($modules, fn ($a, $b) => strtolower(TText::removeDiacritics($a->get('name'))) <=> strtolower(TText::removeDiacritics($b->get('name'))));
|
||||
}
|
||||
foreach ($modules as $module) {
|
||||
if (!$module->get('root_writable') || !dcCore::app()->blog->settings->get(My::id())->get('allow_distrib') && $module->get('distributed')) {
|
||||
if (!$module->get('root_writable') || !My::settings()->get('allow_distrib') && $module->get('distributed')) {
|
||||
continue;
|
||||
}
|
||||
if (dcCore::app()->blog->settings->get(My::id())->get('combosortby') == 'id') {
|
||||
if (My::settings()->get('combosortby') === 'id') {
|
||||
$combo_modules[sprintf(__('%s (%s)'), $module->getId(), __($module->get('name')))] = $module->getId();
|
||||
} else {
|
||||
$combo_modules[sprintf(__('%s (%s)'), __($module->get('name')), $module->getId())] = $module->getId();
|
||||
|
|
|
@ -128,7 +128,7 @@ class Module
|
|||
}
|
||||
|
||||
/**
|
||||
* Replicate adminModulesList::sanitizeModule
|
||||
* Replicate ModulesList::sanitizeModule
|
||||
*
|
||||
* @param string $type Module type
|
||||
* @param string $id Module id
|
||||
|
@ -184,7 +184,7 @@ class Module
|
|||
}
|
||||
|
||||
/**
|
||||
* Replicate adminModulesList::sanitizeString
|
||||
* Replicate ModulesList::sanitizeString
|
||||
*
|
||||
* @param string $str String to sanitize
|
||||
*
|
||||
|
|
32
src/My.php
32
src/My.php
|
@ -15,35 +15,13 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
*/
|
||||
class My
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/**
|
||||
* This module id.
|
||||
*/
|
||||
public static function id(): string
|
||||
protected static function checkCustomContext(int $context): ?bool
|
||||
{
|
||||
return basename(dirname(__DIR__));
|
||||
}
|
||||
|
||||
/**
|
||||
* This module name.
|
||||
*/
|
||||
public static function name(): string
|
||||
{
|
||||
$name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
|
||||
|
||||
return __(is_string($name) ? $name : self::id());
|
||||
}
|
||||
|
||||
/**
|
||||
* This module path.
|
||||
*/
|
||||
public static function path(): string
|
||||
{
|
||||
return dirname(__DIR__);
|
||||
return defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->auth->isSuperAdmin();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,9 +182,7 @@ class CssHeader extends Task
|
|||
$this->bloc = (string) preg_replace_callback(
|
||||
// use \u in bloc content for first_upper_case
|
||||
'/(\\\u([a-z]{1}))/',
|
||||
function ($str) {
|
||||
return ucfirst($str[2]);
|
||||
},
|
||||
fn ($str) => ucfirst($str[2]),
|
||||
str_replace(
|
||||
$this->bloc_wildcards,
|
||||
[
|
||||
|
|
|
@ -15,7 +15,7 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\improve\Task;
|
||||
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use Dotclear\Core\Backend\Page;
|
||||
use Dotclear\Helper\File\Path;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Div,
|
||||
|
@ -76,7 +76,7 @@ class PhpCsFixer extends Task
|
|||
{
|
||||
$this->getPhpPath();
|
||||
|
||||
if (null !== dcCore::app()->auth?->user_prefs) {
|
||||
if (null !== dcCore::app()->auth->user_prefs) {
|
||||
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
||||
self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
||||
self::$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
||||
|
@ -93,7 +93,7 @@ class PhpCsFixer extends Task
|
|||
public function header(): ?string
|
||||
{
|
||||
if (self::$user_ui_colorsyntax) {
|
||||
return dcPage::jsLoadCodeMirror(self::$user_ui_colorsyntax_theme);
|
||||
return Page::jsLoadCodeMirror(self::$user_ui_colorsyntax_theme);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -127,8 +127,8 @@ class PhpCsFixer extends Task
|
|||
]),
|
||||
])->render() . (
|
||||
!self::$user_ui_colorsyntax ? '' :
|
||||
dcPage::jsModuleLoad(My::id() . '/src/Task/phpcsfixer/phpcsfixer.improve.js') .
|
||||
dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', self::$user_ui_colorsyntax_theme)
|
||||
My::jsLoad('/src/Task/phpcsfixer/phpcsfixer.improve.js') .
|
||||
Page::jsRunCodeMirror('editor', 'file_content', 'dotclear', self::$user_ui_colorsyntax_theme)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -181,9 +181,7 @@ class PhpHeader extends Task
|
|||
$this->bloc = (string) preg_replace_callback(
|
||||
// use \u in bloc content for first_upper_case
|
||||
'/(\\\u([a-z]{1}))/',
|
||||
function ($str) {
|
||||
return ucfirst($str[2]);
|
||||
},
|
||||
fn ($str) => ucfirst($str[2]),
|
||||
str_replace(
|
||||
$this->bloc_wildcards,
|
||||
[
|
||||
|
|
|
@ -15,7 +15,7 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\improve\Task;
|
||||
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use Dotclear\Core\Backend\Page;
|
||||
use Dotclear\Helper\File\Path;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
|
@ -79,7 +79,7 @@ class PhpStan extends Task
|
|||
$ignored_vars = $this->settings->get('ignored_vars');
|
||||
$this->ignored_vars = is_string($ignored_vars) ? $ignored_vars : '';
|
||||
|
||||
if (null !== dcCore::app()->auth?->user_prefs) {
|
||||
if (null !== dcCore::app()->auth->user_prefs) {
|
||||
dcCore::app()->auth->user_prefs->addWorkspace('interface');
|
||||
self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax');
|
||||
self::$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme');
|
||||
|
@ -96,7 +96,7 @@ class PhpStan extends Task
|
|||
public function header(): ?string
|
||||
{
|
||||
if (self::$user_ui_colorsyntax) {
|
||||
return dcPage::jsLoadCodeMirror(self::$user_ui_colorsyntax_theme);
|
||||
return Page::jsLoadCodeMirror(self::$user_ui_colorsyntax_theme);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -170,8 +170,8 @@ class PhpStan extends Task
|
|||
]),
|
||||
])->render() . (
|
||||
!self::$user_ui_colorsyntax ? '' :
|
||||
dcPage::jsModuleLoad(My::id() . '/src/Task/phpstan/phpstan.improve.js') .
|
||||
dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', self::$user_ui_colorsyntax_theme)
|
||||
Page::jsLoad('/src/Task/phpstan/phpstan.improve.js') .
|
||||
Page::jsRunCodeMirror('editor', 'file_content', 'dotclear', self::$user_ui_colorsyntax_theme)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,21 +15,19 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\improve;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
class Uninstall extends dcNsProcess
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::UNINSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue