From 3973df3fcadef453ac8e4f6b8d955a6c8e5852b5 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Wed, 18 Oct 2023 23:41:42 +0200 Subject: [PATCH] upgrade plugin activityReport --- CHANGELOG.md | 6 ++ README.md | 6 +- _define.php | 2 +- ...ityReport.php => ActivityReportAction.php} | 56 ++++++++++++------- src/Backend.php | 6 +- src/Prepend.php | 4 -- 6 files changed, 49 insertions(+), 31 deletions(-) rename src/{PluginActivityReport.php => ActivityReportAction.php} (65%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3349750..8caecb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +cinecturlink2 2.2 - 2023.10.18 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade plugin activityReport + cinecturlink2 2.1 - 2023.10.15 =========================================================== * Require Dotclear 2.28 diff --git a/README.md b/README.md index ea51627..6f150a9 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # README -[![Release](https://img.shields.io/badge/release-2.0-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/cinecturlink2/releases) -![Date](https://img.shields.io/badge/date-2023.08.24-c44d58.svg)] -[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) +[![Release](https://img.shields.io/badge/release-2.2-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/cinecturlink2/releases) +![Date](https://img.shields.io/badge/date-2023.10.18-c44d58.svg)] +[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/cinecturlink2) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/cinecturlink2/src/branch/master/LICENSE) diff --git a/_define.php b/_define.php index 9ef57ab..09f5829 100644 --- a/_define.php +++ b/_define.php @@ -21,7 +21,7 @@ $this->registerModule( 'Cinecturlink 2', 'Widgets and pages about books, musics, films, blogs you are interested in', 'Jean-Christian Denis and Contributors', - '2.1', + '2.2', [ 'requires' => [['core', '2.28']], 'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'], diff --git a/src/PluginActivityReport.php b/src/ActivityReportAction.php similarity index 65% rename from src/PluginActivityReport.php rename to src/ActivityReportAction.php index 9cb3718..ba276bf 100644 --- a/src/PluginActivityReport.php +++ b/src/ActivityReportAction.php @@ -5,51 +5,67 @@ declare(strict_types=1); namespace Dotclear\Plugin\cinecturlink2; use Dotclear\App; -use Dotclear\Plugin\activityReport\ActivityReport; +use Dotclear\Core\Process; +use Dotclear\Database\Cursor; +use Dotclear\Plugin\activityReport\{ + Action, + ActivityReport, + Group +}; /** - * @brief cinecturlink2 activityReport class. + * @brief cinecturlink2 plugin activityReport class. * @ingroup cinecturlink2 * * @author Jean-Christian Denis (author) * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html */ -class PluginActivityReport +class ActivityReportAction extends Process { - public static function add() + public static function init(): bool { - ActivityReport::instance()->addGroup('cinecturlink2', __('Plugin cinecturlink2')); + return self::status(true); + } + + public static function process(): bool + { + if (!self::status()) { + return false; + } + + $group = new Group(My::id(), My::name()); // from BEHAVIOR cinecturlink2AfterAddLink in cinecturlink2/inc/class.cinecturlink2.php - ActivityReport::instance()->addAction( - 'cinecturlink2', - 'create', + $group->add(new Action( + 'cinecturlink2Create', __('link creation'), __('A new cineturlink named "%s" was added by "%s"'), 'cinecturlink2AfterAddLink', self::addLink(...) - ); + )); // from BEHAVIOR cinecturlink2AfterUpdLink in cinecturlink2/inc/class.cinecturlink2.php - ActivityReport::instance()->addAction( - 'cinecturlink2', - 'update', + $group->add(new Action( + 'cinecturlink2Update', __('updating link'), __('Cinecturlink named "%s" has been updated by "%s"'), 'cinecturlink2AfterUpdLink', self::updLink(...) - ); + )); // from BEHAVIOR cinecturlink2BeforeDelLink in cinecturlink2/inc/class.cinecturlink2.php - ActivityReport::instance()->addAction( - 'cinecturlink2', - 'delete', + $group->add(new Action( + 'cinecturlink2Delete', __('link deletion'), __('Cinecturlink named "%s" has been deleted by "%s"'), 'cinecturlink2BeforeDelLink', self::delLink(...) - ); + )); + + ActivityReport::instance()->groups->add($group); + + return true; } - public static function addLink($cur) + public static function addLink(Cursor $cur) { $logs = [ $cur->link_title, @@ -58,7 +74,7 @@ class PluginActivityReport ActivityReport::instance()->addLog('cinecturlink2', 'create', $logs); } - public static function updLink($cur, $id) + public static function updLink(Cursor $cur, int $id) { $C2 = new Utils(); $rs = $C2->getLinks(['link_id' => $id]); @@ -70,7 +86,7 @@ class PluginActivityReport ActivityReport::instance()->addLog('cinecturlink2', 'update', $logs); } - public static function delLink($id) + public static function delLink(int $id) { $C2 = new Utils(); $rs = $C2->getLinks(['link_id' => $id]); diff --git a/src/Backend.php b/src/Backend.php index db1002e..22bb929 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -6,7 +6,6 @@ namespace Dotclear\Plugin\cinecturlink2; use ArrayObject; use Dotclear\App; -use Dotclear\Core\BlogSettings; use Dotclear\Core\Backend\Favorites; use Dotclear\Core\Process; use Dotclear\Helper\Html\Form\{ @@ -21,6 +20,7 @@ use Dotclear\Helper\Html\Form\{ Text }; use Dotclear\Helper\File\Files; +use Dotclear\Interface\Core\BlogSettingsInterface; /** * @brief cinecturlink2 backend class. @@ -88,7 +88,7 @@ class Backend extends Process ]); }, - 'adminBlogPreferencesFormV2' => function (BlogSettings $blog_settings): void { + 'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void { $s = $blog_settings->get(My::id()); $url = App::blog()->url() . App::url()->getBase(My::id()); $public_nbrpp = (int) $s->get('public_nbrpp'); @@ -197,7 +197,7 @@ class Backend extends Process ->render(); }, - 'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void { + 'adminBeforeBlogSettingsUpdate' => function (BlogSettingsInterface $blog_settings): void { $s = $blog_settings->get(My::id()); $active = !empty($_POST[My::id() . 'active']); $widthmax = abs((int) $_POST[My::id() . 'widthmax']); diff --git a/src/Prepend.php b/src/Prepend.php index 74b86db..00bd7fa 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -39,10 +39,6 @@ class Prepend extends Process 'sitemapsURLsCollect' => PluginSitemaps::sitemapsURLsCollect(...), ]); - if (defined('ACTIVITY_REPORT_V2')) { - PluginActivityReport::add(); - } - return true; } }