Compare commits
No commits in common. "8a7292ae7eb34d7e056d25edfb06a01889da0f9e" and "54a7c5905a3763af2fa3cbfa93ed75df4b5849ab" have entirely different histories.
8a7292ae7e
...
54a7c5905a
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,15 +1,5 @@
|
||||||
2023.04.22
|
2021.08.27.1 - dev
|
||||||
- require dotclear 2.26
|
- [x] clean up again
|
||||||
- use latest helper namespace
|
|
||||||
- fix plural translations
|
|
||||||
- fix nullsafe warnings
|
|
||||||
|
|
||||||
2023.03.24
|
|
||||||
- require dotclear 2.25
|
|
||||||
- use namespace
|
|
||||||
|
|
||||||
2022.11.20
|
|
||||||
- fix compatibility with Dotclear 2.24 (required)
|
|
||||||
|
|
||||||
2021.08.27
|
2021.08.27
|
||||||
- cleanup (PSR2, short array, ...)
|
- cleanup (PSR2, short array, ...)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
[![Release](https://img.shields.io/github/v/release/JcDenis/myBlogNumbers)](https://github.com/JcDenis/myBlogNumbers/releases)
|
[![Release](https://img.shields.io/github/v/release/JcDenis/myBlogNumbers)](https://github.com/JcDenis/myBlogNumbers/releases)
|
||||||
[![Date](https://img.shields.io/github/release-date/JcDenis/myBlogNumbers)](https://github.com/JcDenis/myBlogNumbers/releases)
|
[![Date](https://img.shields.io/github/release-date/JcDenis/myBlogNumbers)](https://github.com/JcDenis/myBlogNumbers/releases)
|
||||||
[![Issues](https://img.shields.io/github/issues/JcDenis/myBlogNumbers)](https://github.com/JcDenis/myBlogNumbers/issues)
|
[![Issues](https://img.shields.io/github/issues/JcDenis/myBlogNumbers)](https://github.com/JcDenis/myBlogNumbers/issues)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.19-blue.svg)](https://fr.dotclear.org/download)
|
||||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/myBlogNumbers)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/myBlogNumbers)
|
||||||
[![License](https://img.shields.io/github/license/JcDenis/myBlogNumbers)](https://github.com/JcDenis/myBlogNumbers/blob/master/LICENSE)
|
[![License](https://img.shields.io/github/license/JcDenis/myBlogNumbers)](https://github.com/JcDenis/myBlogNumbers/blob/master/LICENSE)
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ Simply show visitors some statistics about current blog.
|
||||||
_myBlogNumbers_ requires:
|
_myBlogNumbers_ requires:
|
||||||
|
|
||||||
* permissions to manage widgets
|
* permissions to manage widgets
|
||||||
* Dotclear 2.26
|
* Dotclear 2.19
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?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
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
require dirname(__FILE__) . '/_widgets.php';
|
12
_define.php
12
_define.php
|
@ -10,6 +10,7 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -18,16 +19,13 @@ $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.04.22',
|
'2021.09.017',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.26']],
|
'requires' => [['core', '2.19']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => 'usage,contentadmin',
|
||||||
dcAuth::PERMISSION_USAGE,
|
|
||||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
|
||||||
]),
|
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'http://forum.dotclear.org/viewtopic.php?id=40934',
|
'support' => 'http://forum.dotclear.org/viewtopic.php?id=40934',
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/myBlogNumbers',
|
'details' => 'http://plugins.dotaddict.org/dc2/details/myBlogNumbers',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/myBlogNumbers/master/dcstore.xml',
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/myBlogNumbers/master/dcstore.xml'
|
||||||
]
|
]
|
||||||
);
|
);
|
|
@ -0,0 +1,153 @@
|
||||||
|
<?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
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
require dirname(__FILE__) . '/_widgets.php';
|
||||||
|
|
||||||
|
function myBlogNumbersWidgetPublic($w)
|
||||||
|
{
|
||||||
|
global $core;
|
||||||
|
|
||||||
|
$content = $addons = '';
|
||||||
|
$s_line = '<li>%s%s</li>';
|
||||||
|
$s_title = '<strong>%s</strong> ';
|
||||||
|
|
||||||
|
if ($w->offline) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($w->homeonly == 1 && !$core->url->isHome($core->url->type))
|
||||||
|
|| ($w->homeonly == 2 && $core->url->isHome($core->url->type))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Entry
|
||||||
|
if ($w->entry_show) {
|
||||||
|
$title = $w->entry_title ?
|
||||||
|
sprintf($s_title, html::escapeHTML($w->entry_title)) : '';
|
||||||
|
|
||||||
|
$count = $core->blog->getPosts([], true)->f(0);
|
||||||
|
|
||||||
|
$text = $count == 0 ?
|
||||||
|
sprintf(__('no entries'), $count) :
|
||||||
|
sprintf(__('one entry', '%s entries', $count), $count);
|
||||||
|
|
||||||
|
$content .= sprintf($s_line, $title, $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Cat
|
||||||
|
if ($w->cat_show) {
|
||||||
|
$title = $w->cat_title ?
|
||||||
|
sprintf($s_title, html::escapeHTML($w->cat_title)) : '';
|
||||||
|
|
||||||
|
$count = $core->blog->getCategories([])->count();
|
||||||
|
|
||||||
|
$text = $count == 0 ?
|
||||||
|
sprintf(__('no categories'), $count) :
|
||||||
|
sprintf(__('one category', '%s categories', $count), $count);
|
||||||
|
|
||||||
|
$content .= sprintf($s_line, $title, $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Comment
|
||||||
|
if ($w->comment_show) {
|
||||||
|
$title = $w->comment_title ?
|
||||||
|
sprintf($s_title, html::escapeHTML($w->comment_title)) : '';
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'post_type' => 'post',
|
||||||
|
'comment_status' => 1,
|
||||||
|
'comment_trackback' => 0
|
||||||
|
];
|
||||||
|
$count = $core->blog->getComments($params, true)->f(0);
|
||||||
|
|
||||||
|
$text = $count == 0 ?
|
||||||
|
sprintf(__('no comments'),$count) :
|
||||||
|
sprintf(__('one comment', '%s comments', $count), $count);
|
||||||
|
|
||||||
|
$content .= sprintf($s_line,$title,$text);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Trackback
|
||||||
|
if ($w->trackback_show) {
|
||||||
|
$title = $w->trackback_title ?
|
||||||
|
sprintf($s_title, html::escapeHTML($w->trackback_title)) : '';
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'post_type' => 'post',
|
||||||
|
'comment_status' => 1,
|
||||||
|
'comment_trackback' => 1
|
||||||
|
];
|
||||||
|
$count = $core->blog->getComments($params, true)->f(0);
|
||||||
|
|
||||||
|
$text = $count == 0 ?
|
||||||
|
sprintf(__('no trackbacks'),$count) :
|
||||||
|
sprintf(__('one trackback', '%s trackbacks', $count), $count);
|
||||||
|
|
||||||
|
$content .= sprintf($s_line,$title,$text);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Tag
|
||||||
|
if ($core->plugins->moduleExists('tags') && $w->tag_show) {
|
||||||
|
$title = $w->tag_title ?
|
||||||
|
sprintf($s_title,html::escapeHTML($w->tag_title)) : '';
|
||||||
|
|
||||||
|
$count = $core->con->select(
|
||||||
|
'SELECT count(M.meta_id) AS count ' .
|
||||||
|
'FROM ' . $core->prefix . 'meta M ' .
|
||||||
|
'LEFT JOIN ' . $core->prefix . 'post P ON P.post_id=M.post_id ' .
|
||||||
|
"WHERE M.meta_type='tag' " .
|
||||||
|
"AND P.blog_id='" . $core->blog->id . "' "
|
||||||
|
)->f(0);
|
||||||
|
|
||||||
|
$text = $count == 0 ?
|
||||||
|
sprintf(__('no tags'), $count) :
|
||||||
|
sprintf(__('one tag', '%s tags', $count), $count);
|
||||||
|
|
||||||
|
$content .= sprintf($s_line, $title, $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
# User (that post)
|
||||||
|
if ($w->user_show) {
|
||||||
|
$title = $w->user_title ?
|
||||||
|
sprintf($s_title, html::escapeHTML($w->user_title)) : '';
|
||||||
|
|
||||||
|
$count = $core->blog->getPostsUsers(array(),true)->count();
|
||||||
|
|
||||||
|
$text = $count == 0 ?
|
||||||
|
sprintf(__('no author'), $count) :
|
||||||
|
sprintf(__('one author', '%s authors', $count), $count);
|
||||||
|
|
||||||
|
$content .= sprintf($s_line,$title,$text);
|
||||||
|
}
|
||||||
|
|
||||||
|
# --BEHAVIOR-- myBlogNumbersWidgetParse
|
||||||
|
$addons = $core->callBehavior('myBlogNumbersWidgetParse', $core, $w);
|
||||||
|
|
||||||
|
# Nothing to display
|
||||||
|
if (!$content && !$addons) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display
|
||||||
|
return $w->renderDiv(
|
||||||
|
$w->content_only,
|
||||||
|
'myblognumbers ' . $w->class,
|
||||||
|
'',
|
||||||
|
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
|
||||||
|
sprintf('<ul>%s</ul>', $content . $addons)
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?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
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$core->addBehavior('initWidgets', 'myBlogNumbersWidgetAdmin');
|
||||||
|
|
||||||
|
function myBlogNumbersWidgetAdmin($w)
|
||||||
|
{
|
||||||
|
global $core;
|
||||||
|
|
||||||
|
$w
|
||||||
|
->create(
|
||||||
|
'myblognumbers',
|
||||||
|
__('My blog numbers'),
|
||||||
|
'myBlogNumbersWidgetPublic',
|
||||||
|
null,
|
||||||
|
__('Show some figures of your blog')
|
||||||
|
)
|
||||||
|
->addTitle(__('My blog numbers'))
|
||||||
|
|
||||||
|
# Entry
|
||||||
|
->setting(
|
||||||
|
'entry_show',
|
||||||
|
__('Show entries count'),
|
||||||
|
1,
|
||||||
|
'check'
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'entry_title',
|
||||||
|
__('Title for entries count:'),
|
||||||
|
__('Entries:'),
|
||||||
|
'text'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Cat
|
||||||
|
->setting(
|
||||||
|
'cat_show',
|
||||||
|
__('Show categories count'),
|
||||||
|
1,
|
||||||
|
'check'
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'cat_title',
|
||||||
|
__('Title for categories count:'),
|
||||||
|
__('Categories:'),
|
||||||
|
'text'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Comment
|
||||||
|
->setting(
|
||||||
|
'comment_show',
|
||||||
|
__('Show comments count'),
|
||||||
|
1,
|
||||||
|
'check'
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'comment_title',
|
||||||
|
__('Title for comments count:'),
|
||||||
|
__('Comments:'),
|
||||||
|
'text'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Trackback
|
||||||
|
->setting(
|
||||||
|
'trackback_show',
|
||||||
|
__('Show trackbacks count'),
|
||||||
|
1,
|
||||||
|
'check'
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'trackback_title',
|
||||||
|
__('Title for trackbacks count:'),
|
||||||
|
__('Trackbacks:'),
|
||||||
|
'text'
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($core->plugins->moduleExists('tags')) {
|
||||||
|
# Tag
|
||||||
|
$w->myblognumbers
|
||||||
|
->setting(
|
||||||
|
'tag_show',
|
||||||
|
__('Show tags count'),
|
||||||
|
1,
|
||||||
|
'check'
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'tag_title',
|
||||||
|
__('Title for tags count:'),
|
||||||
|
__('Tags:'),
|
||||||
|
'text'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Users (that post)
|
||||||
|
$w->myblognumbers
|
||||||
|
->setting(
|
||||||
|
'user_show',
|
||||||
|
__('Show users count'),
|
||||||
|
1,
|
||||||
|
'check'
|
||||||
|
)
|
||||||
|
->setting(
|
||||||
|
'user_title',
|
||||||
|
__('Title for users count:'),
|
||||||
|
__('Authors:'),
|
||||||
|
'text'
|
||||||
|
);
|
||||||
|
|
||||||
|
# --BEHAVIOR-- myBlogNumbersWidgetInit
|
||||||
|
$core->callBehavior('myBlogNumbersWidgetInit',$w);
|
||||||
|
|
||||||
|
# widget option - page to show on
|
||||||
|
$w->myblognumbers
|
||||||
|
->addHomeOnly()
|
||||||
|
->addContentOnly()
|
||||||
|
->addClass()
|
||||||
|
->addOffline();
|
||||||
|
}
|
|
@ -1,12 +1,11 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<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.04.22</version>
|
<version>2021.09.017</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://github.com/JcDenis/myBlogNumbers/releases/download/v2023.04.22/plugin-myBlogNumbers.zip</file>
|
<file>https://github.com/JcDenis/myBlogNumbers/releases/download/v2021.09.017/plugin-myBlogNumbers.zip</file>
|
||||||
<da:dcmin>2.26</da:dcmin>
|
<da:dcmin>2.19</da:dcmin>
|
||||||
<da:details>http://plugins.dotaddict.org/dc2/details/myBlogNumbers</da:details>
|
<da:details>http://plugins.dotaddict.org/dc2/details/myBlogNumbers</da:details>
|
||||||
<da:support>http://forum.dotclear.org/viewtopic.php?id=40934</da:support>
|
<da:support>http://forum.dotclear.org/viewtopic.php?id=40934</da:support>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @package Dotclear
|
|
||||||
*
|
|
||||||
* @copyright Olivier Meunier & Association Dotclear
|
|
||||||
* @copyright GPL-2.0-only
|
|
||||||
*/
|
|
||||||
#
|
|
||||||
# DOT NOT MODIFY THIS FILE !
|
|
||||||
#
|
|
||||||
|
|
||||||
use Dotclear\Helper\L10n;
|
|
||||||
|
|
||||||
L10n::$locales['Show some figures of your blog'] = 'Afficher quelques chiffres de votre blog';
|
|
||||||
L10n::$locales['no entries'] = 'aucun billet';
|
|
||||||
L10n::$locales['one entry'] = [
|
|
||||||
'un billet',
|
|
||||||
'%s billets',
|
|
||||||
];
|
|
||||||
L10n::$locales['no categories'] = 'aucune catégorie';
|
|
||||||
L10n::$locales['one category'] = [
|
|
||||||
'une catégorie',
|
|
||||||
'%s catégories',
|
|
||||||
];
|
|
||||||
L10n::$locales['no comments'] = 'aucun commentaire';
|
|
||||||
L10n::$locales['one comment'] = [
|
|
||||||
'un commentaire',
|
|
||||||
'%s commentaires',
|
|
||||||
];
|
|
||||||
L10n::$locales['no trackbacks'] = 'aucun rétrolien';
|
|
||||||
L10n::$locales['one trackback'] = [
|
|
||||||
'un rétrolien',
|
|
||||||
'%s rétroliens',
|
|
||||||
];
|
|
||||||
L10n::$locales['no tags'] = 'aucun mot-clé';
|
|
||||||
L10n::$locales['one tag'] = [
|
|
||||||
'un mot-clé',
|
|
||||||
'%s mots-clés',
|
|
||||||
];
|
|
||||||
L10n::$locales['no author'] = 'aucun auteur';
|
|
||||||
L10n::$locales['one author'] = [
|
|
||||||
'un auteur',
|
|
||||||
'%s auteurs',
|
|
||||||
];
|
|
||||||
L10n::$locales['My blog numbers'] = 'Mon blog en chiffres';
|
|
||||||
L10n::$locales['Show entries count'] = 'Afficher le nombre de billets';
|
|
||||||
L10n::$locales['Title for entries count:'] = 'Titre pour le nombre de billets :';
|
|
||||||
L10n::$locales['Entries:'] = 'Billets :';
|
|
||||||
L10n::$locales['Show categories count'] = 'Afficher le nombre de catégories';
|
|
||||||
L10n::$locales['Title for categories count:'] = 'Titre pour le nombre de catégories :';
|
|
||||||
L10n::$locales['Categories:'] = 'Catégories :';
|
|
||||||
L10n::$locales['Show comments count'] = 'Afficher le nombre de commentaires';
|
|
||||||
L10n::$locales['Title for comments count:'] = 'Titre pour le nombre de commentaires :';
|
|
||||||
L10n::$locales['Comments:'] = 'Commentaires :';
|
|
||||||
L10n::$locales['Show trackbacks count'] = 'Afficher le nombre de rétroliens';
|
|
||||||
L10n::$locales['Title for trackbacks count:'] = 'Titre pour le nombre de rétroliens :';
|
|
||||||
L10n::$locales['Trackbacks:'] = 'Rétroliens :';
|
|
||||||
L10n::$locales['Show tags count'] = 'Afficher le nombre de mots-clés';
|
|
||||||
L10n::$locales['Title for tags count:'] = 'Titre pour le nombre de mots-clés :';
|
|
||||||
L10n::$locales['Tags:'] = 'Mots-clés :';
|
|
||||||
L10n::$locales['Show users count'] = 'Afficher le nombre d\'auteurs';
|
|
||||||
L10n::$locales['Title for users count:'] = 'Titre pour le nombre d\'auteurs :';
|
|
||||||
L10n::$locales['Authors:'] = 'Auteurs :';
|
|
|
@ -1,41 +0,0 @@
|
||||||
<?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 dcCore;
|
|
||||||
use dcNsProcess;
|
|
||||||
|
|
||||||
class Backend extends dcNsProcess
|
|
||||||
{
|
|
||||||
public static function init(): bool
|
|
||||||
{
|
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function process(): bool
|
|
||||||
{
|
|
||||||
if (!static::$init) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
|
||||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
<?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 dcCore;
|
|
||||||
use dcNsProcess;
|
|
||||||
|
|
||||||
class Frontend extends dcNsProcess
|
|
||||||
{
|
|
||||||
public static function init(): bool
|
|
||||||
{
|
|
||||||
static::$init = true;
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function process(): bool
|
|
||||||
{
|
|
||||||
if (!static::$init) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
|
||||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
263
src/Widgets.php
263
src/Widgets.php
|
@ -1,263 +0,0 @@
|
||||||
<?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 dcCore;
|
|
||||||
use dcMeta;
|
|
||||||
use Dotclear\Helper\Html\Html;
|
|
||||||
use Dotclear\Plugin\widgets\WidgetsStack;
|
|
||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
|
||||||
|
|
||||||
class Widgets
|
|
||||||
{
|
|
||||||
public static function initWidgets(WidgetsStack $w): void
|
|
||||||
{
|
|
||||||
$w
|
|
||||||
->create(
|
|
||||||
'myblognumbers',
|
|
||||||
__('My blog numbers'),
|
|
||||||
[self::class, 'frontendWidget'],
|
|
||||||
null,
|
|
||||||
__('Show some figures of your blog')
|
|
||||||
)
|
|
||||||
->addTitle(__('My blog numbers'))
|
|
||||||
|
|
||||||
# Entry
|
|
||||||
->setting(
|
|
||||||
'entry_show',
|
|
||||||
__('Show entries count'),
|
|
||||||
1,
|
|
||||||
'check'
|
|
||||||
)
|
|
||||||
->setting(
|
|
||||||
'entry_title',
|
|
||||||
__('Title for entries count:'),
|
|
||||||
__('Entries:'),
|
|
||||||
'text'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Cat
|
|
||||||
->setting(
|
|
||||||
'cat_show',
|
|
||||||
__('Show categories count'),
|
|
||||||
1,
|
|
||||||
'check'
|
|
||||||
)
|
|
||||||
->setting(
|
|
||||||
'cat_title',
|
|
||||||
__('Title for categories count:'),
|
|
||||||
__('Categories:'),
|
|
||||||
'text'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Comment
|
|
||||||
->setting(
|
|
||||||
'comment_show',
|
|
||||||
__('Show comments count'),
|
|
||||||
1,
|
|
||||||
'check'
|
|
||||||
)
|
|
||||||
->setting(
|
|
||||||
'comment_title',
|
|
||||||
__('Title for comments count:'),
|
|
||||||
__('Comments:'),
|
|
||||||
'text'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Trackback
|
|
||||||
->setting(
|
|
||||||
'trackback_show',
|
|
||||||
__('Show trackbacks count'),
|
|
||||||
1,
|
|
||||||
'check'
|
|
||||||
)
|
|
||||||
->setting(
|
|
||||||
'trackback_title',
|
|
||||||
__('Title for trackbacks count:'),
|
|
||||||
__('Trackbacks:'),
|
|
||||||
'text'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (dcCore::app()->plugins->moduleExists('tags')) {
|
|
||||||
# Tag
|
|
||||||
$w->myblognumbers
|
|
||||||
->setting(
|
|
||||||
'tag_show',
|
|
||||||
__('Show tags count'),
|
|
||||||
1,
|
|
||||||
'check'
|
|
||||||
)
|
|
||||||
->setting(
|
|
||||||
'tag_title',
|
|
||||||
__('Title for tags count:'),
|
|
||||||
__('Tags:'),
|
|
||||||
'text'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Users (that post)
|
|
||||||
$w->myblognumbers
|
|
||||||
->setting(
|
|
||||||
'user_show',
|
|
||||||
__('Show users count'),
|
|
||||||
1,
|
|
||||||
'check'
|
|
||||||
)
|
|
||||||
->setting(
|
|
||||||
'user_title',
|
|
||||||
__('Title for users count:'),
|
|
||||||
__('Authors:'),
|
|
||||||
'text'
|
|
||||||
);
|
|
||||||
|
|
||||||
# --BEHAVIOR-- myBlogNumbersWidgetInit
|
|
||||||
dcCore::app()->callBehavior('myBlogNumbersWidgetInit', $w);
|
|
||||||
|
|
||||||
# widget option - page to show on
|
|
||||||
$w->myblognumbers
|
|
||||||
->addHomeOnly()
|
|
||||||
->addContentOnly()
|
|
||||||
->addClass()
|
|
||||||
->addOffline();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function frontendWidget(WidgetsElement $w): string
|
|
||||||
{
|
|
||||||
if (is_null(dcCore::app()->blog) || $w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = $addons = '';
|
|
||||||
$s_line = '<li>%s%s</li>';
|
|
||||||
$s_title = '<strong>%s</strong> ';
|
|
||||||
|
|
||||||
# Entry
|
|
||||||
if ($w->entry_show) {
|
|
||||||
$title = $w->entry_title ?
|
|
||||||
sprintf($s_title, Html::escapeHTML($w->entry_title)) : '';
|
|
||||||
|
|
||||||
$count = (int) dcCore::app()->blog->getPosts([], true)->f(0);
|
|
||||||
|
|
||||||
$text = $count == 0 ?
|
|
||||||
sprintf(__('no entries'), $count) :
|
|
||||||
sprintf(__('one entry', '%s entries', $count), $count);
|
|
||||||
|
|
||||||
$content .= sprintf($s_line, $title, $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Cat
|
|
||||||
if ($w->cat_show) {
|
|
||||||
$title = $w->cat_title ?
|
|
||||||
sprintf($s_title, Html::escapeHTML($w->cat_title)) : '';
|
|
||||||
|
|
||||||
$count = dcCore::app()->blog->getCategories([])->count();
|
|
||||||
|
|
||||||
$text = $count == 0 ?
|
|
||||||
sprintf(__('no categories'), $count) :
|
|
||||||
sprintf(__('one category', '%s categories', $count), $count);
|
|
||||||
|
|
||||||
$content .= sprintf($s_line, $title, $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Comment
|
|
||||||
if ($w->comment_show) {
|
|
||||||
$title = $w->comment_title ?
|
|
||||||
sprintf($s_title, Html::escapeHTML($w->comment_title)) : '';
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
'post_type' => 'post',
|
|
||||||
'comment_status' => 1,
|
|
||||||
'comment_trackback' => 0,
|
|
||||||
];
|
|
||||||
$count = (int) dcCore::app()->blog->getComments($params, true)->f(0);
|
|
||||||
|
|
||||||
$text = $count == 0 ?
|
|
||||||
sprintf(__('no comments'), $count) :
|
|
||||||
sprintf(__('one comment', '%s comments', $count), $count);
|
|
||||||
|
|
||||||
$content .= sprintf($s_line, $title, $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Trackback
|
|
||||||
if ($w->trackback_show) {
|
|
||||||
$title = $w->trackback_title ?
|
|
||||||
sprintf($s_title, Html::escapeHTML($w->trackback_title)) : '';
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
'post_type' => 'post',
|
|
||||||
'comment_status' => 1,
|
|
||||||
'comment_trackback' => 1,
|
|
||||||
];
|
|
||||||
$count = (int) dcCore::app()->blog->getComments($params, true)->f(0);
|
|
||||||
|
|
||||||
$text = $count == 0 ?
|
|
||||||
sprintf(__('no trackbacks'), $count) :
|
|
||||||
sprintf(__('one trackback', '%s trackbacks', $count), $count);
|
|
||||||
|
|
||||||
$content .= sprintf($s_line, $title, $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Tag
|
|
||||||
if (dcCore::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(
|
|
||||||
'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 ' .
|
|
||||||
"WHERE M.meta_type='tag' " .
|
|
||||||
"AND P.blog_id='" . dcCore::app()->blog->id . "' "
|
|
||||||
)->f(0);
|
|
||||||
|
|
||||||
$text = $count == 0 ?
|
|
||||||
sprintf(__('no tags'), $count) :
|
|
||||||
sprintf(__('one tag', '%s tags', $count), $count);
|
|
||||||
|
|
||||||
$content .= sprintf($s_line, $title, $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
# User (that post)
|
|
||||||
if ($w->user_show) {
|
|
||||||
$title = $w->user_title ?
|
|
||||||
sprintf($s_title, Html::escapeHTML($w->user_title)) : '';
|
|
||||||
|
|
||||||
$count = dcCore::app()->blog->getPostsUsers('post')->count();
|
|
||||||
|
|
||||||
$text = $count == 0 ?
|
|
||||||
sprintf(__('no author'), $count) :
|
|
||||||
sprintf(__('one author', '%s authors', $count), $count);
|
|
||||||
|
|
||||||
$content .= sprintf($s_line, $title, $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
# --BEHAVIOR-- myBlogNumbersWidgetParse
|
|
||||||
$addons = dcCore::app()->callBehavior('myBlogNumbersWidgetParse', $w);
|
|
||||||
|
|
||||||
# Nothing to display
|
|
||||||
if (!$content && !$addons) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
# Display
|
|
||||||
return $w->renderDiv(
|
|
||||||
(bool) $w->content_only,
|
|
||||||
'myblognumbers ' . $w->class,
|
|
||||||
'',
|
|
||||||
($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
|
|
||||||
sprintf('<ul>%s</ul>', $content . $addons)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue