Compare commits

..

No commits in common. "master" and "v2023.08.13" have entirely different histories.

8 changed files with 109 additions and 96 deletions

View File

@ -1,9 +1,3 @@
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,22 +1,25 @@
# README # README
[![Release](https://img.shields.io/badge/release-2023.10.19-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/myBlogNumber/releases) [![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.10.19-c44d58.svg) [![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.28-137bbb.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-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/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/myBlogNumber/src/branch/master/LICENSE) [![License](https://img.shields.io/github/license/JcDenis/myBlogNumber)](https://git.dotclear.watch/JcDenis/myBlogNumber/blob/master/LICENSE)
## ABOUT ## WHAT IS MYBLOGNUMBERS ?
_myBlogNumber_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). "My Blog Numbers" is a plugin for the open-source
web publishing software called Dotclear.
> Show visitors some statistics about current blog. Simply show visitors some statistics about current blog.
## REQUIREMENTS ## REQUIREMENTS
* Dotclear 2.28 _myBlogNumbers_ requires:
* PHP 8.1+
* Dotclear permissions to manage widgets * permissions to manage widgets
* Dotclear 2.27
* PHP 7.4+
## USAGE ## USAGE
@ -28,15 +31,14 @@ You can add a dashboard item by enable it from your dashboard preferences.
## LINKS ## LINKS
* [License](https://git.dotclear.watch/JcDenis/myBlogNumber/src/branch/master/LICENSE) * License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* [Packages & details](https://git.dotclear.watch/JcDenis/myBlogNumber/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/myBlogNumber)) * Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/myBlogNumber) or [GitHub Page](https://github.com/JcDenis/myBlogNumber)
* [Sources & contributions](https://git.dotclear.watch/JcDenis/myBlogNumber) (or on [GitHub](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)
* [Issues & security](https://git.dotclear.watch/JcDenis/myBlogNumber/issues) (or on [GitHub](https://github.com/JcDenis/myBlogNumber/issues)) * Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?id=40934)
* [Discuss & help](http://forum.dotclear.org/viewtopic.php?id=40934)
## CONTRIBUTORS ## CONTRIBUTORS
* Jean-Christian Denis (author) * Jean-Christian Denis
* 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,29 +1,33 @@
<?php <?php
/** /**
* @file * @brief myBlogNumbers, a plugin for Dotclear 2
* @brief The plugin myBlogNumbers definition
* @ingroup myBlogNumbers
* *
* @defgroup myBlogNumbers Plugin myBlogNumbers. * @package Dotclear
* @subpackage Plugin
* *
* Show some figures of your blog. * @author Jean-Christian Denis, Pierre Van Glabeke
* *
* @author Jean-Christian Denis (author) * @copyright Jean-Christian Denis
* @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
*/ */
declare(strict_types=1); if (!defined('DC_RC_PATH')) {
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.10.19', '2023.08.13',
[ [
'requires' => [['core', '2.28']], 'requires' => [['core', '2.27']],
'permissions' => 'My', 'permissions' => dcCore::app()->auth->makePermissions([
'type' => 'plugin', dcAuth::PERMISSION_USAGE,
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', dcAuth::PERMISSION_CONTENT_ADMIN,
'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', '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',
] ]
); );

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.10.19</version> <version>2023.08.13</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.10.19/plugin-myBlogNumbers.zip</file> <file>https://git.dotclear.watch/JcDenis/myBlogNumbers/releases/download/v2023.08.13/plugin-myBlogNumbers.zip</file>
<da:dcmin>2.28</da:dcmin> <da:dcmin>2.27</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,19 +1,22 @@
<?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\App; use dcCore;
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
@ -27,7 +30,9 @@ class Backend extends Process
return false; return false;
} }
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); dcCore::app()->addBehaviors([
'initWidgets' => [Widgets::class, 'initWidgets'],
]);
return true; return true;
} }

View File

@ -1,19 +1,22 @@
<?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\App; use dcCore;
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
@ -27,7 +30,9 @@ class Frontend extends Process
return false; return false;
} }
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); dcCore::app()->addBehaviors([
'initWidgets' => [Widgets::class, 'initWidgets'],
]);
return true; return true;
} }

View File

@ -1,19 +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 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,21 +1,25 @@
<?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\App; use dcCore;
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
@ -24,7 +28,7 @@ class Widgets
->create( ->create(
'myblognumbers', 'myblognumbers',
__('My blog numbers'), __('My blog numbers'),
self::frontendWidget(...), [self::class, 'frontendWidget'],
null, null,
__('Show some figures of your blog') __('Show some figures of your blog')
) )
@ -86,7 +90,7 @@ class Widgets
'text' 'text'
); );
if (App::plugins()->moduleExists('tags')) { if (dcCore::app()->plugins->moduleExists('tags')) {
# Tag # Tag
$w->myblognumbers $w->myblognumbers
->setting( ->setting(
@ -119,7 +123,7 @@ class Widgets
); );
# --BEHAVIOR-- myBlogNumbersWidgetInit # --BEHAVIOR-- myBlogNumbersWidgetInit
App::behavior()->callBehavior('myBlogNumbersWidgetInit', $w); dcCore::app()->callBehavior('myBlogNumbersWidgetInit', $w);
# widget option - page to show on # widget option - page to show on
$w->myblognumbers $w->myblognumbers
@ -131,10 +135,7 @@ class Widgets
public static function frontendWidget(WidgetsElement $w): string public static function frontendWidget(WidgetsElement $w): string
{ {
if (!App::blog()->isDefined() if (is_null(dcCore::app()->blog) || $w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|| $w->offline
|| !$w->checkHomeOnly(App::url()->type)
) {
return ''; return '';
} }
@ -147,7 +148,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) App::blog()->getPosts([], true)->f(0); $count = (int) dcCore::app()->blog->getPosts([], true)->f(0);
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no entries'), $count) : sprintf(__('no entries'), $count) :
@ -161,7 +162,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 = App::blog()->getCategories([])->count(); $count = dcCore::app()->blog->getCategories([])->count();
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no categories'), $count) : sprintf(__('no categories'), $count) :
@ -180,7 +181,7 @@ class Widgets
'comment_status' => 1, 'comment_status' => 1,
'comment_trackback' => 0, 'comment_trackback' => 0,
]; ];
$count = (int) App::blog()->getComments($params, true)->f(0); $count = (int) dcCore::app()->blog->getComments($params, true)->f(0);
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no comments'), $count) : sprintf(__('no comments'), $count) :
@ -199,7 +200,7 @@ class Widgets
'comment_status' => 1, 'comment_status' => 1,
'comment_trackback' => 1, 'comment_trackback' => 1,
]; ];
$count = (int) App::blog()->getComments($params, true)->f(0); $count = (int) dcCore::app()->blog->getComments($params, true)->f(0);
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no trackbacks'), $count) : sprintf(__('no trackbacks'), $count) :
@ -209,16 +210,16 @@ class Widgets
} }
# Tag # Tag
if (App::plugins()->moduleExists('tags') && $w->tag_show) { if (dcCore::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) App::con()->select( $count = (int) dcCore::app()->con->select(
'SELECT count(M.meta_id) AS count ' . 'SELECT count(M.meta_id) AS count ' .
'FROM ' . App::con()->prefix() . App::meta()::META_TABLE_NAME . ' M ' . 'FROM ' . dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' M ' .
'LEFT JOIN ' . App::con()->prefix() . 'post P ON P.post_id=M.post_id ' . 'LEFT JOIN ' . dcCore::app()->prefix . 'post P ON P.post_id=M.post_id ' .
"WHERE M.meta_type='tag' " . "WHERE M.meta_type='tag' " .
"AND P.blog_id='" . App::blog()->id() . "' " "AND P.blog_id='" . dcCore::app()->blog->id . "' "
)->f(0); )->f(0);
$text = $count == 0 ? $text = $count == 0 ?
@ -233,7 +234,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 = App::blog()->getPostsUsers('post')->count(); $count = dcCore::app()->blog->getPostsUsers('post')->count();
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no author'), $count) : sprintf(__('no author'), $count) :
@ -243,7 +244,7 @@ class Widgets
} }
# --BEHAVIOR-- myBlogNumbersWidgetParse # --BEHAVIOR-- myBlogNumbersWidgetParse
$addons = App::behavior()->callBehavior('myBlogNumbersWidgetParse', $w); $addons = dcCore::app()->callBehavior('myBlogNumbersWidgetParse', $w);
# Nothing to display # Nothing to display
if (!$content && !$addons) { if (!$content && !$addons) {