diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d0b9b2..a441188 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +topWriter 1.4 - 2023.10.20 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + topWriter 1.3 - 2023.08.13 =========================================================== * Require Dotclear 2.27 diff --git a/README.md b/README.md index 20a51fc..492a1ac 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,22 @@ # README -[![Release](https://img.shields.io/badge/release-1.3-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/topWriter/releases) -[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/topWriter/releases) -[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) +[![Release](https://img.shields.io/badge/release-1.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/topWriter/releases) +![Date](https://img.shields.io/badge/date-2023.10.20-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/topWriter) -[![License](https://img.shields.io/github/license/JcDenis/topWriter)](https://git.dotclear.watch/JcDenis/topWriter/blob/master/LICENSE) +[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/topWriter/src/branch/master/LICENSE) -## WHAT IS TOPWRITER ? +## ABOUT -_Top writer_ is a plugin for the open-source -web publishing software called Dotclear. +_topWriter_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -Show most active contributor on a widget. +> Show most active contributor on a widget. ## REQUIREMENTS -_topWriter_ requires: - -* permissions to manage widgets -* Dotclear 2.27 -* PHP 7.4 +* Dotclear 2.28 +* PHP 8.1 +* Dotclear permissions to manage widgets ## USAGE @@ -32,10 +29,11 @@ Or add contents to the backend dashboard from your 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/topWriter) or [GitHub Page](https://github.com/JcDenis/topWriter) -* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/topWriter/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/topWriter) -* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=333002#p333002) +* [License](https://git.dotclear.watch/JcDenis/topWriter/src/branch/master/LICENSE) +* [Packages & details](https://git.dotclear.watch/JcDenis/topWriter/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/topWriter)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/topWriter) (or on [GitHub](https://github.com/JcDenis/topWriter)) +* [Issues & security](https://git.dotclear.watch/JcDenis/topWriter/issues) (or on [GitHub](https://github.com/JcDenis/topWriter/issues)) +* [Discuss & help](http://forum.dotclear.org/viewtopic.php?pid=333002#p333002) ## CONTRIBUTORS diff --git a/_define.php b/_define.php index 51c542e..19ce569 100644 --- a/_define.php +++ b/_define.php @@ -1,32 +1,29 @@ registerModule( 'Top writer', 'Ranking of the most prolific writers and/or commentators', 'Jean-Christian Denis, Pierre Van Glabeke', - '1.3', + '1.4', [ - 'requires' => [['core', '2.27']], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcCore::app()->auth::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 58542aa..35444e0 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Top writer - 1.3 + 1.4 Jean-Christian Denis, Pierre Van Glabeke Ranking of the most prolific writers and/or commentators - https://git.dotclear.watch/JcDenis/topWriter/releases/download/v1.3/plugin-topWriter.zip - 2.27 + https://git.dotclear.watch/JcDenis/topWriter/releases/download/v1.4/plugin-topWriter.zip + 2.28 https://git.dotclear.watch/JcDenis/topWriter/src/branch/master/README.md https://git.dotclear.watch/JcDenis/topWriter/issues diff --git a/src/Backend.php b/src/Backend.php index 67ce112..7725a0c 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -1,22 +1,19 @@ addBehaviors([ - 'adminDashboardItemsV2' => [BackendBehaviors::class, 'adminDashboardItemsV2'], - 'adminDashboardOptionsFormV2' => [BackendBehaviors::class, 'adminDashboardOptionsFormV2'], - 'adminAfterDashboardOptionsUpdate' => [BackendBehaviors::class, 'adminAfterDashboardOptionsUpdate'], - 'initWidgets' => [Widgets::class, 'initWidgets'], + App::behavior()->addBehaviors([ + 'adminDashboardItemsV2' => BackendBehaviors::adminDashboardItemsV2(...), + 'adminDashboardOptionsFormV2' => BackendBehaviors::adminDashboardOptionsFormV2(...), + 'adminAfterDashboardOptionsUpdate' => BackendBehaviors::adminAfterDashboardOptionsUpdate(...), + 'initWidgets' => Widgets::initWidgets(...), ]); return true; diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php index d2b4074..679a41c 100644 --- a/src/BackendBehaviors.php +++ b/src/BackendBehaviors.php @@ -1,21 +1,11 @@ auth->user_prefs->get('dashboard')->put( + App::auth()->prefs()->get('dashboard')->put( 'topWriterPostsItems', !empty($_POST['topWriterPostsItems']), 'boolean' ); - dcCore::app()->auth->user_prefs->get('dashboard')->put( + App::auth()->prefs()->get('dashboard')->put( 'topWriterPostsPeriod', (string) $_POST['topWriterPostsPeriod'], 'string' ); - dcCore::app()->auth->user_prefs->get('dashboard')->put( + App::auth()->prefs()->get('dashboard')->put( 'topWriterPostsLimit', (int) $_POST['topWriterPostsLimit'], 'integer' ); - dcCore::app()->auth->user_prefs->get('dashboard')->put( + App::auth()->prefs()->get('dashboard')->put( 'topWriterCommentsItems', !empty($_POST['topWriterCommentsItems']), 'boolean' ); - dcCore::app()->auth->user_prefs->get('dashboard')->put( + App::auth()->prefs()->get('dashboard')->put( 'topWriterCommentsPeriod', (string) $_POST['topWriterCommentsPeriod'], 'string' ); - dcCore::app()->auth->user_prefs->get('dashboard')->put( + App::auth()->prefs()->get('dashboard')->put( 'topWriterCommentsLimit', (int) $_POST['topWriterCommentsLimit'], 'integer' @@ -149,43 +141,43 @@ class BackendBehaviors private static function setDefaultPref(): array { - if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterPostsItems')) { - dcCore::app()->auth->user_prefs->get('dashboard')->put( + if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterPostsItems')) { + App::auth()->prefs()->get('dashboard')->put( 'topWriterPostsItems', false, 'boolean' ); } - if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterPostsPeriod')) { - dcCore::app()->auth->user_prefs->get('dashboard')->put( + if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterPostsPeriod')) { + App::auth()->prefs()->get('dashboard')->put( 'topWriterPostsPeriod', 'month', 'string' ); } - if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterPostsLimit')) { - dcCore::app()->auth->user_prefs->get('dashboard')->put( + if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterPostsLimit')) { + App::auth()->prefs()->get('dashboard')->put( 'topWriterPostsLimit', 10, 'integer' ); } - if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterCommentsItems')) { - dcCore::app()->auth->user_prefs->get('dashboard')->put( + if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterCommentsItems')) { + App::auth()->prefs()->get('dashboard')->put( 'topWriterCommentsItems', false, 'boolean' ); } - if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterCommentsPeriod')) { - dcCore::app()->auth->user_prefs->get('dashboard')->put( + if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterCommentsPeriod')) { + App::auth()->prefs()->get('dashboard')->put( 'topWriterCommentsPeriod', 'month', 'string' ); } - if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterCommentsLimit')) { - dcCore::app()->auth->user_prefs->get('dashboard')->put( + if (!App::auth()->prefs()->get('dashboard')->prefExists('topWriterCommentsLimit')) { + App::auth()->prefs()->get('dashboard')->put( 'topWriterCommentsLimit', 10, 'integer' @@ -193,12 +185,12 @@ class BackendBehaviors } return [ - 'topWriterPostsItems' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterPostsItems'), - 'topWriterPostsPeriod' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterPostsPeriod'), - 'topWriterPostsLimit' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterPostsLimit') ?? 10, - 'topWriterCommentsItems' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterCommentsItems'), - 'topWriterCommentsPeriod' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterCommentsPeriod'), - 'topWriterCommentsLimit' => dcCore::app()->auth->user_prefs->get('dashboard')->get('topWriterCommentsLimit') ?? 10, + 'topWriterPostsItems' => App::auth()->prefs()->get('dashboard')->get('topWriterPostsItems'), + 'topWriterPostsPeriod' => App::auth()->prefs()->get('dashboard')->get('topWriterPostsPeriod'), + 'topWriterPostsLimit' => App::auth()->prefs()->get('dashboard')->get('topWriterPostsLimit') ?? 10, + 'topWriterCommentsItems' => App::auth()->prefs()->get('dashboard')->get('topWriterCommentsItems'), + 'topWriterCommentsPeriod' => App::auth()->prefs()->get('dashboard')->get('topWriterCommentsPeriod'), + 'topWriterCommentsLimit' => App::auth()->prefs()->get('dashboard')->get('topWriterCommentsLimit') ?? 10, ]; } } diff --git a/src/Frontend.php b/src/Frontend.php index 2a64b6b..8ab68f8 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 f1ae0e5..3f22d1e 100644 --- a/src/My.php +++ b/src/My.php @@ -1,21 +1,19 @@ blog)) { + if (!App::blog()->isDefined()) { return []; } $sql = new SelectStatement(); $sql - ->from($sql->as(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME, 'P')) + ->from($sql->as(App::con()->prefix() . App::blog()::POST_TABLE_NAME, 'P')) ->columns([ $sql->count('*', 'count'), 'U.user_id', @@ -43,12 +36,12 @@ class Utils ->join( (new JoinStatement()) ->inner() - ->from($sql->as(dcCore::app()->prefix . dcAuth::USER_TABLE_NAME, 'U')) + ->from($sql->as(App::con()->prefix() . App::auth()::USER_TABLE_NAME, 'U')) ->on('U.user_id = P.user_id') ->statement() ) - ->where('blog_id = ' . $sql->quote(dcCore::app()->blog->id)) - ->and('post_status = ' . dcBlog::POST_PUBLISHED) + ->where('blog_id = ' . $sql->quote(App::blog()->id())) + ->and('post_status = ' . App::blog()::POST_PUBLISHED) ->and('user_status = 1') ->group('U.user_id') ->order('count ' . ($sort_desc ? 'DESC' : 'ASC') . ' , U.user_id ASC') @@ -67,7 +60,7 @@ class Utils while ($rs->fetch()) { $sql = new SelectStatement(); $user = $sql - ->from(dcCore::app()->prefix . dcAuth::USER_TABLE_NAME) + ->from(App::con()->prefix() . App::auth()::USER_TABLE_NAME) ->column('*') ->where('user_id = ' . $sql->quote($rs->f('user_id'))) ->select(); @@ -76,7 +69,7 @@ class Utils continue; } - $author = dcUtils::getUserCN( + $author = App::users()->getUserCN( $user->f('user_id'), $user->f('user_name'), $user->f('user_firstname'), @@ -87,9 +80,9 @@ class Utils } $i++; - if (dcCore::app()->blog->settings->get('authormode')->get('authormode_active')) { + if (App::blog()->settings()->get('authormode')->get('authormode_active')) { $res[$i]['author_link'] = 'url() . App::url()->getBase('author') . '/' . $user->f('user_id') . '" ' . 'title="' . __('Author posts') . '">' . $author . ''; } elseif ($user->f('user_url')) { $res[$i]['author_link'] = '