diff --git a/src/Backend.php b/src/Backend.php
index 370cba5..267c693 100644
--- a/src/Backend.php
+++ b/src/Backend.php
@@ -14,32 +14,29 @@ declare(strict_types=1);
namespace Dotclear\Plugin\Uninstaller;
-use adminModulesList;
use dcCore;
use dcModuleDefine;
-use dcNsProcess;
-use dcPage;
-use dcUtils;
+use Dotclear\Core\Process;
+use Dotclear\Core\Backend\ModulesList;
+use Dotclear\Core\Backend\Page;
use Exception;
-class Backend extends dcNsProcess
+class Backend extends Process
{
public static function init(): bool
{
- static::$init = defined('DC_CONTEXT_ADMIN');
-
- return static::$init;
+ return self::status(My::checkContext(My::BACKEND));
}
public static function process(): bool
{
- if (!static::$init) {
+ if (!self::status()) {
return false;
}
dcCore::app()->addBehaviors([
// add "unsinstall" button to modules list
- 'adminModulesListGetActionsV2' => function (adminModulesList $list, dcModuleDefine $define): string {
+ 'adminModulesListGetActionsV2' => function (ModulesList $list, dcModuleDefine $define): string {
// do not unsintall current theme
if ($define->get('type') == 'theme' && $define->getId() == dcCore::app()->blog?->settings->get('system')->get('theme')) {
return '';
@@ -48,7 +45,7 @@ class Backend extends dcNsProcess
return !count(Uninstaller::instance()->loadModules([$define])->getUserActions($define->getId())) ? '' :
sprintf(
' ' . __('Uninstall') . '',
- dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['type' => $define->get('type'), 'id' => $define->getId()])
+ My::manageUrl(['type' => $define->get('type'), 'id' => $define->getId()])
);
},
// perform direct action on theme deletion
@@ -92,7 +89,7 @@ class Backend extends dcNsProcess
if ($define->get('state') != dcModuleDefine::STATE_ENABLED) {
if (!in_array($define->get('type'), ['plugin', 'theme'])
|| $define->get('type') == 'plugin' && 1 < count(dcCore::app()->plugins->getDefines(['id' => $define->getId()]))
- || $define->get('type') == 'theme' && 1 < count(dcCore::app()->themes->getDefines(['id' => $define->getId()]))
+ || $define->get('type') == 'theme' && 1 < count(dcCore::app()->themes->getDefines(['id' => $define->getId()]))
) {
return;
}
@@ -112,7 +109,7 @@ class Backend extends dcNsProcess
// if direct actions are made, do not execute dotclear delete action.
if (!empty($done)) {
array_unshift($done, __('Plugin has been successfully uninstalled.'));
- dcPage::addSuccessNotice(implode('
', $done));
+ Page::addSuccessNotice(implode('
', $done));
if ($define->get('type') == 'theme') {
dcCore::app()->adminurl?->redirect('admin.blog.theme', [], '#themes');
} else {
@@ -131,6 +128,6 @@ class Backend extends dcNsProcess
*/
protected static function modulesToolsHeader(): string
{
- return dcUtils::jsModuleLoad(My::id() . '/js/backend.js');
+ return My::jsLoad('backend.js');
}
}
diff --git a/src/Install.php b/src/Install.php
index 1d219e4..6ea5d49 100644
--- a/src/Install.php
+++ b/src/Install.php
@@ -15,24 +15,19 @@ declare(strict_types=1);
namespace Dotclear\Plugin\Uninstaller;
use dcCore;
-use dcNsProcess;
+use Dotclear\Core\Process;
use Exception;
-class Install extends dcNsProcess
+class Install extends Process
{
public static function init(): bool
{
- if (defined('DC_CONTEXT_ADMIN')) {
- $version = dcCore::app()->plugins->moduleInfo(My::id(), 'version');
- static::$init = is_string($version) ? dcCore::app()->newVersion(My::id(), $version) : true;
- }
-
- return static::$init;
+ return self::status(My::checkContext(My::INSTALL));
}
public static function process(): bool
{
- if (!static::$init) {
+ if (!self::status()) {
return false;
}
diff --git a/src/Manage.php b/src/Manage.php
index 4733e0f..e186a46 100644
--- a/src/Manage.php
+++ b/src/Manage.php
@@ -16,9 +16,9 @@ namespace Dotclear\Plugin\Uninstaller;
use dcCore;
use dcModuleDefine;
-use dcNsProcess;
-use dcPage;
use dcThemes;
+use Dotclear\Core\Process;
+use Dotclear\Core\Backend\Page;
use Dotclear\Helper\Html\Form\{
Checkbox,
Div,
@@ -32,19 +32,16 @@ use Dotclear\Helper\Html\Form\{
};
use Exception;
-class Manage extends dcNsProcess
+class Manage extends Process
{
public static function init(): bool
{
- static::$init = defined('DC_CONTEXT_ADMIN')
- && dcCore::app()->auth?->isSuperAdmin();
-
- return static::$init;
+ return self::status(My::checkContext(My::MANAGE));
}
public static function process(): bool
{
- if (!static::$init) {
+ if (!self::status()) {
return false;
}
@@ -96,9 +93,9 @@ class Manage extends dcNsProcess
// list success actions
if (!empty($done)) {
array_unshift($done, __('Uninstall action successfuly excecuted'));
- dcPage::addSuccessNotice(implode('
', $done));
+ Page::addSuccessNotice(implode('
', $done));
} else {
- dcPage::addWarningNotice(__('No uninstall action done'));
+ Page::addWarningNotice(__('No uninstall action done'));
}
self::doRedirect();
} catch (Exception $e) {
@@ -110,7 +107,7 @@ class Manage extends dcNsProcess
public static function render(): void
{
- if (!static::$init) {
+ if (!self::status()) {
return;
}
@@ -124,21 +121,21 @@ class Manage extends dcNsProcess
$fields[] = (new Text('', $uninstaller->render($define->getId())));
}
- dcPage::openModule(
+ Page::openModule(
My::name(),
- dcPage::jsJson('uninstaller', ['confirm_uninstall' => __('Are you sure you perform these ations?')]) .
- dcPage::jsModuleLoad(My::id() . '/js/manage.js') .
+ Page::jsJson('uninstaller', ['confirm_uninstall' => __('Are you sure you perform these ations?')]) .
+ My::jsLoad('manage.js') .
# --BEHAVIOR-- UninstallerHeader
dcCore::app()->callBehavior('UninstallerHeader')
);
echo
- dcPage::breadcrumb([
+ Page::breadcrumb([
__('System') => '',
My::name() => '',
]) .
- dcPage::notices();
+ Page::notices();
// user actions form fields
foreach ($uninstaller->getUserActions($define->getId()) as $cleaner => $stack) {
@@ -166,7 +163,7 @@ class Manage extends dcNsProcess
(new Form('uninstall-form'))->method('post')->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))->fields($fields),
])->render();
- dcPage::closeModule();
+ Page::closeModule();
}
private static function getType(): string
diff --git a/src/My.php b/src/My.php
index 983d502..5e64ed2 100644
--- a/src/My.php
+++ b/src/My.php
@@ -15,35 +15,15 @@ declare(strict_types=1);
namespace Dotclear\Plugin\Uninstaller;
use dcCore;
+use Dotclear\Module\MyPlugin;
-/**
- * This module definitions.
- */
-class My
+class My extends MyPlugin
{
- /**
- * This module id.
- */
- public static function id(): string
+ protected static function checkCustomContext(int $context): ?bool
{
- return basename(dirname(__DIR__));
- }
-
- /**
- * This module name.
- */
- public static function name(): string
- {
- $name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
-
- return __(is_string($name) ? $name : self::id());
- }
-
- /**
- * This module path.
- */
- public static function path(): string
- {
- return dirname(__DIR__);
+ // check super admin except install that follows MyPlugin check
+ return $context === My::INSTALL ? null :
+ defined('DC_CONTEXT_ADMIN')
+ && dcCore::app()->auth->isSuperAdmin();
}
}
diff --git a/src/Prepend.php b/src/Prepend.php
index 2b691e6..fa6c467 100644
--- a/src/Prepend.php
+++ b/src/Prepend.php
@@ -15,21 +15,18 @@ declare(strict_types=1);
namespace Dotclear\Plugin\Uninstaller;
use dcCore;
-use dcNsProcess;
+use Dotclear\Core\Process;
-class Prepend extends dcNsProcess
+class Prepend extends Process
{
public static function init(): bool
{
- static::$init = defined('DC_CONTEXT_ADMIN')
- && dcCore::app()->auth?->isSuperAdmin();
-
- return static::$init;
+ return self::status(My::checkContext(My::BACKEND));
}
public static function process(): bool
{
- if (!static::$init) {
+ if (!self::status()) {
return false;
}
diff --git a/src/Uninstaller.php b/src/Uninstaller.php
index e4841e1..60a99ec 100644
--- a/src/Uninstaller.php
+++ b/src/Uninstaller.php
@@ -15,7 +15,7 @@ declare(strict_types=1);
namespace Dotclear\Plugin\Uninstaller;
use dcModuleDefine;
-use dcNsProcess;
+use Dotclear\Core\Process;
use Dotclear\Helper\Text;
use Exception;
@@ -95,7 +95,7 @@ class Uninstaller
continue;
}
$class = $module->get('namespace') . '\\' . self::UNINSTALL_CLASS_NAME;
- if ($module->getId() != My::id() && is_a($class, dcNsProcess::class, true)) {
+ if ($module->getId() != My::id() && is_a($class, Process::class, true)) {
$this->modules[$module->getId()] = $this->module = $module;
// check class prerequiretics
if ($class::init()) {