prepare to DC 2.24

master
Jean-Christian Paul Denis 2022-11-14 23:20:46 +01:00
parent 54a7c5905a
commit 5985a8400d
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
4 changed files with 64 additions and 69 deletions

View File

@ -1,18 +1,17 @@
<?php <?php
/** /**
* @brief myBlogNumbers, a plugin for Dotclear 2 * @brief myBlogNumbers, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * @author Jean-Christian Denis, Pierre Van Glabeke
* *
* @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_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
require dirname(__FILE__) . '/_widgets.php'; require __DIR__ . '/_widgets.php';

View File

@ -1,16 +1,15 @@
<?php <?php
/** /**
* @brief myBlogNumbers, a plugin for Dotclear 2 * @brief myBlogNumbers, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * @author Jean-Christian Denis, Pierre Van Glabeke
* *
* @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;
} }
@ -19,13 +18,16 @@ $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',
'2021.09.017', '2022.11.12',
[ [
'requires' => [['core', '2.19']], 'requires' => [['core', '2.24']],
'permissions' => 'usage,contentadmin', 'permissions' => dcCore::app()->auth->makePermissions([
'type' => 'plugin', dcAuth::PERMISSION_USAGE,
'support' => 'http://forum.dotclear.org/viewtopic.php?id=40934', dcAuth::PERMISSION_CONTENT_ADMIN,
'details' => 'http://plugins.dotaddict.org/dc2/details/myBlogNumbers', ]),
'repository' => 'https://raw.githubusercontent.com/JcDenis/myBlogNumbers/master/dcstore.xml' 'type' => 'plugin',
'support' => 'http://forum.dotclear.org/viewtopic.php?id=40934',
'details' => 'http://plugins.dotaddict.org/dc2/details/myBlogNumbers',
'repository' => 'https://raw.githubusercontent.com/JcDenis/myBlogNumbers/master/dcstore.xml',
] ]
); );

View File

@ -1,45 +1,42 @@
<?php <?php
/** /**
* @brief myBlogNumbers, a plugin for Dotclear 2 * @brief myBlogNumbers, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * @author Jean-Christian Denis, Pierre Van Glabeke
* *
* @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;
} }
require dirname(__FILE__) . '/_widgets.php'; require __DIR__ . '/_widgets.php';
function myBlogNumbersWidgetPublic($w) function myBlogNumbersWidgetPublic($w)
{ {
global $core;
$content = $addons = ''; $content = $addons = '';
$s_line = '<li>%s%s</li>'; $s_line = '<li>%s%s</li>';
$s_title = '<strong>%s</strong> '; $s_title = '<strong>%s</strong> ';
if ($w->offline) { if ($w->offline) {
return; return;
} }
if (($w->homeonly == 1 && !$core->url->isHome($core->url->type)) if (($w->homeonly == 1 && !dcCore::app()->url->isHome(dcCore::app()->url->type))
|| ($w->homeonly == 2 && $core->url->isHome($core->url->type))) { || ($w->homeonly == 2 && dcCore::app()->url->isHome(dcCore::app()->url->type))) {
return null; return null;
} }
# Entry # Entry
if ($w->entry_show) { if ($w->entry_show) {
$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 = $core->blog->getPosts([], true)->f(0); $count = dcCore::app()->blog->getPosts([], true)->f(0);
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no entries'), $count) : sprintf(__('no entries'), $count) :
@ -50,10 +47,10 @@ function myBlogNumbersWidgetPublic($w)
# Cat # Cat
if ($w->cat_show) { if ($w->cat_show) {
$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 = $core->blog->getCategories([])->count(); $count = dcCore::app()->blog->getCategories([])->count();
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no categories'), $count) : sprintf(__('no categories'), $count) :
@ -64,53 +61,53 @@ function myBlogNumbersWidgetPublic($w)
# Comment # Comment
if ($w->comment_show) { if ($w->comment_show) {
$title = $w->comment_title ? $title = $w->comment_title ?
sprintf($s_title, html::escapeHTML($w->comment_title)) : ''; sprintf($s_title, html::escapeHTML($w->comment_title)) : '';
$params = [ $params = [
'post_type' => 'post', 'post_type' => 'post',
'comment_status' => 1, 'comment_status' => 1,
'comment_trackback' => 0 'comment_trackback' => 0,
]; ];
$count = $core->blog->getComments($params, true)->f(0); $count = dcCore::app()->blog->getComments($params, true)->f(0);
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no comments'),$count) : sprintf(__('no comments'), $count) :
sprintf(__('one comment', '%s comments', $count), $count); sprintf(__('one comment', '%s comments', $count), $count);
$content .= sprintf($s_line,$title,$text); $content .= sprintf($s_line, $title, $text);
} }
# Trackback # Trackback
if ($w->trackback_show) { if ($w->trackback_show) {
$title = $w->trackback_title ? $title = $w->trackback_title ?
sprintf($s_title, html::escapeHTML($w->trackback_title)) : ''; sprintf($s_title, html::escapeHTML($w->trackback_title)) : '';
$params = [ $params = [
'post_type' => 'post', 'post_type' => 'post',
'comment_status' => 1, 'comment_status' => 1,
'comment_trackback' => 1 'comment_trackback' => 1,
]; ];
$count = $core->blog->getComments($params, true)->f(0); $count = dcCore::app()->blog->getComments($params, true)->f(0);
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no trackbacks'),$count) : sprintf(__('no trackbacks'), $count) :
sprintf(__('one trackback', '%s trackbacks', $count), $count); sprintf(__('one trackback', '%s trackbacks', $count), $count);
$content .= sprintf($s_line,$title,$text); $content .= sprintf($s_line, $title, $text);
} }
# Tag # Tag
if ($core->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 = $core->con->select( $count = dcCore::app()->con->select(
'SELECT count(M.meta_id) AS count ' . 'SELECT count(M.meta_id) AS count ' .
'FROM ' . $core->prefix . 'meta M ' . 'FROM ' . dcCore::app()->prefix . 'meta M ' .
'LEFT JOIN ' . $core->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='" . $core->blog->id . "' " "AND P.blog_id='" . dcCore::app()->blog->id . "' "
)->f(0); )->f(0);
$text = $count == 0 ? $text = $count == 0 ?
@ -122,20 +119,20 @@ function myBlogNumbersWidgetPublic($w)
# User (that post) # User (that post)
if ($w->user_show) { if ($w->user_show) {
$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 = $core->blog->getPostsUsers(array(),true)->count(); $count = dcCore::app()->blog->getPostsUsers('post')->count();
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no author'), $count) : sprintf(__('no author'), $count) :
sprintf(__('one author', '%s authors', $count), $count); sprintf(__('one author', '%s authors', $count), $count);
$content .= sprintf($s_line,$title,$text); $content .= sprintf($s_line, $title, $text);
} }
# --BEHAVIOR-- myBlogNumbersWidgetParse # --BEHAVIOR-- myBlogNumbersWidgetParse
$addons = $core->callBehavior('myBlogNumbersWidgetParse', $core, $w); $addons = dcCore::app()->callBehavior('myBlogNumbersWidgetParse', $w);
# Nothing to display # Nothing to display
if (!$content && !$addons) { if (!$content && !$addons) {
@ -147,7 +144,7 @@ function myBlogNumbersWidgetPublic($w)
$w->content_only, $w->content_only,
'myblognumbers ' . $w->class, 'myblognumbers ' . $w->class,
'', '',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
sprintf('<ul>%s</ul>', $content . $addons) sprintf('<ul>%s</ul>', $content . $addons)
); );
} }

View File

@ -1,26 +1,23 @@
<?php <?php
/** /**
* @brief myBlogNumbers, a plugin for Dotclear 2 * @brief myBlogNumbers, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * @author Jean-Christian Denis, Pierre Van Glabeke
* *
* @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;
} }
$core->addBehavior('initWidgets', 'myBlogNumbersWidgetAdmin'); dcCore::app()->addBehavior('initWidgets', 'myBlogNumbersWidgetAdmin');
function myBlogNumbersWidgetAdmin($w) function myBlogNumbersWidgetAdmin($w)
{ {
global $core;
$w $w
->create( ->create(
'myblognumbers', 'myblognumbers',
@ -87,7 +84,7 @@ function myBlogNumbersWidgetAdmin($w)
'text' 'text'
); );
if ($core->plugins->moduleExists('tags')) { if (dcCore::app()->plugins->moduleExists('tags')) {
# Tag # Tag
$w->myblognumbers $w->myblognumbers
->setting( ->setting(
@ -120,7 +117,7 @@ function myBlogNumbersWidgetAdmin($w)
); );
# --BEHAVIOR-- myBlogNumbersWidgetInit # --BEHAVIOR-- myBlogNumbersWidgetInit
$core->callBehavior('myBlogNumbersWidgetInit',$w); dcCore::app()->callBehavior('myBlogNumbersWidgetInit', $w);
# widget option - page to show on # widget option - page to show on
$w->myblognumbers $w->myblognumbers
@ -128,4 +125,4 @@ function myBlogNumbersWidgetAdmin($w)
->addContentOnly() ->addContentOnly()
->addClass() ->addClass()
->addOffline(); ->addOffline();
} }