cleanup 2021

This commit is contained in:
Jean-Christian 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

View file

@ -1,7 +1,7 @@
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.
@ -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",
/* Version */
'2015.04.23',
array(
'permissions' => 'usage,contentadmin', 'permissions' => 'usage,contentadmin',
'type' => 'plugin', 'type' => 'plugin',
'dc_min' => '2.7', 'dc_min' => '2.19',
'support' => 'http://forum.dotclear.org/viewtopic.php?id=40934', 'support' => 'http://forum.dotclear.org/viewtopic.php?id=40934',
'details' => 'http://plugins.dotaddict.org/dc2/details/myBlogNumbers' '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. # 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,11 +12,10 @@
# -- 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)
{ {
@ -26,14 +25,13 @@ function myBlogNumbersWidgetPublic($w)
$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
@ -41,7 +39,7 @@ function myBlogNumbersWidgetPublic($w)
$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) :
@ -55,7 +53,7 @@ function myBlogNumbersWidgetPublic($w)
$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) :
@ -69,11 +67,11 @@ function myBlogNumbersWidgetPublic($w)
$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 ?
@ -88,11 +86,11 @@ function myBlogNumbersWidgetPublic($w)
$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 ?
@ -108,11 +106,11 @@ function myBlogNumbersWidgetPublic($w)
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 ?
@ -141,14 +139,15 @@ function myBlogNumbersWidgetPublic($w)
# Nothing to display # Nothing to display
if (!$content && !$addons) { if (!$content && !$addons) {
return null; return null;
} }
# Display # Display
$res = return $w->renderDiv(
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''). $w->content_only,
'<ul>'.$content.$addons.'</ul>'; 'myblognumbers ' . $w->class,
'',
return $w->renderDiv($w->content_only,'myblognumbers '.$w->class,'',$res); ($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. # 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,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
@ -22,70 +21,66 @@ function myBlogNumbersWidgetAdmin($w)
{ {
global $core; global $core;
$w->create( $w
->create(
'myblognumbers', 'myblognumbers',
__('My blog numbers'), __('My blog numbers'),
'myBlogNumbersWidgetPublic', 'myBlogNumbersWidgetPublic',
null, null,
__('Show some figures of your blog') __('Show some figures of your blog')
); )
$w->myblognumbers->setting( ->addTitle(__('My blog numbers'))
'title',
__('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:'),
@ -94,13 +89,14 @@ function myBlogNumbersWidgetAdmin($w)
if ($core->plugins->moduleExists('tags')) { if ($core->plugins->moduleExists('tags')) {
# Tag # Tag
$w->myblognumbers->setting( $w->myblognumbers
->setting(
'tag_show', 'tag_show',
__('Show tags count'), __('Show tags count'),
1, 1,
'check' 'check'
); )
$w->myblognumbers->setting( ->setting(
'tag_title', 'tag_title',
__('Title for tags count:'), __('Title for tags count:'),
__('Tags:'), __('Tags:'),
@ -109,13 +105,14 @@ function myBlogNumbersWidgetAdmin($w)
} }
# Users (that post) # Users (that post)
$w->myblognumbers->setting( $w->myblognumbers
->setting(
'user_show', 'user_show',
__('Show users count'), __('Show users count'),
1, 1,
'check' 'check'
); )
$w->myblognumbers->setting( ->setting(
'user_title', 'user_title',
__('Title for users count:'), __('Title for users count:'),
__('Authors:'), __('Authors:'),
@ -126,29 +123,9 @@ function myBlogNumbersWidgetAdmin($w)
$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>