diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fef572..35fbbf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +CategoriesPage 1.3 - 2023.10.15 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + CategoriesPage 1.2 - 2023.08.06 =========================================================== * Require Dotclear 2.27 diff --git a/README.md b/README.md index 39ab250..c3dc324 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,22 @@ # README -[![Release](https://img.shields.io/badge/release-1.2-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/CategoriesPage/releases) -[![Date](https://img.shields.io/badge/date-2023.08.06-c44d58.svg)](https://git.dotclear.watch/JcDenis/CategoriesPage/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.3-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/CategoriesPage/releases) +![Date](https://img.shields.io/badge/date-2023.10.15-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/CategoriesPage) -[![License](https://img.shields.io/github/license/JcDenis/CategoriesPage)](https://git.dotclear.watch/JcDenis/CategoriesPage/blob/master/LICENSE) +[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/CategoriesPage/src/branch/master/LICENSE) -## WHAT IS CATEGORIESPAGE ? +## ABOUT -_CategoriesPage_ is a plugin for the open-source -web publishing software called Dotclear. +_CategoriesPage_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -Add a public page to list blog categories. -A widget is also available. +> Add a public page to list blog categories. A widget is also available. ## REQUIREMENTS - _CategoriesPage_ requires: - - * admin permissions - * Dotclear 2.27 +* Dotclear 2.28 +* PHP 8.1 +* admin permissions ## USAGE @@ -31,14 +28,15 @@ default templates are on plugin directory CategoriesPage/default-templates/ ## 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/CategoriesPage) or [GitHub Page](https://github.com/JcDenis/CategoriesPage) - * Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/CategoriesPage/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/CategoriesPage) +* [License](https://git.dotclear.watch/JcDenis/CategoriesPage/src/branch/master/LICENSE) +* [Packages & details](https://git.dotclear.watch/JcDenis/CategoriesPage/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/CategoriesPage)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/CategoriesPage) (or on [GitHub](https://github.com/JcDenis/CategoriesPage)) +* [Issues & security](https://git.dotclear.watch/JcDenis/CategoriesPage/issues) (or on [GitHub](https://github.com/JcDenis/CategoriesPage/issues)) ## CONTRIBUTORS - * Pierre Van Glabeke - * Bernard Le Roux - * Jean-Christian Denis +* Pierre Van Glabeke (author) +* Bernard Le Roux +* Jean-Christian Denis (latest) - You are welcome to contribute to this code. \ No newline at end of file +You are welcome to contribute to this code. diff --git a/_define.php b/_define.php index e81414f..d152338 100644 --- a/_define.php +++ b/_define.php @@ -1,33 +1,31 @@ registerModule( 'Categories Page', 'Add a public page for categories list', 'Pierre Van Glabeke, Bernard Le Roux and Contributors', - '1.2', + '1.3', [ - 'requires' => [['core', '2.27']], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcAuth::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 0ef8a51..e26a740 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Categories Page - 1.2 + 1.3 Pierre Van Glabeke, Bernard Le Roux and Contributors Add a public page for categories list - https://git.dotclear.watch/JcDenis/CategoriesPage/releases/download/v1.2/plugin-CategoriesPage.zip - 2.27 + https://git.dotclear.watch/JcDenis/CategoriesPage/releases/download/v1.3/plugin-CategoriesPage.zip + 2.28 https://git.dotclear.watch/JcDenis/CategoriesPage/src/branch/master/README.md https://git.dotclear.watch/JcDenis/CategoriesPage/issues diff --git a/src/Backend.php b/src/Backend.php index 8de956d..1bc6475 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 172d673..dd32f5b 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,23 +1,21 @@ addBehaviors([ + App::behavior()->addBehaviors([ // template path 'publicBeforeDocumentV2' => function (): void { - // nullsafe PHP < 8.0 - if (is_null(dcCore::app()->blog)) { + if (!App::blog()->isDefined()) { return ; } - $tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->get('system')->get('theme'), 'tplset'); + $tplset = App::themes()->moduleInfo(App::blog()->settings()->get('system')->get('theme'), 'tplset'); if (!empty($tplset) && is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset])); + App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset])); } else { - dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', DC_DEFAULT_TPLSET])); + App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', App::config()->defaultTplset()])); } }, // breacrumb addon @@ -51,15 +48,15 @@ class Frontend extends Process return $context == 'categories' ? My::name() : ''; }, // widget - 'initWidgets' => [Widgets::class, 'initWidgets'], + 'initWidgets' => Widgets::initWidgets(...), ]); // tpl values - dcCore::app()->tpl->addValue('CategoryCount', function (ArrayObject $attr): string { - return 'tpl->getFilters($attr), 'dcCore::app()->ctx->categories->nb_post') . '; ?>'; + App::frontend()->template()->addValue('CategoryCount', function (ArrayObject $attr): string { + return 'template()->getFilters($attr), 'App::frontend()->context()->categories->nb_post') . '; ?>'; }); - dcCore::app()->tpl->addValue('CategoriesURL', function (ArrayObject $attr): string { - return 'tpl->getFilters($attr), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("categories")') . '; ?>'; + App::frontend()->template()->addValue('CategoriesURL', function (ArrayObject $attr): string { + return 'template()->getFilters($attr), 'App::blog()->url().App::url()->getBase("categories")') . '; ?>'; }); return true; diff --git a/src/My.php b/src/My.php index b01b31c..e207c06 100644 --- a/src/My.php +++ b/src/My.php @@ -1,15 +1,5 @@ url->register( + App::url()->register( 'categories', 'categories', '^categories$', - [UrlHandler::class, 'categories'] + UrlHandler::categories(...) ); return true; diff --git a/src/UrlHandler.php b/src/UrlHandler.php index 8d94ae3..4136cf8 100644 --- a/src/UrlHandler.php +++ b/src/UrlHandler.php @@ -1,22 +1,20 @@ create( My::id(), My::name(), - [self::class, 'parseWidget'], + self::parseWidget(...), null, __('Link to categories') ) @@ -40,12 +38,10 @@ class Widgets public static function parseWidget(WidgetsElement $w): string { - if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) { - return ''; - } - - // nullsafe PHP < 8.0 - if (is_null(dcCore::app()->blog)) { + if ($w->offline + || !$w->checkHomeOnly(App::url()->type) + || !App::blog()->isDefined() + ) { return ''; } @@ -54,7 +50,7 @@ class Widgets My::id() . ' ' . $w->class, '', ($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') . - '

' . + '

' . ($w->link_title ? Html::escapeHTML($w->link_title) : __('All categories')) . '

' );