code review
This commit is contained in:
parent
619414e325
commit
1cf66e57e7
9 changed files with 36 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="CategoriesPage">
|
||||
<name>Categories Page</name>
|
||||
<version>1.3</version>
|
||||
<version>1.3.1</version>
|
||||
<author>Pierre Van Glabeke, Bernard Le Roux and Contributors</author>
|
||||
<desc>Add a public page for categories list</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/CategoriesPage/releases/download/v1.3/plugin-CategoriesPage.zip</file>
|
||||
<file>https://git.dotclear.watch/JcDenis/CategoriesPage/releases/download/v1.3.1/plugin-CategoriesPage.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/CategoriesPage/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/CategoriesPage/issues</da:support>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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(...),
|
||||
]);
|
||||
|
|
|
@ -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
|
||||
{
|
|
@ -29,10 +29,10 @@ class Prepend extends Process
|
|||
}
|
||||
|
||||
App::url()->register(
|
||||
'categories',
|
||||
My::id(),
|
||||
'categories',
|
||||
'^categories$',
|
||||
UrlHandler::categories(...)
|
||||
FrontendUrl::categories(...)
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -51,7 +51,7 @@ class Widgets
|
|||
'',
|
||||
($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
|
||||
'<p><a href="' . App::blog()->url() . App::url()->getBase('categories') . '">' .
|
||||
($w->link_title ? Html::escapeHTML($w->link_title) : __('All categories')) .
|
||||
($w->get('link_title') ? Html::escapeHTML($w->get('link_title')) : __('All categories')) .
|
||||
'</a></p>'
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue