From 899a61ed5f0595c19c2a12c77b3e8511df9c40cb Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sun, 13 Aug 2023 18:30:22 +0200 Subject: [PATCH] upgrade to Dotclear 2.27 --- src/Backend.php | 23 +++++++---------------- src/BackendBehaviors.php | 37 ++++++++++++++++++++----------------- src/My.php | 21 +++++++++++++++++++++ 3 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 src/My.php diff --git a/src/Backend.php b/src/Backend.php index 93ce456..40d788d 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -16,37 +16,28 @@ namespace Dotclear\Plugin\postslistOptions; use ArrayObject; use dcCore; -use dcNsProcess; -use dcPostsActions; +use Dotclear\Core\Backend\Action\ActionsPosts; +use Dotclear\Core\Process; /** * Improve admin class * * Add menu and dashboard icons, load Improve action modules. */ -class Backend extends dcNsProcess +class Backend extends Process { public static function init(): bool { - static::$init = defined('DC_CONTEXT_ADMIN') - && !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) - && dcCore::app()->auth->check( - dcCore::app()->auth->makePermissions([ - dcCore::app()->auth::PERMISSION_ADMIN, - ]), - dcCore::app()->blog->id - ); - - return static::$init; + return self::status(My::checkContext(My::BACKEND)); } public static function process(): bool { - if (!static::$init) { + if (!self::status()) { return false; } - dcCore::app()->addBehavior('adminPostsActions', function (dcPostsActions $pa) { + dcCore::app()->addBehavior('adminPostsActions', function (ActionsPosts $pa) { $pa->addAction( [ __('Comments') => [ @@ -60,7 +51,7 @@ class Backend extends dcNsProcess __('Delete all trackbacks') => 'trackbacksdelete', ], ], - function (dcPostsActions $pa, ArrayObject $post) { + function (ActionsPosts $pa, ArrayObject $post) { $actions = [ 'commentsopen', 'commentsclose', diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php index c80330f..62048a8 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -17,8 +17,11 @@ namespace Dotclear\Plugin\postslistOptions; use ArrayObject; use dcBlog; use dcCore; -use dcPage; -use dcPostsActions; +use Dotclear\Core\Backend\{ + Notices, + Page +}; +use Dotclear\Core\Backend\Action\ActionsPosts; use Dotclear\Helper\Html\Form\{ Form, Hidden, @@ -31,25 +34,25 @@ use Exception; class BackendBehaviors { - public static function commentsOpen(dcPostsActions $pa, ArrayObject $post): void + public static function commentsOpen(ActionsPosts $pa, ArrayObject $post): void { foreach (self::getPostsIds($pa) as $post_id) { self::updPostOption($post_id, 'post_open_comment', 1); } - dcPage::addSuccessNotice(__('Comments successfully opened.')); + Notices::addSuccessNotice(__('Comments successfully opened.')); $pa->redirect(true); } - public static function commentsClose(dcPostsActions $pa, ArrayObject $post): void + public static function commentsClose(ActionsPosts $pa, ArrayObject $post): void { foreach (self::getPostsIds($pa) as $post_id) { self::updPostOption($post_id, 'post_open_comment', 0); } - dcPage::addSuccessNotice(__('Comments successfully closed.')); + Notices::addSuccessNotice(__('Comments successfully closed.')); $pa->redirect(true); } - public static function commentsDelete(dcPostsActions $pa, ArrayObject $post): void + public static function commentsDelete(ActionsPosts $pa, ArrayObject $post): void { //nullsafe if (is_null(dcCore::app()->blog)) { @@ -60,7 +63,7 @@ class BackendBehaviors if (empty($_POST['confirmdeletecomments'])) { $pa->beginPage( - dcPage::breadcrumb([ + Page::breadcrumb([ Html::escapeHTML(dcCore::app()->blog->name) => '', $pa->getCallerTitle() => $pa->getRedirection(true), __('Delete posts comments') => '', @@ -94,30 +97,30 @@ class BackendBehaviors self::delPostComments($post_id, false); self::updPostOption($post_id, 'nb_comment', 0); } - dcPage::addSuccessNotice(__('Comments successfully deleted.')); + Notices::addSuccessNotice(__('Comments successfully deleted.')); $pa->redirect(true); } } - public static function trackbacksOpen(dcPostsActions $pa, ArrayObject $post): void + public static function trackbacksOpen(ActionsPosts $pa, ArrayObject $post): void { foreach (self::getPostsIds($pa) as $post_id) { self::updPostOption($post_id, 'post_open_tb', 1); } - dcPage::addSuccessNotice(__('Trackbacks successfully opened.')); + Notices::addSuccessNotice(__('Trackbacks successfully opened.')); $pa->redirect(true); } - public static function trackbacksClose(dcPostsActions $pa, ArrayObject $post): void + public static function trackbacksClose(ActionsPosts $pa, ArrayObject $post): void { foreach (self::getPostsIds($pa) as $post_id) { self::updPostOption($post_id, 'post_open_tb', 0); } - dcPage::addSuccessNotice(__('Trackbacks successfully closed.')); + Notices::addSuccessNotice(__('Trackbacks successfully closed.')); $pa->redirect(true); } - public static function trackbacksDelete(dcPostsActions $pa, ArrayObject $post): void + public static function trackbacksDelete(ActionsPosts $pa, ArrayObject $post): void { //nullsafe if (is_null(dcCore::app()->blog)) { @@ -128,7 +131,7 @@ class BackendBehaviors if (empty($_POST['confirmdeletetrackbacks'])) { $pa->beginPage( - dcPage::breadcrumb([ + Page::breadcrumb([ Html::escapeHTML(dcCore::app()->blog->name) => '', $pa->getCallerTitle() => $pa->getRedirection(true), __('Delete posts trackbacks') => '', @@ -159,12 +162,12 @@ class BackendBehaviors self::delPostComments($post_id, true); self::updPostOption($post_id, 'nb_trackback', 0); } - dcPage::addSuccessNotice(__('Trackbacks successfully deleted.')); + Notices::addSuccessNotice(__('Trackbacks successfully deleted.')); $pa->redirect(true); } } - private static function getPostsIds(dcPostsActions $pa): array + private static function getPostsIds(ActionsPosts $pa): array { $posts_ids = $pa->getIDs(); if (empty($posts_ids)) { diff --git a/src/My.php b/src/My.php new file mode 100644 index 0000000..fe586e8 --- /dev/null +++ b/src/My.php @@ -0,0 +1,21 @@ +