From 9a829ea3f24f2034a86605eeb0aef2056e160380 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sun, 13 Aug 2023 17:19:55 +0200 Subject: [PATCH] upgrade to Dotclear 2.27 --- src/Backend.php | 10 ++++------ src/Frontend.php | 10 ++++------ src/My.php | 21 +++++++++++++++++++++ src/Widgets.php | 6 +++--- 4 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 src/My.php diff --git a/src/Backend.php b/src/Backend.php index 6820a9d..c6152ed 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -15,20 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\lastpostsExtend; 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 5cb13ce..3fdaf77 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -15,20 +15,18 @@ declare(strict_types=1); namespace Dotclear\Plugin\lastpostsExtend; 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..899d862 --- /dev/null +++ b/src/My.php @@ -0,0 +1,21 @@ + 'galitem', ]; // plugin muppet types - if (dcCore::app()->plugins->moduleExists('muppet') && class_exists('\muppet')) { + if (dcCore::app()->plugins->getDefine('muppet')->isDefined() && class_exists('\muppet')) { $muppet_types = \muppet::getPostTypes(); if (is_array($muppet_types) && !empty($muppet_types)) { foreach ($muppet_types as $k => $v) { @@ -234,7 +234,7 @@ class Widgets public static function parseWidget(WidgetsElement $w): string { // Widget is offline & Home page only - if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || $w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) { + if (is_null(dcCore::app()->blog) || $w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) { return ''; } @@ -396,7 +396,7 @@ class Widgets private static function entryFirstImage(string $type, $id, string $size = 's'): string { - if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || !in_array($type, ['post', 'page', 'galitem'])) { + if (is_null(dcCore::app()->blog) || !in_array($type, ['post', 'page', 'galitem'])) { return ''; }