upgrade to Dotclear 2.28
This commit is contained in:
parent
b9c1e55c45
commit
619414e325
10 changed files with 121 additions and 138 deletions
|
@ -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
|
||||
|
|
38
README.md
38
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.
|
||||
You are welcome to contribute to this code.
|
||||
|
|
34
_define.php
34
_define.php
|
@ -1,33 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief CategoriesPage, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin CategoriesPage definition
|
||||
* @ingroup CategoriesPage
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
* @defgroup CategoriesPage Plugin CategoriesPage.
|
||||
*
|
||||
* @author Pierre Van Glabeke, Bernard Le Roux and Contributors
|
||||
* Add a public page for categories list.
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Pierre Van Glabeke (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
declare(strict_types=1);
|
||||
|
||||
$this->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',
|
||||
|
||||
]
|
||||
);
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="CategoriesPage">
|
||||
<name>Categories Page</name>
|
||||
<version>1.2</version>
|
||||
<version>1.3</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.2/plugin-CategoriesPage.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/CategoriesPage/releases/download/v1.3/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>
|
||||
</module>
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief CategoriesPage, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Pierre Van Glabeke, Bernard Le Roux and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\CategoriesPage;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief CategoriesPage backend class.
|
||||
* @ingroup CategoriesPage
|
||||
*
|
||||
* @author Pierre Van Glabeke (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -30,9 +28,7 @@ class Backend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief CategoriesPage, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Pierre Van Glabeke, Bernard Le Roux and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\CategoriesPage;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief CategoriesPage frontend class.
|
||||
* @ingroup CategoriesPage
|
||||
*
|
||||
* @author Pierre Van Glabeke (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -31,19 +29,18 @@ class Frontend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->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 '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->ctx->categories->nb_post') . '; ?>';
|
||||
App::frontend()->template()->addValue('CategoryCount', function (ArrayObject $attr): string {
|
||||
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($attr), 'App::frontend()->context()->categories->nb_post') . '; ?>';
|
||||
});
|
||||
dcCore::app()->tpl->addValue('CategoriesURL', function (ArrayObject $attr): string {
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("categories")') . '; ?>';
|
||||
App::frontend()->template()->addValue('CategoriesURL', function (ArrayObject $attr): string {
|
||||
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($attr), 'App::blog()->url().App::url()->getBase("categories")') . '; ?>';
|
||||
});
|
||||
|
||||
return true;
|
||||
|
|
20
src/My.php
20
src/My.php
|
@ -1,15 +1,5 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief CategoriesPage, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Pierre Van Glabeke, Bernard Le Roux and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\CategoriesPage;
|
||||
|
@ -17,8 +7,14 @@ namespace Dotclear\Plugin\CategoriesPage;
|
|||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
* @brief CategoriesPage My helper.
|
||||
* @ingroup CategoriesPage
|
||||
*
|
||||
* @author Pierre Van Glabeke (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
// Use default permissions
|
||||
}
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief CategoriesPage, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Pierre Van Glabeke, Bernard Le Roux and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\CategoriesPage;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief CategoriesPage prepend class.
|
||||
* @ingroup CategoriesPage
|
||||
*
|
||||
* @author Pierre Van Glabeke (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Prepend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -30,11 +28,11 @@ class Prepend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->url->register(
|
||||
App::url()->register(
|
||||
'categories',
|
||||
'categories',
|
||||
'^categories$',
|
||||
[UrlHandler::class, 'categories']
|
||||
UrlHandler::categories(...)
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief CategoriesPage, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Pierre Van Glabeke, Bernard Le Roux and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\CategoriesPage;
|
||||
|
||||
use dcUrlHandlers;
|
||||
use Dotclear\Core\Frontend\Url;
|
||||
|
||||
class UrlHandler extends dcUrlHandlers
|
||||
/**
|
||||
* @brief CategoriesPage frontend URL handler class.
|
||||
* @ingroup CategoriesPage
|
||||
*
|
||||
* @author Pierre Van Glabeke (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class UrlHandler extends Url
|
||||
{
|
||||
public static function categories(?string $args): void
|
||||
{
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief CategoriesPage, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Pierre Van Glabeke, Bernard Le Roux and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\CategoriesPage;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Plugin\widgets\WidgetsStack;
|
||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||
|
||||
/**
|
||||
* @brief CategoriesPage widgets class.
|
||||
* @ingroup CategoriesPage
|
||||
*
|
||||
* @author Pierre Van Glabeke (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Widgets
|
||||
{
|
||||
public static function initWidgets(WidgetsStack $w): void
|
||||
|
@ -27,7 +25,7 @@ class Widgets
|
|||
->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)) : '') .
|
||||
'<p><a href="' . dcCore::app()->blog->url . dcCore::app()->url->getBase('categories') . '">' .
|
||||
'<p><a href="' . App::blog()->url() . App::url()->getBase('categories') . '">' .
|
||||
($w->link_title ? Html::escapeHTML($w->link_title) : __('All categories')) .
|
||||
'</a></p>'
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue