prepare to DC 2.24
This commit is contained in:
parent
54a7c5905a
commit
5985a8400d
@ -10,9 +10,8 @@
|
||||
* @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';
|
||||
require __DIR__ . '/_widgets.php';
|
||||
|
18
_define.php
18
_define.php
@ -10,7 +10,6 @@
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
@ -19,13 +18,16 @@ $this->registerModule(
|
||||
'My blog numbers',
|
||||
'Show some figures of your blog',
|
||||
'Jean-Christian Denis, Pierre Van Glabeke',
|
||||
'2021.09.017',
|
||||
'2022.11.12',
|
||||
[
|
||||
'requires' => [['core', '2.19']],
|
||||
'permissions' => 'usage,contentadmin',
|
||||
'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'
|
||||
'requires' => [['core', '2.24']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_USAGE,
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
'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',
|
||||
]
|
||||
);
|
57
_public.php
57
_public.php
@ -10,27 +10,24 @@
|
||||
* @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';
|
||||
require __DIR__ . '/_widgets.php';
|
||||
|
||||
function myBlogNumbersWidgetPublic($w)
|
||||
{
|
||||
global $core;
|
||||
|
||||
$content = $addons = '';
|
||||
$s_line = '<li>%s%s</li>';
|
||||
$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))) {
|
||||
if (($w->homeonly == 1 && !dcCore::app()->url->isHome(dcCore::app()->url->type))
|
||||
|| ($w->homeonly == 2 && dcCore::app()->url->isHome(dcCore::app()->url->type))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -39,7 +36,7 @@ function myBlogNumbersWidgetPublic($w)
|
||||
$title = $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 ?
|
||||
sprintf(__('no entries'), $count) :
|
||||
@ -53,7 +50,7 @@ function myBlogNumbersWidgetPublic($w)
|
||||
$title = $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 ?
|
||||
sprintf(__('no categories'), $count) :
|
||||
@ -68,17 +65,17 @@ function myBlogNumbersWidgetPublic($w)
|
||||
sprintf($s_title, html::escapeHTML($w->comment_title)) : '';
|
||||
|
||||
$params = [
|
||||
'post_type' => 'post',
|
||||
'comment_status' => 1,
|
||||
'comment_trackback' => 0
|
||||
'post_type' => 'post',
|
||||
'comment_status' => 1,
|
||||
'comment_trackback' => 0,
|
||||
];
|
||||
$count = $core->blog->getComments($params, true)->f(0);
|
||||
$count = dcCore::app()->blog->getComments($params, true)->f(0);
|
||||
|
||||
$text = $count == 0 ?
|
||||
sprintf(__('no comments'),$count) :
|
||||
sprintf(__('no comments'), $count) :
|
||||
sprintf(__('one comment', '%s comments', $count), $count);
|
||||
|
||||
$content .= sprintf($s_line,$title,$text);
|
||||
$content .= sprintf($s_line, $title, $text);
|
||||
}
|
||||
|
||||
# Trackback
|
||||
@ -87,30 +84,30 @@ function myBlogNumbersWidgetPublic($w)
|
||||
sprintf($s_title, html::escapeHTML($w->trackback_title)) : '';
|
||||
|
||||
$params = [
|
||||
'post_type' => 'post',
|
||||
'comment_status' => 1,
|
||||
'comment_trackback' => 1
|
||||
'post_type' => 'post',
|
||||
'comment_status' => 1,
|
||||
'comment_trackback' => 1,
|
||||
];
|
||||
$count = $core->blog->getComments($params, true)->f(0);
|
||||
$count = dcCore::app()->blog->getComments($params, true)->f(0);
|
||||
|
||||
$text = $count == 0 ?
|
||||
sprintf(__('no trackbacks'),$count) :
|
||||
sprintf(__('no trackbacks'), $count) :
|
||||
sprintf(__('one trackback', '%s trackbacks', $count), $count);
|
||||
|
||||
$content .= sprintf($s_line,$title,$text);
|
||||
$content .= sprintf($s_line, $title, $text);
|
||||
}
|
||||
|
||||
# Tag
|
||||
if ($core->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)) : '';
|
||||
sprintf($s_title, html::escapeHTML($w->tag_title)) : '';
|
||||
|
||||
$count = $core->con->select(
|
||||
$count = dcCore::app()->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 ' .
|
||||
'FROM ' . dcCore::app()->prefix . 'meta M ' .
|
||||
'LEFT JOIN ' . dcCore::app()->prefix . 'post P ON P.post_id=M.post_id ' .
|
||||
"WHERE M.meta_type='tag' " .
|
||||
"AND P.blog_id='" . $core->blog->id . "' "
|
||||
"AND P.blog_id='" . dcCore::app()->blog->id . "' "
|
||||
)->f(0);
|
||||
|
||||
$text = $count == 0 ?
|
||||
@ -125,17 +122,17 @@ function myBlogNumbersWidgetPublic($w)
|
||||
$title = $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 ?
|
||||
sprintf(__('no author'), $count) :
|
||||
sprintf(__('one author', '%s authors', $count), $count);
|
||||
|
||||
$content .= sprintf($s_line,$title,$text);
|
||||
$content .= sprintf($s_line, $title, $text);
|
||||
}
|
||||
|
||||
# --BEHAVIOR-- myBlogNumbersWidgetParse
|
||||
$addons = $core->callBehavior('myBlogNumbersWidgetParse', $core, $w);
|
||||
$addons = dcCore::app()->callBehavior('myBlogNumbersWidgetParse', $w);
|
||||
|
||||
# Nothing to display
|
||||
if (!$content && !$addons) {
|
||||
|
@ -10,17 +10,14 @@
|
||||
* @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');
|
||||
dcCore::app()->addBehavior('initWidgets', 'myBlogNumbersWidgetAdmin');
|
||||
|
||||
function myBlogNumbersWidgetAdmin($w)
|
||||
{
|
||||
global $core;
|
||||
|
||||
$w
|
||||
->create(
|
||||
'myblognumbers',
|
||||
@ -87,7 +84,7 @@ function myBlogNumbersWidgetAdmin($w)
|
||||
'text'
|
||||
);
|
||||
|
||||
if ($core->plugins->moduleExists('tags')) {
|
||||
if (dcCore::app()->plugins->moduleExists('tags')) {
|
||||
# Tag
|
||||
$w->myblognumbers
|
||||
->setting(
|
||||
@ -120,7 +117,7 @@ function myBlogNumbersWidgetAdmin($w)
|
||||
);
|
||||
|
||||
# --BEHAVIOR-- myBlogNumbersWidgetInit
|
||||
$core->callBehavior('myBlogNumbersWidgetInit',$w);
|
||||
dcCore::app()->callBehavior('myBlogNumbersWidgetInit', $w);
|
||||
|
||||
# widget option - page to show on
|
||||
$w->myblognumbers
|
||||
|
Loading…
Reference in New Issue
Block a user