diff --git a/CHANGELOG.md b/CHANGELOG.md index 86f49df..e6644d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +shortArchives 2.2 - 2023.10.20 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + shortArchives 2.1 - 2023.08.13 =========================================================== * Require Dotclear 2.27 diff --git a/README.md b/README.md index 169c58a..0c59e11 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,22 @@ # README -[![Release](https://img.shields.io/badge/release-2.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/shortArchives/releases) -[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/shortArchives/releases) -[![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/shortArchives/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/shortArchives) -[![License](https://img.shields.io/github/license/JcDenis/shortArchives)](https://git.dotclear.watch/JcDenis/shortArchives/blob/master/LICENSE) +[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/shortArchives/src/branch/master/LICENSE) -## WHAT IS SHORTARCHIVES ? +## ABOUT -_shortArchives_ is a plugin for the open-source -web publishing software called Dotclear. +_shortArchives_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -Add a public widget that list links to archives by year. +> Add a public widget that list links to archives by year. ## REQUIREMENTS -_shortArchives_ requires: - -* content admin permissions to manage widgets -* Dotclear 2.27 -* PHP 7.4 +* Dotclear 2.28 +* PHP 8.1+ +* Dotclear content admin permissions to manage widgets ## USAGE @@ -30,15 +27,15 @@ You should add widget to show archives list 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/shortArchives) or [GitHub Page](https://github.com/JcDenis/shortArchives) -* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/shortArchives/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/shortArchives) -* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=321044#p321044) +* [Packages & details](https://git.dotclear.watch/JcDenis/shortArchives/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/shortArchives)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/shortArchives) (or on [GitHub](https://github.com/JcDenis/shortArchives)) +* [Issues & security](https://git.dotclear.watch/JcDenis/shortArchives/issues) (or on [GitHub](https://github.com/JcDenis/shortArchives/issues)) +* [Discuss & help](http://forum.dotclear.org/viewtopic.php?pid=321044#p321044) ## CONTRIBUTORS * annso (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 e325c95..31f8a53 100644 --- a/_define.php +++ b/_define.php @@ -1,32 +1,30 @@ registerModule( 'shortArchives', 'Display blog archives in an accordion menu, sorted by year', 'annso, Pierre Van Glabeke and Contributors', - '2.1', + '2.2', [ - 'requires' => [['core', '2.27']], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcCore::app()->auth::PERMISSION_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 e923faa..b8d94d0 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ shortArchives - 2.1 + 2.2 annso, Pierre Van Glabeke and Contributors Display blog archives in an accordion menu, sorted by year - https://git.dotclear.watch/JcDenis/shortArchives/releases/download/v2.1/plugin-shortArchives.zip - 2.27 + https://git.dotclear.watch/JcDenis/shortArchives/releases/download/v2.2/plugin-shortArchives.zip + 2.28 https://git.dotclear.watch/JcDenis/shortArchives/src/branch/master/README.md https://git.dotclear.watch/JcDenis/shortArchives/issues diff --git a/src/Backend.php b/src/Backend.php index fd07841..5e46113 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -1,22 +1,20 @@ addBehaviors([ - 'initWidgets' => [Widgets::class, 'initWidgets'], - ]); + App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); return true; } diff --git a/src/Frontend.php b/src/Frontend.php index cbaaeec..611e7aa 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,22 +1,20 @@ addBehaviors([ - 'initWidgets' => [Widgets::class, 'initWidgets'], + App::behavior()->addBehaviors([ + 'initWidgets' => Widgets::initWidgets(...), 'publicHeadContent' => function (): void { echo My::jsLoad('accordion') . diff --git a/src/My.php b/src/My.php index 2a42d37..29abc5d 100644 --- a/src/My.php +++ b/src/My.php @@ -1,15 +1,5 @@ create( My::id(), My::name(), - [self::class, 'parseWidget'], + self::parseWidget(...), null, __('Blog Archive List an accordion menu, sorted by year') ) @@ -43,22 +41,20 @@ class Widgets public static function parseWidget(WidgetsElement $w): string { - // nullsafe - if (is_null(dcCore::app()->blog)) { + if (!App::blog()->isDefined() + || $w->__get('offline') + || !$w->checkHomeOnly(App::url()->type) + ) { return ''; } - if ($w->__get('offline') || !$w->checkHomeOnly(dcCore::app()->url->type)) { - return ''; - } - - $rs = dcCore::app()->blog->getDates(['type' => 'month']); + $rs = App::blog()->getDates(['type' => 'month']); if ($rs->isEmpty()) { return ''; } $active_year = null; - if ((dcCore::app()->url->type == 'archive') && preg_match('`^/([0-9]{4})/([0-9]{2})$`', (string) dcCore::app()->url->args, $matches)) { + if ((App::url()->type == 'archive') && preg_match('`^/([0-9]{4})/([0-9]{2})$`', (string) App::url()->args, $matches)) { $active_year = $matches[1]; } @@ -89,8 +85,8 @@ class Widgets } $res .= ''; - if (dcCore::app()->url->getBase('archive') && !is_null($w->__get('allarchivesslinktitle')) && $w->__get('allarchivesslinktitle') !== '') { - $res .= '

' . + if (App::url()->getBase('archive') && !is_null($w->__get('allarchivesslinktitle')) && $w->__get('allarchivesslinktitle') !== '') { + $res .= '

' . Html::escapeHTML($w->__get('allarchivesslinktitle')) . '

'; }