prepare to DC 2.24

master
Jean-Christian Paul Denis 2022-11-15 11:34:45 +01:00
parent 2bbeb2c0d7
commit c5a8f7088c
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
12 changed files with 146 additions and 159 deletions

View File

@ -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()
);

View File

@ -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') . '</label></p>
<p class="form-note">' . __('Enable actions set in _uninstall.php files.') . '</p>
<p><label class="classic" for="dcproperty_hide">' .
form::checkbox(
'dcproperty_hide',
1,
$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide
dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide
) . ' ' . __('Hide Dotclear default properties in actions tabs') . '</label></p>
<p class="form-note">' .
__('Prevent from deleting Dotclear important properties.') . '</p>';

View File

@ -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',
]
);

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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)

View File

@ -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();
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);

View File

@ -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 <var>$id</var> 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,
];
}

View File

@ -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;

View File

@ -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'),

View File

@ -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 '<label class="classic">' .
@ -167,7 +166,7 @@ class behaviorsDcAdvancedCleaner
echo
'</table>' .
'<p>' .
$core->formNonce() .
dcCore::app()->formNonce() .
form::hidden(['path'], $path) .
form::hidden(['redir'], $redir) .
form::hidden(['action'], 'uninstall') .
@ -180,7 +179,7 @@ class behaviorsDcAdvancedCleaner
public static function adminModulesListDoActions($list, $modules, $type)
{
if (!$list->core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) {
if (!dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) {
return null;
}
@ -190,7 +189,7 @@ class behaviorsDcAdvancedCleaner
return null;
}
$uninstaller = new dcUninstaller($list->core);
$uninstaller = new dcUninstaller();
$uninstaller->loadModules($_POST['path']);
$modules = $uninstaller->getModules();
$props = $uninstaller->getAllowedActions();
@ -205,7 +204,7 @@ class behaviorsDcAdvancedCleaner
if (!$extra || !is_callable($extra)) {
continue;
}
call_user_func($extra, $modul_id);
call_user_func($extra, $module_id);
}
}
}
@ -226,10 +225,10 @@ class behaviorsDcAdvancedCleaner
}
}
}
dcPage::addSuccessNotice(__('Action successfuly excecuted'));
dcAdminNotices::addSuccessNotice(__('Action successfuly excecuted'));
http::redirect($_POST['redir']);
} catch (Exception $e) {
$list->core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
}
}

View File

@ -16,7 +16,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
dcPage::checkSuper();
$ac = new dcAdvancedCleaner($core);
$ac = new dcAdvancedCleaner();
$cleaner = false;
$select_menu = [];
@ -38,13 +38,13 @@ if (!empty($_POST['entries']) && !empty($_POST['action'])) {
foreach ($_POST['entries'] as $ns) {
$ac->set($cleaner->id, $_POST['action'], $ns);
}
dcPage::addSuccessNotice(__('Action successfuly excecuted'));
$core->adminurl->redirect(
dcAdminNotices::addSuccessNotice(__('Action successfuly excecuted'));
dcCore::app()->adminurl->redirect(
'admin.plugin.dcAdvancedCleaner',
['part' => $cleaner->id]
);
} catch (Exception $e) {
$core->error->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
}
@ -54,16 +54,16 @@ dcPage::cssLoad(dcPage::getPF('dcAdvancedCleaner/style.css')) .
dcPage::jsLoad(dcPage::getPF('dcAdvancedCleaner/js/index.js'));
# --BEHAVIOR-- dcAdvancedCleanerAdminHeader
$core->callBehavior('dcAdvancedCleanerAdminHeader', $core);
dcCore::app()->callBehavior('dcAdvancedCleanerAdminHeader');
echo '</head><body>' .
dcPage::breadcrumb([
__('Plugins') => '',
__('Advanced cleaner') => ''
__('Advanced cleaner') => '',
]) .
dcPage::notices() .
'<form method="get" action="' . $core->adminurl->get('admin.plugin.dcAdvancedCleaner') . '" id="parts_menu">' .
'<form method="get" action="' . dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner') . '" id="parts_menu">' .
'<p class="anchor-nav"><label for="part" class="classic">' . __('Goto:') . ' </label>' .
form::combo('part', $select_menu, $cleaner->id) . ' ' .
'<input type="submit" value="' . __('Ok') . '" />' .
@ -78,7 +78,7 @@ if (empty($rs)) {
echo '<p>' . __('There is nothing to display') . '</p>';
} else {
echo
'<form method="post" action="' . $core->adminurl->get('admin.plugin.dcAdvancedCleaner') . '" id="form-funcs">' .
'<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner') . '" id="form-funcs">' .
'<div class="table-outer">' .
'<table><caption>' . sprintf(__('There are %s %s'), count($rs), __($cleaner->id)) . '</caption><thead><tr>' .
'<th colspan="2">' . __('Name') . '</th><th>' . __('Objects') . '</th>' .
@ -87,7 +87,7 @@ if (empty($rs)) {
foreach ($rs as $k => $v) {
$offline = in_array($v['key'], $cleaner->official());
if ($offline && $core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) {
if ($offline && dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) {
continue;
}
echo
@ -108,14 +108,14 @@ if (empty($rs)) {
'<input id="do-action" type="submit" value="' . __('ok') . '" />' .
form::hidden(['p'], 'dcAdvancedCleaner') .
form::hidden(['part'], $cleaner->id) .
$core->formNonce() . '</p>' .
dcCore::app()->formNonce() . '</p>' .
'<p class="info">' .
__('Beware: All actions done here are irreversible and are directly applied') .
'</p>' .
'</form>';
}
if ($core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) {
if (dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) {
echo '<p class="info">' .
__('Default values of Dotclear are hidden. You can change this in settings') .
'</p>';