fix dasboard icon, fix #2

This commit is contained in:
Jean-Christian Paul Denis 2023-01-30 19:15:12 +01:00
parent 949041f081
commit 02813085c2
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951

View File

@ -14,8 +14,6 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
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.' . basename(__DIR__)), dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
@ -27,182 +25,184 @@ dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
dcCore::app()->auth->isSuperAdmin() dcCore::app()->auth->isSuperAdmin()
); );
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function ($favs) { dcCore::app()->addBehaviors([
$favs->register(basename(__DIR__), [ 'adminDashboardFavoritesV2' => function ($favs) {
'title' => __('Advanced cleaner'), $favs->register(basename(__DIR__), [
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)), 'title' => __('Advanced cleaner'),
'small-icon' => dcPage::getPF(basename(__DIR__) . '/icon.png'), 'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
'large-icon' => dcPage::getPF(basename(__DIR__) . '/icon-big.png'), 'small-icon' => dcPage::getPF(basename(__DIR__) . '/icon.svg'),
//'permissions' => dcCore::app()->auth->isSuperAdmin(), 'large-icon' => dcPage::getPF(basename(__DIR__) . '/icon-big.svg'),
]); //'permissions' => dcCore::app()->auth->isSuperAdmin(),
}); ]);
},
dcCore::app()->addBehavior('pluginsToolsTabsV2', function () { 'pluginsToolsTabsV2' => function () {
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_behavior_active) { if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_behavior_active) {
return null; return null;
} }
$path = DC_PLUGINS_ROOT; $path = DC_PLUGINS_ROOT;
$redir = dcCore::app()->adminurl->get('admin.plugins', [], '#uninstaller'); $redir = dcCore::app()->adminurl->get('admin.plugins', [], '#uninstaller');
$title = ''; $title = '';
$uninstaller = new dcUninstaller(); $uninstaller = new dcUninstaller();
$uninstaller->loadModules($path); $uninstaller->loadModules($path);
$modules = $uninstaller->getModules(); $modules = $uninstaller->getModules();
$props = $uninstaller->getAllowedActions(); $props = $uninstaller->getAllowedActions();
echo '<div class="multi-part" id="uninstaller" title="' . __('Advanced uninstall') . '"><h3>' . __('Advanced uninstall') . '</h3>'; echo '<div class="multi-part" id="uninstaller" title="' . __('Advanced uninstall') . '"><h3>' . __('Advanced uninstall') . '</h3>';
if (!count($modules)) { if (!count($modules)) {
echo '<p>' . __('There is no module with uninstall features') . '</p></div>'; echo '<p>' . __('There is no module with uninstall features') . '</p></div>';
return null; return null;
} }
echo
'<p>' . __('List of modules with advanced uninstall features') . '</p>' .
'<form method="post" action="' . $redir . '">' .
'<table class="clear"><tr>' .
'<th colspan="2">' . __('module') . '</th>';
foreach ($props as $pro_id => $prop) {
echo '<th>' . __($pro_id) . '</th>';
}
echo '<th>' . __('other') . '</th>' . '</tr>';
$i = 0;
foreach ($modules as $module_id => $module) {
echo echo
'<tr class="line">' . '<p>' . __('List of modules with advanced uninstall features') . '</p>' .
'<td class="nowrap">' . $module_id . '</td>' . '<form method="post" action="' . $redir . '">' .
'<td class="nowrap">' . $module['version'] . '</td>'; '<table class="clear"><tr>' .
'<th colspan="2">' . __('module') . '</th>';
$actions = $uninstaller->getUserActions($module_id); foreach ($props as $pro_id => $prop) {
echo '<th>' . __($pro_id) . '</th>';
}
foreach ($props as $prop_id => $prop) { echo '<th>' . __('other') . '</th>' . '</tr>';
echo '<td class="nowrap">';
if (!isset($actions[$prop_id])) { $i = 0;
echo '--</td>'; foreach ($modules as $module_id => $module) {
echo
'<tr class="line">' .
'<td class="nowrap">' . $module_id . '</td>' .
'<td class="nowrap">' . $module['version'] . '</td>';
continue; $actions = $uninstaller->getUserActions($module_id);
}
foreach ($props as $prop_id => $prop) {
echo '<td class="nowrap">';
if (!isset($actions[$prop_id])) {
echo '--</td>';
$j = 0;
foreach ($actions[$prop_id] as $action_id => $action) {
if (!isset($props[$prop_id][$action['action']])) {
continue; continue;
} }
$ret = base64_encode(serialize([
'type' => $prop_id, $j = 0;
'action' => $action['action'], foreach ($actions[$prop_id] as $action_id => $action) {
'ns' => $action['ns'], if (!isset($props[$prop_id][$action['action']])) {
])); continue;
}
$ret = base64_encode(serialize([
'type' => $prop_id,
'action' => $action['action'],
'ns' => $action['ns'],
]));
echo '<label class="classic">' .
form::checkbox(['actions[' . $module_id . '][' . $j . ']'], $ret) .
' ' . $action['desc'] . '</label><br />';
$j++;
}
echo '</td>';
}
echo '<td class="nowrap">';
$callbacks = $uninstaller->getUserCallbacks($module_id);
if (empty($callbacks)) {
echo '--';
}
$k = 0;
foreach ($callbacks as $callback_id => $callback) {
$ret = base64_encode(serialize($callback['func']));
echo '<label class="classic">' . echo '<label class="classic">' .
form::checkbox(['actions[' . $module_id . '][' . $j . ']'], $ret) . form::checkbox(['extras[' . $module_id . '][' . $k . ']'], $ret) .
' ' . $action['desc'] . '</label><br />'; ' ' . $callback['desc'] . '</label><br />';
$j++;
} }
echo '</td>';
echo '</td></tr>';
}
echo
'</table>' .
'<p>' .
dcCore::app()->formNonce() .
form::hidden(['path'], $path) .
form::hidden(['redir'], $redir) .
form::hidden(['action'], 'uninstall') .
'<input type="submit" name="submit" value="' . __('Perform selected actions') . '" /> ' .
'</p>' .
'</form>';
echo '</div>';
},
'adminModulesListDoActions' => function ($list, $modules, $type) {
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_behavior_active) {
return null;
} }
echo '<td class="nowrap">'; if (!isset($_POST['action']) || $_POST['action'] != 'uninstall'
|| (empty($_POST['extras']) && empty($_POST['actions']))
$callbacks = $uninstaller->getUserCallbacks($module_id); ) {
return null;
if (empty($callbacks)) {
echo '--';
} }
$k = 0; $uninstaller = new dcUninstaller();
foreach ($callbacks as $callback_id => $callback) { $uninstaller->loadModules($_POST['path']);
$ret = base64_encode(serialize($callback['func'])); $modules = $uninstaller->getModules();
$props = $uninstaller->getAllowedActions();
echo '<label class="classic">' . try {
form::checkbox(['extras[' . $module_id . '][' . $k . ']'], $ret) . // Extras
' ' . $callback['desc'] . '</label><br />'; if (!empty($_POST['extras'])) {
} foreach ($_POST['extras'] as $module_id => $extras) {
foreach ($extras as $k => $sentence) {
$extra = @unserialize(@base64_decode($sentence));
echo '</td></tr>'; if (!$extra || !is_callable($extra)) {
} continue;
echo }
'</table>' . call_user_func($extra, $module_id);
'<p>' .
dcCore::app()->formNonce() .
form::hidden(['path'], $path) .
form::hidden(['redir'], $redir) .
form::hidden(['action'], 'uninstall') .
'<input type="submit" name="submit" value="' . __('Perform selected actions') . '" /> ' .
'</p>' .
'</form>';
echo '</div>';
});
dcCore::app()->addBehavior('adminModulesListDoActions', function ($list, $modules, $type) {
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->dcAdvancedCleaner_behavior_active) {
return null;
}
if (!isset($_POST['action']) || $_POST['action'] != 'uninstall'
|| (empty($_POST['extras']) && empty($_POST['actions']))
) {
return null;
}
$uninstaller = new dcUninstaller();
$uninstaller->loadModules($_POST['path']);
$modules = $uninstaller->getModules();
$props = $uninstaller->getAllowedActions();
try {
// Extras
if (!empty($_POST['extras'])) {
foreach ($_POST['extras'] as $module_id => $extras) {
foreach ($extras as $k => $sentence) {
$extra = @unserialize(@base64_decode($sentence));
if (!$extra || !is_callable($extra)) {
continue;
} }
call_user_func($extra, $module_id);
} }
} }
} // Actions
// Actions if (!empty($_POST['actions'])) {
if (!empty($_POST['actions'])) { foreach ($_POST['actions'] as $module_id => $actions) {
foreach ($_POST['actions'] as $module_id => $actions) { foreach ($actions as $k => $sentence) {
foreach ($actions as $k => $sentence) { $action = @unserialize(@base64_decode($sentence));
$action = @unserialize(@base64_decode($sentence));
if (!$action if (!$action
|| !isset($action['type']) || !isset($action['type'])
|| !isset($action['action']) || !isset($action['action'])
|| !isset($action['ns']) || !isset($action['ns'])
) { ) {
continue; continue;
}
$uninstaller->execute($action['type'], $action['action'], $action['ns']);
} }
$uninstaller->execute($action['type'], $action['action'], $action['ns']);
} }
} }
dcAdminNotices::addSuccessNotice(__('Action successfuly excecuted'));
http::redirect($_POST['redir']);
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
} }
dcAdminNotices::addSuccessNotice(__('Action successfuly excecuted')); },
http::redirect($_POST['redir']);
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
}
});
dcCore::app()->addBehavior('pluginsBeforeDelete', function ($plugin) { 'pluginsBeforeDelete' => function ($plugin) {
dcAdvancedCleanerModuleBeforeDelete($plugin); dcAdvancedCleanerModuleBeforeDelete($plugin);
}); },
dcCore::app()->addBehavior('themeBeforeDelete', function ($theme) { 'themeBeforeDelete' => function ($theme) {
dcAdvancedCleanerModuleBeforeDelete($theme); dcAdvancedCleanerModuleBeforeDelete($theme);
}); },
]);
function dcAdvancedCleanerModuleBeforeDelete($module) function dcAdvancedCleanerModuleBeforeDelete($module)
{ {