diff --git a/_admin.php b/_admin.php index 4428711..4184a46 100644 --- a/_admin.php +++ b/_admin.php @@ -14,15 +14,15 @@ if (!defined('DC_CONTEXT_ADMIN')) { return null; } -$core->blog->settings->addNamespace('dcAdvancedCleaner'); +dcCore::app()->blog->settings->addNamespace('dcAdvancedCleaner'); -$_menu['Plugins']->addItem( +dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( __('Advanced cleaner'), - $core->adminurl->get('admin.plugin.dcAdvancedCleaner'), + dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner'), dcPage::getPF('dcAdvancedCleaner/icon.png'), preg_match( - '/' . preg_quote($core->adminurl->get('admin.plugin.dcAdvancedCleaner')) . '(&.*)?$/', + '/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner')) . '(&.*)?$/', $_SERVER['REQUEST_URI'] ), - $core->auth->isSuperAdmin() + dcCore::app()->auth->isSuperAdmin() ); diff --git a/_config.php b/_config.php index e013ee4..c63247d 100644 --- a/_config.php +++ b/_config.php @@ -14,16 +14,16 @@ if (!defined('DC_CONTEXT_MODULE')) { return null; } -if (!$core->auth->isSuperAdmin()) { +if (!dcCore::app()->auth->isSuperAdmin()) { return null; } if (!empty($_POST['save'])) { try { - $core->blog->settings->dcAdvancedCleaner->dropEvery( + dcCore::app()->blog->settings->dcAdvancedCleaner->dropEvery( 'dcAdvancedCleaner_behavior_active' ); - $core->blog->settings->dcAdvancedCleaner->put( + dcCore::app()->blog->settings->dcAdvancedCleaner->put( 'dcAdvancedCleaner_behavior_active', !empty($_POST['behavior_active']), 'boolean', @@ -31,10 +31,10 @@ if (!empty($_POST['save'])) { true, true ); - $core->blog->settings->dcAdvancedCleaner->dropEvery( + dcCore::app()->blog->settings->dcAdvancedCleaner->dropEvery( 'dcAdvancedCleaner_dcproperty_hide' ); - $core->blog->settings->dcAdvancedCleaner->put( + dcCore::app()->blog->settings->dcAdvancedCleaner->put( 'dcAdvancedCleaner_dcproperty_hide', !empty($_POST['dcproperty_hide']), 'boolean', @@ -42,19 +42,19 @@ if (!empty($_POST['save'])) { true, true ); - dcPage::addSuccessNotice( + dcAdminNotices::addSuccessNotice( __('Configuration successfully updated.') ); - $core->adminurl->redirect( + dcCore::app()->adminurl->redirect( 'admin.plugins', [ 'module' => 'dcAdvancedCleaner', 'conf' => 1, - 'redir' => empty($_REQUEST['redir']) ? $list->getURL() . '#plugins' : $_REQUEST['redir'] + 'redir' => empty($_REQUEST['redir']) ? dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'], ] ); } catch (Exception $e) { - $core->error->add($e->getMessage()); + dcCore::app()->error->add($e->getMessage()); } } echo ' @@ -62,14 +62,14 @@ echo ' form::checkbox( 'behavior_active', 1, - $core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active + dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active ) . ' ' . __('Activate behaviors') . '

' . __('Enable actions set in _uninstall.php files.') . '

' . __('Prevent from deleting Dotclear important properties.') . '

'; diff --git a/_define.php b/_define.php index 5fd1e7f..6d848fb 100644 --- a/_define.php +++ b/_define.php @@ -18,13 +18,13 @@ $this->registerModule( 'Advanced cleaner', 'Make a huge cleaning of dotclear', 'Jean-Christian Denis and Contributors', - '0.9', + '0.10', [ - 'requires' => [['core', '2.19']], + 'requires' => [['core', '2.24']], 'permissions' => null, 'type' => 'plugin', 'support' => 'https://github.com/JcDenis/dcAdvancedCleaner', 'details' => 'https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner', - 'repository' => 'https://raw.githubusercontent.com/JcDenis/dcAdvancedCleaner/master/dcstore.xml' + 'repository' => 'https://raw.githubusercontent.com/JcDenis/dcAdvancedCleaner/master/dcstore.xml', ] ); diff --git a/_install.php b/_install.php index f5db60a..ff94d8c 100644 --- a/_install.php +++ b/_install.php @@ -14,17 +14,17 @@ if (!defined('DC_CONTEXT_ADMIN')) { return null; } -$new_version = $core->plugins->moduleInfo('dcAdvancedCleaner', 'version'); -$old_version = $core->getVersion('dcAdvancedCleaner'); +$new_version = dcCore::app()->plugins->moduleInfo('dcAdvancedCleaner', 'version'); +$old_version = dcCore::app()->getVersion('dcAdvancedCleaner'); if (version_compare($old_version, $new_version, '>=')) { return null; } try { - $core->blog->settings->addNamespace('dcAdvancedCleaner'); + dcCore::app()->blog->settings->addNamespace('dcAdvancedCleaner'); - $core->blog->settings->dcAdvancedCleaner->put( + dcCore::app()->blog->settings->dcAdvancedCleaner->put( 'dcAdvancedCleaner_behavior_active', true, 'boolean', @@ -32,7 +32,7 @@ try { false, true ); - $core->blog->settings->dcAdvancedCleaner->put( + dcCore::app()->blog->settings->dcAdvancedCleaner->put( 'dcAdvancedCleaner_dcproperty_hide', true, 'boolean', @@ -41,11 +41,11 @@ try { true ); - $core->setVersion('dcAdvancedCleaner', $new_version); + dcCore::app()->setVersion('dcAdvancedCleaner', $new_version); return true; } catch (Exception $e) { - $core->error->add($e->getMessage()); + dcCore::app()->error->add($e->getMessage()); return false; } diff --git a/_prepend.php b/_prepend.php index 4dd2069..a8805af 100644 --- a/_prepend.php +++ b/_prepend.php @@ -17,39 +17,37 @@ if (!defined('DC_CONTEXT_ADMIN')) { return null; } -$d = dirname(__FILE__) . '/inc/'; - # dcac class -$__autoload['advancedCleaner'] = $d . 'class.advanced.cleaner.php'; -$__autoload['dcAdvancedCleaner'] = $d . 'class.dc.advanced.cleaner.php'; -$__autoload['behaviorsDcAdvancedCleaner'] = $d . 'lib.dc.advanced.cleaner.behaviors.php'; -$__autoload['dcUninstaller'] = $d . 'class.dc.uninstaller.php'; -$__autoload['dcAdvancedCleanerActivityReportBehaviors'] = $d . 'lib.dc.advanced.cleaner.activityreport.php'; +Clearbricks::lib()->autoload(['advancedCleaner' => __DIR__ . '/inc/class.advanced.cleaner.php']); +Clearbricks::lib()->autoload(['dcAdvancedCleaner' => __DIR__ . '/inc/class.dc.advanced.cleaner.php']); +Clearbricks::lib()->autoload(['behaviorsDcAdvancedCleaner' => __DIR__ . '/inc/lib.dc.advanced.cleaner.behaviors.php']); +Clearbricks::lib()->autoload(['dcUninstaller' => __DIR__ . '/inc/class.dc.uninstaller.php']); +Clearbricks::lib()->autoload(['dcAdvancedCleanerActivityReportBehaviors' => __DIR__ . '/inc/lib.dc.advanced.cleaner.activityreport.php']); # cleaners class -$__autoload['advancedCleanerVersions'] = $d . 'lib.advanced.cleaner.php'; -$__autoload['advancedCleanerSettings'] = $d . 'lib.advanced.cleaner.php'; -$__autoload['advancedCleanerTables'] = $d . 'lib.advanced.cleaner.php'; -$__autoload['advancedCleanerThemes'] = $d . 'lib.advanced.cleaner.php'; -$__autoload['advancedCleanerPlugins'] = $d . 'lib.advanced.cleaner.php'; -$__autoload['advancedCleanerCaches'] = $d . 'lib.advanced.cleaner.php'; -$__autoload['advancedCleanerVars'] = $d . 'lib.advanced.cleaner.php'; +Clearbricks::lib()->autoload(['advancedCleanerVersions' => __DIR__ . '/inc/lib.advanced.cleaner.php']); +Clearbricks::lib()->autoload(['advancedCleanerSettings' => __DIR__ . '/inc/lib.advanced.cleaner.php']); +Clearbricks::lib()->autoload(['advancedCleanerTables' => __DIR__ . '/inc/lib.advanced.cleaner.php']); +Clearbricks::lib()->autoload(['advancedCleanerThemes' => __DIR__ . '/inc/lib.advanced.cleaner.php']); +Clearbricks::lib()->autoload(['advancedCleanerPlugins' => __DIR__ . '/inc/lib.advanced.cleaner.php']); +Clearbricks::lib()->autoload(['advancedCleanerCaches' => __DIR__ . '/inc/lib.advanced.cleaner.php']); +Clearbricks::lib()->autoload(['advancedCleanerVars' => __DIR__ . '/inc/lib.advanced.cleaner.php']); -$core->addBehavior('advancedCleanerAdd', ['advancedCleanerVersions', 'create']); -$core->addBehavior('advancedCleanerAdd', ['advancedCleanerSettings', 'create']); -$core->addBehavior('advancedCleanerAdd', ['advancedCleanerTables', 'create']); -$core->addBehavior('advancedCleanerAdd', ['advancedCleanerThemes', 'create']); -$core->addBehavior('advancedCleanerAdd', ['advancedCleanerPlugins', 'create']); -$core->addBehavior('advancedCleanerAdd', ['advancedCleanerCaches', 'create']); -$core->addBehavior('advancedCleanerAdd', ['advancedCleanerVars', 'create']); +dcCore::app()->addBehavior('advancedCleanerAdd', ['advancedCleanerVersions', 'create']); +dcCore::app()->addBehavior('advancedCleanerAdd', ['advancedCleanerSettings', 'create']); +dcCore::app()->addBehavior('advancedCleanerAdd', ['advancedCleanerTables', 'create']); +dcCore::app()->addBehavior('advancedCleanerAdd', ['advancedCleanerThemes', 'create']); +dcCore::app()->addBehavior('advancedCleanerAdd', ['advancedCleanerPlugins', 'create']); +dcCore::app()->addBehavior('advancedCleanerAdd', ['advancedCleanerCaches', 'create']); +dcCore::app()->addBehavior('advancedCleanerAdd', ['advancedCleanerVars', 'create']); # dcac behaviors -$core->addBehavior('adminDashboardFavorites', ['behaviorsDcAdvancedCleaner', 'adminDashboardFavorites']); -$core->addBehavior('pluginsToolsTabs', ['behaviorsDcAdvancedCleaner', 'pluginsToolsTabs']); -$core->addBehavior('adminModulesListDoActions', ['behaviorsDcAdvancedCleaner', 'adminModulesListDoActions']); -$core->addBehavior('pluginsBeforeDelete', ['behaviorsDcAdvancedCleaner', 'pluginsBeforeDelete']); -$core->addBehavior('themeBeforeDelete', ['behaviorsDcAdvancedCleaner', 'themeBeforeDelete']); +dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['behaviorsDcAdvancedCleaner', 'adminDashboardFavorites']); +dcCore::app()->addBehavior('pluginsToolsTabsV2', ['behaviorsDcAdvancedCleaner', 'pluginsToolsTabs']); +dcCore::app()->addBehavior('adminModulesListDoActions', ['behaviorsDcAdvancedCleaner', 'adminModulesListDoActions']); +dcCore::app()->addBehavior('pluginsBeforeDelete', ['behaviorsDcAdvancedCleaner', 'pluginsBeforeDelete']); +dcCore::app()->addBehavior('themeBeforeDelete', ['behaviorsDcAdvancedCleaner', 'themeBeforeDelete']); if (defined('ACTIVITY_REPORT')) { - dcAdvancedCleanerActivityReportBehaviors::add($core); + dcAdvancedCleanerActivityReportBehaviors::add(); } diff --git a/inc/class.advanced.cleaner.php b/inc/class.advanced.cleaner.php index 65331ce..33dc248 100644 --- a/inc/class.advanced.cleaner.php +++ b/inc/class.advanced.cleaner.php @@ -12,31 +12,27 @@ */ abstract class advancedCleaner { - protected $core; - private static $exclude = [ - '.', '..', '__MACOSX', '.svn', 'CVS', '.DS_Store', 'Thumbs.db' + '.', '..', '__MACOSX', '.svn', 'CVS', '.DS_Store', 'Thumbs.db', ]; private $properties = [ 'id' => '', 'name' => '', - 'desc' => '' + 'desc' => '', ]; private $actions = []; - final public function __construct(dcCore $core) + final public function __construct() { - $this->core = $core; - $this->init(); } - public static function create(arrayObject $o, dcCore $core) + public static function create(arrayObject $o) { $c = get_called_class(); - $o->append(new $c($core)); + $o->append(new $c()); } final public function __get(string $property) diff --git a/inc/class.dc.advanced.cleaner.php b/inc/class.dc.advanced.cleaner.php index 8cd287c..670d631 100644 --- a/inc/class.dc.advanced.cleaner.php +++ b/inc/class.dc.advanced.cleaner.php @@ -16,16 +16,14 @@ if (!defined('DC_ADMIN_CONTEXT')) { class dcAdvancedCleaner { - protected $core; protected $cleaners = []; - public function __construct($core) + public function __construct() { - $this->core = $core; - $cleaners = new arrayObject(); + $cleaners = new arrayObject(); try { - $this->core->callBehavior('advancedCleanerAdd', $cleaners, $this->core); + dcCore::app()->callBehavior('advancedCleanerAdd', $cleaners); foreach ($cleaners as $cleaner) { if ($cleaner instanceof advancedCleaner && !isset($this->cleaners[$cleaner->id])) { @@ -33,7 +31,7 @@ class dcAdvancedCleaner } } } catch (Exception $e) { - $core->error->add($e->getMessage()); + dcCore::app()->error->add($e->getMessage()); } } @@ -62,7 +60,7 @@ class dcAdvancedCleaner } # BEHAVIOR dcAdvancedCleanerBeforeAction - $this->core->callBehavior('dcAdvancedCleanerBeforeAction', $type, $action, $ns); + dcCore::app()->callBehavior('dcAdvancedCleanerBeforeAction', $type, $action, $ns); $ret = $this->cleaners[$type]->set($action, $ns); diff --git a/inc/class.dc.uninstaller.php b/inc/class.dc.uninstaller.php index f34418e..4c4657f 100644 --- a/inc/class.dc.uninstaller.php +++ b/inc/class.dc.uninstaller.php @@ -48,19 +48,15 @@ class dcUninstaller protected $id = null; protected $mroot = null; - public $core; private $ac; private $allowed_actions = null; /** * Object constructor. - * - * @param dcCore $core dcCore instance */ - public function __construct(dcCore $core) + public function __construct() { - $this->core = & $core; - $this->ac = new dcAdvancedCleaner($core); + $this->ac = new dcAdvancedCleaner(); $res = []; foreach ($this->ac->get() as $cleaner) { @@ -151,7 +147,7 @@ class dcUninstaller 'desc' => $desc, 'author' => $author, 'version' => $version, - 'root_writable' => is_writable($this->mroot) + 'root_writable' => is_writable($this->mroot), ]; } } @@ -176,7 +172,7 @@ class dcUninstaller /** * Returns true if the module with ID $id exists. * - * @param string $idModule ID + * @param string $id Module ID * * @return boolean Success */ @@ -224,7 +220,7 @@ class dcUninstaller $this->actions[$group][$this->id][$type][] = [ 'ns' => $ns, 'action' => $action, - 'desc' => $desc + 'desc' => $desc, ]; } @@ -295,7 +291,7 @@ class dcUninstaller } $this->callbacks[$group][$this->id][] = [ 'func' => $func, - 'desc' => $desc + 'desc' => $desc, ]; } diff --git a/inc/lib.advanced.cleaner.php b/inc/lib.advanced.cleaner.php index c54bb81..83b7986 100644 --- a/inc/lib.advanced.cleaner.php +++ b/inc/lib.advanced.cleaner.php @@ -17,13 +17,13 @@ class advancedCleanerSettings extends advancedCleaner $this->setProperties([ 'id' => 'settings', 'name' => __('Settings'), - 'desc' => __('Namespaces registered in dcSettings') + 'desc' => __('Namespaces registered in dcSettings'), ]); $this->setActions([ 'delete_global' => __('delete global settings'), 'delete_local' => __('delete blog settings'), - 'delete_all' => __('delete all settings') + 'delete_all' => __('delete all settings'), ]); return true; @@ -57,15 +57,15 @@ class advancedCleanerSettings extends advancedCleaner 'pings', 'system', 'themes', - 'widgets' + 'widgets', ]; } public function get(): array { - $res = $this->core->con->select( + $res = dcCore::app()->con->select( 'SELECT setting_ns ' . - 'FROM ' . $this->core->prefix . 'setting ' . + 'FROM ' . dcCore::app()->prefix . 'setting ' . 'WHERE blog_id IS NULL ' . 'OR blog_id IS NOT NULL ' . 'GROUP BY setting_ns' @@ -75,8 +75,8 @@ class advancedCleanerSettings extends advancedCleaner $i = 0; while ($res->fetch()) { $rs[$i]['key'] = $res->setting_ns; - $rs[$i]['value'] = $this->core->con->select( - 'SELECT count(*) FROM ' . $this->core->prefix . 'setting ' . + $rs[$i]['value'] = dcCore::app()->con->select( + 'SELECT count(*) FROM ' . dcCore::app()->prefix . 'setting ' . "WHERE setting_ns = '" . $res->setting_ns . "' " . 'AND (blog_id IS NULL OR blog_id IS NOT NULL) ' . 'GROUP BY setting_ns ' @@ -90,27 +90,27 @@ class advancedCleanerSettings extends advancedCleaner public function set($action, $ns): bool { if ($action == 'delete_global') { - $this->core->con->execute( - 'DELETE FROM ' . $this->core->prefix . 'setting ' . + dcCore::app()->con->execute( + 'DELETE FROM ' . dcCore::app()->prefix . 'setting ' . 'WHERE blog_id IS NULL ' . - "AND setting_ns = '" . $this->core->con->escape($ns) . "' " + "AND setting_ns = '" . dcCore::app()->con->escape($ns) . "' " ); return true; } if ($action == 'delete_local') { - $this->core->con->execute( - 'DELETE FROM ' . $this->core->prefix . 'setting ' . - "WHERE blog_id = '" . $this->core->con->escape($this->core->blog->id) . "' " . - "AND setting_ns = '" . $this->core->con->escape($ns) . "' " + dcCore::app()->con->execute( + 'DELETE FROM ' . dcCore::app()->prefix . 'setting ' . + "WHERE blog_id = '" . dcCore::app()->con->escape(dcCore::app()->blog->id) . "' " . + "AND setting_ns = '" . dcCore::app()->con->escape($ns) . "' " ); return true; } if ($action == 'delete_all') { - $this->core->con->execute( - 'DELETE FROM ' . $this->core->prefix . 'setting ' . - "WHERE setting_ns = '" . $this->core->con->escape($ns) . "' " . + dcCore::app()->con->execute( + 'DELETE FROM ' . dcCore::app()->prefix . 'setting ' . + "WHERE setting_ns = '" . dcCore::app()->con->escape($ns) . "' " . "AND (blog_id IS NULL OR blog_id != '') " ); @@ -128,12 +128,12 @@ class advancedCleanerTables extends advancedCleaner $this->setProperties([ 'id' => 'tables', 'name' => __('Tables'), - 'desc' => __('All database tables of Dotclear') + 'desc' => __('All database tables of Dotclear'), ]); $this->setActions([ 'delete' => __('delete'), - 'empty' => __('empty') + 'empty' => __('empty'), ]); return true; @@ -170,26 +170,26 @@ class advancedCleanerTables extends advancedCleaner 'setting', 'spamrule', 'user', - 'version' + 'version', ]; } public function get(): array { - $object = dbSchema::init($this->core->con); + $object = dbSchema::init(dcCore::app()->con); $res = $object->getTables(); $rs = []; $i = 0; foreach ($res as $k => $v) { - if ('' != $this->core->prefix) { - if (!preg_match('/^' . preg_quote($this->core->prefix) . '(.*?)$/', $v, $m)) { + if ('' != dcCore::app()->prefix) { + if (!preg_match('/^' . preg_quote(dcCore::app()->prefix) . '(.*?)$/', $v, $m)) { continue; } $v = $m[1]; } $rs[$i]['key'] = $v; - $rs[$i]['value'] = $this->core->con->select('SELECT count(*) FROM ' . $res[$k])->f(0); + $rs[$i]['value'] = dcCore::app()->con->select('SELECT count(*) FROM ' . $res[$k])->f(0); $i++; } @@ -199,16 +199,16 @@ class advancedCleanerTables extends advancedCleaner public function set($action, $ns): bool { if (in_array($action, ['empty', 'delete'])) { - $this->core->con->execute( - 'DELETE FROM ' . $this->core->con->escapeSystem($this->core->prefix . $ns) + dcCore::app()->con->execute( + 'DELETE FROM ' . dcCore::app()->con->escapeSystem(dcCore::app()->prefix . $ns) ); } if ($action == 'empty') { return true; } if ($action == 'delete') { - $this->core->con->execute( - 'DROP TABLE ' . $this->core->con->escapeSystem($this->core->prefix . $ns) + dcCore::app()->con->execute( + 'DROP TABLE ' . dcCore::app()->con->escapeSystem(dcCore::app()->prefix . $ns) ); return true; @@ -225,11 +225,11 @@ class advancedCleanerVersions extends advancedCleaner $this->setProperties([ 'id' => 'versions', 'name' => __('Versions'), - 'desc' => __('Versions registered in table "version" of Dotclear') + 'desc' => __('Versions registered in table "version" of Dotclear'), ]); $this->setActions([ - 'delete' => __('delete') + 'delete' => __('delete'), ]); return true; @@ -257,13 +257,13 @@ class advancedCleanerVersions extends advancedCleaner 'pings', 'simpleMenu', 'tags', - 'widgets' + 'widgets', ]; } public function get(): array { - $res = $this->core->con->select('SELECT * FROM ' . $this->core->prefix . 'version'); + $res = dcCore::app()->con->select('SELECT * FROM ' . dcCore::app()->prefix . 'version'); $rs = []; $i = 0; @@ -279,9 +279,9 @@ class advancedCleanerVersions extends advancedCleaner public function set($action, $ns): bool { if ($action == 'delete') { - $this->core->con->execute( - 'DELETE FROM ' . $this->core->prefix . 'version ' . - "WHERE module = '" . $this->core->con->escape($ns) . "' " + dcCore::app()->con->execute( + 'DELETE FROM ' . dcCore::app()->prefix . 'version ' . + "WHERE module = '" . dcCore::app()->con->escape($ns) . "' " ); return true; @@ -298,12 +298,12 @@ class advancedCleanerPlugins extends advancedCleaner $this->setProperties([ 'id' => 'plugins', 'name' => __('Plugins'), - 'desc' => __('Folders from plugins directories') + 'desc' => __('Folders from plugins directories'), ]); $this->setActions([ 'delete' => __('delete'), - 'empty' => __('empty') + 'empty' => __('empty'), ]); return true; @@ -360,12 +360,12 @@ class advancedCleanerThemes extends advancedCleaner $this->setProperties([ 'id' => 'themes', 'name' => __('Themes'), - 'desc' => __('Folders from blog themes directory') + 'desc' => __('Folders from blog themes directory'), ]); $this->setActions([ 'delete' => __('delete'), - 'empty' => __('empty') + 'empty' => __('empty'), ]); return true; @@ -390,7 +390,7 @@ class advancedCleanerThemes extends advancedCleaner public function get(): array { - $res = self::getDirs($this->core->blog->themes_path); + $res = self::getDirs(dcCore::app()->blog->themes_path); sort($res); return $res; @@ -399,12 +399,12 @@ class advancedCleanerThemes extends advancedCleaner public function set($action, $ns): bool { if ($action == 'empty') { - self::delDir($this->core->blog->themes_path, $ns, false); + self::delDir(dcCore::app()->blog->themes_path, $ns, false); return true; } if ($action == 'delete') { - self::delDir($this->core->blog->themes_path, $ns, true); + self::delDir(dcCore::app()->blog->themes_path, $ns, true); return true; } @@ -420,12 +420,12 @@ class advancedCleanerCaches extends advancedCleaner $this->setProperties([ 'id' => 'caches', 'name' => __('Cache'), - 'desc' => __('Folders from cache directory') + 'desc' => __('Folders from cache directory'), ]); $this->setActions([ 'delete' => __('delete'), - 'empty' => __('empty') + 'empty' => __('empty'), ]); return true; @@ -477,11 +477,11 @@ class advancedCleanerVars extends advancedCleaner $this->setProperties([ 'id' => 'vars', 'name' => __('Var'), - 'desc' => __('Folders from Dotclear VAR directory') + 'desc' => __('Folders from Dotclear VAR directory'), ]); $this->setActions([ - 'delete' => __('delete') + 'delete' => __('delete'), ]); return true; diff --git a/inc/lib.dc.advanced.cleaner.activityreport.php b/inc/lib.dc.advanced.cleaner.activityreport.php index 5447e54..c8eb46f 100644 --- a/inc/lib.dc.advanced.cleaner.activityreport.php +++ b/inc/lib.dc.advanced.cleaner.activityreport.php @@ -18,20 +18,20 @@ class dcAdvancedCleanerActivityReportBehaviors { public static function maintenance($type, $action, $ns) { - $GLOBALS['core']->activityReport->addLog('dcadvancedcleaner', 'maintenance', [$type,$action, $ns]); + dcCore::app()->activityReport->addLog('dcadvancedcleaner', 'maintenance', [$type,$action, $ns]); } - public static function add($core) + public static function add() { // This file is used with plugin activityReport - $core->activityReport->addGroup( + dcCore::app()->activityReport->addGroup( 'dcadvancedcleaner', __('Plugin dcAdvancedCleaner') ); // from BEHAVIOR dcAdvancedCleanerBeforeAction // in dcAdvancedCleaner/inc/class.dc.advanced.cleaner.php - $core->activityReport->addAction( + dcCore::app()->activityReport->addAction( 'dcadvancedcleaner', 'maintenance', __('Maintenance'), diff --git a/inc/lib.dc.advanced.cleaner.behaviors.php b/inc/lib.dc.advanced.cleaner.behaviors.php index 44fdea9..0d058df 100644 --- a/inc/lib.dc.advanced.cleaner.behaviors.php +++ b/inc/lib.dc.advanced.cleaner.behaviors.php @@ -16,14 +16,14 @@ if (!defined('DC_ADMIN_CONTEXT')) { class behaviorsDcAdvancedCleaner { - public static function adminDashboardFavorites(dcCore $core, $favs) + public static function adminDashboardFavorites($favs) { $favs->register('dcAdvancedCleaner', [ 'title' => __('Advanced cleaner'), - 'url' => $core->adminurl->get('admin.plugin.dcAdvancedCleaner'), + 'url' => dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner'), 'small-icon' => dcPage::getPF('dcAdvancedCleaner/icon.png'), 'large-icon' => dcPage::getPF('dcAdvancedCleaner/icon-big.png'), - 'permissions' => $core->auth->isSuperAdmin() + 'permissions' => dcCore::app()->auth->isSuperAdmin(), ]); } @@ -40,13 +40,12 @@ class behaviorsDcAdvancedCleaner // Generic module before delete public static function moduleBeforeDelete($module, $redir) { - global $core; $done = false; - if (!$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) { + if (!dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) { return null; } - $uninstaller = new dcUninstaller($core); + $uninstaller = new dcUninstaller(); $uninstaller->loadModule($module['root']); $m_callbacks = $uninstaller->getDirectCallbacks($module['id']); @@ -70,19 +69,19 @@ class behaviorsDcAdvancedCleaner } } - public static function pluginsToolsTabs($core) + public static function pluginsToolsTabs() { - self::modulesTabs($core, DC_PLUGINS_ROOT, $core->adminurl->get('admin.plugins') . '#uninstaller'); + self::modulesTabs(DC_PLUGINS_ROOT, dcCore::app()->adminurl->get('admin.plugins') . '#uninstaller'); } - public static function modulesTabs($core, $path, $redir, $title = '') + public static function modulesTabs($path, $redir, $title = '') { - if (!$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) { + if (!dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) { return null; } $title = empty($title) ? __('Advanced uninstall') : $title; - $uninstaller = new dcUninstaller($core); + $uninstaller = new dcUninstaller(); $uninstaller->loadModules($path); $modules = $uninstaller->getModules(); $props = $uninstaller->getAllowedActions(); @@ -133,7 +132,7 @@ class behaviorsDcAdvancedCleaner $ret = base64_encode(serialize([ 'type' => $prop_id, 'action' => $action['action'], - 'ns' => $action['ns'] + 'ns' => $action['ns'], ])); echo '