diff --git a/_admin.php b/_admin.php index 95a6ea3..8810160 100644 --- a/_admin.php +++ b/_admin.php @@ -14,25 +14,25 @@ if (!defined('DC_CONTEXT_ADMIN')) { return null; } -dcCore::app()->blog->settings->addNamespace('dcAdvancedCleaner'); +dcCore::app()->blog->settings->addNamespace(basename(__DIR__)); dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( __('Advanced cleaner'), - dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner'), - dcPage::getPF('dcAdvancedCleaner/icon.svg'), + dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)), + dcPage::getPF(basename(__DIR__) . '/icon.svg'), preg_match( - '/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner')) . '(&.*)?$/', + '/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/', $_SERVER['REQUEST_URI'] ), dcCore::app()->auth->isSuperAdmin() ); dcCore::app()->addBehavior('adminDashboardFavoritesV2', function ($favs) { - $favs->register('dcAdvancedCleaner', [ + $favs->register(basename(__DIR__), [ 'title' => __('Advanced cleaner'), - 'url' => dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner'), - 'small-icon' => dcPage::getPF('dcAdvancedCleaner/icon.png'), - 'large-icon' => dcPage::getPF('dcAdvancedCleaner/icon-big.png'), + 'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)), + 'small-icon' => dcPage::getPF(basename(__DIR__) . '/icon.png'), + 'large-icon' => dcPage::getPF(basename(__DIR__) . '/icon-big.png'), //'permissions' => dcCore::app()->auth->isSuperAdmin(), ]); }); @@ -42,7 +42,7 @@ dcCore::app()->addBehavior('pluginsToolsTabsV2', function () { $redir = dcCore::app()->adminurl->get('admin.plugins', [], '#uninstaller'); $title = ''; - if (!dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) { + if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_behavior_active) { return null; } $title = empty($title) ? __('Advanced uninstall') : $title; @@ -144,7 +144,7 @@ dcCore::app()->addBehavior('pluginsToolsTabsV2', function () { }); dcCore::app()->addBehavior('adminModulesListDoActions', function ($list, $modules, $type) { - if (!dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) { + if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_behavior_active) { return null; } @@ -209,7 +209,7 @@ function dcAdvancedCleanerModuleBeforeDelete($module) { $done = false; - if (!dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) { + if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_behavior_active) { return null; } $uninstaller = new dcUninstaller(); diff --git a/_config.php b/_config.php index c63247d..6be05da 100644 --- a/_config.php +++ b/_config.php @@ -20,10 +20,10 @@ if (!dcCore::app()->auth->isSuperAdmin()) { if (!empty($_POST['save'])) { try { - dcCore::app()->blog->settings->dcAdvancedCleaner->dropEvery( + dcCore::app()->blog->settings->__get(basename(__DIR__))->dropEvery( 'dcAdvancedCleaner_behavior_active' ); - dcCore::app()->blog->settings->dcAdvancedCleaner->put( + dcCore::app()->blog->settings->__get(basename(__DIR__))->put( 'dcAdvancedCleaner_behavior_active', !empty($_POST['behavior_active']), 'boolean', @@ -31,10 +31,10 @@ if (!empty($_POST['save'])) { true, true ); - dcCore::app()->blog->settings->dcAdvancedCleaner->dropEvery( + dcCore::app()->blog->settings->__get(basename(__DIR__))->dropEvery( 'dcAdvancedCleaner_dcproperty_hide' ); - dcCore::app()->blog->settings->dcAdvancedCleaner->put( + dcCore::app()->blog->settings->__get(basename(__DIR__))->put( 'dcAdvancedCleaner_dcproperty_hide', !empty($_POST['dcproperty_hide']), 'boolean', @@ -48,7 +48,7 @@ if (!empty($_POST['save'])) { dcCore::app()->adminurl->redirect( 'admin.plugins', [ - 'module' => 'dcAdvancedCleaner', + 'module' => basename(__DIR__), 'conf' => 1, 'redir' => empty($_REQUEST['redir']) ? dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'], ] @@ -62,14 +62,14 @@ echo ' form::checkbox( 'behavior_active', 1, - dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active + dcCore::app()->blog->settings->__get(basename(__DIR__))->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 6d848fb..c6c0aee 100644 --- a/_define.php +++ b/_define.php @@ -23,8 +23,8 @@ $this->registerModule( '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', + 'support' => 'https://github.com/JcDenis/' . basename(__DIR__), + 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__), + 'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml', ] ); diff --git a/_install.php b/_install.php index 801d8d1..ad38e51 100644 --- a/_install.php +++ b/_install.php @@ -22,9 +22,9 @@ try { return null; } - dcCore::app()->blog->settings->addNamespace('dcAdvancedCleaner'); + dcCore::app()->blog->settings->addNamespace(basename(__DIR__)); - dcCore::app()->blog->settings->dcAdvancedCleaner->put( + dcCore::app()->blog->settings->__get(basename(__DIR__))->put( 'dcAdvancedCleaner_behavior_active', true, 'boolean', @@ -32,7 +32,7 @@ try { false, true ); - dcCore::app()->blog->settings->dcAdvancedCleaner->put( + dcCore::app()->blog->settings->__get(basename(__DIR__))->put( 'dcAdvancedCleaner_dcproperty_hide', true, 'boolean', diff --git a/inc/class.dc.advanced.cleaner.php b/inc/class.dc.advanced.cleaner.php index 670d631..fc10927 100644 --- a/inc/class.dc.advanced.cleaner.php +++ b/inc/class.dc.advanced.cleaner.php @@ -55,7 +55,7 @@ class dcAdvancedCleaner if (!isset($this->cleaners[$type])) { throw new exception(sprintf(__('unknow cleaner type %s'), $type)); } - if (strtolower($ns) == 'dcadvancedcleaner') { + if ($ns == basename(dirname('../' . __DIR__))) { throw new exception(__("dcAdvancedCleaner can't remove itself")); } diff --git a/index.php b/index.php index 19c722b..1cde6c8 100644 --- a/index.php +++ b/index.php @@ -40,7 +40,7 @@ if (!empty($_POST['entries']) && !empty($_POST['action'])) { } dcAdminNotices::addSuccessNotice(__('Action successfuly excecuted')); dcCore::app()->adminurl->redirect( - 'admin.plugin.dcAdvancedCleaner', + 'admin.plugin.' . basename(__DIR__), ['part' => $cleaner->id] ); } catch (Exception $e) { @@ -50,8 +50,8 @@ if (!empty($_POST['entries']) && !empty($_POST['action'])) { # Display echo '' . __('Advanced cleaner') . '' . -dcPage::cssLoad(dcPage::getPF('dcAdvancedCleaner/style.css')) . -dcPage::jsLoad(dcPage::getPF('dcAdvancedCleaner/js/index.js')); +dcPage::cssLoad(dcPage::getPF(basename(__DIR__) . '/style.css')) . +dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/index.js')); # --BEHAVIOR-- dcAdvancedCleanerAdminHeader dcCore::app()->callBehavior('dcAdvancedCleanerAdminHeader'); @@ -63,11 +63,11 @@ dcPage::breadcrumb([ ]) . dcPage::notices() . -'
' . +'' . '

