From ff511566f87ac7e7b22caa23e3530d085cca44c8 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Fri, 27 Aug 2021 18:24:02 +0200 Subject: [PATCH] cleanup 2021 --- CHANGELOG => CHANGELOG.md | 5 + LICENSE | 23 ++-- README.md | 36 +++++- _admin.php | 7 +- _define.php | 32 +++--- _public.php | 209 +++++++++++++++++------------------ _widgets.php | 227 +++++++++++++++++--------------------- dcstore.xml | 13 +++ 8 files changed, 286 insertions(+), 266 deletions(-) rename CHANGELOG => CHANGELOG.md (81%) create mode 100644 dcstore.xml diff --git a/CHANGELOG b/CHANGELOG.md similarity index 81% rename from CHANGELOG rename to CHANGELOG.md index 788a4f3..00b605b 100644 --- a/CHANGELOG +++ b/CHANGELOG.md @@ -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 diff --git a/LICENSE b/LICENSE index 8cdb845..d511905 100644 --- a/LICENSE +++ b/LICENSE @@ -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., + 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} + + Copyright (C) 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 + , 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. - diff --git a/README.md b/README.md index 4ec14f9..687453e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/_admin.php b/_admin.php index ab154d3..9fe9bd4 100644 --- a/_admin.php +++ b/_admin.php @@ -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'; \ No newline at end of file +require dirname(__FILE__) . '/_widgets.php'; \ No newline at end of file diff --git a/_define.php b/_define.php index 5386e10..3ad5f1b 100644 --- a/_define.php +++ b/_define.php @@ -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' + ] ); \ No newline at end of file diff --git a/_public.php b/_public.php index 9e01123..621eb23 100644 --- a/_public.php +++ b/_public.php @@ -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 = '
  • %s%s
  • '; - $s_title = '%s '; + $content = $addons = ''; + $s_line = '
  • %s%s
  • '; + $s_title = '%s '; - 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)) : ''). - '
      '.$content.$addons.'
    '; - - 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('
      %s
    ', $content . $addons) + ); } \ No newline at end of file diff --git a/_widgets.php b/_widgets.php index 1422ae3..63001e6 100644 --- a/_widgets.php +++ b/_widgets.php @@ -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(); } \ No newline at end of file diff --git a/dcstore.xml b/dcstore.xml new file mode 100644 index 0000000..d3c6fe7 --- /dev/null +++ b/dcstore.xml @@ -0,0 +1,13 @@ + + +myBlogNumbers +2021.08.27 +Jean-Christian Denis, Pierre Van Glabeke +Show some figures of your blog +https://github.com/JcDenis/myBlogNumbers/releases/download/v2021.08.27/plugin-myBlogNumbers.zip +2.19 +http://plugins.dotaddict.org/dc2/details/myBlogNumbers + +http://forum.dotclear.org/viewtopic.php?id=40934 + + \ No newline at end of file