Compare commits
No commits in common. "057fa96fed88c7addddca144d927ae11d8b11aad" and "16d67e0b4391ede12d38ae527bd8d7245c0ece32" have entirely different histories.
057fa96fed
...
16d67e0b43
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -2,21 +2,6 @@ dev
|
||||||
- [ ] orphan media cleaner
|
- [ ] orphan media cleaner
|
||||||
- [ ] move to plugin maintenance
|
- [ ] move to plugin maintenance
|
||||||
|
|
||||||
1.2 - 2023.07.28
|
|
||||||
- require dotclear 2.27
|
|
||||||
- require php 8.1+
|
|
||||||
- update to dotclear 2.27-dev
|
|
||||||
|
|
||||||
1.1 - 2023.05.13
|
|
||||||
- require dotclear 2.26
|
|
||||||
- require php 8.1+
|
|
||||||
- use define php_min
|
|
||||||
|
|
||||||
1.0.1 - 2023.05.01
|
|
||||||
- require dotclear 2.26
|
|
||||||
- require php 8.1+
|
|
||||||
- require plugin Uninstaller 0.8
|
|
||||||
|
|
||||||
1.0 - 2023.04.24
|
1.0 - 2023.04.24
|
||||||
- require dotclear 2.26
|
- require dotclear 2.26
|
||||||
- require php 8.1+
|
- require php 8.1+
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
[![Release](https://img.shields.io/github/v/release/JcDenis/dcAdvancedCleaner)](https://github.com/JcDenis/dcAdvancedCleaner/releases)
|
[![Release](https://img.shields.io/github/v/release/JcDenis/dcAdvancedCleaner)](https://github.com/JcDenis/dcAdvancedCleaner/releases)
|
||||||
[![Date](https://img.shields.io/github/release-date/JcDenis/dcAdvancedCleaner)](https://github.com/JcDenis/dcAdvancedCleaner/releases)
|
[![Date](https://img.shields.io/github/release-date/JcDenis/dcAdvancedCleaner)](https://github.com/JcDenis/dcAdvancedCleaner/releases)
|
||||||
[![Issues](https://img.shields.io/github/issues/JcDenis/dcAdvancedCleaner)](https://github.com/JcDenis/dcAdvancedCleaner/issues)
|
[![Issues](https://img.shields.io/github/issues/JcDenis/dcAdvancedCleaner)](https://github.com/JcDenis/dcAdvancedCleaner/issues)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
|
||||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner)
|
||||||
[![License](https://img.shields.io/github/license/JcDenis/dcAdvancedCleaner)](https://github.com/JcDenis/dcAdvancedCleaner/blob/master/LICENSE)
|
[![License](https://img.shields.io/github/license/JcDenis/dcAdvancedCleaner)](https://github.com/JcDenis/dcAdvancedCleaner/blob/master/LICENSE)
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ settings, tables, cache, etc...
|
||||||
_dcAdvancedCleaner_ requires:
|
_dcAdvancedCleaner_ requires:
|
||||||
|
|
||||||
* Permissions superadmin
|
* Permissions superadmin
|
||||||
* Dotclear 2.27
|
* Dotclear 2.26
|
||||||
* PHP >= 8.1
|
* PHP >= 8.1
|
||||||
* Plugin Uninstaller (temporary at https://github.com/JcDenis/Uninstaller )
|
* Plugin Uninstaller
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
@ -44,4 +44,4 @@ Once it's done you can manage cleaners from menu
|
||||||
* Jean-Christian Denis
|
* Jean-Christian Denis
|
||||||
* Pierre Van Glabeke
|
* Pierre Van Glabeke
|
||||||
|
|
||||||
You are welcome to contribute to this code.
|
You are welcome to contribute to this code.
|
|
@ -18,12 +18,11 @@ $this->registerModule(
|
||||||
'Advanced cleaner',
|
'Advanced cleaner',
|
||||||
'Make a huge cleaning of dotclear',
|
'Make a huge cleaning of dotclear',
|
||||||
'Jean-Christian Denis and Contributors',
|
'Jean-Christian Denis and Contributors',
|
||||||
'1.2',
|
'1.0',
|
||||||
[
|
[
|
||||||
'requires' => [
|
'requires' => [
|
||||||
['php', '8.1'],
|
['core', '2.26'],
|
||||||
['core', '2.27'],
|
['Uninstaller', '0.6'],
|
||||||
['Uninstaller', '0.8'],
|
|
||||||
],
|
],
|
||||||
'permissions' => null,
|
'permissions' => null,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="dcAdvancedCleaner">
|
<module id="dcAdvancedCleaner">
|
||||||
<name>Advanced cleaner</name>
|
<name>Advanced cleaner</name>
|
||||||
<version>1.2</version>
|
<version>1.0</version>
|
||||||
<author>Jean-Christian Denis and Contributors</author>
|
<author>Jean-Christian Denis and Contributors</author>
|
||||||
<desc>Make a huge cleaning of dotclear</desc>
|
<desc>Make a huge cleaning of dotclear</desc>
|
||||||
<file>https://github.com/JcDenis/dcAdvancedCleaner/releases/download/v1.2/plugin-dcAdvancedCleaner.zip</file>
|
<file>https://github.com/JcDenis/dcAdvancedCleaner/releases/download/v1.0/plugin-dcAdvancedCleaner.zip</file>
|
||||||
<da:dcmin>2.27</da:dcmin>
|
<da:dcmin>2.26</da:dcmin>
|
||||||
<da:details>https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner</da:details>
|
<da:details>https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner</da:details>
|
||||||
<da:support>https://github.com/JcDenis/dcAdvancedCleaner</da:support>
|
<da:support>https://github.com/JcDenis/dcAdvancedCleaner</da:support>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -14,32 +14,46 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\dcAdvancedCleaner;
|
namespace Dotclear\Plugin\dcAdvancedCleaner;
|
||||||
|
|
||||||
|
use dcAdmin;
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use Dotclear\Core\Process;
|
use dcFavorites;
|
||||||
use Dotclear\Core\Backend\Favorites;
|
use dcNsProcess;
|
||||||
|
use dcPage;
|
||||||
|
|
||||||
class Backend extends Process
|
class Backend extends dcNsProcess
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
return self::status(My::checkContext(My::BACKEND));
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||||
|
&& My::phpCompliant();
|
||||||
|
|
||||||
|
return static::$init;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
My::addBackendMenuItem();
|
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||||
|
My::name(),
|
||||||
|
dcCore::app()->adminurl?->get('admin.plugin.' . My::id()),
|
||||||
|
dcPage::getPF(My::id() . '/icon.svg'),
|
||||||
|
preg_match(
|
||||||
|
'/' . preg_quote((string) dcCore::app()->adminurl?->get('admin.plugin.' . My::id())) . '(&.*)?$/',
|
||||||
|
$_SERVER['REQUEST_URI']
|
||||||
|
),
|
||||||
|
dcCore::app()->auth?->isSuperAdmin()
|
||||||
|
);
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
dcCore::app()->addBehaviors([
|
||||||
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
|
||||||
$favs->register(My::id(), [
|
$favs->register(My::id(), [
|
||||||
'title' => My::name(),
|
'title' => My::name(),
|
||||||
'url' => My::manageURL(),
|
'url' => dcCore::app()->adminurl?->get('admin.plugin.' . My::id()),
|
||||||
'small-icon' => My::icons(),
|
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||||
'large-icon' => My::icons(),
|
'large-icon' => dcPage::getPF(My::id() . '/icon-big.svg'),
|
||||||
//'permissions' => dcCore::app()->auth?->isSuperAdmin(),
|
//'permissions' => dcCore::app()->auth?->isSuperAdmin(),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,11 +15,8 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\dcAdvancedCleaner;
|
namespace Dotclear\Plugin\dcAdvancedCleaner;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use Dotclear\Core\Process;
|
use dcNsProcess;
|
||||||
use Dotclear\Core\Backend\{
|
use dcPage;
|
||||||
Notices,
|
|
||||||
Page
|
|
||||||
};
|
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Div,
|
Div,
|
||||||
|
@ -35,16 +32,20 @@ use Dotclear\Helper\Html\Form\{
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
class Manage extends Process
|
class Manage extends dcNsProcess
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
return self::status(My::checkContext(My::MANAGE));
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||||
|
&& dcCore::app()->auth?->isSuperAdmin()
|
||||||
|
&& My::phpCompliant();
|
||||||
|
|
||||||
|
return static::$init;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,10 +56,10 @@ class Manage extends Process
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['option-action'])) {
|
if (!empty($_POST['option-action'])) {
|
||||||
My::settings()->dropEvery(
|
dcCore::app()->blog?->settings->get(My::id())->dropEvery(
|
||||||
'dcproperty_hide'
|
'dcproperty_hide'
|
||||||
);
|
);
|
||||||
My::settings()->put(
|
dcCore::app()->blog?->settings->get(My::id())->put(
|
||||||
'dcproperty_hide',
|
'dcproperty_hide',
|
||||||
!empty($_POST['dcproperty_hide']),
|
!empty($_POST['dcproperty_hide']),
|
||||||
'boolean',
|
'boolean',
|
||||||
|
@ -66,8 +67,11 @@ class Manage extends Process
|
||||||
true,
|
true,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
Notices::addSuccessNotice(__('Configuration successfully updated.'));
|
dcPage::addSuccessNotice(__('Configuration successfully updated.'));
|
||||||
My::redirect(['part' => $vars->cleaner->id]);
|
dcCore::app()->adminurl?->redirect(
|
||||||
|
'admin.plugin.' . My::id(),
|
||||||
|
['part' => $vars->cleaner->id]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($vars->entries) && !empty($vars->action)) {
|
if (!empty($vars->entries) && !empty($vars->action)) {
|
||||||
|
@ -86,8 +90,11 @@ class Manage extends Process
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Notices::addSuccessNotice(__('Action successfuly excecuted'));
|
dcPage::addSuccessNotice(__('Action successfuly excecuted'));
|
||||||
My::redirect(['part' => $vars->cleaner->id]);
|
dcCore::app()->adminurl?->redirect(
|
||||||
|
'admin.plugin.' . My::id(),
|
||||||
|
['part' => $vars->cleaner->id]
|
||||||
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -98,17 +105,17 @@ class Manage extends Process
|
||||||
|
|
||||||
public static function render(): void
|
public static function render(): void
|
||||||
{
|
{
|
||||||
if (!self::status()) {
|
if (!static::$init) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$vars = ManageVars::init();
|
$vars = ManageVars::init();
|
||||||
|
|
||||||
Page::openModule(
|
dcPage::openModule(
|
||||||
My::name(),
|
My::name(),
|
||||||
Page::jsJson('dcAdvancedCleaner', ['confirm_delete' => __('Are you sure you perform these ations?')]) .
|
dcPage::jsJson('dcAdvancedCleaner', ['confirm_delete' => __('Are you sure you perform these ations?')]) .
|
||||||
My::cssLoad('backend') .
|
dcPage::cssModuleLoad(My::id() . '/css/backend.css') .
|
||||||
My::jsLoad('backend')
|
dcPage::jsModuleLoad(My::id() . '/js/backend.js')
|
||||||
);
|
);
|
||||||
|
|
||||||
# --BEHAVIOR-- dcAdvancedCleanerAdminHeader
|
# --BEHAVIOR-- dcAdvancedCleanerAdminHeader
|
||||||
|
@ -122,34 +129,34 @@ class Manage extends Process
|
||||||
// something went wrong !
|
// something went wrong !
|
||||||
if (null === $vars->cleaner) {
|
if (null === $vars->cleaner) {
|
||||||
echo
|
echo
|
||||||
Page::breadcrumb($breadcrumb) .
|
dcPage::breadcrumb($breadcrumb) .
|
||||||
Notices::getNotices();
|
dcPage::notices();
|
||||||
echo (new Text('p', __('There is nothing to display')))->class('error')->render();
|
echo (new Text('p', __('There is nothing to display')))->class('error')->render();
|
||||||
Page::closeModule();
|
dcPage::closeModule();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$breadcrumb[My::name()] = My::manageUrl();
|
$breadcrumb[My::name()] = dcCore::app()->adminurl?->get('admin.plugin.' . My::id());
|
||||||
$breadcrumb[$vars->cleaner->name] = '';
|
$breadcrumb[$vars->cleaner->name] = '';
|
||||||
|
|
||||||
if (!empty($vars->related)) {
|
if (!empty($vars->related)) {
|
||||||
$breadcrumb[$vars->cleaner->name] = My::manageUrl(['part' => $vars->cleaner->id]);
|
$breadcrumb[$vars->cleaner->name] = dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['part' => $vars->cleaner->id]);
|
||||||
$breadcrumb[$vars->related] = '';
|
$breadcrumb[$vars->related] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
Page::breadcrumb($breadcrumb) .
|
dcPage::breadcrumb($breadcrumb) .
|
||||||
Notices::getNotices();
|
dcPage::notices();
|
||||||
|
|
||||||
if (empty($vars->related)) {
|
if (empty($vars->related)) {
|
||||||
echo
|
echo
|
||||||
(new Form('parts_menu'))->method('get')->action(dcCore::app()->admin->getPageURL())->fields([
|
(new Form('parts_menu'))->method('get')->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))->fields([
|
||||||
(new Para())->class('anchor-nav')->items([
|
(new Para())->class('anchor-nav')->items([
|
||||||
(new Label(__('Goto:'), Label::OUTSIDE_LABEL_BEFORE))->for('part')->class('classic'),
|
(new Label(__('Goto:'), Label::OUTSIDE_LABEL_BEFORE))->for('part')->class('classic'),
|
||||||
(new Select(['part', 'select_part']))->default($vars->cleaner->id)->items($vars->combo),
|
(new Select(['part', 'select_part']))->default($vars->cleaner->id)->items($vars->combo),
|
||||||
(new Submit('go'))->value(__('Ok')),
|
(new Submit('go'))->value(__('Ok')),
|
||||||
... My::hiddenFields(),
|
(new Hidden(['p'], My::id())),
|
||||||
]),
|
]),
|
||||||
])->render() .
|
])->render() .
|
||||||
|
|
||||||
|
@ -172,7 +179,7 @@ class Manage extends Process
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<form method="post" action="' . dcCore::app()->admin->getPageURL() . '" id="form-funcs">' .
|
'<form method="post" action="' . dcCore::app()->adminurl?->get('admin.plugin.' . My::id()) . '" id="form-funcs">' .
|
||||||
'<div class="table-outer">' .
|
'<div class="table-outer">' .
|
||||||
'<table><caption>' . sprintf(__('There are %s entries'), count($rs)) . '</caption><thead><tr>' .
|
'<table><caption>' . sprintf(__('There are %s entries'), count($rs)) . '</caption><thead><tr>' .
|
||||||
'<th colspan="2">' . __('Name') . '</th><th colspan="2">' . __('Objects') . '</th>' .
|
'<th colspan="2">' . __('Name') . '</th><th colspan="2">' . __('Objects') . '</th>' .
|
||||||
|
@ -182,7 +189,7 @@ class Manage extends Process
|
||||||
foreach ($rs as $key => $value) {
|
foreach ($rs as $key => $value) {
|
||||||
$distrib = in_array($value->ns, $vars->cleaner->distributed());
|
$distrib = in_array($value->ns, $vars->cleaner->distributed());
|
||||||
|
|
||||||
if ($distrib && My::settings()->getGlobal('dcproperty_hide')) {
|
if ($distrib && dcCore::app()->blog?->settings->get(My::id())->get('dcproperty_hide')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
echo
|
echo
|
||||||
|
@ -200,7 +207,7 @@ class Manage extends Process
|
||||||
__('Values from official distribution') . '" />'
|
__('Values from official distribution') . '" />'
|
||||||
: '') . '</td>' .
|
: '') . '</td>' .
|
||||||
'<td class="maximal">' . ($has_related ? ' <a href="' .
|
'<td class="maximal">' . ($has_related ? ' <a href="' .
|
||||||
My::manageUrl(['part' => $vars->cleaner->id, 'related' => $value->ns]) .
|
dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['part' => $vars->cleaner->id, 'related' => $value->ns]) .
|
||||||
'">' . __('Details') . '<a>' : '') . '</td>' .
|
'">' . __('Details') . '<a>' : '') . '</td>' .
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
@ -211,8 +218,9 @@ class Manage extends Process
|
||||||
(new Label(__('Action on selected rows:'), Label::OUTSIDE_LABEL_BEFORE))->for('select_action'),
|
(new Label(__('Action on selected rows:'), Label::OUTSIDE_LABEL_BEFORE))->for('select_action'),
|
||||||
(new Select(['action', 'select_action']))->items($combo_actions),
|
(new Select(['action', 'select_action']))->items($combo_actions),
|
||||||
(new Submit('do-action'))->class('delete')->value(__('I understand and I am want to delete this')),
|
(new Submit('do-action'))->class('delete')->value(__('I understand and I am want to delete this')),
|
||||||
|
(new Hidden(['p'], My::id())),
|
||||||
(new Hidden(['part'], $vars->cleaner->id)),
|
(new Hidden(['part'], $vars->cleaner->id)),
|
||||||
... My::hiddenFields(),
|
dcCore::app()->formNonce(false),
|
||||||
])->render() .
|
])->render() .
|
||||||
'<p class="warning">' .
|
'<p class="warning">' .
|
||||||
__('Beware: All actions done here are irreversible and are directly applied') .
|
__('Beware: All actions done here are irreversible and are directly applied') .
|
||||||
|
@ -221,17 +229,18 @@ class Manage extends Process
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
(new Form('option'))->method('post')->action(dcCore::app()->admin->getPageURL())->fields([
|
(new Form('option'))->method('post')->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))->fields([
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Submit('option-action'))->value(My::settings()->getGlobal('dcproperty_hide') ? __('Show Dotclear default properties') : __('Hide Dotclear default properties')),
|
(new Submit('option-action'))->value(dcCore::app()->blog?->settings->get(My::id())->get('dcproperty_hide') ? __('Show Dotclear default properties') : __('Hide Dotclear default properties')),
|
||||||
(new Hidden('dcproperty_hide', My::settings()->getGlobal('dcproperty_hide') ? '0' : '1')),
|
(new Hidden('dcproperty_hide', (string) (int) !dcCore::app()->blog->settings->get(My::id())->get('dcproperty_hide'))),
|
||||||
|
(new Hidden(['p'], My::id())),
|
||||||
(new Hidden(['part'], $vars->cleaner->id)),
|
(new Hidden(['part'], $vars->cleaner->id)),
|
||||||
... My::hiddenFields(),
|
dcCore::app()->formNonce(false),
|
||||||
]),
|
]),
|
||||||
])->render();
|
])->render();
|
||||||
} else {
|
} else {
|
||||||
echo
|
echo
|
||||||
'<p><a class="back" href="' . My::manageUrl(['part' => $vars->cleaner->id]) . '">' . __('Back') . '</a></p>' .
|
'<p><a class="back" href="' . dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['part' => $vars->cleaner->id]) . '">' . __('Back') . '</a></p>' .
|
||||||
'<h3>' . $vars->cleaner->name . ' : ' . $vars->related . '</h3><p>' . $vars->cleaner->desc . '</p>';
|
'<h3>' . $vars->cleaner->name . ' : ' . $vars->related . '</h3><p>' . $vars->cleaner->desc . '</p>';
|
||||||
|
|
||||||
$distrib = in_array($vars->related, $vars->cleaner->distributed());
|
$distrib = in_array($vars->related, $vars->cleaner->distributed());
|
||||||
|
@ -240,7 +249,7 @@ class Manage extends Process
|
||||||
echo (new Text('p', __('There is nothing to display')))->class('error')->render();
|
echo (new Text('p', __('There is nothing to display')))->class('error')->render();
|
||||||
} else {
|
} else {
|
||||||
echo
|
echo
|
||||||
'<form method="post" action="' . dcCore::app()->admin->getPageURL() . '" id="form-funcs">' .
|
'<form method="post" action="' . dcCore::app()->adminurl?->get('admin.plugin.' . My::id()) . '" id="form-funcs">' .
|
||||||
'<div class="table-outer">' .
|
'<div class="table-outer">' .
|
||||||
'<table><caption>' . sprintf(__('There are %s related entries for the group "%s"'), count($rs), $vars->related) . '</caption><thead><tr>' .
|
'<table><caption>' . sprintf(__('There are %s related entries for the group "%s"'), count($rs), $vars->related) . '</caption><thead><tr>' .
|
||||||
'<th colspan="2">' . __('Name') . '</th><th>' . __('Objects') . '</th>' .
|
'<th colspan="2">' . __('Name') . '</th><th>' . __('Objects') . '</th>' .
|
||||||
|
@ -263,10 +272,11 @@ class Manage extends Process
|
||||||
'</tbody></table></div>' .
|
'</tbody></table></div>' .
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Submit('do-action'))->class('delete')->value(__('I understand and I am want to delete this')),
|
(new Submit('do-action'))->class('delete')->value(__('I understand and I am want to delete this')),
|
||||||
|
(new Hidden(['p'], My::id())),
|
||||||
(new Hidden(['related'], $vars->related)),
|
(new Hidden(['related'], $vars->related)),
|
||||||
(new Hidden(['part'], $vars->cleaner->id)),
|
(new Hidden(['part'], $vars->cleaner->id)),
|
||||||
(new Hidden(['action'], 'delete_related')),
|
(new Hidden(['action'], 'delete_related')),
|
||||||
... My::hiddenFields(),
|
dcCore::app()->formNonce(false),
|
||||||
])->render() .
|
])->render() .
|
||||||
'<p class="warning">' .
|
'<p class="warning">' .
|
||||||
__('Beware: All actions done here are irreversible and are directly applied') .
|
__('Beware: All actions done here are irreversible and are directly applied') .
|
||||||
|
@ -275,6 +285,6 @@ class Manage extends Process
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Page::closeModule();
|
dcPage::closeModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,25 +23,16 @@ use Exception;
|
||||||
|
|
||||||
class ManageVars
|
class ManageVars
|
||||||
{
|
{
|
||||||
/** @var ManageVars self instance */
|
/**
|
||||||
|
* @var ManageVars self instance
|
||||||
|
*/
|
||||||
private static $container;
|
private static $container;
|
||||||
|
|
||||||
/** @var CleanersStack The cleaners stack */
|
|
||||||
public readonly CleanersStack $cleaners;
|
public readonly CleanersStack $cleaners;
|
||||||
|
|
||||||
/** @var null|CleanerParent The post form cleaner */
|
|
||||||
public readonly ?CleanerParent $cleaner;
|
public readonly ?CleanerParent $cleaner;
|
||||||
|
|
||||||
/** @var string $related The post form related action id */
|
|
||||||
public readonly string $related;
|
public readonly string $related;
|
||||||
|
|
||||||
/** @var array<int,string> The post form selected ns */
|
|
||||||
public readonly array $entries;
|
public readonly array $entries;
|
||||||
|
|
||||||
/** @var string The post form action id */
|
|
||||||
public readonly string $action;
|
public readonly string $action;
|
||||||
|
|
||||||
/** @var array<string,string> The form actions combo */
|
|
||||||
public readonly array $combo;
|
public readonly array $combo;
|
||||||
|
|
||||||
protected function __construct()
|
protected function __construct()
|
||||||
|
|
40
src/My.php
40
src/My.php
|
@ -15,12 +15,44 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\dcAdvancedCleaner;
|
namespace Dotclear\Plugin\dcAdvancedCleaner;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use Dotclear\Module\MyPlugin;
|
|
||||||
|
|
||||||
class My extends MyPlugin
|
/**
|
||||||
|
* Plugin definitions
|
||||||
|
*/
|
||||||
|
class My
|
||||||
{
|
{
|
||||||
public static function checkCustomContext(int $context): ?bool
|
/** @var string Required php version */
|
||||||
|
public const PHP_MIN = '8.1';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This module id
|
||||||
|
*/
|
||||||
|
public static function id(): string
|
||||||
{
|
{
|
||||||
return $context === self::PREPEND ? dcCore::app()->auth->isSuperAdmin() : null;
|
return basename(dirname(__DIR__));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This module name
|
||||||
|
*/
|
||||||
|
public static function name(): string
|
||||||
|
{
|
||||||
|
return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This plugin root
|
||||||
|
*/
|
||||||
|
public static function root(): string
|
||||||
|
{
|
||||||
|
return dirname(__DIR__);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check php version
|
||||||
|
*/
|
||||||
|
public static function phpCompliant(): bool
|
||||||
|
{
|
||||||
|
return version_compare(phpversion(), self::PHP_MIN, '>=');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\dcAdvancedCleaner;
|
namespace Dotclear\Plugin\dcAdvancedCleaner;
|
||||||
|
|
||||||
use Dotclear\Core\Process;
|
use dcCore;
|
||||||
|
use dcNsProcess;
|
||||||
use Dotclear\Plugin\activityReport\{
|
use Dotclear\Plugin\activityReport\{
|
||||||
Action,
|
Action,
|
||||||
ActivityReport,
|
ActivityReport,
|
||||||
|
@ -22,16 +23,20 @@ use Dotclear\Plugin\activityReport\{
|
||||||
};
|
};
|
||||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||||
|
|
||||||
class Prepend extends Process
|
class Prepend extends dcNsProcess
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
return self::status(My::checkContext(My::PREPEND));
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||||
|
&& My::phpCompliant()
|
||||||
|
&& dcCore::app()->auth?->isSuperAdmin();
|
||||||
|
|
||||||
|
return static::$init;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!self::status()) {
|
if (!static::$init) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,19 +15,21 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\dcAdvancedCleaner;
|
namespace Dotclear\Plugin\dcAdvancedCleaner;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use Dotclear\Core\Process;
|
use dcNsProcess;
|
||||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||||
|
|
||||||
class Uninstall extends Process
|
class Uninstall extends dcNsProcess
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
return self::status(My::checkContext(My::UNINSTALL));
|
static::$init = defined('DC_CONTEXT_ADMIN');
|
||||||
|
|
||||||
|
return static::$init;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue