Compare commits

...

7 commits
v1.2 ... master

Author SHA1 Message Date
JcDenis
e82818d9ec Update dcstore.xml
Some checks failed
Release package / check_release (push) Has been cancelled
Release package / do_release (push) Has been cancelled
2024-12-01 10:22:42 +00:00
Jean-Christian Paul Denis
8cc87c63b0
Create release.yml 2024-12-01 11:22:11 +01:00
96c7e87cba
fix host 2023-11-04 10:56:38 +01:00
1cf66e57e7
code review 2023-10-25 00:04:37 +02:00
619414e325
upgrade to Dotclear 2.28 2023-10-15 19:52:58 +02:00
b9c1e55c45
fix ZIP URL 2023-08-07 23:12:59 +02:00
8011807f07
use static badge 2023-08-07 00:55:11 +02:00
12 changed files with 307 additions and 162 deletions

142
.github/workflows/release.yml vendored Normal file
View 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 }}

View file

@ -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

View file

@ -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.

View file

@ -1,29 +1,27 @@
<?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)
* @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
*/ */
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', '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',

View file

@ -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>

View file

@ -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;

View file

@ -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
View 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;
}
}

View file

@ -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
} }

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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>'
); );
} }