diff --git a/CHANGELOG.md b/CHANGELOG.md
index ec9beb0..9aa6c15 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,11 @@ dev
- [ ] add module to create full README file
- [ ] write documentation of php class
+0.9 - 2022.11.12
+- update to Dotclear 2.24
+- update to php-cs-fixer.phar 3.13.0
+- update to phpstan.phar 1.9.2
+
0.8.2 - 2021.11.18
- update php-cs-fixer.phar to 3.3.2
- update phpstan.phar to 1.2.0
diff --git a/README.md b/README.md
index 539b637..3efddca 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/improve)](https://github.com/JcDenis/improve/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/improve)](https://github.com/JcDenis/improve/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/improve)](https://github.com/JcDenis/improve/issues)
-[![Dotclear](https://img.shields.io/badge/dotclear-v2.19-blue.svg)](https://fr.dotclear.org/download)
+[![Dotclear](https://img.shields.io/badge/dotclear-v2.24-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/improve)
[![License](https://img.shields.io/github/license/JcDenis/improve)](https://github.com/JcDenis/improve/blob/master/LICENSE)
@@ -23,7 +23,7 @@ It helps dev to clean up plugin or theme before publishing code.
**improve** requires:
* admin permission
- * Dotclear 2.19
+ * Dotclear 2.24
## USAGE
diff --git a/_admin.php b/_admin.php
index e3b9222..9067c78 100644
--- a/_admin.php
+++ b/_admin.php
@@ -19,16 +19,15 @@ if (!defined('DC_CONTEXT_ADMIN')) {
}
/* dotclear */
+use dcAdmin;
use dcCore;
use dcPage;
use dcFavorites;
/* clearbricks */
+use Clearbricks;
use files;
-/* php */
-use ArrayObject;
-
/**
* Improve admin class
*
@@ -36,54 +35,52 @@ use ArrayObject;
*/
class admin
{
- public static function process(dcCore $core, ArrayObject $_menu): void
+ public static function process(): void
{
- self::addSettingsNamespace($core);
- self::addAdminBehaviors($core);
- self::addAdminMenu($core, $_menu);
- self::addImproveActions($core);
+ self::addSettingsNamespace();
+ self::addAdminBehaviors();
+ self::addAdminMenu();
+ self::addImproveActions();
}
- private static function addSettingsNamespace(dcCore $core): void
+ private static function addSettingsNamespace(): void
{
- $core->blog->settings->addNamespace('improve');
+ dcCore::app()->blog->settings->addNamespace('improve');
}
- private static function addAdminBehaviors(dcCore $core): void
+ private static function addAdminBehaviors(): void
{
- $core->addBehavior('adminDashboardFavorites', __NAMESPACE__ . '\admin::adminDashboardFavorites');
+ dcCore::app()->addBehavior('adminDashboardFavoritesV2', __NAMESPACE__ . '\admin::adminDashboardFavorites');
}
- private static function addAdminMenu(dcCore $core, ArrayObject $_menu): void
+ private static function addAdminMenu(): void
{
- $_menu['Plugins']->addItem(
+ dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('improve'),
- $core->adminurl->get('admin.plugin.improve'),
+ dcCore::app()->adminurl->get('admin.plugin.improve'),
dcPage::getPF('improve/icon.png'),
- preg_match('/' . preg_quote($core->adminurl->get('admin.plugin.improve')) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
- $core->auth->isSuperAdmin()
+ preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.improve')) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
+ dcCore::app()->auth->isSuperAdmin()
);
}
- private static function addImproveActions(dcCore $core): void
+ private static function addImproveActions(): void
{
- global $__autoload;
-
foreach (files::scandir(prepend::getActionsDir()) as $file) {
if (is_file(prepend::getActionsDir() . $file) && '.php' == substr($file, -4)) {
- $__autoload[prepend::getActionsNS() . substr($file, 0, -4)] = prepend::getActionsDir() . $file;
- $core->addBehavior('improveAddAction', [prepend::getActionsNS() . substr($file, 0, -4), 'create']); /* @phpstan-ignore-line */
+ Clearbricks::lib()->autoload([prepend::getActionsNS() . substr($file, 0, -4) => prepend::getActionsDir() . $file]);
+ dcCore::app()->addBehavior('improveAddAction', [prepend::getActionsNS() . substr($file, 0, -4), 'create']); /* @phpstan-ignore-line */
}
}
}
- public static function adminDashboardFavorites(dcCore $core, dcFavorites $favs): void
+ public static function adminDashboardFavorites(dcFavorites $favs): void
{
$favs->register(
'improve',
[
'title' => __('improve'),
- 'url' => $core->adminurl->get('admin.plugin.improve'),
+ 'url' => dcCore::app()->adminurl->get('admin.plugin.improve'),
'small-icon' => dcPage::getPF('improve/icon.png'),
'large-icon' => dcPage::getPF('improve/icon-b.png'),
'permissions' => null,
@@ -93,4 +90,4 @@ class admin
}
/* process */
-admin::process($core, $_menu);
+admin::process();
diff --git a/_config.php b/_config.php
index 2a4afbd..8308853 100644
--- a/_config.php
+++ b/_config.php
@@ -20,7 +20,6 @@ if (!defined('DC_CONTEXT_ADMIN')) {
/* dotclear */
use dcCore;
-use adminModulesList;
use dcPage;
/* clearbricks */
@@ -36,20 +35,14 @@ use Exception;
*/
class config
{
- /** @var dcCore $core dcCore instance */
- private $core = null;
- /** @var adminModulesList $list adminModulesList instance */
- private $list = null;
/** @var improve $improve improve core instance */
private $improve = null;
- public function __construct(dcCore $core, adminModulesList $list)
+ public function __construct()
{
dcPage::checkSuper();
- $this->core = $core;
- $this->list = $list;
- $this->improve = new improve($core);
+ $this->improve = new improve();
$this->saveConfig();
$this->displayConfig();
@@ -77,17 +70,17 @@ class config
if (!empty($_POST['disabled']) && is_array($_POST['disabled'])) {
$pdisabled = implode(';', $_POST['disabled']);
}
- $this->core->blog->settings->improve->put('disabled', $pdisabled);
- $this->core->blog->settings->improve->put('nodetails', !empty($_POST['nodetails']));
+ dcCore::app()->blog->settings->improve->put('disabled', $pdisabled);
+ dcCore::app()->blog->settings->improve->put('nodetails', !empty($_POST['nodetails']));
dcPage::addSuccessNotice(__('Configuration successfully updated'));
- $this->core->adminurl->redirect(
+ dcCore::app()->adminurl->redirect(
'admin.plugins',
- ['module' => 'improve', 'conf' => 1, 'chk' => 1, 'redir' => $this->list->getRedir()]
+ ['module' => 'improve', 'conf' => 1, 'chk' => 1, 'redir' => dcCore::app()->admin->list->getRedir()]
);
} catch (Exception $e) {
- $this->core->error->add($e->getMessage());
+ dcCore::app()->error->add($e->getMessage());
}
}
@@ -104,11 +97,11 @@ class config
echo
'
' . __('Options') . '
' .
'
' .
'
';
}
}
/* process */
-new config($core, $list);
+new config();
diff --git a/_define.php b/_define.php
index fb03e39..57036dd 100644
--- a/_define.php
+++ b/_define.php
@@ -18,9 +18,9 @@ $this->registerModule(
'improve',
'Tiny tools to fix things for module devs',
'Jean-Christian Denis and contributors',
- '0.8.2',
+ '0.9',
[
- 'requires' => [['core', '2.19']],
+ 'requires' => [['core', '2.24']],
'permissions' => null,
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/improve',
diff --git a/_install.php b/_install.php
index 42b12ef..ffa62b8 100644
--- a/_install.php
+++ b/_install.php
@@ -34,7 +34,7 @@ use Exception;
class install
{
/** @var string Dotclear minimal version */
- private static $dotclear_version = '2.19';
+ private static $dotclear_version = '2.24';
/** @var array Improve default settings */
private static $default_settings = [[
'disabled',
@@ -43,12 +43,12 @@ class install
'string',
]];
- public static function process(dcCore $core): ?bool
+ public static function process(): ?bool
{
- if (!self::checkModuleVersion($core)) {
+ if (!self::checkModuleVersion()) {
return null;
}
- if (!self::checkDotclearVersion($core)) {
+ if (!self::checkDotclearVersion()) {
throw new Exception(sprintf(
'%s requires Dotclear %s',
'improve',
@@ -56,40 +56,40 @@ class install
));
}
- $core->blog->settings->addNamespace('improve');
- self::update_0_8_0($core);
- self::putSettings($core);
- self::setVersion($core);
+ dcCore::app()->blog->settings->addNamespace('improve');
+ self::update_0_8_0();
+ self::putSettings();
+ self::setVersion();
return true;
}
- private static function getInstalledVersion(dcCore $core): string
+ private static function getInstalledVersion(): string
{
- $version = $core->getVersion('improve');
+ $version = dcCore::app()->getVersion('improve');
return is_string($version) ? $version : '0';
}
- private static function checkModuleVersion(dcCore $core): bool
+ private static function checkModuleVersion(): bool
{
return version_compare(
- self::getInstalledVersion($core),
- $core->plugins->moduleInfo('improve', 'version'),
+ self::getInstalledVersion(),
+ dcCore::app()->plugins->moduleInfo('improve', 'version'),
'<'
);
}
- private static function checkDotclearVersion(dcCore $core): bool
+ private static function checkDotclearVersion(): bool
{
return method_exists('dcUtils', 'versionsCompare')
&& dcUtils::versionsCompare(DC_VERSION, self::$dotclear_version, '>=', false);
}
- private static function putSettings(dcCore $core): void
+ private static function putSettings(): void
{
foreach (self::$default_settings as $v) {
- $core->blog->settings->improve->put(
+ dcCore::app()->blog->settings->improve->put(
$v[0],
$v[2],
$v[3],
@@ -100,19 +100,19 @@ class install
}
}
- private static function setVersion(dcCore $core): void
+ private static function setVersion(): void
{
- $core->setVersion('improve', $core->plugins->moduleInfo('improve', 'version'));
+ dcCore::app()->setVersion('improve', dcCore::app()->plugins->moduleInfo('improve', 'version'));
}
/** Update improve < 0.8 : action modules settings name */
- private static function update_0_8_0(dcCore $core): void
+ private static function update_0_8_0(): void
{
- if (version_compare(self::getInstalledVersion($core), '0.8', '<')) {
- foreach ($core->blog->settings->improve->dumpGlobalSettings() as $id => $values) {
+ if (version_compare(self::getInstalledVersion(), '0.8', '<')) {
+ foreach (dcCore::app()->blog->settings->improve->dumpGlobalSettings() as $id => $values) {
$newId = str_replace('ImproveAction', '', $id);
if ($id != $newId) {
- $core->blog->settings->improve->rename($id, strtolower($newId));
+ dcCore::app()->blog->settings->improve->rename($id, strtolower($newId));
}
}
}
@@ -121,7 +121,7 @@ class install
/* process */
try {
- return install::process($core);
+ return install::process();
} catch (Exception $e) {
$core->error->add($e->getMessage());
diff --git a/_prepend.php b/_prepend.php
index ab40098..d559923 100644
--- a/_prepend.php
+++ b/_prepend.php
@@ -14,6 +14,8 @@ declare(strict_types=1);
namespace plugins\improve;
+use Clearbricks;
+
if (!defined('DC_RC_PATH') || !defined('DC_CONTEXT_ADMIN')) {
return;
}
@@ -25,16 +27,16 @@ if (!defined('DC_RC_PATH') || !defined('DC_CONTEXT_ADMIN')) {
*/
class prepend
{
- public static function process(array &$__autoload): void
+ public static function process(): void
{
foreach (['improve', 'action', 'module'] as $class) {
- $__autoload['plugins\\improve\\' . $class] = dirname(__FILE__) . '/inc/core/' . $class . '.php';
+ Clearbricks::lib()->autoload(['plugins\\improve\\' . $class => __DIR__ . '/inc/core/' . $class . '.php']);
}
}
public static function getActionsDir(): string
{
- return dirname(__FILE__) . '/inc/module/';
+ return __DIR__ . '/inc/module/';
}
public static function getActionsNS(): string
@@ -44,4 +46,4 @@ class prepend
}
/* process */
-prepend::process($__autoload);
+prepend::process();
diff --git a/inc/core/action.php b/inc/core/action.php
index 58daeeb..7fb0b1f 100644
--- a/inc/core/action.php
+++ b/inc/core/action.php
@@ -29,16 +29,13 @@ use arrayObject;
*
* Action class must extends class action.
* If your class signature is myActionClass extends plugins\improve\class\action,
- * do $core->addBehavior('ImproveAddAction'), ['myClass', 'create']);
+ * do dcCore::app()->addBehavior('ImproveAddAction'), ['myClass', 'create']);
* your action class is automatically created,
* then function init() of your class wil be called.
* One class must manage only one action.
*/
abstract class action
{
- /** @var dcCore dcCore instance */
- protected $core;
-
/** @var array Current module */
protected $module = [];
@@ -83,15 +80,12 @@ abstract class action
/**
* Action constructor inits properties and settings of a child class.
- *
- * @param dcCore $core dcCore instance
*/
- final public function __construct(dcCore $core)
+ final public function __construct()
{
- $this->core = $core;
$this->class_name = str_replace(prepend::getActionsNS(), '', get_called_class());
- $settings = $core->blog->settings->improve->get('settings_' . $this->class_name);
+ $settings = dcCore::app()->blog->settings->improve->get('settings_' . $this->class_name);
if (null != $settings) {
$settings = unserialize($settings);
}
@@ -100,7 +94,7 @@ abstract class action
$this->init();
// can overload priority by settings
- if (1 < ($p = (int) $core->blog->settings->improve->get('priority_' . $this->class_name))) {
+ if (1 < ($p = (int) dcCore::app()->blog->settings->improve->get('priority_' . $this->class_name))) {
$this->priority = $p;
}
}
@@ -109,12 +103,11 @@ abstract class action
* Helper to create an instance of a ImproveAction child class.
*
* @param ArrayObject $list ArrayObject of actions list
- * @param dcCore $core dcCore instance
*/
- final public static function create(arrayObject $list, dcCore $core): void
+ final public static function create(arrayObject $list): void
{
$child = static::class;
- $class = new $child($core);
+ $class = new $child();
$list->append($class);
}
@@ -242,7 +235,7 @@ abstract class action
*/
final protected function redirect(string $url): bool
{
- $this->core->blog->settings->improve->put(
+ dcCore::app()->blog->settings->improve->put(
'settings_' . $this->class_name,
serialize($this->settings),
'string',
@@ -250,7 +243,7 @@ abstract class action
true,
true
);
- $this->core->blog->triggerBlog();
+ dcCore::app()->blog->triggerBlog();
dcPage::addSuccessNotice(__('Configuration successfully updated'));
http::redirect($url);
diff --git a/inc/core/improve.php b/inc/core/improve.php
index 2a327d0..77c9bdb 100644
--- a/inc/core/improve.php
+++ b/inc/core/improve.php
@@ -35,9 +35,6 @@ class improve
'php', 'xml', 'js', 'css', 'csv', 'html', 'htm', 'txt', 'md',
];
- /** @var dcCore $core dcCore instance */
- private $core;
-
/** @var array $actions Loaded actions modules */
private $actions = [];
@@ -52,17 +49,14 @@ class improve
/**
* Constructor
- *
- * @param dcCore $core dcCore instance
*/
- public function __construct(dcCore $core)
+ public function __construct()
{
- $this->core = &$core;
- $disabled = explode(';', (string) $core->blog->settings->improve->disabled);
- $list = new arrayObject();
+ $disabled = explode(';', (string) dcCore::app()->blog->settings->improve->disabled);
+ $list = new arrayObject();
try {
- $this->core->callBehavior('improveAddAction', $list, $this->core);
+ dcCore::app()->callBehavior('improveAddAction', $list);
foreach ($list as $action) {
if ($action instanceof action && !isset($this->actions[$action->id()])) {
@@ -74,7 +68,7 @@ class improve
}
}
} catch (Exception $e) {
- $core->error->add($e->getMessage());
+ dcCore::app()->error->add($e->getMessage());
}
uasort($this->actions, [$this, 'sortModules']);
}
@@ -94,21 +88,21 @@ class improve
if (empty($this->logs)) {
return 0;
}
- $cur = $this->core->con->openCursor($this->core->prefix . 'log');
+ $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . 'log');
$cur->log_msg = serialize($this->logs);
$cur->log_table = 'improve';
- $id = $this->core->log->addLog($cur);
+ $id = dcCore::app()->log->addLog($cur);
return $id;
}
public function readLogs(int $id): array
{
- $rs = $this->core->log->getLogs(['log_table' => 'improve', 'log_id' => $id, 'limit' => 1]);
+ $rs = dcCore::app()->log->getLogs(['log_table' => 'improve', 'log_id' => $id, 'limit' => 1]);
if ($rs->isEmpty()) {
return [];
}
- $this->core->log->delLogs($rs->log_id);
+ dcCore::app()->log->delLogs($rs->log_id);
$res = unserialize($rs->log_msg);
@@ -308,7 +302,7 @@ class improve
public function getURL(array $params = []): string
{
- return $this->core->adminurl->get('admin.plugin.improve', $params, '&');
+ return dcCore::app()->adminurl->get('admin.plugin.improve', $params, '&');
}
/**
diff --git a/inc/module/gitshields.php b/inc/module/gitshields.php
index 3bafafd..e9270d0 100644
--- a/inc/module/gitshields.php
+++ b/inc/module/gitshields.php
@@ -14,6 +14,9 @@ declare(strict_types=1);
namespace plugins\improve\module;
+/* dotclear */
+use dcCore;
+
/* improve */
use plugins\improve\action;
@@ -165,7 +168,7 @@ class gitshields extends action
$version = $this->module['dc_min'];
}
- return $version ?: $this->core->getVersion('core');
+ return $version ?: dcCore::app()->getVersion('core');
}
private function writeShieldsBloc(string $content): string
diff --git a/inc/module/newline.php b/inc/module/newline.php
index 949633f..e36b727 100644
--- a/inc/module/newline.php
+++ b/inc/module/newline.php
@@ -37,7 +37,7 @@ class newline extends action
'types' => ['plugin', 'theme'],
]);
/*
- $ext = @unserialize($this->core->blog->settings->improve->newline_extensions);
+ $ext = @unserialize(dcCore::app()->blog->settings->improve->newline_extensions);
$ext = Improve::cleanExtensions($ext);
if (!empty($ext)) {
$this->extensions = $ext;
diff --git a/inc/module/phpcsfixer.php b/inc/module/phpcsfixer.php
index dfa6f4c..9273db3 100644
--- a/inc/module/phpcsfixer.php
+++ b/inc/module/phpcsfixer.php
@@ -18,6 +18,7 @@ namespace plugins\improve\module;
use plugins\improve\action;
/* dotclear */
+use dcCore;
use dcPage;
/* clearbricks */
@@ -66,9 +67,9 @@ class phpcsfixer extends action
$this->getPhpPath();
- $this->core->auth->user_prefs->addWorkspace('interface');
- self::$user_ui_colorsyntax = $this->core->auth->user_prefs->interface->colorsyntax;
- self::$user_ui_colorsyntax_theme = $this->core->auth->user_prefs->interface->colorsyntax_theme;
+ dcCore::app()->auth->user_prefs->addWorkspace('interface');
+ self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->interface->colorsyntax;
+ self::$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->interface->colorsyntax_theme;
return true;
}
diff --git a/inc/module/phpcsfixer/libs/php-cs-fixer.phar b/inc/module/phpcsfixer/libs/php-cs-fixer.phar
index 55d1ba0..7912db6 100644
Binary files a/inc/module/phpcsfixer/libs/php-cs-fixer.phar and b/inc/module/phpcsfixer/libs/php-cs-fixer.phar differ
diff --git a/inc/module/phpheader.php b/inc/module/phpheader.php
index 90c3994..a81e353 100644
--- a/inc/module/phpheader.php
+++ b/inc/module/phpheader.php
@@ -14,6 +14,9 @@ declare(strict_types=1);
namespace plugins\improve\module;
+/* dotclear */
+use dcCore;
+
/* improve */
use plugins\improve\action;
@@ -162,10 +165,10 @@ class phpheader extends action
$this->module['name'],
$this->module['author'],
$this->module['type'],
- $this->core->auth->getInfo('user_cn'),
- $this->core->auth->getinfo('user_name'),
- $this->core->auth->getInfo('user_email'),
- $this->core->auth->getInfo('user_url'),
+ dcCore::app()->auth->getInfo('user_cn'),
+ dcCore::app()->auth->getinfo('user_name'),
+ dcCore::app()->auth->getInfo('user_email'),
+ dcCore::app()->auth->getInfo('user_url'),
],
(string) $bloc
)
diff --git a/inc/module/phpstan.php b/inc/module/phpstan.php
index 55783bb..bfb3b5b 100644
--- a/inc/module/phpstan.php
+++ b/inc/module/phpstan.php
@@ -18,6 +18,7 @@ namespace plugins\improve\module;
use plugins\improve\action;
/* dotclear */
+use dcCore;
use dcPage;
/* clearbricks */
@@ -67,9 +68,9 @@ class phpstan extends action
$ignored_vars = $this->getSetting('ignored_vars');
$this->ignored_vars = is_string($ignored_vars) ? $ignored_vars : '';
- $this->core->auth->user_prefs->addWorkspace('interface');
- self::$user_ui_colorsyntax = $this->core->auth->user_prefs->interface->colorsyntax;
- self::$user_ui_colorsyntax_theme = $this->core->auth->user_prefs->interface->colorsyntax_theme;
+ dcCore::app()->auth->user_prefs->addWorkspace('interface');
+ self::$user_ui_colorsyntax = dcCore::app()->auth->user_prefs->interface->colorsyntax;
+ self::$user_ui_colorsyntax_theme = dcCore::app()->auth->user_prefs->interface->colorsyntax_theme;
return true;
}
@@ -200,7 +201,6 @@ class phpstan extends action
return true;
} catch (Exception $e) {
$this->setError(__('Failed to run phpstan'));
- pdump($e);
return false;
}
diff --git a/inc/module/phpstan/libs/phpstan.phar b/inc/module/phpstan/libs/phpstan.phar
index 61ac33d..112187c 100644
Binary files a/inc/module/phpstan/libs/phpstan.phar and b/inc/module/phpstan/libs/phpstan.phar differ
diff --git a/inc/module/zip.php b/inc/module/zip.php
index 0593b66..aa84f49 100644
--- a/inc/module/zip.php
+++ b/inc/module/zip.php
@@ -14,6 +14,9 @@ declare(strict_types=1);
namespace plugins\improve\module;
+/* dotclear */
+use dcCore;
+
/* improve */
use plugins\improve\action;
@@ -111,8 +114,8 @@ class zip extends action
'' .
'' . sprintf(
__('Preconization: %s'),
- $this->core->blog->public_path ?
- path::real($this->core->blog->public_path) : __("Blog's public directory")
+ dcCore::app()->blog->public_path ?
+ path::real(dcCore::app()->blog->public_path) : __("Blog's public directory")
) . '
diff --git a/index.php b/index.php
index b59f353..c0ca7aa 100644
--- a/index.php
+++ b/index.php
@@ -21,6 +21,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
/* dotclear */
use dcCore;
use dcPage;
+use dcAdminNotices;
use dcThemes;
use dcUtils;
@@ -39,8 +40,6 @@ use Exception;
*/
class index
{
- /** @var dcCore $core dcCore instance */
- private $core = null;
/** @var improve $improve improve core instance */
private $improve = null;
/** @var string $type Current module(s) type */
@@ -50,12 +49,11 @@ class index
/** @var action|null $action Current action module */
private $action = null;
- public function __construct(dcCore $core)
+ public function __construct()
{
dcPage::checkSuper();
- $this->core = $core;
- $this->improve = new improve($core);
+ $this->improve = new improve();
$this->type = $this->getType();
$this->module = $this->getModule();
$this->action = $this->getAction();
@@ -88,7 +86,7 @@ class index
{
try {
if (!empty($this->type)) {
- $preferences = $this->core->blog->settings->improve->preferences;
+ $preferences = dcCore::app()->blog->settings->improve->preferences;
if (is_string($preferences)) {
$preferences = unserialize($preferences);
if (is_array($preferences)) {
@@ -113,8 +111,8 @@ class index
}
}
}
- $this->core->blog->settings->improve->put('preferences', serialize($preferences), 'string', null, true, true);
- dcPage::addSuccessNotice(__('Configuration successfully updated'));
+ dcCore::app()->blog->settings->improve->put('preferences', serialize($preferences), 'string', null, true, true);
+ dcAdminNotices::addSuccessNotice(__('Configuration successfully updated'));
return true;
}
@@ -124,19 +122,19 @@ class index
private function comboModules(): array
{
- $allow_distrib = (bool) $this->core->blog->settings->improve->allow_distrib;
+ $allow_distrib = (bool) dcCore::app()->blog->settings->improve->allow_distrib;
$official = [
'plugin' => explode(',', DC_DISTRIB_PLUGINS),
'theme' => explode(',', DC_DISTRIB_THEMES),
];
- if (!isset($this->core->themes)) {
- $this->core->themes = new dcThemes($this->core);
- $this->core->themes->loadModules($this->core->blog->themes_path, null);
+ if (!isset(dcCore::app()->themes)) {
+ dcCore::app()->themes = new dcThemes();
+ dcCore::app()->themes->loadModules(dcCore::app()->blog->themes_path, null);
}
$combo_modules = [];
- $modules = $this->type == 'plugin' ? $this->core->plugins->getModules() : $this->core->themes->getModules();
+ $modules = $this->type == 'plugin' ? dcCore::app()->plugins->getModules() : dcCore::app()->themes->getModules();
foreach ($modules as $id => $m) {
if (!$m['root_writable'] || !$allow_distrib && in_array($id, $official[$this->type])) {
continue;
@@ -155,41 +153,41 @@ class index
if (!empty($_POST['fix'])) {
if (empty($_POST['actions'])) {
- dcPage::addWarningNotice(__('No action selected'));
+ dcAdminNotices::addWarningNotice(__('No action selected'));
} elseif ($this->module == '-') {
- dcPage::addWarningNotice(__('No module selected'));
+ dcAdminNotices::addWarningNotice(__('No module selected'));
} else {
try {
$time = $this->improve->fixModule(
$this->type,
$this->module,
- $this->type == 'plugin' ? $this->core->plugins->getModules($this->module) : $this->core->themes->getModules($this->module),
+ $this->type == 'plugin' ? dcCore::app()->plugins->getModules($this->module) : dcCore::app()->themes->getModules($this->module),
$_POST['actions']
);
$log_id = $this->improve->writeLogs();
- $this->core->blog->triggerBlog();
+ dcCore::app()->blog->triggerBlog();
if ($this->improve->hasLog('error')) {
- $notice = ['type' => 'error', 'msg' => __('Fix of "%s" complete in %s secondes with errors')];
+ $notice = ['type' => dcAdminNotices::NOTICE_ERROR, 'msg' => __('Fix of "%s" complete in %s secondes with errors')];
} elseif ($this->improve->hasLog('warning')) {
- $notice = ['type' => 'warning', 'msg' => __('Fix of "%s" complete in %s secondes with warnings')];
+ $notice = ['type' => dcAdminNotices::NOTICE_WARNING, 'msg' => __('Fix of "%s" complete in %s secondes with warnings')];
} elseif ($this->improve->hasLog('success')) {
- $notice = ['type' => 'success', 'msg' => __('Fix of "%s" complete in %s secondes')];
+ $notice = ['type' => dcAdminNotices::NOTICE_SUCCESS, 'msg' => __('Fix of "%s" complete in %s secondes')];
} else {
- $notice = ['type' => 'success', 'msg' => __('Fix of "%s" complete in %s secondes without messages')];
+ $notice = ['type' => dcAdminNotices::NOTICE_SUCCESS, 'msg' => __('Fix of "%s" complete in %s secondes without messages')];
}
- dcPage::addNotice($notice['type'], sprintf($notice['msg'], $this->module, $time));
+ dcAdminNotices::addNotice($notice['type'], sprintf($notice['msg'], $this->module, $time));
$done = true;
} catch (Exception $e) {
- $this->core->error->add($e->getMessage());
+ dcCore::app()->error->add($e->getMessage());
$done = false;
}
}
}
if ($done) {
- $this->core->adminurl->redirect('admin.plugin.improve', ['type' => $this->type, 'module' => $this->module, 'upd' => $log_id]);
+ dcCore::app()->adminurl->redirect('admin.plugin.improve', ['type' => $this->type, 'module' => $this->module, 'upd' => $log_id]);
}
}
@@ -221,27 +219,27 @@ class index
private function displayConfigurator(): void
{
- $back_url = $_REQUEST['redir'] ?? $this->core->adminurl->get('admin.plugin.improve', ['type' => $this->type]);
+ $back_url = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.improve', ['type' => $this->type]);
if (null === $this->action) {
echo '
' . __('Unknow module') . '
' . __('Back') . '
';
} else {
- $redir = $_REQUEST['redir'] ?? $this->core->adminurl->get('admin.plugin.improve', ['type' => $this->type, 'config' => $this->action->id()]);
+ $redir = $_REQUEST['redir'] ?? dcCore::app()->adminurl->get('admin.plugin.improve', ['type' => $this->type, 'config' => $this->action->id()]);
$res = $this->action->configure($redir);
echo '
' . sprintf(__('Configure module "%s"'), $this->action->name()) . '
' . __('Back') . '
' . html::escapeHTML($this->action->description()) . '
- ';
}
}
@@ -249,7 +247,7 @@ class index
private function displayActions(): void
{
echo
- '