diff --git a/_prepend.php b/_prepend.php index d946a7e..70f84d2 100644 --- a/_prepend.php +++ b/_prepend.php @@ -30,8 +30,6 @@ $core->addBehavior('pluginsBeforeDelete', ['behaviorsDcAdvancedCleaner', 'pluginsBeforeDelete']); $core->addBehavior('themeBeforeDelete', ['behaviorsDcAdvancedCleaner', 'themeBeforeDelete']); -$core->addBehavior('dcAdvancedCleanerAdminTabs', - ['behaviorsDcAdvancedCleaner', 'dcAdvancedCleanerAdminTabs']); if (defined('ACTIVITY_REPORT')) { dcAdvancedCleanerActivityReportBehaviors::add($core); diff --git a/inc/lib.dc.advanced.cleaner.behaviors.php b/inc/lib.dc.advanced.cleaner.behaviors.php index 6fa23d4..407db3e 100644 --- a/inc/lib.dc.advanced.cleaner.behaviors.php +++ b/inc/lib.dc.advanced.cleaner.behaviors.php @@ -60,11 +60,6 @@ class behaviorsDcAdvancedCleaner } } - public static function dcAdvancedCleanerAdminTabs($core) - { - self::modulesTabs($core, DC_PLUGINS_ROOT, $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => 'uninstaller'])); - } - public static function pluginsToolsTabs($core) { self::modulesTabs($core, DC_PLUGINS_ROOT, $core->adminurl->get('admin.plugins', ['tab' => 'uninstaller'])); diff --git a/index.php b/index.php index be65f00..4060a9f 100644 --- a/index.php +++ b/index.php @@ -14,9 +14,8 @@ if (!defined('DC_CONTEXT_ADMIN')) { return null; } -if (!$core->auth->isSuperAdmin()) { - return null; -} + +dcPage::checkSuper(); # Localized l10n __('Settings'); __('settings'); __('setting'); @@ -41,59 +40,56 @@ __('delete %s theme file'); __('delete %s cache files'); # vars -$tab = $_REQUEST['tab'] ?? 'lists'; -$part = $_REQUEST['part'] ?? 'caches'; +$part = $_REQUEST['part'] ?? 'caches'; $entries = $_POST['entries'] ?? []; -$action = $_POST['action'] ?? ''; -$s = $core->blog->settings->dcAdvancedCleaner; -$p_url = $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => $tab, 'part' => $part]); +$action = $_POST['action'] ?? ''; # Combos $combo_title = [ 'settings' => __('Settings'), - 'tables' => __('Tables'), - 'plugins' => __('Extensions'), - 'themes' => __('Themes'), - 'caches' => __('Cache'), + 'tables' => __('Tables'), + 'plugins' => __('Extensions'), + 'themes' => __('Themes'), + 'caches' => __('Cache'), 'versions' => __('Versions') ]; $combo_type = [ 'settings' => ['delete_global', 'delete_local', 'delete_all'], - 'tables' => ['empty', 'delete'], - 'plugins' => ['empty', 'delete'], - 'themes' => ['empty', 'delete'], - 'caches' => ['empty', 'delete'], + 'tables' => ['empty', 'delete'], + 'plugins' => ['empty', 'delete'], + 'themes' => ['empty', 'delete'], + 'caches' => ['empty', 'delete'], 'versions' => ['delete'] ]; $combo_funcs = [ 'settings' => ['dcAdvancedCleaner', 'getSettings'], - 'tables' => ['dcAdvancedCleaner', 'getTables'], - 'plugins' => ['dcAdvancedCleaner', 'getPlugins'], - 'themes' => ['dcAdvancedCleaner', 'getThemes'], - 'caches' => ['dcAdvancedCleaner', 'getCaches'], + 'tables' => ['dcAdvancedCleaner', 'getTables'], + 'plugins' => ['dcAdvancedCleaner', 'getPlugins'], + 'themes' => ['dcAdvancedCleaner', 'getThemes'], + 'caches' => ['dcAdvancedCleaner', 'getCaches'], 'versions' => ['dcAdvancedCleaner', 'getVersions'] ]; $combo_actions = [ 'settings' => [ __('delete global settings') => 'delete_global', - __('delete blog settings') => 'delete_local', - __('delete all settings') =>'delete_all' + __('delete blog settings') => 'delete_local', + __('delete all settings') =>'delete_all' ], - 'tables' => [ + 'tables' => [ __('delete') => 'delete', - __('empty') => 'empty' + __('empty') => 'empty' ], - 'plugins' => [ + 'plugins' => [ __('delete') => 'delete', - __('empty') => 'empty' + __('empty') => 'empty' ], - 'themes' => [ + 'themes' => [ __('delete') => 'delete', - __('empty') => 'empty' + __('empty') => 'empty' ], - 'caches' => [ + 'caches' => [ __('delete') => 'delete', - __('empty') => 'empty' + __('empty') => 'empty' ], 'versions' => [ __('delete') => 'delete' @@ -101,16 +97,15 @@ $combo_actions = [ ]; $combo_help = [ 'settings' => __('Namespaces registered in dcSettings'), - 'tables' => __('All database tables of Dotclear'), - 'plugins' => __('Folders from plugins directories'), - 'themes' => __('Folders from blog themes directory'), - 'caches' => __('Folders from cache directory'), + 'tables' => __('All database tables of Dotclear'), + 'plugins' => __('Folders from plugins directories'), + 'themes' => __('Folders from blog themes directory'), + 'caches' => __('Folders from cache directory'), 'versions' => __('Versions registered in table "version" of Dotclear') ]; # Actions -if ($tab == 'lists' - && !empty($entries) +if (!empty($entries) && isset($combo_type[$part]) && in_array($action, $combo_type[$part]) ) { @@ -121,7 +116,7 @@ if ($tab == 'lists' dcPage::addSuccessNotice(__('Action successfuly excecuted')); $core->adminurl->redirect( 'admin.plugin.dcAdvancedCleaner', - ['tab' => 'lists', 'part' => $part] + ['part' => $part] ); } catch(Exception $e) { @@ -130,35 +125,30 @@ if ($tab == 'lists' } echo '' . __('Advanced cleaner') . '' . -dcPage::cssLoad('index.php?pf=dcAdvancedCleaner/style.css') . -dcPage::jsPageTabs($tab); +dcPage::cssLoad(dcPage::getPF('dcAdvancedCleaner/style.css')) . +dcPage::jsLoad(dcPage::getPF('dcAdvancedCleaner/js/index.js')); # --BEHAVIOR-- dcAdvancedCleanerAdminHeader -$core->callBehavior('dcAdvancedCleanerAdminHeader', $core, $p_url, $tab); +$core->callBehavior('dcAdvancedCleanerAdminHeader', $core); echo '' . dcPage::breadcrumb([ - html::escapeHTML($core->blog->name) => '', - '' . __('Advanced cleaner') . '' => '' + __('Plugins') => '', + __('Advanced cleaner') => '' ]) . -dcPage::notices() . ' -
-

'. __('Records and folders') .'

'; +dcPage::notices(); -foreach($combo_title as $k => $v) { - echo sprintf( - '%s', - $core->adminurl->get( - 'admin.plugin.dcAdvancedCleaner', - ['tab' => 'lists', 'part' => $k] - ), - $v - ); -} -echo '

'; +# select menu list +echo +'
' . +'

' . +form::combo('part', array_flip($combo_title), $part) . ' ' . +'' . +form::hidden('p', 'dcAdvancedCleaner') . '

' . +'
'; if (isset($combo_funcs[$part])) { - echo '

' . $combo_title[$part] . '

' . $combo_help[$part] . '

'; + echo '

' . $combo_title[$part] . '

' . $combo_help[$part] . '

'; $rs = call_user_func($combo_funcs[$part], $core); @@ -166,39 +156,36 @@ if (isset($combo_funcs[$part])) { echo '

' . sprintf(__('There is no %s'), __(substr($part, 0, -1))) . '

'; } else { echo - '

' . sprintf(__('There are %s %s'), count($rs), __($part)) . '

' . - '
' . + '' . '
' . - '' . - '' . + '
' . __('Name') . '' . __('Objects') . '
' . + '' . ''; $official = dcAdvancedCleaner::getOfficial($part); foreach($rs as $k => $v) { $offline = in_array($v['key'], $official); - if ($s->dcAdvancedCleaner_dcproperty_hide && $offline) { + if ($offline && $core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) { continue; } echo - '' . - '' . - '' . + '' . + ' ' . + '' . + '' . ''; } echo '
' . sprintf(__('There are %s %s'), count($rs), __($part)) . '
' . __('Name') . '' . __('Objects') . '
' . $v['value'] . '
' . + form::checkbox( + ['entries[' . $k . ']', 'entries_' . $k], + html::escapeHTML($v['key']) + ) . '' . $v['value'] . '
' . '

' . __('Action on selected rows:') . ' ' . form::combo(['action'], $combo_actions[$part]) . - '' . + '' . form::hidden(['p'], 'dcAdvancedCleaner') . - form::hidden(['tab'], 'lists') . form::hidden(['part'], $part) . $core->formNonce() . '

' . '

' . @@ -207,17 +194,12 @@ if (isset($combo_funcs[$part])) { '

'; } } -if ($s->dcAdvancedCleaner_dcproperty_hide) { +if ($core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) { echo '

' . - __('Default values of Dotclear are hidden. You can change this in settings tab') . + __('Default values of Dotclear are hidden. You can change this in settings') . '

'; } -echo '
'; - -# --BEHAVIOR-- dcAdvancedCleanerAdminTabs -$core->callBehavior('dcAdvancedCleanerAdminTabs', $core); - dcPage::helpBlock('dcAdvancedCleaner'); echo ''; \ No newline at end of file diff --git a/js/index.js b/js/index.js new file mode 100644 index 0000000..f36deef --- /dev/null +++ b/js/index.js @@ -0,0 +1,8 @@ +/*global $, dotclear */ +'use strict'; + +$(function () { + $('#parts_menu input[type=submit]').hide(); + $('#parts_menu #part').on('change', function () {this.form.submit();}); + dotclear.condSubmit('#form-funcs td input[type=checkbox]', '#form-funcs #do-action'); +}); \ No newline at end of file