diff --git a/src/Backend.php b/src/Backend.php index 47882a0..3a7432a 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -15,26 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\lunarPhase; use dcCore; -use dcNsProcess; -use Dotclear\Helper\Html\Form\{ - Checkbox, - Input, - Label, - Para -}; +use Dotclear\Core\Process; -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 2ed3f37..88dfc22 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -15,21 +15,19 @@ declare(strict_types=1); namespace Dotclear\Plugin\lunarPhase; use dcCore; -use dcNsProcess; use dcUtils; +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; } diff --git a/src/My.php b/src/My.php index 62c80f4..0dc5852 100644 --- a/src/My.php +++ b/src/My.php @@ -14,12 +14,12 @@ declare(strict_types=1); namespace Dotclear\Plugin\lunarPhase; -use dcCore; +use Dotclear\Module\MyPlugin; /** * This module definitions. */ -class My +class My extends MyPlugin { /** @var array List of lunar phase => image */ public const LUNAR_PHASES = [ @@ -32,30 +32,4 @@ class My 'last_quarter_moon' => 'tqm.png', 'waning_crescent_moon' => 'wcm2.png', ]; - - /** - * 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 89c69fa..2c8186b 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -15,20 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\lunarPhase; 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_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; } @@ -38,11 +36,6 @@ class Prepend extends dcNsProcess 'lunarphase.css', '^lunarphase\.css', function (?string $args): void { - // avoid null warning - if (is_null(dcCore::app()->blog)) { - return; - } - header('Content-Type: text/css; charset=UTF-8'); echo "/* lunarphase widget style */\n"; @@ -50,7 +43,7 @@ class Prepend extends dcNsProcess echo sprintf( "#sidebar .lunarphase ul li.%s{background:transparent url(%s) no-repeat left 0.2em;padding-left:2em;}\n", $phase, - dcCore::app()->blog->getPF(My::id() . '/img/' . $image) + My::fileURL('img/' . $image) ); }