use abstract plugin name

This commit is contained in:
Jean-Christian Paul Denis 2022-12-10 18:02:56 +01:00
parent fdda434480
commit 05a74d8f8a
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
6 changed files with 34 additions and 34 deletions

View File

@ -14,25 +14,25 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
dcCore::app()->blog->settings->addNamespace('dcAdvancedCleaner'); dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Advanced cleaner'), __('Advanced cleaner'),
dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner'), dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
dcPage::getPF('dcAdvancedCleaner/icon.svg'), dcPage::getPF(basename(__DIR__) . '/icon.svg'),
preg_match( preg_match(
'/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner')) . '(&.*)?$/', '/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/',
$_SERVER['REQUEST_URI'] $_SERVER['REQUEST_URI']
), ),
dcCore::app()->auth->isSuperAdmin() dcCore::app()->auth->isSuperAdmin()
); );
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function ($favs) { dcCore::app()->addBehavior('adminDashboardFavoritesV2', function ($favs) {
$favs->register('dcAdvancedCleaner', [ $favs->register(basename(__DIR__), [
'title' => __('Advanced cleaner'), 'title' => __('Advanced cleaner'),
'url' => dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner'), 'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
'small-icon' => dcPage::getPF('dcAdvancedCleaner/icon.png'), 'small-icon' => dcPage::getPF(basename(__DIR__) . '/icon.png'),
'large-icon' => dcPage::getPF('dcAdvancedCleaner/icon-big.png'), 'large-icon' => dcPage::getPF(basename(__DIR__) . '/icon-big.png'),
//'permissions' => dcCore::app()->auth->isSuperAdmin(), //'permissions' => dcCore::app()->auth->isSuperAdmin(),
]); ]);
}); });
@ -42,7 +42,7 @@ dcCore::app()->addBehavior('pluginsToolsTabsV2', function () {
$redir = dcCore::app()->adminurl->get('admin.plugins', [], '#uninstaller'); $redir = dcCore::app()->adminurl->get('admin.plugins', [], '#uninstaller');
$title = ''; $title = '';
if (!dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) { if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_behavior_active) {
return null; return null;
} }
$title = empty($title) ? __('Advanced uninstall') : $title; $title = empty($title) ? __('Advanced uninstall') : $title;
@ -144,7 +144,7 @@ dcCore::app()->addBehavior('pluginsToolsTabsV2', function () {
}); });
dcCore::app()->addBehavior('adminModulesListDoActions', function ($list, $modules, $type) { 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; return null;
} }
@ -209,7 +209,7 @@ function dcAdvancedCleanerModuleBeforeDelete($module)
{ {
$done = false; $done = false;
if (!dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) { if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_behavior_active) {
return null; return null;
} }
$uninstaller = new dcUninstaller(); $uninstaller = new dcUninstaller();

View File

@ -20,10 +20,10 @@ if (!dcCore::app()->auth->isSuperAdmin()) {
if (!empty($_POST['save'])) { if (!empty($_POST['save'])) {
try { try {
dcCore::app()->blog->settings->dcAdvancedCleaner->dropEvery( dcCore::app()->blog->settings->__get(basename(__DIR__))->dropEvery(
'dcAdvancedCleaner_behavior_active' 'dcAdvancedCleaner_behavior_active'
); );
dcCore::app()->blog->settings->dcAdvancedCleaner->put( dcCore::app()->blog->settings->__get(basename(__DIR__))->put(
'dcAdvancedCleaner_behavior_active', 'dcAdvancedCleaner_behavior_active',
!empty($_POST['behavior_active']), !empty($_POST['behavior_active']),
'boolean', 'boolean',
@ -31,10 +31,10 @@ if (!empty($_POST['save'])) {
true, true,
true true
); );
dcCore::app()->blog->settings->dcAdvancedCleaner->dropEvery( dcCore::app()->blog->settings->__get(basename(__DIR__))->dropEvery(
'dcAdvancedCleaner_dcproperty_hide' 'dcAdvancedCleaner_dcproperty_hide'
); );
dcCore::app()->blog->settings->dcAdvancedCleaner->put( dcCore::app()->blog->settings->__get(basename(__DIR__))->put(
'dcAdvancedCleaner_dcproperty_hide', 'dcAdvancedCleaner_dcproperty_hide',
!empty($_POST['dcproperty_hide']), !empty($_POST['dcproperty_hide']),
'boolean', 'boolean',
@ -48,7 +48,7 @@ if (!empty($_POST['save'])) {
dcCore::app()->adminurl->redirect( dcCore::app()->adminurl->redirect(
'admin.plugins', 'admin.plugins',
[ [
'module' => 'dcAdvancedCleaner', 'module' => basename(__DIR__),
'conf' => 1, 'conf' => 1,
'redir' => empty($_REQUEST['redir']) ? dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'], 'redir' => empty($_REQUEST['redir']) ? dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'],
] ]
@ -62,14 +62,14 @@ echo '
form::checkbox( form::checkbox(
'behavior_active', 'behavior_active',
1, 1,
dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_behavior_active
) . ' ' . __('Activate behaviors') . '</label></p> ) . ' ' . __('Activate behaviors') . '</label></p>
<p class="form-note">' . __('Enable actions set in _uninstall.php files.') . '</p> <p class="form-note">' . __('Enable actions set in _uninstall.php files.') . '</p>
<p><label class="classic" for="dcproperty_hide">' . <p><label class="classic" for="dcproperty_hide">' .
form::checkbox( form::checkbox(
'dcproperty_hide', 'dcproperty_hide',
1, 1,
dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_dcproperty_hide
) . ' ' . __('Hide Dotclear default properties in actions tabs') . '</label></p> ) . ' ' . __('Hide Dotclear default properties in actions tabs') . '</label></p>
<p class="form-note">' . <p class="form-note">' .
__('Prevent from deleting Dotclear important properties.') . '</p>'; __('Prevent from deleting Dotclear important properties.') . '</p>';

View File

@ -23,8 +23,8 @@ $this->registerModule(
'requires' => [['core', '2.24']], 'requires' => [['core', '2.24']],
'permissions' => null, 'permissions' => null,
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://github.com/JcDenis/dcAdvancedCleaner', 'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
'details' => 'https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner', 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://raw.githubusercontent.com/JcDenis/dcAdvancedCleaner/master/dcstore.xml', 'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
] ]
); );

View File

@ -22,9 +22,9 @@ try {
return null; 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', 'dcAdvancedCleaner_behavior_active',
true, true,
'boolean', 'boolean',
@ -32,7 +32,7 @@ try {
false, false,
true true
); );
dcCore::app()->blog->settings->dcAdvancedCleaner->put( dcCore::app()->blog->settings->__get(basename(__DIR__))->put(
'dcAdvancedCleaner_dcproperty_hide', 'dcAdvancedCleaner_dcproperty_hide',
true, true,
'boolean', 'boolean',

View File

@ -55,7 +55,7 @@ class dcAdvancedCleaner
if (!isset($this->cleaners[$type])) { if (!isset($this->cleaners[$type])) {
throw new exception(sprintf(__('unknow cleaner type %s'), $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")); throw new exception(__("dcAdvancedCleaner can't remove itself"));
} }

View File

@ -40,7 +40,7 @@ if (!empty($_POST['entries']) && !empty($_POST['action'])) {
} }
dcAdminNotices::addSuccessNotice(__('Action successfuly excecuted')); dcAdminNotices::addSuccessNotice(__('Action successfuly excecuted'));
dcCore::app()->adminurl->redirect( dcCore::app()->adminurl->redirect(
'admin.plugin.dcAdvancedCleaner', 'admin.plugin.' . basename(__DIR__),
['part' => $cleaner->id] ['part' => $cleaner->id]
); );
} catch (Exception $e) { } catch (Exception $e) {
@ -50,8 +50,8 @@ if (!empty($_POST['entries']) && !empty($_POST['action'])) {
# Display # Display
echo '<html><head><title>' . __('Advanced cleaner') . '</title>' . echo '<html><head><title>' . __('Advanced cleaner') . '</title>' .
dcPage::cssLoad(dcPage::getPF('dcAdvancedCleaner/style.css')) . dcPage::cssLoad(dcPage::getPF(basename(__DIR__) . '/style.css')) .
dcPage::jsLoad(dcPage::getPF('dcAdvancedCleaner/js/index.js')); dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/index.js'));
# --BEHAVIOR-- dcAdvancedCleanerAdminHeader # --BEHAVIOR-- dcAdvancedCleanerAdminHeader
dcCore::app()->callBehavior('dcAdvancedCleanerAdminHeader'); dcCore::app()->callBehavior('dcAdvancedCleanerAdminHeader');
@ -63,11 +63,11 @@ dcPage::breadcrumb([
]) . ]) .
dcPage::notices() . dcPage::notices() .
'<form method="get" action="' . dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner') . '" id="parts_menu">' . '<form method="get" action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" id="parts_menu">' .
'<p class="anchor-nav"><label for="part" class="classic">' . __('Goto:') . ' </label>' . '<p class="anchor-nav"><label for="part" class="classic">' . __('Goto:') . ' </label>' .
form::combo('part', $select_menu, $cleaner->id) . ' ' . form::combo('part', $select_menu, $cleaner->id) . ' ' .
'<input type="submit" value="' . __('Ok') . '" />' . '<input type="submit" value="' . __('Ok') . '" />' .
form::hidden('p', 'dcAdvancedCleaner') . '</p>' . form::hidden('p', basename(__DIR__)) . '</p>' .
'</form>' . '</form>' .
'<h3>' . $cleaner->name . '</h3><p>' . $cleaner->desc . '</p>'; '<h3>' . $cleaner->name . '</h3><p>' . $cleaner->desc . '</p>';
@ -78,7 +78,7 @@ if (empty($rs)) {
echo '<p>' . __('There is nothing to display') . '</p>'; echo '<p>' . __('There is nothing to display') . '</p>';
} else { } else {
echo echo
'<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.dcAdvancedCleaner') . '" id="form-funcs">' . '<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" id="form-funcs">' .
'<div class="table-outer">' . '<div class="table-outer">' .
'<table><caption>' . sprintf(__('There are %s %s'), count($rs), __($cleaner->id)) . '</caption><thead><tr>' . '<table><caption>' . sprintf(__('There are %s %s'), count($rs), __($cleaner->id)) . '</caption><thead><tr>' .
'<th colspan="2">' . __('Name') . '</th><th>' . __('Objects') . '</th>' . '<th colspan="2">' . __('Name') . '</th><th>' . __('Objects') . '</th>' .
@ -87,7 +87,7 @@ if (empty($rs)) {
foreach ($rs as $k => $v) { foreach ($rs as $k => $v) {
$offline = in_array($v['key'], $cleaner->official()); $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; continue;
} }
echo echo
@ -106,7 +106,7 @@ if (empty($rs)) {
'<p class="field">' . __('Action on selected rows:') . ' ' . '<p class="field">' . __('Action on selected rows:') . ' ' .
form::combo(['action'], array_flip($cleaner->getActions())) . form::combo(['action'], array_flip($cleaner->getActions())) .
'<input id="do-action" type="submit" value="' . __('ok') . '" />' . '<input id="do-action" type="submit" value="' . __('ok') . '" />' .
form::hidden(['p'], 'dcAdvancedCleaner') . form::hidden(['p'], basename(__DIR__)) .
form::hidden(['part'], $cleaner->id) . form::hidden(['part'], $cleaner->id) .
dcCore::app()->formNonce() . '</p>' . dcCore::app()->formNonce() . '</p>' .
'<p class="info">' . '<p class="info">' .
@ -115,7 +115,7 @@ if (empty($rs)) {
'</form>'; '</form>';
} }
if (dcCore::app()->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) { if (dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_dcproperty_hide) {
echo '<p class="info">' . echo '<p class="info">' .
__('Default values of Dotclear are hidden. You can change this in settings') . __('Default values of Dotclear are hidden. You can change this in settings') .
'</p>'; '</p>';