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
|
CategoriesPage 1.3 - 2023.10.15
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.28
|
* Require Dotclear 2.28
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-1.3-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/CategoriesPage/releases)
|
[![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.15-c44d58.svg)
|
![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)
|
[![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)
|
[![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)
|
[![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
|
* Dotclear 2.28
|
||||||
* PHP 8.1
|
* PHP 8.1
|
||||||
* admin permissions
|
* Dotclear admin permissions
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ $this->registerModule(
|
||||||
'Categories Page',
|
'Categories Page',
|
||||||
'Add a public page for categories list',
|
'Add a public page for categories list',
|
||||||
'Pierre Van Glabeke, Bernard Le Roux and Contributors',
|
'Pierre Van Glabeke, Bernard Le Roux and Contributors',
|
||||||
'1.3',
|
'1.3.1',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.28']],
|
'requires' => [['core', '2.28']],
|
||||||
'permissions' => 'My',
|
'permissions' => 'My',
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="CategoriesPage">
|
<module id="CategoriesPage">
|
||||||
<name>Categories Page</name>
|
<name>Categories Page</name>
|
||||||
<version>1.3</version>
|
<version>1.3.1</version>
|
||||||
<author>Pierre Van Glabeke, Bernard Le Roux and Contributors</author>
|
<author>Pierre Van Glabeke, Bernard Le Roux and Contributors</author>
|
||||||
<desc>Add a public page for categories list</desc>
|
<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:dcmin>2.28</da:dcmin>
|
||||||
<da:details>https://git.dotclear.watch/JcDenis/CategoriesPage/src/branch/master/README.md</da:details>
|
<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>
|
<da:support>https://git.dotclear.watch/JcDenis/CategoriesPage/issues</da:support>
|
||||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\CategoriesPage;
|
namespace Dotclear\Plugin\CategoriesPage;
|
||||||
|
|
||||||
|
use ArrayObject;
|
||||||
use Dotclear\App;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
|
@ -28,7 +29,19 @@ class Backend extends Process
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,21 +32,14 @@ class Frontend extends Process
|
||||||
App::behavior()->addBehaviors([
|
App::behavior()->addBehaviors([
|
||||||
// template path
|
// template path
|
||||||
'publicBeforeDocumentV2' => function (): void {
|
'publicBeforeDocumentV2' => function (): void {
|
||||||
if (!App::blog()->isDefined()) {
|
$tplset = App::themes()->getDefine(App::blog()->settings()->get('system')->get('theme'))->get('tplset');
|
||||||
return ;
|
if (empty($tplset) || !is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) {
|
||||||
}
|
$tplset = App::config()->defaultTplset();
|
||||||
|
|
||||||
$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()]));
|
|
||||||
}
|
}
|
||||||
|
App::frontend()->template()->appendPath(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]));
|
||||||
},
|
},
|
||||||
// breacrumb addon
|
// breacrumb addon
|
||||||
'publicBreadcrumb' => function (string $context, string $separator): string {
|
'publicBreadcrumb' => fn (string $context, string $separator) => $context == 'categories' ? My::name() : '',
|
||||||
return $context == 'categories' ? My::name() : '';
|
|
||||||
},
|
|
||||||
// widget
|
// widget
|
||||||
'initWidgets' => Widgets::initWidgets(...),
|
'initWidgets' => Widgets::initWidgets(...),
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -14,7 +14,7 @@ use Dotclear\Core\Frontend\Url;
|
||||||
* @author Jean-Christian Denis (latest)
|
* @author Jean-Christian Denis (latest)
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @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
|
public static function categories(?string $args): void
|
||||||
{
|
{
|
|
@ -29,10 +29,10 @@ class Prepend extends Process
|
||||||
}
|
}
|
||||||
|
|
||||||
App::url()->register(
|
App::url()->register(
|
||||||
'categories',
|
My::id(),
|
||||||
'categories',
|
'categories',
|
||||||
'^categories$',
|
'^categories$',
|
||||||
UrlHandler::categories(...)
|
FrontendUrl::categories(...)
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Widgets
|
||||||
'',
|
'',
|
||||||
($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
|
($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
|
||||||
'<p><a href="' . App::blog()->url() . App::url()->getBase('categories') . '">' .
|
'<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>'
|
'</a></p>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue