diff --git a/CHANGELOG.md b/CHANGELOG.md index 35fbbf8..aba2af0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +CategoriesPage 1.3.1 - 2023.10.24 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Add plugin simpleMenu helper +* Code review + CategoriesPage 1.3 - 2023.10.15 =========================================================== * Require Dotclear 2.28 diff --git a/README.md b/README.md index c3dc324..089a37d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # README -[![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) +[![Release](https://img.shields.io/badge/release-1.3.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/CategoriesPage/releases) +![Date](https://img.shields.io/badge/date-2023.10.24-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/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/CategoriesPage/src/branch/master/LICENSE) @@ -16,7 +16,7 @@ _CategoriesPage_ is a plugin for the open-source web publishing software called * Dotclear 2.28 * PHP 8.1 -* admin permissions +* Dotclear admin permissions ## USAGE diff --git a/_define.php b/_define.php index d152338..4e863c9 100644 --- a/_define.php +++ b/_define.php @@ -18,7 +18,7 @@ $this->registerModule( 'Categories Page', 'Add a public page for categories list', 'Pierre Van Glabeke, Bernard Le Roux and Contributors', - '1.3', + '1.3.1', [ 'requires' => [['core', '2.28']], 'permissions' => 'My', diff --git a/dcstore.xml b/dcstore.xml index e26a740..560a024 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,10 +2,10 @@ Categories Page - 1.3 + 1.3.1 Pierre Van Glabeke, Bernard Le Roux and Contributors Add a public page for categories list - https://git.dotclear.watch/JcDenis/CategoriesPage/releases/download/v1.3/plugin-CategoriesPage.zip + https://git.dotclear.watch/JcDenis/CategoriesPage/releases/download/v1.3.1/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 1bc6475..72c3210 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Dotclear\Plugin\CategoriesPage; +use ArrayObject; use Dotclear\App; use Dotclear\Core\Process; @@ -28,7 +29,19 @@ class Backend extends Process return false; } - App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); + App::behavior()->addBehaviors([ + 'adminSimpleMenuAddType' => function (ArrayObject $items): void { + $items[My::id()] = new ArrayObject([My::name(), false]); + }, + 'adminSimpleMenuBeforeEdit' => function (string $type, string $select, array &$item): void { + if (My::id() == $type) { + $item[0] = My::name(); + $item[1] = My::name(); + $item[2] = App::url()->getURLFor(My::id()); + } + }, + 'initWidgets' => Widgets::initWidgets(...), + ]); return true; } diff --git a/src/Frontend.php b/src/Frontend.php index dd32f5b..1757cd5 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -32,21 +32,14 @@ class Frontend extends Process App::behavior()->addBehaviors([ // template path 'publicBeforeDocumentV2' => function (): void { - if (!App::blog()->isDefined()) { - return ; - } - - $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]))) { - App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset])); - } else { - App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', App::config()->defaultTplset()])); + $tplset = App::themes()->getDefine(App::blog()->settings()->get('system')->get('theme'))->get('tplset'); + if (empty($tplset) || !is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) { + $tplset = App::config()->defaultTplset(); } + App::frontend()->template()->appendPath(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset])); }, // breacrumb addon - 'publicBreadcrumb' => function (string $context, string $separator): string { - return $context == 'categories' ? My::name() : ''; - }, + 'publicBreadcrumb' => fn (string $context, string $separator) => $context == 'categories' ? My::name() : '', // widget 'initWidgets' => Widgets::initWidgets(...), ]); diff --git a/src/UrlHandler.php b/src/FrontendUrl.php similarity index 94% rename from src/UrlHandler.php rename to src/FrontendUrl.php index 4136cf8..b05fcf2 100644 --- a/src/UrlHandler.php +++ b/src/FrontendUrl.php @@ -14,7 +14,7 @@ use Dotclear\Core\Frontend\Url; * @author Jean-Christian Denis (latest) * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html */ -class UrlHandler extends Url +class FrontendUrl extends Url { public static function categories(?string $args): void { diff --git a/src/Prepend.php b/src/Prepend.php index 0ab530a..4c569ea 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -29,10 +29,10 @@ class Prepend extends Process } App::url()->register( - 'categories', + My::id(), 'categories', '^categories$', - UrlHandler::categories(...) + FrontendUrl::categories(...) ); return true; diff --git a/src/Widgets.php b/src/Widgets.php index d8a9675..a3843ca 100644 --- a/src/Widgets.php +++ b/src/Widgets.php @@ -51,7 +51,7 @@ class Widgets '', ($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') . '

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

' ); }