Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
|
e82818d9ec | ||
|
8cc87c63b0 | ||
96c7e87cba | |||
1cf66e57e7 | |||
619414e325 | |||
b9c1e55c45 | |||
8011807f07 |
12 changed files with 307 additions and 162 deletions
142
.github/workflows/release.yml
vendored
Normal file
142
.github/workflows/release.yml
vendored
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
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,3 +1,22 @@
|
||||||
|
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
|
||||||
|
|
42
README.md
42
README.md
|
@ -1,26 +1,22 @@
|
||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/github/v/release/JcDenis/CategoriesPage)](https://github.com/JcDenis/CategoriesPage/releases)
|
[![Release](https://img.shields.io/badge/release-1.3.2-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/CategoriesPage/releases)
|
||||||
[![Date](https://img.shields.io/github/release-date/JcDenis/CategoriesPage)](https://github.com/JcDenis/CategoriesPage/releases)
|
![Date](https://img.shields.io/badge/date-2023.11.04-c44d58.svg)
|
||||||
[![Issues](https://img.shields.io/github/issues/JcDenis/CategoriesPage)](https://github.com/JcDenis/CategoriesPage/issues)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.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-green.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/github/license/JcDenis/CategoriesPage)](https://github.com/JcDenis/CategoriesPage/blob/master/LICENSE)
|
|
||||||
|
|
||||||
## WHAT IS CATEGORIESPAGE ?
|
## ABOUT
|
||||||
|
|
||||||
_CategoriesPage_ is a plugin for the open-source
|
_CategoriesPage_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||||
web publishing software called Dotclear.
|
|
||||||
|
|
||||||
Add a public page to list blog categories.
|
> Add a public page to list blog categories. A widget is also available.
|
||||||
A widget is also available.
|
|
||||||
|
|
||||||
## REQUIREMENTS
|
## REQUIREMENTS
|
||||||
|
|
||||||
_CategoriesPage_ requires:
|
* Dotclear 2.28
|
||||||
|
* PHP 8.1
|
||||||
* admin permissions
|
* Dotclear admin permissions
|
||||||
* Dotclear 2.27
|
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
@ -32,14 +28,16 @@ default templates are on plugin directory CategoriesPage/default-templates/
|
||||||
|
|
||||||
## LINKS
|
## LINKS
|
||||||
|
|
||||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
* [License](https://git.dotclear.watch/JcDenis/CategoriesPage/src/branch/master/LICENSE)
|
||||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/CategoriesPage) or [GitHub Page](https://github.com/JcDenis/CategoriesPage)
|
* [Packages & details](https://git.dotclear.watch/JcDenis/CategoriesPage/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/CategoriesPage))
|
||||||
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/CategoriesPage/releases) or [Dotaddict Page](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))
|
||||||
|
* [Discuss & help](https://forum.dotclear.org/viewtopic.php?id=43627)
|
||||||
|
|
||||||
## CONTRIBUTORS
|
## CONTRIBUTORS
|
||||||
|
|
||||||
* Pierre Van Glabeke
|
* Pierre Van Glabeke (author)
|
||||||
* Bernard Le Roux
|
* Bernard Le Roux
|
||||||
* Jean-Christian Denis
|
* 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
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief CategoriesPage, a plugin for Dotclear 2
|
* @file
|
||||||
|
* @brief The plugin CategoriesPage definition
|
||||||
|
* @ingroup CategoriesPage
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @defgroup CategoriesPage Plugin CategoriesPage.
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
*
|
||||||
* @author Pierre Van Glabeke, Bernard Le Roux and Contributors
|
* Add a public page for categories list.
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @author Pierre Van Glabeke (author)
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @author Jean-Christian Denis (latest)
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
declare(strict_types=1);
|
||||||
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.2',
|
'1.3.2',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.27']],
|
'requires' => [['core', '2.28']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => 'My',
|
||||||
dcAuth::PERMISSION_ADMIN,
|
'type' => 'plugin',
|
||||||
]),
|
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||||
'type' => 'plugin',
|
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||||
'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/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="CategoriesPage">
|
<module id="CategoriesPage">
|
||||||
<name>Categories Page</name>
|
<name>Categories Page</name>
|
||||||
<version>1.2</version>
|
<version>1.3.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://gitea.dotclear.watch/JcDenis/CategoriesPage/releases/download/v1.2/plugin-CategoriesPage.zip</file>
|
<file>https://github.com/JcDenis/CategoriesPage/releases/download/v1.3.2/plugin-CategoriesPage.zip</file>
|
||||||
<da:dcmin>2.27</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>
|
||||||
</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 dcCore;
|
use ArrayObject;
|
||||||
|
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,8 +30,18 @@ class Backend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
App::behavior()->addBehaviors([
|
||||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
'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] = Html::stripHostURL(App::blog()->url()) . App::url()->getURLFor(My::id());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'initWidgets' => Widgets::initWidgets(...),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,23 +1,21 @@
|
||||||
<?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 dcCore;
|
use Dotclear\App;
|
||||||
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
|
||||||
|
@ -31,35 +29,27 @@ class Frontend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
App::behavior()->addBehaviors([
|
||||||
// template path
|
// template path
|
||||||
'publicBeforeDocumentV2' => function (): void {
|
'publicBeforeDocumentV2' => function (): void {
|
||||||
// nullsafe PHP < 8.0
|
$tplset = App::themes()->getDefine(App::blog()->settings()->get('system')->get('theme'))->get('tplset');
|
||||||
if (is_null(dcCore::app()->blog)) {
|
if (empty($tplset) || !is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) {
|
||||||
return ;
|
$tplset = App::config()->defaultTplset();
|
||||||
}
|
|
||||||
|
|
||||||
$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' => 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::class, 'initWidgets'],
|
'initWidgets' => Widgets::initWidgets(...),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// tpl values
|
// tpl values
|
||||||
dcCore::app()->tpl->addValue('CategoryCount', function (ArrayObject $attr): string {
|
App::frontend()->template()->addValue('CategoryCount', function (ArrayObject $attr): string {
|
||||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->ctx->categories->nb_post') . '; ?>';
|
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($attr), 'App::frontend()->context()->categories->nb_post') . '; ?>';
|
||||||
});
|
});
|
||||||
dcCore::app()->tpl->addValue('CategoriesURL', function (ArrayObject $attr): string {
|
App::frontend()->template()->addValue('CategoriesURL', function (ArrayObject $attr): string {
|
||||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($attr), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("categories")') . '; ?>';
|
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($attr), 'App::blog()->url().App::url()->getBase("categories")') . '; ?>';
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
24
src/FrontendUrl.php
Normal file
24
src/FrontendUrl.php
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?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,15 +1,5 @@
|
||||||
<?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;
|
||||||
|
@ -17,8 +7,14 @@ namespace Dotclear\Plugin\CategoriesPage;
|
||||||
use Dotclear\Module\MyPlugin;
|
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
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
|
// Use default permissions
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
<?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 dcCore;
|
use Dotclear\App;
|
||||||
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
|
||||||
|
@ -30,11 +28,11 @@ class Prepend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->url->register(
|
App::url()->register(
|
||||||
'categories',
|
My::id(),
|
||||||
'categories',
|
'categories',
|
||||||
'^categories$',
|
'^categories$',
|
||||||
[UrlHandler::class, 'categories']
|
FrontendUrl::categories(...)
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?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,24 +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 dcCore;
|
use Dotclear\App;
|
||||||
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
|
||||||
|
@ -27,7 +25,7 @@ class Widgets
|
||||||
->create(
|
->create(
|
||||||
My::id(),
|
My::id(),
|
||||||
My::name(),
|
My::name(),
|
||||||
[self::class, 'parseWidget'],
|
self::parseWidget(...),
|
||||||
null,
|
null,
|
||||||
__('Link to categories')
|
__('Link to categories')
|
||||||
)
|
)
|
||||||
|
@ -40,12 +38,10 @@ class Widgets
|
||||||
|
|
||||||
public static function parseWidget(WidgetsElement $w): string
|
public static function parseWidget(WidgetsElement $w): string
|
||||||
{
|
{
|
||||||
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
if ($w->offline
|
||||||
return '';
|
|| !$w->checkHomeOnly(App::url()->type)
|
||||||
}
|
|| !App::blog()->isDefined()
|
||||||
|
) {
|
||||||
// nullsafe PHP < 8.0
|
|
||||||
if (is_null(dcCore::app()->blog)) {
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +50,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="' . 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')) .
|
($w->get('link_title') ? Html::escapeHTML($w->get('link_title')) : __('All categories')) .
|
||||||
'</a></p>'
|
'</a></p>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue