From d408637db269907fea536372f0b1bb6bb03131f0 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 19 Oct 2023 21:39:07 +0200 Subject: [PATCH] upgrade to Dotclear 2.28 --- CHANGELOG.md | 6 ++++++ README.md | 34 ++++++++++++++---------------- _define.php | 34 +++++++++++++----------------- dcstore.xml | 6 +++--- src/Backend.php | 25 +++++++++------------- src/Frontend.php | 25 +++++++++------------- src/My.php | 20 ++++++++---------- src/Widgets.php | 55 ++++++++++++++++++++++++------------------------ 8 files changed, 96 insertions(+), 109 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95e6a16..8d32d57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +myBlogNumbers 2023.10.19 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + myBlogNumbers 2023.08.13 =========================================================== * Require Dotclear 2.27 diff --git a/README.md b/README.md index 1d68a4d..bb70605 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/myBlogNumber/releases) -[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/myBlogNumber/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/myBlogNumber/releases) +![Date](https://img.shields.io/badge/date-2023.10.19-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/myBlogNumber) -[![License](https://img.shields.io/github/license/JcDenis/myBlogNumber)](https://git.dotclear.watch/JcDenis/myBlogNumber/blob/master/LICENSE) +[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/myBlogNumber/src/branch/master/LICENSE) -## WHAT IS MYBLOGNUMBERS ? +## ABOUT -"My Blog Numbers" is a plugin for the open-source -web publishing software called Dotclear. +_myBlogNumber_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -Simply show visitors some statistics about current blog. +> Show visitors some statistics about current blog. ## REQUIREMENTS -_myBlogNumbers_ requires: - -* permissions to manage widgets -* Dotclear 2.27 -* PHP 7.4+ +* Dotclear 2.28 +* PHP 8.1+ +* Dotclear permissions to manage widgets ## USAGE @@ -31,14 +28,15 @@ You can add a dashboard item by enable it from your dashboard preferences. ## 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/myBlogNumber) or [GitHub Page](https://github.com/JcDenis/myBlogNumber) -* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/myBlogNumber/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/myBlogNumber) -* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?id=40934) +* [License](https://git.dotclear.watch/JcDenis/myBlogNumber/src/branch/master/LICENSE) +* [Packages & details](https://git.dotclear.watch/JcDenis/myBlogNumber/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/myBlogNumber)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/myBlogNumber) (or on [GitHub](https://github.com/JcDenis/myBlogNumber)) +* [Issues & security](https://git.dotclear.watch/JcDenis/myBlogNumber/issues) (or on [GitHub](https://github.com/JcDenis/myBlogNumber/issues)) +* [Discuss & help](http://forum.dotclear.org/viewtopic.php?id=40934) ## CONTRIBUTORS -* Jean-Christian Denis +* Jean-Christian Denis (author) * Pierre Van Glabeke You are welcome to contribute to this code. diff --git a/_define.php b/_define.php index d7cc27b..1a201e3 100644 --- a/_define.php +++ b/_define.php @@ -1,33 +1,29 @@ registerModule( 'My blog numbers', 'Show some figures of your blog', 'Jean-Christian Denis, Pierre Van Glabeke', - '2023.08.13', + '2023.10.19', [ - 'requires' => [['core', '2.27']], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcAuth::PERMISSION_USAGE, - dcAuth::PERMISSION_CONTENT_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 4430827..96e70a1 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ My blog numbers - 2023.08.13 + 2023.10.19 Jean-Christian Denis, Pierre Van Glabeke Show some figures of your blog - https://git.dotclear.watch/JcDenis/myBlogNumbers/releases/download/v2023.08.13/plugin-myBlogNumbers.zip - 2.27 + https://git.dotclear.watch/JcDenis/myBlogNumbers/releases/download/v2023.10.19/plugin-myBlogNumbers.zip + 2.28 https://git.dotclear.watch/JcDenis/myBlogNumbers/src/branch/master/README.md https://git.dotclear.watch/JcDenis/myBlogNumbers/issues diff --git a/src/Backend.php b/src/Backend.php index 30547fb..58c7d62 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 7e1df30..1dfe01c 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 a3d5e3e..c00d1dd 100644 --- a/src/My.php +++ b/src/My.php @@ -1,21 +1,19 @@ create( 'myblognumbers', __('My blog numbers'), - [self::class, 'frontendWidget'], + self::frontendWidget(...), null, __('Show some figures of your blog') ) @@ -90,7 +86,7 @@ class Widgets 'text' ); - if (dcCore::app()->plugins->moduleExists('tags')) { + if (App::plugins()->moduleExists('tags')) { # Tag $w->myblognumbers ->setting( @@ -123,7 +119,7 @@ class Widgets ); # --BEHAVIOR-- myBlogNumbersWidgetInit - dcCore::app()->callBehavior('myBlogNumbersWidgetInit', $w); + App::behavior()->callBehavior('myBlogNumbersWidgetInit', $w); # widget option - page to show on $w->myblognumbers @@ -135,7 +131,10 @@ class Widgets public static function frontendWidget(WidgetsElement $w): string { - 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 ''; } @@ -148,7 +147,7 @@ class Widgets $title = $w->entry_title ? sprintf($s_title, Html::escapeHTML($w->entry_title)) : ''; - $count = (int) dcCore::app()->blog->getPosts([], true)->f(0); + $count = (int) App::blog()->getPosts([], true)->f(0); $text = $count == 0 ? sprintf(__('no entries'), $count) : @@ -162,7 +161,7 @@ class Widgets $title = $w->cat_title ? sprintf($s_title, Html::escapeHTML($w->cat_title)) : ''; - $count = dcCore::app()->blog->getCategories([])->count(); + $count = App::blog()->getCategories([])->count(); $text = $count == 0 ? sprintf(__('no categories'), $count) : @@ -181,7 +180,7 @@ class Widgets 'comment_status' => 1, 'comment_trackback' => 0, ]; - $count = (int) dcCore::app()->blog->getComments($params, true)->f(0); + $count = (int) App::blog()->getComments($params, true)->f(0); $text = $count == 0 ? sprintf(__('no comments'), $count) : @@ -200,7 +199,7 @@ class Widgets 'comment_status' => 1, 'comment_trackback' => 1, ]; - $count = (int) dcCore::app()->blog->getComments($params, true)->f(0); + $count = (int) App::blog()->getComments($params, true)->f(0); $text = $count == 0 ? sprintf(__('no trackbacks'), $count) : @@ -210,16 +209,16 @@ class Widgets } # Tag - if (dcCore::app()->plugins->moduleExists('tags') && $w->tag_show) { + if (App::plugins()->moduleExists('tags') && $w->tag_show) { $title = $w->tag_title ? sprintf($s_title, Html::escapeHTML($w->tag_title)) : ''; - $count = (int) dcCore::app()->con->select( + $count = (int) App::con()->select( 'SELECT count(M.meta_id) AS count ' . - 'FROM ' . dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' M ' . - 'LEFT JOIN ' . dcCore::app()->prefix . 'post P ON P.post_id=M.post_id ' . + 'FROM ' . App::con()->prefix() . App::meta()::META_TABLE_NAME . ' M ' . + 'LEFT JOIN ' . App::con()->prefix() . 'post P ON P.post_id=M.post_id ' . "WHERE M.meta_type='tag' " . - "AND P.blog_id='" . dcCore::app()->blog->id . "' " + "AND P.blog_id='" . App::blog()->id() . "' " )->f(0); $text = $count == 0 ? @@ -234,7 +233,7 @@ class Widgets $title = $w->user_title ? sprintf($s_title, Html::escapeHTML($w->user_title)) : ''; - $count = dcCore::app()->blog->getPostsUsers('post')->count(); + $count = App::blog()->getPostsUsers('post')->count(); $text = $count == 0 ? sprintf(__('no author'), $count) : @@ -244,7 +243,7 @@ class Widgets } # --BEHAVIOR-- myBlogNumbersWidgetParse - $addons = dcCore::app()->callBehavior('myBlogNumbersWidgetParse', $w); + $addons = App::behavior()->callBehavior('myBlogNumbersWidgetParse', $w); # Nothing to display if (!$content && !$addons) {