2018-02-19 18:10:58 +00:00
|
|
|
<?php
|
2021-09-06 22:09:09 +00:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2018-02-19 18:10:58 +00:00
|
|
|
|
2021-09-07 00:02:48 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-10-26 22:10:42 +00:00
|
|
|
|
|
|
|
dcPage::checkSuper();
|
2018-02-19 18:10:58 +00:00
|
|
|
|
2021-10-28 20:17:38 +00:00
|
|
|
$ac = new dcAdvancedCleaner($core);
|
|
|
|
|
|
|
|
$cleaner = false;
|
|
|
|
$select_menu = [];
|
|
|
|
foreach($ac->get() as $k) {
|
|
|
|
$select_menu[$k->name] = $k->id;
|
|
|
|
if ($k->id == $_REQUEST['part']) {
|
|
|
|
$cleaner = $k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$cleaner) {
|
|
|
|
if (!($cleaner = $ac->get('caches', true))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2018-02-19 18:10:58 +00:00
|
|
|
|
|
|
|
# Actions
|
2021-10-28 20:17:38 +00:00
|
|
|
if (!empty($_POST['entries']) && !empty($_POST['action'])) {
|
2021-09-06 22:09:09 +00:00
|
|
|
try {
|
2021-10-28 20:17:38 +00:00
|
|
|
foreach($_POST['entries'] as $ns) {
|
|
|
|
$ac->set($cleaner->id, $_POST['action'], $ns);
|
2021-09-06 22:09:09 +00:00
|
|
|
}
|
2021-09-07 00:02:48 +00:00
|
|
|
dcPage::addSuccessNotice(__('Action successfuly excecuted'));
|
2021-09-07 08:31:22 +00:00
|
|
|
$core->adminurl->redirect(
|
|
|
|
'admin.plugin.dcAdvancedCleaner',
|
2021-10-28 20:17:38 +00:00
|
|
|
['part' => $cleaner->id]
|
2021-09-07 08:31:22 +00:00
|
|
|
);
|
2021-09-06 22:09:09 +00:00
|
|
|
}
|
|
|
|
catch(Exception $e) {
|
|
|
|
$core->error->add($e->getMessage());
|
|
|
|
}
|
2018-02-19 18:10:58 +00:00
|
|
|
}
|
|
|
|
|
2021-10-28 20:17:38 +00:00
|
|
|
# Display
|
2021-09-07 08:31:22 +00:00
|
|
|
echo '<html><head><title>' . __('Advanced cleaner') . '</title>' .
|
2021-10-26 22:10:42 +00:00
|
|
|
dcPage::cssLoad(dcPage::getPF('dcAdvancedCleaner/style.css')) .
|
|
|
|
dcPage::jsLoad(dcPage::getPF('dcAdvancedCleaner/js/index.js'));
|
2018-02-19 18:10:58 +00:00
|
|
|
|
|
|
|
# --BEHAVIOR-- dcAdvancedCleanerAdminHeader
|
2021-10-26 22:10:42 +00:00
|
|
|
$core->callBehavior('dcAdvancedCleanerAdminHeader', $core);
|
2018-02-19 18:10:58 +00:00
|
|
|
|
2021-09-07 08:31:22 +00:00
|
|
|
echo '</head><body>' .
|
|
|
|
dcPage::breadcrumb([
|
2021-10-26 22:10:42 +00:00
|
|
|
__('Plugins') => '',
|
|
|
|
__('Advanced cleaner') => ''
|
2021-09-07 08:31:22 +00:00
|
|
|
]) .
|
2021-10-28 20:17:38 +00:00
|
|
|
dcPage::notices() .
|
2021-10-26 22:10:42 +00:00
|
|
|
|
|
|
|
'<form method="get" action="' . $core->adminurl->get('admin.plugin.dcAdvancedCleaner') . '" id="parts_menu">' .
|
|
|
|
'<p class="anchor-nav"><label for="part" class="classic">' . __('Goto:') . ' </label>' .
|
2021-10-28 20:17:38 +00:00
|
|
|
form::combo('part', $select_menu, $cleaner->id) . ' ' .
|
2021-10-26 22:10:42 +00:00
|
|
|
'<input type="submit" value="' . __('Ok') . '" />' .
|
|
|
|
form::hidden('p', 'dcAdvancedCleaner') . '</p>' .
|
2021-10-28 20:17:38 +00:00
|
|
|
'</form>' .
|
|
|
|
|
|
|
|
'<h3>' . $cleaner->name . '</h3><p>' . $cleaner->desc . '</p>';
|
|
|
|
|
|
|
|
$rs = $cleaner->get();
|
|
|
|
|
|
|
|
if (empty($rs)) {
|
|
|
|
echo '<p>' . __('There is nothing to display') . '</p>';
|
|
|
|
} else {
|
|
|
|
echo
|
|
|
|
'<form method="post" action="' . $core->adminurl->get('admin.plugin.dcAdvancedCleaner') . '" 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>' .
|
|
|
|
'</tr></thead><tbody>';
|
|
|
|
|
|
|
|
foreach($rs as $k => $v) {
|
|
|
|
$offline = in_array($v['key'], $cleaner->official());
|
|
|
|
|
|
|
|
if ($offline && $core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) {
|
|
|
|
continue;
|
2021-09-07 08:31:22 +00:00
|
|
|
}
|
2021-10-28 20:17:38 +00:00
|
|
|
echo
|
|
|
|
'<tr class="line' . ($offline ? ' offline' : '') . '">' .
|
|
|
|
'<td class="nowrap">' .
|
|
|
|
form::checkbox(
|
|
|
|
['entries[' . $k . ']', 'entries_' . $k],
|
|
|
|
html::escapeHTML($v['key'])
|
|
|
|
) . '</td> ' .
|
|
|
|
'<td class="nowrap"><label for="entries_' . $k . '" class="classic">' . $v['key'] . '</label></td>' .
|
|
|
|
'<td class="nowrap maximal">' . $v['value'] . '</td>' .
|
|
|
|
'</tr>';
|
2021-09-07 08:31:22 +00:00
|
|
|
}
|
2021-10-28 20:17:38 +00:00
|
|
|
echo
|
|
|
|
'</tbody></table></div>' .
|
|
|
|
'<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(['part'], $cleaner->id) .
|
|
|
|
$core->formNonce() . '</p>' .
|
|
|
|
'<p class="info">' .
|
|
|
|
__('Beware: All actions done here are irreversible and are directly applied') .
|
|
|
|
'</p>' .
|
|
|
|
'</form>';
|
2018-02-19 18:10:58 +00:00
|
|
|
}
|
2021-10-28 20:17:38 +00:00
|
|
|
|
2021-10-26 22:10:42 +00:00
|
|
|
if ($core->blog->settings->dcAdvancedCleaner->dcAdvancedCleaner_dcproperty_hide) {
|
2021-09-07 08:31:22 +00:00
|
|
|
echo '<p class="info">' .
|
2021-10-26 22:10:42 +00:00
|
|
|
__('Default values of Dotclear are hidden. You can change this in settings') .
|
2021-09-07 08:31:22 +00:00
|
|
|
'</p>';
|
2018-02-19 18:10:58 +00:00
|
|
|
}
|
2021-09-07 08:31:22 +00:00
|
|
|
|
2018-02-19 18:10:58 +00:00
|
|
|
dcPage::helpBlock('dcAdvancedCleaner');
|
2021-09-07 00:02:48 +00:00
|
|
|
|
|
|
|
echo '</body></html>';
|