From 5e7765d39576b20a4ad6566d0b91b481f41473cc Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Fri, 20 Oct 2023 21:28:21 +0200 Subject: [PATCH] code review --- CHANGELOG.md | 7 +++++++ README.md | 8 ++++---- _define.php | 25 ++++++------------------- dcstore.xml | 4 ++-- src/Backend.php | 10 +++++----- src/Frontend.php | 4 ++-- src/My.php | 19 +++---------------- src/Prepend.php | 4 ++-- src/UrlHandler.php | 4 ++-- 9 files changed, 33 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0c77fe..f57ef77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +simplyFavicon 2023.10.20 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Fix use of interface +* Use default permissions + simplyFavicon 2023.10.14 =========================================================== * Require Dotclear 2.28 diff --git a/README.md b/README.md index 5430ed0..d8c4e6a 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # README -[![Release](https://img.shields.io/badge/release-2023.10.14-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/simplyFavicon/releases) -![Date](https://img.shields.io/badge/date-2023.10.13-c44d58.svg) +[![Release](https://img.shields.io/badge/release-2023.10.20-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/simplyFavicon/releases) +![Date](https://img.shields.io/badge/date-2023.10.20-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/simplyFavicon) [![License](https://img.shields.io/github/license/JcDenis/simplyFavicon)](https://git.dotclear.watch/JcDenis/simplyFavicon/blob/master/LICENSE) ## ABOUT -_pacKman_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). +_simplyFavicon_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). > Add a favicon to your blog. @@ -17,7 +17,7 @@ _pacKman_ is a plugin for the open-source web publishing software called [Dotcle * Dotclear 2.28 * PHP 8.1+ * A readable public directory -* Administrator permissions +* Dotclear admin permissions ## USAGE diff --git a/_define.php b/_define.php index 2d13cb0..0336bd1 100644 --- a/_define.php +++ b/_define.php @@ -1,16 +1,5 @@ registerModule( 'Simply favicon', 'Multi-agents favicon', 'Jean-Christian Denis', - '2023.10.14', + '2023.10.20', [ 'requires' => [['core', '2.28']], 'permissions' => 'My', - 'settings' => [ - 'blog' => '#params.' . basename(__DIR__) . '_params', - ], - 'type' => 'plugin', - 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', - 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', - 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', + 'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'], + 'type' => 'plugin', + 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', + 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', + 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', ] ); diff --git a/dcstore.xml b/dcstore.xml index 00653ef..d9d9e16 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,10 +2,10 @@ Simply favicon - 2023.10.14 + 2023.10.20 Jean-Christian Denis Multi-agents favicon - https://git.dotclear.watch/JcDenis/simplyFavicon/releases/download/v2023.10.14/plugin-simplyFavicon.zip + https://git.dotclear.watch/JcDenis/simplyFavicon/releases/download/v2023.10.20/plugin-simplyFavicon.zip 2.28 https://git.dotclear.watch/JcDenis/simplyFavicon/src/branch/master/README.md https://git.dotclear.watch/JcDenis/simplyFavicon/issues diff --git a/src/Backend.php b/src/Backend.php index d23b14a..2fe4f64 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Dotclear\Plugin\simplyFavicon; use Dotclear\App; -use Dotclear\Core\BlogSettings; use Dotclear\Core\Process; use Dotclear\Helper\File\Path; use Dotclear\Helper\Html\Form\{ @@ -15,10 +14,11 @@ use Dotclear\Helper\Html\Form\{ Note, Para }; +use Dotclear\Interface\Core\BlogSettingsInterface; /** - * @brief simplyFavicon backend class. - * @ingroup simplyFavicon + * @brief simplyFavicon backend class. + * @ingroup simplyFavicon * * @author Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html @@ -37,7 +37,7 @@ class Backend extends Process } App::behavior()->addBehaviors([ - 'adminBlogPreferencesFormV2' => function (BlogSettings $blog_settings): void { + 'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void { if (!App::blog()->isDefined()) { return; } @@ -78,7 +78,7 @@ class Backend extends Process ) . '
'; }, - 'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void { + 'adminBeforeBlogSettingsUpdate' => function (BlogSettingsInterface $blog_settings): void { $blog_settings->get('system')->put('simply_favicon', !empty($_POST['simply_favicon'])); }, ]); diff --git a/src/Frontend.php b/src/Frontend.php index 9503ef3..fd1618f 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -9,8 +9,8 @@ use Dotclear\Core\Process; use Dotclear\Helper\File\Path; /** - * @brief simplyFavicon frontend class. - * @ingroup simplyFavicon + * @brief simplyFavicon frontend class. + * @ingroup simplyFavicon * * @author Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html diff --git a/src/My.php b/src/My.php index a5fcf5a..cafb671 100644 --- a/src/My.php +++ b/src/My.php @@ -4,29 +4,16 @@ declare(strict_types=1); namespace Dotclear\Plugin\simplyFavicon; -use Dotclear\App; use Dotclear\Module\MyPlugin; /** - * @brief simplyFavicon My helper. - * @ingroup simplyFavicon + * @brief simplyFavicon My helper. + * @ingroup simplyFavicon * * @author Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html */ class My extends MyPlugin { - protected static function checkCustomContext(int $context): ?bool - { - return match ($context) { - // Limit BACKEND to admin - self::BACKEND => App::task()->checkContext('BACKEND') - && App::blog()->isDefined() - && App::auth()->check(App::auth()->makePermissions([ - App::auth()::PERMISSION_ADMIN, - ]), App::blog()->id()), - - default => null, - }; - } + // Use default permissions } diff --git a/src/Prepend.php b/src/Prepend.php index a531aa3..f2f3d6b 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -8,8 +8,8 @@ use Dotclear\App; use Dotclear\Core\Process; /** - * @brief simplyFavicon prepend class. - * @ingroup simplyFavicon + * @brief simplyFavicon prepend class. + * @ingroup simplyFavicon * * @author Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html diff --git a/src/UrlHandler.php b/src/UrlHandler.php index f012663..8a7aec0 100644 --- a/src/UrlHandler.php +++ b/src/UrlHandler.php @@ -9,8 +9,8 @@ use Dotclear\Core\Frontend\Url; use Dotclear\Helper\File\Path; /** - * @brief simplyFavicon frontend URL handler. - * @ingroup simplyFavicon + * @brief simplyFavicon frontend URL handler. + * @ingroup simplyFavicon * * @author Jean-Christian Denis * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html