diff --git a/src/Backend.php b/src/Backend.php index b31a960..15d3dd7 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -15,20 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\countdown; use dcCore; -use dcNsProcess; +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 05fa838..985e33f 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -15,20 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\countdown; use dcCore; -use dcNsProcess; +use Dotclear\Core\Process; -class Frontend extends dcNsProcess +class Frontend extends Process { public static function init(): bool { - static::$init = true; - - 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 new file mode 100644 index 0000000..1f0df97 --- /dev/null +++ b/src/My.php @@ -0,0 +1,24 @@ +blog)) { @@ -203,7 +198,7 @@ class Widgets } if (!$w->dynamic || is_null(dcCore::app()->ctx)) { - $res = ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . + $res = ($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') . '
' . $text . '' . $str . '
'; return $w->renderDiv((bool) $w->content_only, 'countdown ' . $w->class, '', $res); @@ -219,13 +214,13 @@ class Widgets $script = ''; if (!defined('COUNTDOWN_SCRIPT')) { - $script .= dcUtils::cssLoad(dcCore::app()->blog->getPF(self::id() . '/css/jquery.countdown.css')) . - dcUtils::jsLoad(dcCore::app()->blog->getPF(self::id() . '/js/jquery.plugin.min.js')) . - dcUtils::jsLoad(dcCore::app()->blog->getPF(self::id() . '/js/jquery.countdown.min.js')); + $script .= My::cssLoad('jquery.countdown.css') . + My::jsLoad('jquery.plugin.min.js') . + My::jsLoad('jquery.countdown.min.js'); $l10n_file = 'jquery.countdown-' . dcCore::app()->blog->settings->get('system')->get('lang') . '.js'; if (file_exists(__DIR__ . '/../js/' . $l10n_file)) { - $script .= dcUtils::jsLoad(dcCore::app()->blog->getPF(self::id() . '/js/' . $l10n_file)); + $script .= My::jsLoad($l10n_file); } define('COUNTDOWN_SCRIPT', (bool) true);