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

View File

@ -1,22 +1,25 @@
# README
[![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)
[![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)
[![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
* Dotclear 2.28
* PHP 8.1+
* Dotclear permissions to manage widgets
_myBlogNumbers_ requires:
* permissions to manage widgets
* Dotclear 2.27
* PHP 7.4+
## USAGE
@ -28,15 +31,14 @@ You can add a dashboard item by enable it from your dashboard preferences.
## LINKS
* [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)
* 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)
## CONTRIBUTORS
* Jean-Christian Denis (author)
* Jean-Christian Denis
* Pierre Van Glabeke
You are welcome to contribute to this code.

View File

@ -1,29 +1,33 @@
<?php
/**
* @file
* @brief The plugin myBlogNumbers definition
* @ingroup myBlogNumbers
* @brief myBlogNumbers, a plugin for Dotclear 2
*
* @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 GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* @copyright Jean-Christian Denis
* @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(
'My blog numbers',
'Show some figures of your blog',
'Jean-Christian Denis, Pierre Van Glabeke',
'2023.10.19',
'2023.08.13',
[
'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',
'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',
]
);

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="myBlogNumbers">
<name>My blog numbers</name>
<version>2023.10.19</version>
<version>2023.08.13</version>
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
<desc>Show some figures of your blog</desc>
<file>https://git.dotclear.watch/JcDenis/myBlogNumbers/releases/download/v2023.10.19/plugin-myBlogNumbers.zip</file>
<da:dcmin>2.28</da:dcmin>
<file>https://git.dotclear.watch/JcDenis/myBlogNumbers/releases/download/v2023.08.13/plugin-myBlogNumbers.zip</file>
<da:dcmin>2.27</da:dcmin>
<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>
</module>

View File

@ -1,19 +1,22 @@
<?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);
namespace Dotclear\Plugin\myBlogNumbers;
use Dotclear\App;
use dcCore;
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
{
public static function init(): bool
@ -27,7 +30,9 @@ class Backend extends Process
return false;
}
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
dcCore::app()->addBehaviors([
'initWidgets' => [Widgets::class, 'initWidgets'],
]);
return true;
}

View File

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

View File

@ -1,19 +1,21 @@
<?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);
namespace Dotclear\Plugin\myBlogNumbers;
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
{
// Use default permissions
}

View File

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