Compare commits
No commits in common. "master" and "v1.2" have entirely different histories.
12 changed files with 162 additions and 307 deletions
142
.github/workflows/release.yml
vendored
142
.github/workflows/release.yml
vendored
|
@ -1,142 +0,0 @@
|
||||||
name: Release package
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
DC_TYPE: plugin
|
|
||||||
DC_MIN: 2.32
|
|
||||||
|
|
||||||
# required to set secrets in
|
|
||||||
# https://github.com/xxx/xxx/settings/secrets/actions
|
|
||||||
# TELEGRAM_ID, TELEGRAM_TOKEN
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check_release:
|
|
||||||
if: (contains(github.event.head_commit.message, 'release') || (github.event_name != 'push'))
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
version: ${{ steps.dotclear.outputs.version }}
|
|
||||||
dcmin: ${{ steps.dotclear.outputs.dcmin }}
|
|
||||||
exists: ${{ steps.repository.outputs.release-exists }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository master branch
|
|
||||||
uses: actions/checkout@master
|
|
||||||
|
|
||||||
# Parser from https://github.com/franck-paul
|
|
||||||
- name: Run PHP code
|
|
||||||
id: dotclear
|
|
||||||
shell: php {0}
|
|
||||||
run: |
|
|
||||||
<?php
|
|
||||||
$version = '';
|
|
||||||
$dcmin = '${{ env.DC_MIN }}';
|
|
||||||
$df = file_get_contents('./_define.php');
|
|
||||||
if (preg_match('/registerModule\((.*?),(.*?)[\'\"],(.*?)[\'\"],(.*?)[\'\"](.*?)[\'\"](.*?)(,.*)\)/s',$df,$matches)) {
|
|
||||||
if (isset($matches[5])) {
|
|
||||||
$version = $matches[5];
|
|
||||||
if (isset($matches[7])) {
|
|
||||||
$str = $matches[7];
|
|
||||||
if (preg_match('/\[(.*?)[\'\"]core[\'\"](.*?),(.*?)[\'\"](.*?)[\'\"](.*?)\]/s',$str,$submatches)) {
|
|
||||||
$dcmin = $submatches[4];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_put_contents(getenv('GITHUB_OUTPUT'), "version=$version\n", FILE_APPEND);
|
|
||||||
file_put_contents(getenv('GITHUB_OUTPUT'), "dcmin=$dcmin\n", FILE_APPEND);
|
|
||||||
|
|
||||||
- name: Check repository releases
|
|
||||||
id: repository
|
|
||||||
uses: insightsengineering/release-existence-action@v1.0.0
|
|
||||||
with:
|
|
||||||
release-tag: 'v${{ steps.dotclear.outputs.version }}'
|
|
||||||
|
|
||||||
do_release:
|
|
||||||
needs: check_release
|
|
||||||
if: needs.check_release.outputs.exists == 'false'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository master branch
|
|
||||||
uses: actions/checkout@master
|
|
||||||
|
|
||||||
- name: Get repository name
|
|
||||||
id: repository
|
|
||||||
uses: MariachiBear/get-repo-name-action@v1.1.0
|
|
||||||
with:
|
|
||||||
with-owner: 'false'
|
|
||||||
|
|
||||||
- name: Get download URL
|
|
||||||
id: download
|
|
||||||
run: |
|
|
||||||
fulltag=${{ github.ref_name }}
|
|
||||||
echo download-url="https://github.com/${{ github.repository }}/releases/download/v${{ needs.check_release.outputs.version }}/${{ env.DC_TYPE }}-${{ steps.repository.outputs.repository-name }}.zip" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
# Parser from https://github.com/franck-paul
|
|
||||||
- name: Read dcstore
|
|
||||||
id: readstore
|
|
||||||
shell: php {0}
|
|
||||||
run: |
|
|
||||||
<?php
|
|
||||||
if (file_exists('dcstore.xml')) {
|
|
||||||
$ds = file_get_contents('dcstore.xml');
|
|
||||||
if ($ds) {
|
|
||||||
$ds = preg_replace('/<version>(.*?)<\/version>/s',"<version>${{ needs.check_release.outputs.version }}</version>",$ds);
|
|
||||||
$ds = preg_replace('/<file>(.*?)<\/file>/s',"<file>${{ steps.download.outputs.download-url }}</file>",$ds);
|
|
||||||
$ds = preg_replace('/<da:dcmin>(.*?)<\/da:dcmin>/s',"<da:dcmin>${{ needs.check_release.outputs.dcmin }}</da:dcmin>",$ds);
|
|
||||||
if ($ds) {
|
|
||||||
file_put_contents('dcstore.xml',$ds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Write dcstore
|
|
||||||
id: writestore
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
test=$(git diff --name-only -- dcstore.xml)
|
|
||||||
if [[ "$test" != "" ]]; then
|
|
||||||
echo "dcstore.xml modified, need to be commit"
|
|
||||||
git config user.name "${{ github.actor }}"
|
|
||||||
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
|
|
||||||
git add dcstore.xml
|
|
||||||
git commit -m "Update dcstore.xml"
|
|
||||||
git push
|
|
||||||
else
|
|
||||||
echo "dcstore.xml not modified"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Create archive
|
|
||||||
id: writearchive
|
|
||||||
uses: thedoctor0/zip-release@0.7.6
|
|
||||||
with:
|
|
||||||
type: 'zip'
|
|
||||||
directory: ..
|
|
||||||
path: '${{ steps.repository.outputs.repository-name }}'
|
|
||||||
filename: '${{ env.DC_TYPE }}-${{ steps.repository.outputs.repository-name }}.zip'
|
|
||||||
exclusions: '*.git* /*node_modules/* .editorconfig'
|
|
||||||
|
|
||||||
- name: Create release with archive
|
|
||||||
id: writerelease
|
|
||||||
uses: ncipollo/release-action@v1.14.0
|
|
||||||
with:
|
|
||||||
artifacts: '../${{ env.DC_TYPE }}-${{ steps.repository.outputs.repository-name }}.zip'
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
commit: master
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
generateReleaseNotes: true
|
|
||||||
name: ${{ steps.repository.outputs.repository-name }} ${{ needs.check_release.outputs.version }}
|
|
||||||
tag: 'v${{ needs.check_release.outputs.version }}'
|
|
||||||
|
|
||||||
- name: Send Telegram Message Ok
|
|
||||||
uses: appleboy/telegram-action@v1.0.0
|
|
||||||
with:
|
|
||||||
to: ${{ secrets.TELEGRAM_ID }}
|
|
||||||
token: ${{ secrets.TELEGRAM_TOKEN }}
|
|
||||||
format: markdown
|
|
||||||
message: |
|
|
||||||
__Github workflow run__
|
|
||||||
- Trigger: ${{ github.event_name }}
|
|
||||||
- Release: ${{ steps.repository.outputs.repository-name }} ${{ needs.check_release.outputs.version }}
|
|
||||||
- Download URL: ${{ steps.download.outputs.download-url }}
|
|
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -1,22 +1,3 @@
|
||||||
CategoriesPage 1.3.2 - 2023.11.04
|
|
||||||
===========================================================
|
|
||||||
* Require Dotclear 2.28
|
|
||||||
* Require PHP 8.1
|
|
||||||
* Fix host
|
|
||||||
|
|
||||||
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
|
|
||||||
* Require PHP 8.1
|
|
||||||
* Upgrade to Dotclear 2.28
|
|
||||||
|
|
||||||
CategoriesPage 1.2 - 2023.08.06
|
CategoriesPage 1.2 - 2023.08.06
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.27
|
* Require Dotclear 2.27
|
||||||
|
|
38
README.md
38
README.md
|
@ -1,22 +1,26 @@
|
||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-1.3.2-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/CategoriesPage/releases)
|
[![Release](https://img.shields.io/github/v/release/JcDenis/CategoriesPage)](https://github.com/JcDenis/CategoriesPage/releases)
|
||||||
![Date](https://img.shields.io/badge/date-2023.11.04-c44d58.svg)
|
[![Date](https://img.shields.io/github/release-date/JcDenis/CategoriesPage)](https://github.com/JcDenis/CategoriesPage/releases)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
[![Issues](https://img.shields.io/github/issues/JcDenis/CategoriesPage)](https://github.com/JcDenis/CategoriesPage/issues)
|
||||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/CategoriesPage)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download)
|
||||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/CategoriesPage/src/branch/master/LICENSE)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/CategoriesPage)
|
||||||
|
[![License](https://img.shields.io/github/license/JcDenis/CategoriesPage)](https://github.com/JcDenis/CategoriesPage/blob/master/LICENSE)
|
||||||
|
|
||||||
## ABOUT
|
## WHAT IS CATEGORIESPAGE ?
|
||||||
|
|
||||||
_CategoriesPage_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
_CategoriesPage_ is a plugin for the open-source
|
||||||
|
web publishing software called Dotclear.
|
||||||
|
|
||||||
> 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
|
## REQUIREMENTS
|
||||||
|
|
||||||
* Dotclear 2.28
|
_CategoriesPage_ requires:
|
||||||
* PHP 8.1
|
|
||||||
* Dotclear admin permissions
|
* admin permissions
|
||||||
|
* Dotclear 2.27
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
@ -28,16 +32,14 @@ default templates are on plugin directory CategoriesPage/default-templates/
|
||||||
|
|
||||||
## LINKS
|
## LINKS
|
||||||
|
|
||||||
* [License](https://git.dotclear.watch/JcDenis/CategoriesPage/src/branch/master/LICENSE)
|
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||||
* [Packages & details](https://git.dotclear.watch/JcDenis/CategoriesPage/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/CategoriesPage))
|
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/CategoriesPage) or [GitHub Page](https://github.com/JcDenis/CategoriesPage)
|
||||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/CategoriesPage) (or on [GitHub](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)
|
||||||
* [Issues & security](https://git.dotclear.watch/JcDenis/CategoriesPage/issues) (or on [GitHub](https://github.com/JcDenis/CategoriesPage/issues))
|
|
||||||
* [Discuss & help](https://forum.dotclear.org/viewtopic.php?id=43627)
|
|
||||||
|
|
||||||
## CONTRIBUTORS
|
## CONTRIBUTORS
|
||||||
|
|
||||||
* Pierre Van Glabeke (author)
|
* Pierre Van Glabeke
|
||||||
* Bernard Le Roux
|
* Bernard Le Roux
|
||||||
* Jean-Christian Denis (latest)
|
* Jean-Christian Denis
|
||||||
|
|
||||||
You are welcome to contribute to this code.
|
You are welcome to contribute to this code.
|
24
_define.php
24
_define.php
|
@ -1,27 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file
|
* @brief CategoriesPage, a plugin for Dotclear 2
|
||||||
* @brief The plugin CategoriesPage definition
|
|
||||||
* @ingroup CategoriesPage
|
|
||||||
*
|
*
|
||||||
* @defgroup CategoriesPage Plugin CategoriesPage.
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* Add a public page for categories list.
|
* @author Pierre Van Glabeke, Bernard Le Roux and Contributors
|
||||||
*
|
*
|
||||||
* @author Pierre Van Glabeke (author)
|
* @copyright Jean-Christian Denis
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$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.2',
|
'1.2',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.28']],
|
'requires' => [['core', '2.27']],
|
||||||
'permissions' => 'My',
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
|
dcAuth::PERMISSION_ADMIN,
|
||||||
|
]),
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<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.2</version>
|
<version>1.2</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://github.com/JcDenis/CategoriesPage/releases/download/v1.3.2/plugin-CategoriesPage.zip</file>
|
<file>https://gitea.dotclear.watch/JcDenis/CategoriesPage/releases/download/v1.2/plugin-CategoriesPage.zip</file>
|
||||||
<da:dcmin>2.28</da:dcmin>
|
<da:dcmin>2.27</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>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\CategoriesPage;
|
namespace Dotclear\Plugin\CategoriesPage;
|
||||||
|
|
||||||
use ArrayObject;
|
use dcCore;
|
||||||
use Dotclear\App;
|
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Helper\Html\Html;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
class Backend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -30,18 +30,8 @@ class Backend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
App::behavior()->addBehaviors([
|
dcCore::app()->addBehaviors([
|
||||||
'adminSimpleMenuAddType' => function (ArrayObject $items): void {
|
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||||
$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] = Html::stripHostURL(App::blog()->url()) . App::url()->getURLFor(My::id());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'initWidgets' => Widgets::initWidgets(...),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,21 +1,23 @@
|
||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\CategoriesPage;
|
namespace Dotclear\Plugin\CategoriesPage;
|
||||||
|
|
||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use Dotclear\App;
|
use dcCore;
|
||||||
use Dotclear\Core\Process;
|
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
|
class Frontend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -29,27 +31,35 @@ class Frontend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
App::behavior()->addBehaviors([
|
dcCore::app()->addBehaviors([
|
||||||
// template path
|
// template path
|
||||||
'publicBeforeDocumentV2' => function (): void {
|
'publicBeforeDocumentV2' => function (): void {
|
||||||
$tplset = App::themes()->getDefine(App::blog()->settings()->get('system')->get('theme'))->get('tplset');
|
// nullsafe PHP < 8.0
|
||||||
if (empty($tplset) || !is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) {
|
if (is_null(dcCore::app()->blog)) {
|
||||||
$tplset = App::config()->defaultTplset();
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tplset = dcCore::app()->themes->moduleInfo(dcCore::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]));
|
||||||
|
} else {
|
||||||
|
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', DC_DEFAULT_TPLSET]));
|
||||||
}
|
}
|
||||||
App::frontend()->template()->appendPath(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]));
|
|
||||||
},
|
},
|
||||||
// breacrumb addon
|
// breacrumb addon
|
||||||
'publicBreadcrumb' => fn (string $context, string $separator) => $context == 'categories' ? My::name() : '',
|
'publicBreadcrumb' => function (string $context, string $separator): string {
|
||||||
|
return $context == 'categories' ? My::name() : '';
|
||||||
|
},
|
||||||
// widget
|
// widget
|
||||||
'initWidgets' => Widgets::initWidgets(...),
|
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// tpl values
|
// tpl values
|
||||||
App::frontend()->template()->addValue('CategoryCount', function (ArrayObject $attr): string {
|
dcCore::app()->tpl->addValue('CategoryCount', function (ArrayObject $attr): string {
|
||||||
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($attr), 'App::frontend()->context()->categories->nb_post') . '; ?>';
|
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->ctx->categories->nb_post') . '; ?>';
|
||||||
});
|
});
|
||||||
App::frontend()->template()->addValue('CategoriesURL', function (ArrayObject $attr): string {
|
dcCore::app()->tpl->addValue('CategoriesURL', function (ArrayObject $attr): string {
|
||||||
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($attr), 'App::blog()->url().App::url()->getBase("categories")') . '; ?>';
|
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("categories")') . '; ?>';
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Dotclear\Plugin\CategoriesPage;
|
|
||||||
|
|
||||||
use Dotclear\Core\Frontend\Url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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 FrontendUrl extends Url
|
|
||||||
{
|
|
||||||
public static function categories(?string $args): void
|
|
||||||
{
|
|
||||||
self::serveDocument('categories.html');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
20
src/My.php
20
src/My.php
|
@ -1,5 +1,15 @@
|
||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\CategoriesPage;
|
namespace Dotclear\Plugin\CategoriesPage;
|
||||||
|
@ -7,14 +17,8 @@ namespace Dotclear\Plugin\CategoriesPage;
|
||||||
use Dotclear\Module\MyPlugin;
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CategoriesPage My helper.
|
* This module definitions.
|
||||||
* @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
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
// Use default permissions
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\CategoriesPage;
|
namespace Dotclear\Plugin\CategoriesPage;
|
||||||
|
|
||||||
use Dotclear\App;
|
use dcCore;
|
||||||
use Dotclear\Core\Process;
|
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
|
class Prepend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -28,11 +30,11 @@ class Prepend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
App::url()->register(
|
dcCore::app()->url->register(
|
||||||
My::id(),
|
'categories',
|
||||||
'categories',
|
'categories',
|
||||||
'^categories$',
|
'^categories$',
|
||||||
FrontendUrl::categories(...)
|
[UrlHandler::class, 'categories']
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
26
src/UrlHandler.php
Normal file
26
src/UrlHandler.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?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;
|
||||||
|
|
||||||
|
class UrlHandler extends dcUrlHandlers
|
||||||
|
{
|
||||||
|
public static function categories(?string $args): void
|
||||||
|
{
|
||||||
|
self::serveDocument('categories.html');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,22 +1,24 @@
|
||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\CategoriesPage;
|
namespace Dotclear\Plugin\CategoriesPage;
|
||||||
|
|
||||||
use Dotclear\App;
|
use dcCore;
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Dotclear\Plugin\widgets\WidgetsStack;
|
use Dotclear\Plugin\widgets\WidgetsStack;
|
||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
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
|
class Widgets
|
||||||
{
|
{
|
||||||
public static function initWidgets(WidgetsStack $w): void
|
public static function initWidgets(WidgetsStack $w): void
|
||||||
|
@ -25,7 +27,7 @@ class Widgets
|
||||||
->create(
|
->create(
|
||||||
My::id(),
|
My::id(),
|
||||||
My::name(),
|
My::name(),
|
||||||
self::parseWidget(...),
|
[self::class, 'parseWidget'],
|
||||||
null,
|
null,
|
||||||
__('Link to categories')
|
__('Link to categories')
|
||||||
)
|
)
|
||||||
|
@ -38,10 +40,12 @@ class Widgets
|
||||||
|
|
||||||
public static function parseWidget(WidgetsElement $w): string
|
public static function parseWidget(WidgetsElement $w): string
|
||||||
{
|
{
|
||||||
if ($w->offline
|
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
||||||
|| !$w->checkHomeOnly(App::url()->type)
|
return '';
|
||||||
|| !App::blog()->isDefined()
|
}
|
||||||
) {
|
|
||||||
|
// nullsafe PHP < 8.0
|
||||||
|
if (is_null(dcCore::app()->blog)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +54,8 @@ class Widgets
|
||||||
My::id() . ' ' . $w->class,
|
My::id() . ' ' . $w->class,
|
||||||
'',
|
'',
|
||||||
($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="' . dcCore::app()->blog->url . dcCore::app()->url->getBase('categories') . '">' .
|
||||||
($w->get('link_title') ? Html::escapeHTML($w->get('link_title')) : __('All categories')) .
|
($w->link_title ? Html::escapeHTML($w->link_title) : __('All categories')) .
|
||||||
'</a></p>'
|
'</a></p>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue