upgrade to Dotclear 2.28

This commit is contained in:
Jean-Christian Paul Denis 2023-10-19 21:39:07 +02:00
parent 54d29c0a0f
commit d408637db2
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
8 changed files with 96 additions and 109 deletions

View File

@ -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 myBlogNumbers 2023.08.13
=========================================================== ===========================================================
* Require Dotclear 2.27 * Require Dotclear 2.27

View File

@ -1,25 +1,22 @@
# README # README
[![Release](https://img.shields.io/badge/release-2023.08.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/myBlogNumber/releases) [![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.08.13-c44d58.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.27-137bbb.svg)](https://fr.dotclear.org/download) [![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) [![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 _myBlogNumber_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
web publishing software called Dotclear.
Simply show visitors some statistics about current blog. > Show visitors some statistics about current blog.
## REQUIREMENTS ## REQUIREMENTS
_myBlogNumbers_ requires: * Dotclear 2.28
* PHP 8.1+
* permissions to manage widgets * Dotclear permissions to manage widgets
* Dotclear 2.27
* PHP 7.4+
## USAGE ## USAGE
@ -31,14 +28,15 @@ You can add a dashboard item by enable it from your dashboard preferences.
## LINKS ## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html) * [License](https://git.dotclear.watch/JcDenis/myBlogNumber/src/branch/master/LICENSE)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/myBlogNumber) or [GitHub Page](https://github.com/JcDenis/myBlogNumber) * [Packages & details](https://git.dotclear.watch/JcDenis/myBlogNumber/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/myBlogNumber))
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/myBlogNumber/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/myBlogNumber) * [Sources & contributions](https://git.dotclear.watch/JcDenis/myBlogNumber) (or on [GitHub](https://github.com/JcDenis/myBlogNumber))
* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?id=40934) * [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 ## CONTRIBUTORS
* Jean-Christian Denis * Jean-Christian Denis (author)
* Pierre Van Glabeke * Pierre Van Glabeke
You are welcome to contribute to this code. You are welcome to contribute to this code.

View File

@ -1,30 +1,26 @@
<?php <?php
/** /**
* @brief myBlogNumbers, a plugin for Dotclear 2 * @file
* @brief The plugin myBlogNumbers definition
* @ingroup myBlogNumbers
* *
* @package Dotclear * @defgroup myBlogNumbers Plugin myBlogNumbers.
* @subpackage Plugin
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * Show some figures of your blog.
* *
* @copyright Jean-Christian Denis * @author Jean-Christian Denis (author)
* @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(
'My blog numbers', 'My blog numbers',
'Show some figures of your blog', 'Show some figures of your blog',
'Jean-Christian Denis, Pierre Van Glabeke', 'Jean-Christian Denis, Pierre Van Glabeke',
'2023.08.13', '2023.10.19',
[ [
'requires' => [['core', '2.27']], 'requires' => [['core', '2.28']],
'permissions' => dcCore::app()->auth->makePermissions([ 'permissions' => 'My',
dcAuth::PERMISSION_USAGE,
dcAuth::PERMISSION_CONTENT_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="myBlogNumbers"> <module id="myBlogNumbers">
<name>My blog numbers</name> <name>My blog numbers</name>
<version>2023.08.13</version> <version>2023.10.19</version>
<author>Jean-Christian Denis, Pierre Van Glabeke</author> <author>Jean-Christian Denis, Pierre Van Glabeke</author>
<desc>Show some figures of your blog</desc> <desc>Show some figures of your blog</desc>
<file>https://git.dotclear.watch/JcDenis/myBlogNumbers/releases/download/v2023.08.13/plugin-myBlogNumbers.zip</file> <file>https://git.dotclear.watch/JcDenis/myBlogNumbers/releases/download/v2023.10.19/plugin-myBlogNumbers.zip</file>
<da:dcmin>2.27</da:dcmin> <da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/myBlogNumbers/src/branch/master/README.md</da:details> <da:details>https://git.dotclear.watch/JcDenis/myBlogNumbers/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/myBlogNumbers/issues</da:support> <da:support>https://git.dotclear.watch/JcDenis/myBlogNumbers/issues</da:support>
</module> </module>

View File

@ -1,22 +1,19 @@
<?php <?php
/**
* @brief myBlogNumbers, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @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\myBlogNumbers; namespace Dotclear\Plugin\myBlogNumbers;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/**
* @brief myBlogNumbers backend class.
* @ingroup myBlogNumbers
*
* @author Jean-Christian Denis (author)
* @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,9 +27,7 @@ class Backend extends Process
return false; return false;
} }
dcCore::app()->addBehaviors([ App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
'initWidgets' => [Widgets::class, 'initWidgets'],
]);
return true; return true;
} }

View File

@ -1,22 +1,19 @@
<?php <?php
/**
* @brief myBlogNumbers, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @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\myBlogNumbers; namespace Dotclear\Plugin\myBlogNumbers;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/**
* @brief myBlogNumbers frontend class.
* @ingroup myBlogNumbers
*
* @author Jean-Christian Denis (author)
* @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
@ -30,9 +27,7 @@ class Frontend extends Process
return false; return false;
} }
dcCore::app()->addBehaviors([ App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
'initWidgets' => [Widgets::class, 'initWidgets'],
]);
return true; return true;
} }

View File

@ -1,21 +1,19 @@
<?php <?php
/**
* @brief myBlogNumbers, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @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\myBlogNumbers; namespace Dotclear\Plugin\myBlogNumbers;
use Dotclear\Module\MyPlugin; use Dotclear\Module\MyPlugin;
/**
* @brief myBlogNumbers My helper.
* @ingroup myBlogNumbers
*
* @author Jean-Christian Denis (author)
* @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,25 +1,21 @@
<?php <?php
/**
* @brief myBlogNumbers, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @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\myBlogNumbers; namespace Dotclear\Plugin\myBlogNumbers;
use dcCore; use Dotclear\App;
use dcMeta;
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 myBlogNumbers widgets class.
* @ingroup myBlogNumbers
*
* @author Jean-Christian Denis (author)
* @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
@ -28,7 +24,7 @@ class Widgets
->create( ->create(
'myblognumbers', 'myblognumbers',
__('My blog numbers'), __('My blog numbers'),
[self::class, 'frontendWidget'], self::frontendWidget(...),
null, null,
__('Show some figures of your blog') __('Show some figures of your blog')
) )
@ -90,7 +86,7 @@ class Widgets
'text' 'text'
); );
if (dcCore::app()->plugins->moduleExists('tags')) { if (App::plugins()->moduleExists('tags')) {
# Tag # Tag
$w->myblognumbers $w->myblognumbers
->setting( ->setting(
@ -123,7 +119,7 @@ class Widgets
); );
# --BEHAVIOR-- myBlogNumbersWidgetInit # --BEHAVIOR-- myBlogNumbersWidgetInit
dcCore::app()->callBehavior('myBlogNumbersWidgetInit', $w); App::behavior()->callBehavior('myBlogNumbersWidgetInit', $w);
# widget option - page to show on # widget option - page to show on
$w->myblognumbers $w->myblognumbers
@ -135,7 +131,10 @@ class Widgets
public static function frontendWidget(WidgetsElement $w): string 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 ''; return '';
} }
@ -148,7 +147,7 @@ class Widgets
$title = $w->entry_title ? $title = $w->entry_title ?
sprintf($s_title, Html::escapeHTML($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 ? $text = $count == 0 ?
sprintf(__('no entries'), $count) : sprintf(__('no entries'), $count) :
@ -162,7 +161,7 @@ class Widgets
$title = $w->cat_title ? $title = $w->cat_title ?
sprintf($s_title, Html::escapeHTML($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 ? $text = $count == 0 ?
sprintf(__('no categories'), $count) : sprintf(__('no categories'), $count) :
@ -181,7 +180,7 @@ class Widgets
'comment_status' => 1, 'comment_status' => 1,
'comment_trackback' => 0, '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 ? $text = $count == 0 ?
sprintf(__('no comments'), $count) : sprintf(__('no comments'), $count) :
@ -200,7 +199,7 @@ class Widgets
'comment_status' => 1, 'comment_status' => 1,
'comment_trackback' => 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 ? $text = $count == 0 ?
sprintf(__('no trackbacks'), $count) : sprintf(__('no trackbacks'), $count) :
@ -210,16 +209,16 @@ class Widgets
} }
# Tag # Tag
if (dcCore::app()->plugins->moduleExists('tags') && $w->tag_show) { if (App::plugins()->moduleExists('tags') && $w->tag_show) {
$title = $w->tag_title ? $title = $w->tag_title ?
sprintf($s_title, Html::escapeHTML($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 ' . 'SELECT count(M.meta_id) AS count ' .
'FROM ' . dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' M ' . 'FROM ' . App::con()->prefix() . App::meta()::META_TABLE_NAME . ' M ' .
'LEFT JOIN ' . dcCore::app()->prefix . 'post P ON P.post_id=M.post_id ' . 'LEFT JOIN ' . App::con()->prefix() . 'post P ON P.post_id=M.post_id ' .
"WHERE M.meta_type='tag' " . "WHERE M.meta_type='tag' " .
"AND P.blog_id='" . dcCore::app()->blog->id . "' " "AND P.blog_id='" . App::blog()->id() . "' "
)->f(0); )->f(0);
$text = $count == 0 ? $text = $count == 0 ?
@ -234,7 +233,7 @@ class Widgets
$title = $w->user_title ? $title = $w->user_title ?
sprintf($s_title, Html::escapeHTML($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 ? $text = $count == 0 ?
sprintf(__('no author'), $count) : sprintf(__('no author'), $count) :
@ -244,7 +243,7 @@ class Widgets
} }
# --BEHAVIOR-- myBlogNumbersWidgetParse # --BEHAVIOR-- myBlogNumbersWidgetParse
$addons = dcCore::app()->callBehavior('myBlogNumbersWidgetParse', $w); $addons = App::behavior()->callBehavior('myBlogNumbersWidgetParse', $w);
# Nothing to display # Nothing to display
if (!$content && !$addons) { if (!$content && !$addons) {