' . form::combo('part', $select_menu, $cleaner->id) . ' ' . '' . -form::hidden('p', 'dcAdvancedCleaner') . '

' . +form::hidden('p', basename(__DIR__)) . '

' . '
' . '

' . $cleaner->name . '

' . $cleaner->desc . '

'; @@ -78,7 +78,7 @@ if (empty($rs)) { echo '

' . __('There is nothing to display') . '

'; } else { echo - '
' . + '' . '
' . '' . '' . @@ -87,7 +87,7 @@ if (empty($rs)) { foreach ($rs as $k => $v) { $offline = in_array($v['key'], $cleaner->official()); - if ($offline && dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) { + if ($offline && dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_dcproperty_hide) { continue; } echo @@ -106,7 +106,7 @@ if (empty($rs)) { '

' . __('Action on selected rows:') . ' ' . form::combo(['action'], array_flip($cleaner->getActions())) . '' . - form::hidden(['p'], 'dcAdvancedCleaner') . + form::hidden(['p'], basename(__DIR__)) . form::hidden(['part'], $cleaner->id) . dcCore::app()->formNonce() . '

' . '

' . @@ -115,7 +115,7 @@ if (empty($rs)) { ''; } -if (dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) { +if (dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_dcproperty_hide) { echo '

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

';
' . sprintf(__('There are %s %s'), count($rs), __($cleaner->id)) . '
' . __('Name') . '' . __('Objects') . '