From afe38af912e8c73a3a9e1df8b4e5444d06e68034 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 3 Aug 2023 11:18:13 +0200 Subject: [PATCH] upgrade to Dotclear 2.27 --- src/Install.php | 16 +++++----------- src/My.php | 29 ++--------------------------- src/Prepend.php | 10 ++++------ src/ReservedWhiteList.php | 4 ++-- src/Uninstall.php | 10 ++++------ src/UnmoderatedWhiteList.php | 4 ++-- src/Utils.php | 20 ++++---------------- 7 files changed, 23 insertions(+), 70 deletions(-) diff --git a/src/Install.php b/src/Install.php index a408a1e..0a4e855 100644 --- a/src/Install.php +++ b/src/Install.php @@ -16,10 +16,10 @@ namespace Dotclear\Plugin\whiteListCom; use dcCore; use dcNamespace; -use dcNsProcess; +use Dotclear\Core\Process; use Exception; -class Install extends dcNsProcess +class Install extends Process { // Module specs private static array $mod_conf = [ @@ -39,18 +39,12 @@ class Install extends dcNsProcess public static function init(): bool { - static::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version')); - - return static::$init; + return self::status(My::checkContext(My::INSTALL)); } public static function process(): bool { - if (!static::$init) { - return false; - } - - if (is_null(dcCore::app()->blog)) { + if (!self::status()) { return false; } @@ -60,7 +54,7 @@ class Install extends dcNsProcess // Set module settings foreach (self::$mod_conf as $v) { - dcCore::app()->blog->settings->get(My::id())->put( + My::settings()->put( $v[0], $v[1], $v[2], diff --git a/src/My.php b/src/My.php index 95e9c6a..3ebb626 100644 --- a/src/My.php +++ b/src/My.php @@ -14,36 +14,11 @@ declare(strict_types=1); namespace Dotclear\Plugin\whiteListCom; -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 cda5923..d6026f3 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -16,20 +16,18 @@ namespace Dotclear\Plugin\whiteListCom; use dcBlog; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; -class Prepend extends dcNsProcess +class Prepend extends Process { public static function init(): bool { - static::$init = true; - - 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/ReservedWhiteList.php b/src/ReservedWhiteList.php index 9ce891a..c5343d9 100644 --- a/src/ReservedWhiteList.php +++ b/src/ReservedWhiteList.php @@ -15,7 +15,7 @@ declare(strict_types=1); namespace Dotclear\Plugin\whiteListCom; use dcCore; -use dcPage; +use Dotclear\Core\Backend\Notices; use Dotclear\Helper\Html\Form\{ Checkbox, Hidden @@ -91,7 +91,7 @@ class ReservedWhiteList extends SpamFilter Utils::addReserved($name, $_POST['reserved_email'][$i]); } Utils::commit(); - dcPage::addSuccessNotice(__('Reserved names have been successfully updated.')); + Notices::addSuccessNotice(__('Reserved names have been successfully updated.')); Http::redirect($url); } diff --git a/src/Uninstall.php b/src/Uninstall.php index 9e7c6a4..f411ecb 100644 --- a/src/Uninstall.php +++ b/src/Uninstall.php @@ -15,21 +15,19 @@ declare(strict_types=1); namespace Dotclear\Plugin\whiteListCom; 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; } diff --git a/src/UnmoderatedWhiteList.php b/src/UnmoderatedWhiteList.php index 666032d..5dfb455 100644 --- a/src/UnmoderatedWhiteList.php +++ b/src/UnmoderatedWhiteList.php @@ -15,7 +15,7 @@ declare(strict_types=1); namespace Dotclear\Plugin\whiteListCom; use dcCore; -use dcPage; +use Dotclear\COre\Backend\Notices; use Dotclear\Helper\Html\Form\Checkbox; use Dotclear\Helper\Html\Html; use Dotclear\Helper\Network\Http; @@ -79,7 +79,7 @@ class UnmoderatedWhiteList extends SpamFilter Utils::addUnmoderated($email); } Utils::commit(); - dcPage::addSuccessNotice(__('Unmoderated names have been successfully updated.')); + Notices::addSuccessNotice(__('Unmoderated names have been successfully updated.')); Http::redirect($url); } $posts = Utils::getPostsUsers(); diff --git a/src/Utils.php b/src/Utils.php index 88a7724..dd4975b 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -47,14 +47,8 @@ class Utils return; } - if (is_null(dcCore::app()->blog)) { - return; - } - - $s = dcCore::app()->blog->settings->get(My::id()); - - self::$unmoderated = self::decode($s->get('unmoderated')); - self::$reserved = self::decode($s->get('reserved')); + self::$unmoderated = self::decode(My::settings()->get('unmoderated')); + self::$reserved = self::decode(My::settings()->get('reserved')); self::$init = true; } @@ -64,15 +58,9 @@ class Utils */ public static function commit(): void { - if (is_null(dcCore::app()->blog)) { - return; - } - self::init(); - $s = dcCore::app()->blog->settings->get(My::id()); - - $s->put( + My::settings()->put( 'unmoderated', self::encode(self::$unmoderated), 'string', @@ -81,7 +69,7 @@ class Utils false ); - $s->put( + My::settings()->put( 'reserved', self::encode(self::$reserved), 'string',