From 24077d4370586bcba4fd8ed93e6f48043130fbdf Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 19 Oct 2023 21:18:26 +0200 Subject: [PATCH] upgrade to Dotclear 2.28 --- CHANGELOG.md | 6 ++++++ README.md | 32 +++++++++++++++----------------- _define.php | 38 ++++++++++++++++---------------------- dcstore.xml | 6 +++--- src/Backend.php | 24 +++++++++++------------- src/Frontend.php | 33 ++++++++++++++------------------- src/LunarPhase.php | 20 +++++++++----------- src/My.php | 27 ++++++++++++++------------- src/Prepend.php | 24 +++++++++++------------- src/Widgets.php | 34 ++++++++++++++++------------------ 10 files changed, 115 insertions(+), 129 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cc981e..b08d4db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +lunarPhase 1.9 - 2023.10.19 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + lunarPhase 1.8 - 2023.08.14 =========================================================== * Require Dotclear 2.27 diff --git a/README.md b/README.md index 8b0bc25..5453321 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,22 @@ # README -[![Release](https://img.shields.io/badge/release-1.8-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lunarPhase/releases) -[![Date](https://img.shields.io/badge/date-2023.08.15-c44d58.svg)](https://git.dotclear.watch/JcDenis/lunarPhase/releases) -[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) +[![Release](https://img.shields.io/badge/release-1.9-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lunarPhase/releases) +![Date](https://img.shields.io/badge/date-2023.10.19-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/lunarPhase) -[![License](https://img.shields.io/github/license/JcDenis/lunarPhase)](https://git.dotclear.watch/JcDenis/lunarPhase/blob/master/LICENSE) +[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/lunarPhase/src/branch/master/LICENSE) -## WHAT IS LUNARPHASE ? +## ABOUT -_lunarPhase_ is a plugin for the open-source -web publishing software called Dotclear. +_lunarPhase_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -It shows lunar phases on a widget. +> Show lunar phases on a widget. ## REQUIREMENTS -_lunarPhase_ requires: - -* content admin permissions to manage widgets -* Dotclear 2.27 +* Dotclear 2.28 * PHP 8.1+ +* Dotclear content admin permissions to manage widgets ## USAGE @@ -30,15 +27,16 @@ You should add widget to show lunar phases on your blog. ## LINKS -* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html) -* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/lunarPhase) or [GitHub Page](https://github.com/JcDenis/lunarPhase) -* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/lunarPhase/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/lunarPhase) -* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=332971#p332971) +* [License](https://git.dotclear.watch/JcDenis/lunarPhase/src/branch/master/LICENSE) +* [Packages & details](https://git.dotclear.watch/JcDenis/lunarPhase/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/lunarPhase)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/lunarPhase) (or on [GitHub](https://github.com/JcDenis/lunarPhase)) +* [Issues & security](https://git.dotclear.watch/JcDenis/lunarPhase/issues) (or on [GitHub](https://github.com/JcDenis/lunarPhase/issues)) +* [Discuss & help](http://forum.dotclear.org/viewtopic.php?pid=332971#p332971) ## CONTRIBUTORS * Tomtom (author) * Pierre Van Glabeke -* Jean-Christian Denis +* Jean-Christian Denis (latest) You are welcome to contribute to this code. diff --git a/_define.php b/_define.php index 0bddb31..4afc249 100644 --- a/_define.php +++ b/_define.php @@ -1,36 +1,30 @@ registerModule( 'Moon phases', 'Display the moon phases on a widget', 'Tomtom, Pierre Van Glabeke and Contributors', - '1.8', + '1.9', [ - 'requires' => [ - ['php', '8.1'], - ['core', '2.26'], - ], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcCore::app()->auth::PERMISSION_USAGE, - dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, - ]), - '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', + 'requires' => [['core', '2.28']], + 'permissions' => 'My', + '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 18abe5f..9fabae3 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Moon phases - 1.8 + 1.9 Tomtom, Pierre Van Glabeke and Contributors Display the moon phases on a widget - https://git.dotclear.watch/JcDenis/lunarPhase/releases/download/v1.8/plugin-lunarPhase.zip - 2.26 + https://git.dotclear.watch/JcDenis/lunarPhase/releases/download/v1.9/plugin-lunarPhase.zip + 2.28 https://git.dotclear.watch/JcDenis/lunarPhase/src/branch/master/README.md https://git.dotclear.watch/JcDenis/lunarPhase/issues diff --git a/src/Backend.php b/src/Backend.php index 3a7432a..49251af 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -1,22 +1,20 @@ addBehavior('initWidgets', [Widgets::class, 'initWidgets']); + App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); return true; } diff --git a/src/Frontend.php b/src/Frontend.php index 88dfc22..058ed2b 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,23 +1,20 @@ addBehaviors([ + App::behavior()->addBehaviors([ // Add public header for lunarphase css 'publicHeadContent' => function (): void { - if (is_null(dcCore::app()->blog)) { - return; + if (App::blog()->isDefined()) { + echo App::plugins()->cssLoad(App::blog()->url() . App::url()->getURLFor('lunarphase')); } - - echo dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('lunarphase')); }, // Widgets - 'initWidgets' => [Widgets::class, 'initWidgets'], + 'initWidgets' => Widgets::initWidgets(...), ]); return true; diff --git a/src/LunarPhase.php b/src/LunarPhase.php index 5f21b0b..806a6a1 100644 --- a/src/LunarPhase.php +++ b/src/LunarPhase.php @@ -1,21 +1,19 @@ List of lunar phase => image */ + /** + * List of lunar phase => image. + * + * @var array LUNAR_PHASES + */ public const LUNAR_PHASES = [ 'new_moon' => 'nm.png', 'waxing_crescent_moon' => 'wcm1.png', @@ -32,4 +31,6 @@ class My extends MyPlugin 'last_quarter_moon' => 'tqm.png', 'waning_crescent_moon' => 'wcm2.png', ]; + + // Use default permissions } diff --git a/src/Prepend.php b/src/Prepend.php index 2c8186b..5b5ae54 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -1,22 +1,20 @@ url->register( + App::url()->register( 'lunarphase', 'lunarphase.css', '^lunarphase\.css', diff --git a/src/Widgets.php b/src/Widgets.php index 1d92769..cac487d 100644 --- a/src/Widgets.php +++ b/src/Widgets.php @@ -1,25 +1,23 @@ create( 'lunarphase', __('Moon phases'), - [self::class, 'parseWidget'], + self::parseWidget(...), null, __('Display the moon phases') ) @@ -49,7 +47,7 @@ class Widgets public static function parseWidget(WidgetsElement $w): string { - if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) { + if ($w->offline || !$w->checkHomeOnly(App::url()->type)) { return ''; } @@ -200,14 +198,14 @@ class Widgets */ public static function formatValue(string $type, mixed $value): mixed { - if (is_null(dcCore::app()->blog)) { + if (!App::blog()->isDefined()) { return null; } $res = ''; - $format = dcCore::app()->blog->settings->get('system')->get('date_format') . ' - '; - $format .= dcCore::app()->blog->settings->get('system')->get('time_format'); - $tz = dcCore::app()->blog->settings->get('system')->get('blog_timezone'); + $format = App::blog()->settings()->get('system')->get('date_format') . ' - '; + $format .= App::blog()->settings()->get('system')->get('time_format'); + $tz = App::blog()->settings()->get('system')->get('blog_timezone'); return match ($type) { 'int' => number_format($value, 0),