From a969f1b66abb438668c1726953ef6e071d0ad85a Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sun, 13 Aug 2023 21:19:54 +0200 Subject: [PATCH] upgrade to Dotclear 2.27 --- src/Backend.php | 10 ++++------ src/Frontend.php | 14 ++++++-------- src/My.php | 29 ++--------------------------- src/Prepend.php | 10 ++++------ src/Uninstall.php | 10 ++++------ 5 files changed, 20 insertions(+), 53 deletions(-) diff --git a/src/Backend.php b/src/Backend.php index ec8f6d3..ce419ee 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -15,26 +15,24 @@ declare(strict_types=1); namespace Dotclear\Plugin\saba; use dcCore; -use dcNsProcess; use dcSettings; +use Dotclear\Core\Process; use Dotclear\Helper\Html\Form\{ Checkbox, Label, Para }; -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; } diff --git a/src/Frontend.php b/src/Frontend.php index 3cec7e1..5b3685a 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -15,28 +15,26 @@ declare(strict_types=1); namespace Dotclear\Plugin\saba; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; -class Frontend extends dcNsProcess +class Frontend extends Process { public static function init(): bool { - static::$init = defined('DC_RC_PATH'); - - return static::$init; + return self::status(My::checkContext(My::FRONTEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } - if (is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get(My::id())->get('active')) { + if (My::settings()->get('active')) { return false; } - if (dcCore::app()->blog->settings->get(My::id())->get('error')) { + if (My::settings()->get('error')) { dcCore::app()->url->registerError([UrlHandler::class, 'error']); } diff --git a/src/My.php b/src/My.php index 48f8b1b..8b5e019 100644 --- a/src/My.php +++ b/src/My.php @@ -14,36 +14,11 @@ declare(strict_types=1); namespace Dotclear\Plugin\saba; -use dcCore; +use Dotclear\Module\MyPlugin; /** * This module definitions. */ -class My +class My extends MyPlugin { - /** - * This module id. - */ - public static function id(): string - { - 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__); - } } diff --git a/src/Prepend.php b/src/Prepend.php index 60d3535..976be25 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -15,25 +15,23 @@ declare(strict_types=1); namespace Dotclear\Plugin\saba; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; use Dotclear\Plugin\activityReport\{ Action, ActivityReport, Group }; -class Prepend extends dcNsProcess +class Prepend extends Process { public static function init(): bool { - static::$init = defined('DC_RC_PATH'); - - return static::$init; + return self::status(My::checkContext(My::PREPEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } diff --git a/src/Uninstall.php b/src/Uninstall.php index e1b8c57..6df4d26 100644 --- a/src/Uninstall.php +++ b/src/Uninstall.php @@ -15,21 +15,19 @@ declare(strict_types=1); namespace Dotclear\Plugin\saba; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; use Dotclear\Plugin\Uninstaller\Uninstaller; -class Uninstall extends dcNsProcess +class Uninstall extends Process { public static function init(): bool { - static::$init = defined('DC_CONTEXT_ADMIN'); - - return static::$init; + return self::status(My::checkContext(My::UNINSTALL)); } public static function process(): bool { - if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) { + if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) { return false; }