cleanup 2021

This commit is contained in:
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 myBlogNumbers 2015.04.23 - Pierre Van Glabeke
* modif url support * modif url support

23
LICENSE
View File

@ -1,12 +1,12 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 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 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
Preamble Preamble
The licenses for most software are designed to take away your The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public 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 The precise terms and conditions for copying, distribution and
modification follow. modification follow.
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains 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 preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally. 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 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 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 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. 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 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 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 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. the "copyright" line and a pointer to where the full notice is found.
{description} <one line to give the program's name and a brief idea of what it does.>
Copyright (C) {year} {fullname} Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify 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 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 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker. `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 Ty Coon, President of Vice
This General Public License does not permit incorporating your program into 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 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 library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. Public License instead of this License.

View File

@ -1,2 +1,34 @@
# myBlogNumbers # README
Afficher quelques chiffres à propos de votre blog
## 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. # 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. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
@ -12,8 +12,7 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { 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. # 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. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
@ -12,24 +12,20 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null;
return null;
} }
$this->registerModule( $this->registerModule(
/* Name */ 'myBlogNumbers',
"myBlogNumbers", 'Show some figures of your blog',
/* Description*/ 'Jean-Christian Denis, Pierre Van Glabeke',
"Show some figures of your blog", '2021.08.27',
/* Author */ [
"Jean-Christian Denis, Pierre Van Glabeke", 'permissions' => 'usage,contentadmin',
/* Version */ 'type' => 'plugin',
'2015.04.23', 'dc_min' => '2.19',
array( 'support' => 'http://forum.dotclear.org/viewtopic.php?id=40934',
'permissions' => 'usage,contentadmin', 'details' => 'http://plugins.dotaddict.org/dc2/details/myBlogNumbers',
'type' => 'plugin', 'repository' => 'https://raw.githubusercontent.com/JcDenis/myBlogNumbers/master/dcstore.xml'
'dc_min' => '2.7', ]
'support' => 'http://forum.dotclear.org/viewtopic.php?id=40934',
'details' => 'http://plugins.dotaddict.org/dc2/details/myBlogNumbers'
)
); );

View File

@ -3,7 +3,7 @@
# #
# This file is part of myBlogNumbers, a plugin for Dotclear 2. # 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. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
@ -12,143 +12,142 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null;
return null;
} }
require dirname(__FILE__).'/_widgets.php'; require dirname(__FILE__) . '/_widgets.php';
function myBlogNumbersWidgetPublic($w) function myBlogNumbersWidgetPublic($w)
{ {
global $core; 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;
}
# Home only if (($w->homeonly == 1 && !$core->url->isHome($core->url->type))
if ($w->homeonly == 1 && $core->url->type != 'default' || ($w->homeonly == 2 && $core->url->isHome($core->url->type))) {
|| $w->homeonly == 2 && $core->url->type == 'default' return null;
) { }
return;
}
# 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(array(), true)->f(0); $count = $core->blog->getPosts([], true)->f(0);
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no entries'), $count) : sprintf(__('no entries'), $count) :
sprintf(__('one entry', '%s entries', $count), $count); sprintf(__('one entry', '%s entries', $count), $count);
$content .= sprintf($s_line, $title, $text); $content .= sprintf($s_line, $title, $text);
} }
# 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(array())->count(); $count = $core->blog->getCategories([])->count();
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no categories'), $count) : sprintf(__('no categories'), $count) :
sprintf(__('one category', '%s categories', $count), $count); sprintf(__('one category', '%s categories', $count), $count);
$content .= sprintf($s_line, $title, $text); $content .= sprintf($s_line, $title, $text);
} }
# 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 = array( $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 = $core->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 = array( $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 = $core->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 ($core->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 = $core->con->select(
'SELECT count(M.meta_id) AS count '. 'SELECT count(M.meta_id) AS count ' .
'FROM '.$core->prefix.'meta M '. 'FROM ' . $core->prefix . 'meta M ' .
'LEFT JOIN '.$core->prefix.'post P ON P.post_id=M.post_id '. 'LEFT JOIN ' . $core->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='" . $core->blog->id . "' "
)->f(0); )->f(0);
$text = $count == 0 ? $text = $count == 0 ?
sprintf(__('no tags'), $count) : sprintf(__('no tags'), $count) :
sprintf(__('one tag', '%s tags', $count), $count); sprintf(__('one tag', '%s tags', $count), $count);
$content .= sprintf($s_line, $title, $text); $content .= sprintf($s_line, $title, $text);
} }
# 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 = $core->blog->getPostsUsers(array(),true)->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 = $core->callBehavior('myBlogNumbersWidgetParse', $core, $w);
# Nothing to display # Nothing to display
if (!$content && !$addons) { if (!$content && !$addons) {
return null;
}
return null; # Display
} return $w->renderDiv(
$w->content_only,
# Display 'myblognumbers ' . $w->class,
$res = '',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''). ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
'<ul>'.$content.$addons.'</ul>'; sprintf('<ul>%s</ul>', $content . $addons)
);
return $w->renderDiv($w->content_only,'myblognumbers '.$w->class,'',$res);
} }

View File

@ -3,7 +3,7 @@
# #
# This file is part of myBlogNumbers, a plugin for Dotclear 2. # 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. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
@ -12,143 +12,120 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null;
return null;
} }
$core->addBehavior('initWidgets', 'myBlogNumbersWidgetAdmin'); $core->addBehavior('initWidgets', 'myBlogNumbersWidgetAdmin');
function myBlogNumbersWidgetAdmin($w) function myBlogNumbersWidgetAdmin($w)
{ {
global $core; global $core;
$w->create( $w
'myblognumbers', ->create(
__('My blog numbers'), 'myblognumbers',
'myBlogNumbersWidgetPublic', __('My blog numbers'),
null, 'myBlogNumbersWidgetPublic',
__('Show some figures of your blog') null,
); __('Show some figures of your blog')
$w->myblognumbers->setting( )
'title', ->addTitle(__('My blog numbers'))
__('Title:'),
__('My blog numbers'),
'text'
);
# Entry # Entry
$w->myblognumbers->setting( ->setting(
'entry_show', 'entry_show',
__('Show entries count'), __('Show entries count'),
1, 1,
'check' 'check'
); )
$w->myblognumbers->setting( ->setting(
'entry_title', 'entry_title',
__('Title for entries count:'), __('Title for entries count:'),
__('Entries:'), __('Entries:'),
'text' 'text'
); )
# Cat # Cat
$w->myblognumbers->setting( ->setting(
'cat_show', 'cat_show',
__('Show categories count'), __('Show categories count'),
1, 1,
'check' 'check'
); )
$w->myblognumbers->setting( ->setting(
'cat_title', 'cat_title',
__('Title for categories count:'), __('Title for categories count:'),
__('Categories:'), __('Categories:'),
'text' 'text'
); )
# Comment # Comment
$w->myblognumbers->setting( ->setting(
'comment_show', 'comment_show',
__('Show comments count'), __('Show comments count'),
1, 1,
'check' 'check'
); )
$w->myblognumbers->setting( ->setting(
'comment_title', 'comment_title',
__('Title for comments count:'), __('Title for comments count:'),
__('Comments:'), __('Comments:'),
'text' 'text'
); )
# Trackback # Trackback
$w->myblognumbers->setting( ->setting(
'trackback_show', 'trackback_show',
__('Show trackbacks count'), __('Show trackbacks count'),
1, 1,
'check' 'check'
); )
$w->myblognumbers->setting( ->setting(
'trackback_title', 'trackback_title',
__('Title for trackbacks count:'), __('Title for trackbacks count:'),
__('Trackbacks:'), __('Trackbacks:'),
'text' 'text'
); );
if ($core->plugins->moduleExists('tags')) { if ($core->plugins->moduleExists('tags')) {
# Tag # Tag
$w->myblognumbers->setting( $w->myblognumbers
'tag_show', ->setting(
__('Show tags count'), 'tag_show',
1, __('Show tags count'),
'check' 1,
); 'check'
$w->myblognumbers->setting( )
'tag_title', ->setting(
__('Title for tags count:'), 'tag_title',
__('Tags:'), __('Title for tags count:'),
'text' __('Tags:'),
); 'text'
} );
}
# Users (that post) # Users (that post)
$w->myblognumbers->setting( $w->myblognumbers
'user_show', ->setting(
__('Show users count'), 'user_show',
1, __('Show users count'),
'check' 1,
); 'check'
$w->myblognumbers->setting( )
'user_title', ->setting(
__('Title for users count:'), 'user_title',
__('Authors:'), __('Title for users count:'),
'text' __('Authors:'),
); 'text'
);
# --BEHAVIOR-- myBlogNumbersWidgetInit # --BEHAVIOR-- myBlogNumbersWidgetInit
$core->callBehavior('myBlogNumbersWidgetInit',$w); $core->callBehavior('myBlogNumbersWidgetInit',$w);
# widget option - page to show on # widget option - page to show on
$w->myblognumbers->setting( $w->myblognumbers
'homeonly', ->addHomeOnly()
__('Display on:'), ->addContentOnly()
0, ->addClass()
'combo', ->addOffline();
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');
} }

13
dcstore.xml Normal file
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>