From f378ba1faaf633a2f8652bdbb68b03a0e749fc69 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 19 Oct 2023 20:55:57 +0200 Subject: [PATCH] upgrade to Dotclear 2.28 --- CHANGELOG.md | 6 ++++ README.md | 33 +++++++++++---------- _define.php | 33 ++++++++++----------- dcstore.xml | 6 ++-- src/Backend.php | 25 +++++++--------- src/Frontend.php | 25 +++++++--------- src/My.php | 20 ++++++------- src/Widgets.php | 75 +++++++++++++++++++++++------------------------- 8 files changed, 105 insertions(+), 118 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c6cde0..80c4f09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +lastpostsExtend 2023.10.19 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + lastpostsExtend 2023.08.13 =========================================================== * Require Dotclear 2.27 diff --git a/README.md b/README.md index 47aceaa..97fba22 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,22 @@ # README -[![Release](https://img.shields.io/badge/release-2023.08.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases) -[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases) -[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) +[![Release](https://img.shields.io/badge/release-2023.10.19-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases) +[![Date](https://img.shields.io/badge/date-2023.10.19-c44d58.svg)](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases) +[![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/lastpostsExtend) -[![License](https://img.shields.io/github/license/JcDenis/lastpostsExtend)](https://git.dotclear.watch/JcDenis/lastpostsExtend/blob/master/LICENSE) +[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/lastpostsExtend/src/branch/master/LICENSE) -## WHAT IS LASTPOSTSEXTEND ? +## ABOUT -_lastpostsExtend_ "Last entries (Extended)" is a plugin for the open-source -web publishing software called Dotclear. +_lastpostsExtend_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -Like widget lastposts but with more options. +> Same as widget lastposts but with more options. ## REQUIREMENTS -_lastpostsExtend_ requires: - -* permissions to manage widgets -* Dotclear 2.27 -* PHP 7.4 +* Dotclear 2.28 +* PHP 8.1 +* Dotclear permissions to manage widgets ## USAGE @@ -30,13 +27,15 @@ Add and configure "Last entries (Extended)" from widgets manager. ## 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/lastpostsExtend) or [GitHub Page](https://github.com/JcDenis/lastpostsExtend) -* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/lastpostsExtend) +* [License](https://git.dotclear.watch/JcDenis/lastpostsExtend/src/branch/master/LICENSE) +* [Packages & details](https://git.dotclear.watch/JcDenis/lastpostsExtend/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/lastpostsExtend)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/lastpostsExtend) (or on [GitHub](https://github.com/JcDenis/lastpostsExtend)) +* [Issues & security](https://git.dotclear.watch/JcDenis/lastpostsExtend/issues) (or on [GitHub](https://github.com/JcDenis/lastpostsExtend/issues)) + ## CONTRIBUTORS -* Jean-Chirstian Denis +* Jean-Chirstian Denis (author) * Pierre Van Glabeke You are welcome to contribute to this code. diff --git a/_define.php b/_define.php index c0cfbd2..a378b0d 100644 --- a/_define.php +++ b/_define.php @@ -1,32 +1,29 @@ registerModule( 'Last entries (Extended)', 'Extended list of entries', 'Jean-Christian Denis and contributors', - '2023.08.13', + '2023.10.19', [ - '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', ] ); diff --git a/dcstore.xml b/dcstore.xml index 8f60064..1c1de41 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Last entries (Extended) - 2023.08.13 + 2023.10.19 Jean-Christian Denis and contributors Extended list of entries - https://git.dotclear.watch/JcDenis/lastpostsExtend/releases/download/v2023.08.13/plugin-lastpostsExtend.zip - 2.27 + https://git.dotclear.watch/JcDenis/lastpostsExtend/releases/download/v2023.10.19/plugin-lastpostsExtend.zip + 2.28 https://git.dotclear.watch/JcDenis/lastpostsExtend/src/branch/master/README.md https://git.dotclear.watch/JcDenis/lastpostsExtend/issues diff --git a/src/Backend.php b/src/Backend.php index c6152ed..28fb2a0 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -1,22 +1,19 @@ addBehaviors([ - 'initWidgets' => [Widgets::class, 'initWidgets'], - ]); + App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); return true; } diff --git a/src/Frontend.php b/src/Frontend.php index 3fdaf77..2dde659 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,22 +1,19 @@ addBehaviors([ - 'initWidgets' => [Widgets::class, 'initWidgets'], - ]); + App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); return true; } diff --git a/src/My.php b/src/My.php index 899d862..113dd60 100644 --- a/src/My.php +++ b/src/My.php @@ -1,21 +1,19 @@ blog)) { + if (!App::blog()->isDefined()) { return; } @@ -37,7 +31,7 @@ class Widgets $w->create( 'lastpostsextend', __('Last entries (Extended)'), - [self::class, 'parseWidget'], + self::parseWidget(...), null, __('Extended list of entries') ); @@ -51,7 +45,7 @@ class Widgets __('Gallery') => 'galitem', ]; // plugin muppet types - if (dcCore::app()->plugins->getDefine('muppet')->isDefined() && class_exists('\muppet')) { + if (App::plugins()->getDefine('muppet')->isDefined() && class_exists('\muppet')) { $muppet_types = \muppet::getPostTypes(); if (is_array($muppet_types) && !empty($muppet_types)) { foreach ($muppet_types as $k => $v) { @@ -68,7 +62,7 @@ class Widgets ); // Category (post and page have same category) - $rs = dcCore::app()->blog->getCategories([ + $rs = App::blog()->getCategories([ 'post_type' => 'post', ]); $categories = [ @@ -135,7 +129,7 @@ class Widgets ); // Tag - if (dcCore::app()->plugins->moduleExists('tags')) { + if (App::plugins()->moduleExists('tags')) { $w->lastpostsextend->setting( 'tag', __('Limit to tags:'), @@ -234,7 +228,10 @@ class Widgets public static function parseWidget(WidgetsElement $w): string { // Widget is offline & Home page only - if (is_null(dcCore::app()->blog) || $w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) { + if (!App::blog()->isDefined() + || $w->offline + || !$w->checkHomeOnly(App::url()->type) + ) { return ''; } @@ -306,19 +303,19 @@ class Widgets } // Tags - if (dcCore::app()->plugins->moduleExists('tags') && $w->tag) { + if (App::plugins()->moduleExists('tags') && $w->tag) { $tags = explode(',', $w->tag); foreach ($tags as $i => $tag) { $tags[$i] = trim($tag); } - $params['from'] .= ', ' . dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' META '; + $params['from'] .= ', ' . App::con()->prefix() . App::meta()::META_TABLE_NAME . ' META '; $params['sql'] .= 'AND META.post_id = P.post_id '; - $params['sql'] .= 'AND META.meta_id ' . dcCore::app()->con->in($tags) . ' '; + $params['sql'] .= 'AND META.meta_id ' . App::con()->in($tags) . ' '; $params['sql'] .= "AND META.meta_type = 'tag' "; } - $rs = dcCore::app()->auth->sudo( - [dcCore::app()->blog, 'getPosts'], + $rs = App::auth()->sudo( + App::blog()->getPosts(...), $params, false ); @@ -332,20 +329,20 @@ class Widgets $res = $w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : ''; while ($rs->fetch()) { - if (is_null(dcCore::app()->blog)) { // phpstan ignores previous check !? + if (!App::blog()->isDefined()) { // phpstan ignores previous check !? break; } - $published = ((int) $rs->f('post_status')) == dcBlog::POST_PUBLISHED; + $published = ((int) $rs->f('post_status')) == App::blog()::POST_PUBLISHED; $res .= '
  • ' . '<' . ($published ? 'a href="' . $rs->getURL() . '"' : 'span') . ' title="' . Date::dt2str( - dcCore::app()->blog->settings->get('system')->get('date_format'), + App::blog()->settings()->get('system')->get('date_format'), $rs->f('post_upddt') ) . ', ' . Date::dt2str( - dcCore::app()->blog->settings->get('system')->get('time_format'), + App::blog()->settings()->get('system')->get('time_format'), $rs->f('post_upddt') ) . '">' . Html::escapeHTML($rs->f('post_title')) . @@ -369,9 +366,9 @@ class Widgets if ($w->excerpt) { $excerpt = $rs->f('post_excerpt'); if ($rs->f('post_format') == 'wiki') { - dcCore::app()->initWikiComment(); - $excerpt = dcCore::app()->wikiTransform($excerpt); - $excerpt = dcCore::app()->HTMLfilter($excerpt); + App::filter()->initWikiComment(); + $excerpt = App::filter()->wikiTransform($excerpt); + $excerpt = App::filter()->HTMLfilter($excerpt); } if (strlen($excerpt) > 0) { $cut = Text::cutString( @@ -396,12 +393,12 @@ class Widgets private static function entryFirstImage(string $type, $id, string $size = 's'): string { - if (is_null(dcCore::app()->blog) || !in_array($type, ['post', 'page', 'galitem'])) { + if (!App::blog()->isDefined() || !in_array($type, ['post', 'page', 'galitem'])) { return ''; } - $rs = dcCore::app()->auth->sudo( - [dcCore::app()->blog, 'getPosts'], + $rs = App::auth()->sudo( + App::blog()->getPosts(...), ['post_id' => $id, 'post_type' => $type], false ); @@ -414,13 +411,13 @@ class Widgets $size = 's'; } - $p_url = (string) dcCore::app()->blog->settings->get('system')->get('public_url'); + $p_url = (string) App::blog()->settings()->get('system')->get('public_url'); $p_site = (string) preg_replace( '#^(.+?//.+?)/(.*)$#', '$1', - dcCore::app()->blog->url + App::blog()->url() ); - $p_root = dcCore::app()->blog->public_path; + $p_root = App::blog()->publicPath(); $pattern = '(?:' . preg_quote($p_site, '/') . ')?' . preg_quote($p_url, '/'); $pattern = sprintf('/]+/msu', $pattern);