revamp admin design
This commit is contained in:
parent
d469782cfb
commit
8743445164
@ -1,10 +1,10 @@
|
|||||||
0.7.3.1 - dev
|
0.7.3.1 - dev
|
||||||
- [ ] orphan media cleaner
|
- [ ] orphan media cleaner
|
||||||
- [ ] ajouter dossier /var dans la liste des caches
|
- [ ] ajouter dossier /var dans la liste des caches
|
||||||
- [ ] update DC official values (themes,settings,tables...)
|
- [x] update DC official values (themes,settings,tables...)
|
||||||
- [ ] fix admin design
|
- [x] fix admin design
|
||||||
- [ ] fix php7.3+ and php8.0
|
- [x] fix php7.3+ and php8.0
|
||||||
- [ ] fix PSR(1)2 coding style
|
- [x] fix PSR(1)2 coding style
|
||||||
- [ ] fix translation
|
- [ ] fix translation
|
||||||
- [x] add dcstore (pre release)
|
- [x] add dcstore (pre release)
|
||||||
- [x] update license
|
- [x] update license
|
||||||
|
12
_config.php
12
_config.php
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_MODULE')) {
|
if (!defined('DC_CONTEXT_MODULE')) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -31,7 +31,7 @@ class dcAdvancedCleanerActivityReportBehaviors
|
|||||||
'dcadvancedcleaner',
|
'dcadvancedcleaner',
|
||||||
__('Plugin dcAdvancedCleaner')
|
__('Plugin dcAdvancedCleaner')
|
||||||
);
|
);
|
||||||
|
|
||||||
// from BEHAVIOR dcAdvancedCleanerBeforeAction
|
// from BEHAVIOR dcAdvancedCleanerBeforeAction
|
||||||
// in dcAdvancedCleaner/inc/class.dc.advanced.cleaner.php
|
// in dcAdvancedCleaner/inc/class.dc.advanced.cleaner.php
|
||||||
$core->activityReport->addAction(
|
$core->activityReport->addAction(
|
||||||
|
@ -60,17 +60,16 @@ class behaviorsDcAdvancedCleaner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function dcAdvancedCleanerAdminTabs($core, $p_url)
|
public static function dcAdvancedCleanerAdminTabs($core)
|
||||||
{
|
{
|
||||||
self::modulesTabs($core,DC_PLUGINS_ROOT,$p_url.'&tab=uninstaller');
|
self::modulesTabs($core, DC_PLUGINS_ROOT, $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => 'uninstaller']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function pluginsToolsTabs($core)
|
public static function pluginsToolsTabs($core)
|
||||||
{
|
{
|
||||||
self::modulesTabs($core, DC_PLUGINS_ROOT, 'plugins.php?tab=uninstaller');
|
self::modulesTabs($core, DC_PLUGINS_ROOT, $core->adminurl->get('admin.plugins', ['tab' => 'uninstaller']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic module tabs
|
|
||||||
public static function modulesTabs($core, $path, $redir, $title = '')
|
public static function modulesTabs($core, $path, $redir, $title = '')
|
||||||
{
|
{
|
||||||
if (!$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) {
|
if (!$core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_behavior_active) {
|
||||||
@ -119,13 +118,14 @@ class behaviorsDcAdvancedCleaner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
http::redirect($redir . '&msg=1');
|
dcPage::addSuccessNotice(__('Action successfuly excecuted'));
|
||||||
|
http::redirect($redir);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$err = $e->getMessage();
|
$err = $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<div class="multi-part" id="uninstaller" title="' . __($title) . '">';
|
echo '<div class="multi-part" id="uninstaller" title="' . __($title) . '"><h3>' . __($title) . '</h3>';
|
||||||
|
|
||||||
if($err) {
|
if($err) {
|
||||||
echo '<p class="error">' . $err . '</p>';
|
echo '<p class="error">' . $err . '</p>';
|
||||||
@ -214,7 +214,8 @@ class behaviorsDcAdvancedCleaner
|
|||||||
form::hidden(['action'], 'uninstall') .
|
form::hidden(['action'], 'uninstall') .
|
||||||
'<input type="submit" name="submit" value="' . __('Perform selected actions') . '" /> ' .
|
'<input type="submit" name="submit" value="' . __('Perform selected actions') . '" /> ' .
|
||||||
'</p>' .
|
'</p>' .
|
||||||
'</form>' .
|
'</form>';
|
||||||
'</div>';
|
|
||||||
|
echo '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
279
index.php
279
index.php
@ -18,107 +18,6 @@ if (!$core->auth->isSuperAdmin()) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$page_title = __('Advanced cleaner');
|
|
||||||
|
|
||||||
# Lists
|
|
||||||
function drawDcAdvancedCleanerLists($core, $type)
|
|
||||||
{
|
|
||||||
$combo_funcs = [
|
|
||||||
'settings' => ['dcAdvancedCleaner','getSettings'],
|
|
||||||
'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'
|
|
||||||
],
|
|
||||||
'tables' => [
|
|
||||||
__('delete') => 'delete',
|
|
||||||
__('empty') => 'empty'
|
|
||||||
],
|
|
||||||
'plugins' => [
|
|
||||||
__('delete') => 'delete',
|
|
||||||
__('empty') => 'empty'
|
|
||||||
],
|
|
||||||
'themes' => [
|
|
||||||
__('delete') => 'delete',
|
|
||||||
__('empty') => 'empty'
|
|
||||||
],
|
|
||||||
'caches' => [
|
|
||||||
__('delete') => 'delete',
|
|
||||||
__('empty') => 'empty'
|
|
||||||
],
|
|
||||||
'versions' => [
|
|
||||||
__('delete') => 'delete'
|
|
||||||
]
|
|
||||||
];
|
|
||||||
$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'),
|
|
||||||
'versions' => __('Versions registered in table "version" of Dotclear')
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!isset($combo_funcs[$type])) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$rs = call_user_func($combo_funcs[$type], $core);
|
|
||||||
|
|
||||||
echo
|
|
||||||
'<div class="listDcAdvancedCleaner">' .
|
|
||||||
'<p class="form-note">' . $combo_help[$type] . '</p>';
|
|
||||||
|
|
||||||
if (empty($rs)) {
|
|
||||||
echo
|
|
||||||
'<p>' . sprintf(__('There is no %s'), __(substr($type, 0, -1))) . '</p>';
|
|
||||||
} else {
|
|
||||||
echo
|
|
||||||
'<p>' . sprintf(__('There are %s %s'), count($rs), __($type)) . '</p>' .
|
|
||||||
'<form method="post" action="' . $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => 'lists', 'part' => $type]) . '">' .
|
|
||||||
'<table><thead><tr>' .
|
|
||||||
'<th>' . __('Name') . '</th><th>' . __('Objects') . '</th>' .
|
|
||||||
'</tr></thead><tbody>';
|
|
||||||
|
|
||||||
$official = dcAdvancedCleaner::getOfficial($type);
|
|
||||||
foreach($rs as $k => $v) {
|
|
||||||
$offline = in_array($v['key'], $official);
|
|
||||||
|
|
||||||
if ($core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide && $offline) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
echo
|
|
||||||
'<tr class="line' .
|
|
||||||
($offline ? ' offline' : '') .
|
|
||||||
'">' .
|
|
||||||
'<td class="nowrap"><label class="classic">' .
|
|
||||||
form::checkbox(['entries[' . $k . ']'], html::escapeHTML($v['key'])) . ' ' . $v['key'] . '</label></td>' .
|
|
||||||
'<td class="nowrap">' . $v['value'] . '</td>' .
|
|
||||||
'</tr>';
|
|
||||||
}
|
|
||||||
echo
|
|
||||||
'</tbody></table>' .
|
|
||||||
'<p>' . __('Action on selected rows:') . '<br />' .
|
|
||||||
form::combo(['action'], $combo_actions[$type]) .
|
|
||||||
'<input type="submit" value="' . __('save') . '" />' .
|
|
||||||
form::hidden(['p'], 'dcAdvancedCleaner') .
|
|
||||||
form::hidden(['tab'], 'lists') .
|
|
||||||
form::hidden(['part'], $type) .
|
|
||||||
form::hidden(['type'], $type) .
|
|
||||||
$core->formNonce() . '</p>' .
|
|
||||||
'</form>';
|
|
||||||
}
|
|
||||||
echo
|
|
||||||
'<div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
# Localized l10n
|
# Localized l10n
|
||||||
__('Settings'); __('settings'); __('setting');
|
__('Settings'); __('settings'); __('setting');
|
||||||
__('Tables'); __('tables'); __('table');
|
__('Tables'); __('tables'); __('table');
|
||||||
@ -142,12 +41,12 @@ __('delete %s theme file');
|
|||||||
__('delete %s cache files');
|
__('delete %s cache files');
|
||||||
|
|
||||||
# vars
|
# vars
|
||||||
$tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : 'dcac';
|
$tab = $_REQUEST['tab'] ?? 'lists';
|
||||||
$part = isset($_REQUEST['part']) ? $_REQUEST['part'] : 'caches';
|
$part = $_REQUEST['part'] ?? 'caches';
|
||||||
$entries = isset($_POST['entries']) ? $_POST['entries'] : '';
|
$entries = $_POST['entries'] ?? [];
|
||||||
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
$action = $_POST['action'] ?? '';
|
||||||
$type = isset($_POST['type']) ? $_POST['type'] : '';
|
|
||||||
$s = $core->blog->settings->dcAdvancedCleaner;
|
$s = $core->blog->settings->dcAdvancedCleaner;
|
||||||
|
$p_url = $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => $tab, 'part' => $part]);
|
||||||
|
|
||||||
# Combos
|
# Combos
|
||||||
$combo_title = [
|
$combo_title = [
|
||||||
@ -158,74 +57,166 @@ $combo_title = [
|
|||||||
'caches' => __('Cache'),
|
'caches' => __('Cache'),
|
||||||
'versions' => __('Versions')
|
'versions' => __('Versions')
|
||||||
];
|
];
|
||||||
|
|
||||||
$combo_type = [
|
$combo_type = [
|
||||||
'settings' => ['delete_global','delete_local','delete_all'],
|
'settings' => ['delete_global', 'delete_local', 'delete_all'],
|
||||||
'tables' => ['empty','delete'],
|
'tables' => ['empty', 'delete'],
|
||||||
'plugins' => ['empty','delete'],
|
'plugins' => ['empty', 'delete'],
|
||||||
'themes' => ['empty','delete'],
|
'themes' => ['empty', 'delete'],
|
||||||
'caches' => ['empty','delete'],
|
'caches' => ['empty', 'delete'],
|
||||||
'versions' => ['delete']
|
'versions' => ['delete']
|
||||||
];
|
];
|
||||||
|
$combo_funcs = [
|
||||||
|
'settings' => ['dcAdvancedCleaner', 'getSettings'],
|
||||||
|
'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'
|
||||||
|
],
|
||||||
|
'tables' => [
|
||||||
|
__('delete') => 'delete',
|
||||||
|
__('empty') => 'empty'
|
||||||
|
],
|
||||||
|
'plugins' => [
|
||||||
|
__('delete') => 'delete',
|
||||||
|
__('empty') => 'empty'
|
||||||
|
],
|
||||||
|
'themes' => [
|
||||||
|
__('delete') => 'delete',
|
||||||
|
__('empty') => 'empty'
|
||||||
|
],
|
||||||
|
'caches' => [
|
||||||
|
__('delete') => 'delete',
|
||||||
|
__('empty') => 'empty'
|
||||||
|
],
|
||||||
|
'versions' => [
|
||||||
|
__('delete') => 'delete'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$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'),
|
||||||
|
'versions' => __('Versions registered in table "version" of Dotclear')
|
||||||
|
];
|
||||||
|
|
||||||
# Actions
|
# Actions
|
||||||
if ($tab == 'lists' && !empty($entries)
|
if ($tab == 'lists'
|
||||||
&& isset($combo_type[$type])
|
&& !empty($entries)
|
||||||
&& in_array($action,$combo_type[$type])) {
|
&& isset($combo_type[$part])
|
||||||
|
&& in_array($action, $combo_type[$part])
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
foreach($entries as $v) {
|
foreach($entries as $v) {
|
||||||
dcAdvancedCleaner::execute($core, $type, $action, $v);
|
dcAdvancedCleaner::execute($core, $part, $action, $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Action successfuly excecuted'));
|
dcPage::addSuccessNotice(__('Action successfuly excecuted'));
|
||||||
$core->adminurl->redirect('admin.plugin.dcAdvancedCleaner', ['tab' => 'list', 'part' => $part]);
|
$core->adminurl->redirect(
|
||||||
|
'admin.plugin.dcAdvancedCleaner',
|
||||||
|
['tab' => 'lists', 'part' => $part]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch(Exception $e) {
|
catch(Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '<html><head><title>' . __('Advanced cleaner') . '</title>' .
|
||||||
<html><head>
|
dcPage::cssLoad('index.php?pf=dcAdvancedCleaner/style.css') .
|
||||||
<title>' . $page_title . '</title>
|
dcPage::jsPageTabs($tab);
|
||||||
<link rel="stylesheet" type="text/css" href="index.php?pf=dcAdvancedCleaner/style.css" />' .
|
|
||||||
dcPage::jsToolBar() .
|
|
||||||
dcPage::jsPageTabs($tab) . '
|
|
||||||
</style>';
|
|
||||||
|
|
||||||
# --BEHAVIOR-- dcAdvancedCleanerAdminHeader
|
# --BEHAVIOR-- dcAdvancedCleanerAdminHeader
|
||||||
$core->callBehavior('dcAdvancedCleanerAdminHeader', $core, $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => $tab, 'part' => $part]), $tab);
|
$core->callBehavior('dcAdvancedCleanerAdminHeader', $core, $p_url, $tab);
|
||||||
|
|
||||||
echo '
|
echo '</head><body>' .
|
||||||
</head><body>' .
|
dcPage::breadcrumb([
|
||||||
dcPage::breadcrumb([
|
|
||||||
html::escapeHTML($core->blog->name) => '',
|
html::escapeHTML($core->blog->name) => '',
|
||||||
'<span class="page-title">' . $page_title . '</span>' => ''
|
'<span class="page-title">' . __('Advanced cleaner') . '</span>' => ''
|
||||||
]);
|
]) .
|
||||||
echo
|
dcPage::notices() . '
|
||||||
'<p class="warning">' . __('Beware: All actions done here are irreversible and are directly applied') . '</p>';
|
<div class="multi-part" id="lists" title="' . __('Records and folders') . '">
|
||||||
|
<h3>'. __('Records and folders') .'</h3><p>';
|
||||||
|
|
||||||
echo '<div class="multi-part" id="lists" title="' . __('Records and folders') . '">' .
|
|
||||||
'<p>';
|
|
||||||
foreach($combo_title as $k => $v) {
|
foreach($combo_title as $k => $v) {
|
||||||
echo '<a class="button" href="' . $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => 'lists', 'part' => $k]) . '">' . $v . '</a> ';
|
echo sprintf(
|
||||||
|
'<a class="button" href="%s">%s</a>',
|
||||||
|
$core->adminurl->get(
|
||||||
|
'admin.plugin.dcAdvancedCleaner',
|
||||||
|
['tab' => 'lists', 'part' => $k]
|
||||||
|
),
|
||||||
|
$v
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo '</p>';
|
echo '</p>';
|
||||||
|
|
||||||
# Load "part" page
|
if (isset($combo_funcs[$part])) {
|
||||||
if (isset($combo_title[$part])) {
|
echo '<h4>' . $combo_title[$part] . '</h4><p>' . $combo_help[$part] . '</p>';
|
||||||
echo '<fieldset><legend>' . $combo_title[$part] . '</legend>';
|
|
||||||
drawDcAdvancedCleanerLists($core, $part);
|
$rs = call_user_func($combo_funcs[$part], $core);
|
||||||
echo '</fieldset>';
|
|
||||||
|
if (empty($rs)) {
|
||||||
|
echo '<p>' . sprintf(__('There is no %s'), __(substr($part, 0, -1))) . '</p>';
|
||||||
|
} else {
|
||||||
|
echo
|
||||||
|
'<p>' . sprintf(__('There are %s %s'), count($rs), __($part)) . '</p>' .
|
||||||
|
'<form method="post" action="' . $p_url . '">' .
|
||||||
|
'<div class="table-outer">' .
|
||||||
|
'<table><caption class="hidden">' . __($part) . '</caption><thead><tr>' .
|
||||||
|
'<th>' . __('Name') . '</th><th>' . __('Objects') . '</th>' .
|
||||||
|
'</tr></thead><tbody>';
|
||||||
|
|
||||||
|
$official = dcAdvancedCleaner::getOfficial($part);
|
||||||
|
foreach($rs as $k => $v) {
|
||||||
|
$offline = in_array($v['key'], $official);
|
||||||
|
|
||||||
|
if ($s->dcAdvancedCleaner_dcproperty_hide && $offline) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
echo
|
||||||
|
'<tr class="line' .
|
||||||
|
($offline ? ' offline' : '') .
|
||||||
|
'">' .
|
||||||
|
'<td class="nowrap"><label class="classic">' .
|
||||||
|
form::checkbox(
|
||||||
|
['entries[' . $k . ']'],
|
||||||
|
html::escapeHTML($v['key'])
|
||||||
|
) . ' ' . $v['key'] . '</label></td>' .
|
||||||
|
'<td class="nowrap">' . $v['value'] . '</td>' .
|
||||||
|
'</tr>';
|
||||||
|
}
|
||||||
|
echo
|
||||||
|
'</tbody></table></div>' .
|
||||||
|
'<p class="field">' . __('Action on selected rows:') . ' ' .
|
||||||
|
form::combo(['action'], $combo_actions[$part]) .
|
||||||
|
'<input type="submit" value="' . __('Save') . '" />' .
|
||||||
|
form::hidden(['p'], 'dcAdvancedCleaner') .
|
||||||
|
form::hidden(['tab'], 'lists') .
|
||||||
|
form::hidden(['part'], $part) .
|
||||||
|
$core->formNonce() . '</p>' .
|
||||||
|
'<p class="info">' .
|
||||||
|
__('Beware: All actions done here are irreversible and are directly applied') .
|
||||||
|
'</p>' .
|
||||||
|
'</form>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($s->dcAdvancedCleaner_dcproperty_hide) {
|
if ($s->dcAdvancedCleaner_dcproperty_hide) {
|
||||||
echo '<p class="info">' . __('Default values of Dotclear are hidden. You can change this in settings tab') . '</p>';
|
echo '<p class="info">' .
|
||||||
|
__('Default values of Dotclear are hidden. You can change this in settings tab') .
|
||||||
|
'</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
# --BEHAVIOR-- dcAdvancedCleanerAdminTabs
|
# --BEHAVIOR-- dcAdvancedCleanerAdminTabs
|
||||||
$core->callBehavior('dcAdvancedCleanerAdminTabs', $core, $core->adminurl->get('admin.plugin.dcAdvancedCleaner', ['tab' => $tab, 'part' => $part]));
|
$core->callBehavior('dcAdvancedCleanerAdminTabs', $core);
|
||||||
|
|
||||||
dcPage::helpBlock('dcAdvancedCleaner');
|
dcPage::helpBlock('dcAdvancedCleaner');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user