cleanup 2021

master
Jean-Christian Paul Denis 2021-08-27 18:24:02 +02:00
parent 4ae72bf866
commit ff511566f8
8 changed files with 286 additions and 266 deletions

View File

@ -1,3 +1,8 @@
myBlogNumbers 2021.08.27
- cleanup (PSR2, short array, ...)
- enhance widget style
- update license
myBlogNumbers 2015.04.23 - Pierre Van Glabeke
* modif url support

23
LICENSE
View File

@ -1,12 +1,12 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -329,7 +329,7 @@ necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
@ -337,4 +337,3 @@ proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@ -1,2 +1,34 @@
# myBlogNumbers
Afficher quelques chiffres à propos de votre blog
# README
## WHAT IS MYBLOGNUMBERS ?
"My Blog Numbers" is a plugin for the open-source
web publishing software called Dotclear.
Simply show visitors some statistics about current blog.
## REQUIREMENTS
myBlogNumbers requires:
* permissions to manage widgets
* Dotclear 2.19
## USAGE
First install myBlogNumbers, manualy from a zip package or from
Dotaddict repository. (See Dotclear's documentation to know how do this)
Add and configure "My Blog Numbers" from widgets manager.
You can add a dashboard item by enable it from your dashboard preferences.
## MORE
* License : GNU GPL v2
* Source & contribution : [GitHub Page](https://github.com/JcDenis/myBlogNumbers)
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/myBlogNumbers)
## CONTRIBUTORS
* Jean-Chirstian Denis
* Pierre Van Glabeke

View File

@ -3,7 +3,7 @@
#
# This file is part of myBlogNumbers, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -12,8 +12,7 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
}
require dirname(__FILE__).'/_widgets.php';
require dirname(__FILE__) . '/_widgets.php';

View File

@ -3,7 +3,7 @@
#
# This file is part of myBlogNumbers, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -12,24 +12,20 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
return null;
}
$this->registerModule(
/* Name */
"myBlogNumbers",
/* Description*/
"Show some figures of your blog",
/* Author */
"Jean-Christian Denis, Pierre Van Glabeke",
/* Version */
'2015.04.23',
array(
'permissions' => 'usage,contentadmin',
'type' => 'plugin',
'dc_min' => '2.7',
'support' => 'http://forum.dotclear.org/viewtopic.php?id=40934',
'details' => 'http://plugins.dotaddict.org/dc2/details/myBlogNumbers'
)
'myBlogNumbers',
'Show some figures of your blog',
'Jean-Christian Denis, Pierre Van Glabeke',
'2021.08.27',
[
'permissions' => 'usage,contentadmin',
'type' => 'plugin',
'dc_min' => '2.19',
'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

@ -3,7 +3,7 @@
#
# This file is part of myBlogNumbers, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -12,143 +12,142 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
return null;
}
require dirname(__FILE__).'/_widgets.php';
require dirname(__FILE__) . '/_widgets.php';
function myBlogNumbersWidgetPublic($w)
{
global $core;
global $core;
$content = $addons = '';
$s_line = '<li>%s%s</li>';
$s_title = '<strong>%s</strong> ';
$content = $addons = '';
$s_line = '<li>%s%s</li>';
$s_title = '<strong>%s</strong> ';
if ($w->offline)
return;
if ($w->offline) {
return;
}
# Home only
if ($w->homeonly == 1 && $core->url->type != 'default'
|| $w->homeonly == 2 && $core->url->type == 'default'
) {
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)) : '';
# Entry
if ($w->entry_show) {
$title = $w->entry_title ?
sprintf($s_title, html::escapeHTML($w->entry_title)) : '';
$count = $core->blog->getPosts(array(), true)->f(0);
$count = $core->blog->getPosts([], true)->f(0);
$text = $count == 0 ?
sprintf(__('no entries'), $count) :
sprintf(__('one entry', '%s entries', $count), $count);
$text = $count == 0 ?
sprintf(__('no entries'), $count) :
sprintf(__('one entry', '%s entries', $count), $count);
$content .= sprintf($s_line, $title, $text);
}
$content .= sprintf($s_line, $title, $text);
}
# Cat
if ($w->cat_show) {
$title = $w->cat_title ?
sprintf($s_title, html::escapeHTML($w->cat_title)) : '';
# Cat
if ($w->cat_show) {
$title = $w->cat_title ?
sprintf($s_title, html::escapeHTML($w->cat_title)) : '';
$count = $core->blog->getCategories(array())->count();
$count = $core->blog->getCategories([])->count();
$text = $count == 0 ?
sprintf(__('no categories'), $count) :
sprintf(__('one category', '%s categories', $count), $count);
$text = $count == 0 ?
sprintf(__('no categories'), $count) :
sprintf(__('one category', '%s categories', $count), $count);
$content .= sprintf($s_line, $title, $text);
}
$content .= sprintf($s_line, $title, $text);
}
# Comment
if ($w->comment_show) {
$title = $w->comment_title ?
sprintf($s_title, html::escapeHTML($w->comment_title)) : '';
# Comment
if ($w->comment_show) {
$title = $w->comment_title ?
sprintf($s_title, html::escapeHTML($w->comment_title)) : '';
$params = array(
'post_type' => 'post',
'comment_status' => 1,
'comment_trackback' => 0
);
$count = $core->blog->getComments($params, true)->f(0);
$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);
$text = $count == 0 ?
sprintf(__('no comments'),$count) :
sprintf(__('one comment', '%s comments', $count), $count);
$content .= sprintf($s_line,$title,$text);
}
$content .= sprintf($s_line,$title,$text);
}
# Trackback
if ($w->trackback_show) {
$title = $w->trackback_title ?
sprintf($s_title, html::escapeHTML($w->trackback_title)) : '';
# Trackback
if ($w->trackback_show) {
$title = $w->trackback_title ?
sprintf($s_title, html::escapeHTML($w->trackback_title)) : '';
$params = array(
'post_type' => 'post',
'comment_status' => 1,
'comment_trackback' => 1
);
$count = $core->blog->getComments($params, true)->f(0);
$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);
$text = $count == 0 ?
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) {
$title = $w->tag_title ?
sprintf($s_title,html::escapeHTML($w->tag_title)) : '';
# 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);
$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);
$text = $count == 0 ?
sprintf(__('no tags'), $count) :
sprintf(__('one tag', '%s tags', $count), $count);
$content .= sprintf($s_line, $title, $text);
}
$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)) : '';
# 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();
$count = $core->blog->getPostsUsers(array(),true)->count();
$text = $count == 0 ?
sprintf(__('no author'), $count) :
sprintf(__('one author', '%s authors', $count), $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);
# --BEHAVIOR-- myBlogNumbersWidgetParse
$addons = $core->callBehavior('myBlogNumbersWidgetParse', $core, $w);
# Nothing to display
if (!$content && !$addons) {
# Nothing to display
if (!$content && !$addons) {
return null;
}
return null;
}
# Display
$res =
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'<ul>'.$content.$addons.'</ul>';
return $w->renderDiv($w->content_only,'myblognumbers '.$w->class,'',$res);
# Display
return $w->renderDiv(
$w->content_only,
'myblognumbers ' . $w->class,
'',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
sprintf('<ul>%s</ul>', $content . $addons)
);
}

View File

@ -3,7 +3,7 @@
#
# This file is part of myBlogNumbers, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -12,143 +12,120 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
return null;
}
$core->addBehavior('initWidgets', 'myBlogNumbersWidgetAdmin');
function myBlogNumbersWidgetAdmin($w)
{
global $core;
global $core;
$w->create(
'myblognumbers',
__('My blog numbers'),
'myBlogNumbersWidgetPublic',
null,
__('Show some figures of your blog')
);
$w->myblognumbers->setting(
'title',
__('Title:'),
__('My blog numbers'),
'text'
);
$w
->create(
'myblognumbers',
__('My blog numbers'),
'myBlogNumbersWidgetPublic',
null,
__('Show some figures of your blog')
)
->addTitle(__('My blog numbers'))
# Entry
$w->myblognumbers->setting(
'entry_show',
__('Show entries count'),
1,
'check'
);
$w->myblognumbers->setting(
'entry_title',
__('Title for entries count:'),
__('Entries:'),
'text'
);
# Entry
->setting(
'entry_show',
__('Show entries count'),
1,
'check'
)
->setting(
'entry_title',
__('Title for entries count:'),
__('Entries:'),
'text'
)
# Cat
$w->myblognumbers->setting(
'cat_show',
__('Show categories count'),
1,
'check'
);
$w->myblognumbers->setting(
'cat_title',
__('Title for categories count:'),
__('Categories:'),
'text'
);
# Cat
->setting(
'cat_show',
__('Show categories count'),
1,
'check'
)
->setting(
'cat_title',
__('Title for categories count:'),
__('Categories:'),
'text'
)
# Comment
$w->myblognumbers->setting(
'comment_show',
__('Show comments count'),
1,
'check'
);
$w->myblognumbers->setting(
'comment_title',
__('Title for comments count:'),
__('Comments:'),
'text'
);
# Comment
->setting(
'comment_show',
__('Show comments count'),
1,
'check'
)
->setting(
'comment_title',
__('Title for comments count:'),
__('Comments:'),
'text'
)
# Trackback
$w->myblognumbers->setting(
'trackback_show',
__('Show trackbacks count'),
1,
'check'
);
$w->myblognumbers->setting(
'trackback_title',
__('Title for trackbacks count:'),
__('Trackbacks:'),
'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'
);
$w->myblognumbers->setting(
'tag_title',
__('Title for tags count:'),
__('Tags:'),
'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'
);
$w->myblognumbers->setting(
'user_title',
__('Title for users count:'),
__('Authors:'),
'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);
# --BEHAVIOR-- myBlogNumbersWidgetInit
$core->callBehavior('myBlogNumbersWidgetInit',$w);
# widget option - page to show on
$w->myblognumbers->setting(
'homeonly',
__('Display on:'),
0,
'combo',
array(
__('All pages') => 0,
__('Home page only') => 1,
__('Except on home page') => 2
)
);
# widget option - content only
$w->myblognumbers->setting(
'content_only',
__('Content only'),
0,
'check'
);
# widget option - additionnal CSS
$w->myblognumbers->setting(
'class',
__('CSS class:'),
''
);
$w->myblognumbers->setting('offline',__('Offline'),0,'check');
# widget option - page to show on
$w->myblognumbers
->addHomeOnly()
->addContentOnly()
->addClass()
->addOffline();
}

13
dcstore.xml 100644
View File

@ -0,0 +1,13 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="myBlogNumbers">
<name>myBlogNumbers</name>
<version>2021.08.27</version>
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
<desc>Show some figures of your blog</desc>
<file>https://github.com/JcDenis/myBlogNumbers/releases/download/v2021.08.27/plugin-myBlogNumbers.zip</file>
<da:dcmin>2.19</da:dcmin>
<da:details>http://plugins.dotaddict.org/dc2/details/myBlogNumbers</da:details>
<da:section></da:section>
<da:support>http://forum.dotclear.org/viewtopic.php?id=40934</da:support>
</module>
</modules>