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

View File

@ -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') . '</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,
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>
<p class="form-note">' .
__('Prevent from deleting Dotclear important properties.') . '</p>';

View File

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

View File

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

View File

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

View File

@ -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 '<html><head><title>' . __('Advanced cleaner') . '</title>' .
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 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>' .
form::combo('part', $select_menu, $cleaner->id) . ' ' .
'<input type="submit" value="' . __('Ok') . '" />' .
form::hidden('p', 'dcAdvancedCleaner') . '</p>' .
form::hidden('p', basename(__DIR__)) . '</p>' .
'</form>' .
'<h3>' . $cleaner->name . '</h3><p>' . $cleaner->desc . '</p>';
@ -78,7 +78,7 @@ if (empty($rs)) {
echo '<p>' . __('There is nothing to display') . '</p>';
} else {
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">' .
'<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 && 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)) {
'<p class="field">' . __('Action on selected rows:') . ' ' .
form::combo(['action'], array_flip($cleaner->getActions())) .
'<input id="do-action" type="submit" value="' . __('ok') . '" />' .
form::hidden(['p'], 'dcAdvancedCleaner') .
form::hidden(['p'], basename(__DIR__)) .
form::hidden(['part'], $cleaner->id) .
dcCore::app()->formNonce() . '</p>' .
'<p class="info">' .
@ -115,7 +115,7 @@ if (empty($rs)) {
'</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">' .
__('Default values of Dotclear are hidden. You can change this in settings') .
'</p>';