This commit is contained in:
brol 2015-04-25 20:37:25 +02:00
parent f9310d9f32
commit d6be467e63
7 changed files with 589 additions and 2 deletions

View file

@ -1,2 +1,22 @@
# topWriter
Classement des plus prolifiques rédacteurs et/ou commentateurs
# README
## WHAT IS POSTINFOWIDGET ?
postInfoWidget "Entry information list" is a plugin for the open-source
web publishing software called Dotclear.
Show entry details in a widget.
## REQUIREMENTS
postInfoWidget requires:
* permissions to manage widgets
* Dotclear 2.6
## USAGE
First install postInfoWidget, manualy from a zip package or from
Dotaddict repository. (See Dotclear's documentation to know how do this)
Add and configure "Entry information list" from widgets manager.

19
_admin.php Normal file
View file

@ -0,0 +1,19 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of topWriter, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 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
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
require dirname(__FILE__).'/_widgets.php';

35
_define.php Normal file
View file

@ -0,0 +1,35 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of topWriter, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 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
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
}
$this->registerModule(
/* Name */
"topWriter",
/* Description*/
"Ranking of the most prolific writers and/or commentators",
/* Author */
"Jean-Christian Denis, Pierre Van Glabeke",
/* Version */
'0.7',
array(
'permissions' => 'admin',
'type' => 'plugin',
'dc_min' => '2.6',
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=333002#p333002',
'details' => 'http://plugins.dotaddict.org/dc2/details/topWriter'
)
);

19
_public.php Normal file
View file

@ -0,0 +1,19 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of topWriter, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 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
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
}
require dirname(__FILE__).'/_widgets.php';

368
_widgets.php Normal file
View file

@ -0,0 +1,368 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of topWriter, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 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
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
}
$core->addBehavior('initWidgets', array('topWriterWidget', 'init'));
class topWriterWidget
{
public static function init($w)
{
#Top comments widget
$w->create(
'topcom',
__('Top Writer: top comments'),
array('topWriterWidget', 'topCom'),
null,
__('List users who write more comments')
);
$w->topcom->setting(
'title',
__('Title:'),
__('Top comments'),
'text'
);
$w->topcom->setting(
'text',
__('Text:'),
'%author% (%count%)',
'text'
);
$w->topcom->setting(
'period',
__('Period:'),
'year',
'combo',
array(
__('day') => 'day',
__('week') => 'week',
__('month') => 'month',
__('year') => 'year',
__('from begining') => ''
)
);
$w->topcom->setting(
'sort',
__('Sort:'),
'desc',
'combo',
array(
__('Ascending') => 'asc',
__('Descending') => 'desc'
)
);
$w->topcom->setting(
'limit',
__('Limit:'),
'10',
'text'
);
$w->topcom->setting(
'exclude',
__('Exclude post writer from list'),
0,
'check'
);
$w->topcom->setting(
'homeonly',
__('Display on:'),
0,
'combo',
array(
__('All pages') => 0,
__('Home page only') => 1,
__('Except on home page') => 2
)
);
$w->topcom->setting('content_only',__('Content only'),0,'check');
$w->topcom->setting('class',__('CSS class:'),'');
$w->topcom->setting('offline',__('Offline'),0,'check');
#Top entries widget
$w->create(
'toppost',
__('Top Writer: top entries'),
array('topWriterWidget', 'topPost'),
null,
__('List users who write more posts')
);
$w->toppost->setting(
'title',
__('Title:'),
__('Top entries'),
'text'
);
$w->toppost->setting(
'text',
__('Text:'),
'%author% (%count%)',
'text'
);
$w->toppost->setting(
'period',
__('Period:'),
'year',
'combo',
array(
__('day') => 'day',
__('week') => 'week',
__('month') => 'month',
__('year') => 'year',
__('from begining') => ''
)
);
$w->toppost->setting(
'sort',
__('Sort:'),'desc',
'combo',
array(
__('Ascending') => 'asc',
__('Descending') => 'desc'
)
);
$w->toppost->setting(
'limit',
__('Limit:'),
'10',
'text'
);
$w->toppost->setting(
'homeonly',
__('Display on:'),
0,
'combo',
array(
__('All pages') => 0,
__('Home page only') => 1,
__('Except on home page') => 2
)
);
$w->toppost->setting('content_only',__('Content only'),0,'check');
$w->toppost->setting('class',__('CSS class:'),'');
$w->toppost->setting('offline',__('Offline'),0,'check');
}
public static function topCom($w)
{
global $core;
if ($w->offline)
return;
if ($w->homeonly == 1 && $core->url->type != 'default'
|| $w->homeonly == 2 && $core->url->type == 'default'
) {
return null;
}
$req =
'SELECT COUNT(*) AS count, comment_email '.
"FROM ".$core->prefix."post P, ".$core->prefix."comment C ".
'WHERE P.post_id=C.post_id '.
"AND blog_id='".$core->con->escape($core->blog->id)."' ".
'AND post_status=1 AND comment_status=1 '.
self::period('comment_dt',$w->period);
if ($w->exclude) {
$req .=
'AND comment_email NOT IN ('.
' SELECT U.user_email '.
' FROM '.$core->prefix.'user U'.
' INNER JOIN '.$core->prefix.'post P ON P.user_id = U.user_id '.
" WHERE blog_id='".$core->con->escape($core->blog->id)."' ".
' GROUP BY U.user_email) ';
}
$req .=
'GROUP BY comment_email '.
'ORDER BY count '.($w->sort == 'asc' ? 'ASC' : 'DESC').' '.
$core->con->limit(abs((integer) $w->limit));
$rs = $core->con->select($req);
if ($rs->isEmpty()) {
return null;
}
$content = '';
$i = 0;
while($rs->fetch()) {
$user = $core->con->select(
"SELECT * FROM ".$core->prefix."comment ".
"WHERE comment_email='".$rs->comment_email."' ".
'ORDER BY comment_dt DESC'
);
if (!$user->comment_author) {
continue;
}
$i++;
$rank = '<span class="topcomments-rank">'.$i.'</span>';
if ($user->comment_site) {
$author = '<a href="'.$user->comment_site.'" title="'.
__('Author link').'">'.$user->comment_author.'</a>';
}
else {
$author = $user->comment_author;
}
$author = '<span class="topcomments-author">'.$author.'</span>';
if ($rs->count == 0) {
$count = __('no comment');
}
else {
$count = sprintf(__('one comment', '%s comments', $rs->count), $rs->count);
}
$content .= '<li>'.str_replace(
array('%rank%', '%author%', '%count%'),
array($rank, $author, $count),
$w->text
).'</li>';
}
if ($i < 1) {
return null;
}
$res =
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'<ul>'.$content.'</ul>';
return $w->renderDiv($w->content_only,'topcomments '.$w->class,'',$res);
}
public static function topPost($w)
{
global $core;
if ($w->offline)
return;
if ($w->homeonly == 1 && $core->url->type != 'default'
|| $w->homeonly == 2 && $core->url->type == 'default'
) {
return null;
}
$rs = $core->con->select(
'SELECT COUNT(*) AS count, U.user_id '.
"FROM ".$core->prefix."post P ".
'INNER JOIN '.$core->prefix.'user U ON U.user_id = P.user_id '.
"WHERE blog_id='".$core->con->escape($core->blog->id)."' ".
'AND post_status=1 AND user_status=1 '.
self::period('post_dt',$w->period).
'GROUP BY U.user_id '.
'ORDER BY count '.($w->sort == 'asc' ? 'ASC' : 'DESC').', U.user_id ASC '.
$core->con->limit(abs((integer) $w->limit)));
if ($rs->isEmpty()) {
return null;
}
$content = '';
$i = 0;
while($rs->fetch()) {
$user = $core->con->select(
"SELECT * FROM ".$core->prefix."user WHERE user_id='".$rs->user_id."' "
);
$author = dcUtils::getUserCN($user->user_id,$user->user_name,
$user->user_firstname,$user->user_displayname);
if (empty($author)) {
continue;
}
$i++;
$rank = '<span class="topentries-rank">'.$i.'</span>';
$core->blog->settings->addNamespace('authormode');
if ($core->blog->settings->authormode->authormode_active) {
$author = '<a href="'.
$core->blog->url.$core->url->getBase("author").'/'.$user->user_id.'" '.
'title="'.__('Author posts').'">'.$author.'</a>';
}
elseif ($user->user_url) {
$author = '<a href="'.$user->user_url.'" title="'.
__('Author link').'">'.$author.'</a>';
}
$author = '<span class="topentries-author">'.$author.'</span>';
if ($rs->count == 0) {
$count = __('no post');
}
else {
$count = sprintf(__('one post', '%s posts', $rs->count), $rs->count);
}
$content .= '<li>'.str_replace(
array('%rank%', '%author%', '%count%'),
array($rank, $author, $count),
$w->text
).'</li>';
}
if ($i < 1) {
return null;
}
$res =
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
'<ul>'.$content.'</ul>';
return $w->renderDiv($w->content_only,'topentries '.$w->class,'',$res);
}
private static function period($t,$p)
{
$pat = '%Y-%m-%d %H:%M:%S';
switch($p) {
case 'day':
return
"AND $t > TIMESTAMP '".dt::str($pat, time() - 3600*24)."' ";
break;
case 'week':
return
"AND $t > TIMESTAMP '".dt::str($pat, time() - 3600*24*7)."' ";
break;
case 'month':
return
"AND $t > TIMESTAMP '".dt::str($pat, time() - 3600*24*30)."' ";
break;
case 'year':
return
"AND $t > TIMESTAMP '".dt::str($pat, time() - 3600*24*30*12)."' ";
break;
}
return '';
}
}

25
changelog Normal file
View file

@ -0,0 +1,25 @@
topWriter x.x - xxxx-xx-xx
* literal rank of writer depending of num of com
topWriter 0.7 - 25-04-2015 - Pierre Van Glabeke
* Modification url support
topWriter 0.6 - 23-01-2015 - Pierre Van Glabeke
* Modifications locales pour widget
topWriter 0.5 - 19-01-2015 - Pierre Van Glabeke
* Compatibilité dc2.7
topWriter 0.4 - 2013-11-12
* Switch to Dotclear 2.6
* Add widget options
* Use plural forms
topWriter 0.3 - 2010-10-06
* Switched to DC 2.2
* Fixed list order (thanks to Atv')
topWriter 0.2 - 2009-08-10
* Fixed php 5.3 compatibility
* Fixed PostGreSQL compatibility
* Added option to exclude post authors from comment list

101
locales/fr/main.po Normal file
View file

@ -0,0 +1,101 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: topWriter 0.4\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2013-11-12T17:15:44+00:00\n"
"Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
#: _widgets.php:26
msgid "Top Writer: top comments"
msgstr "Top Writer : top commentaires"
#: _widgets.php:34
msgid "Top comments"
msgstr "Top commentaires"
#: _widgets.php:29
msgid "List users who write more posts"
msgstr "Liste les utilisateurs qui ont écrit le plus de billets"
#: _widgets.php:45
#: _widgets.php:122
msgid "Period:"
msgstr "Période :"
#: _widgets.php:49
#: _widgets.php:126
msgid "day"
msgstr "jour"
#: _widgets.php:50
#: _widgets.php:127
msgid "week"
msgstr "semaine"
#: _widgets.php:51
#: _widgets.php:128
msgid "month"
msgstr "mois"
#: _widgets.php:52
#: _widgets.php:129
msgid "year"
msgstr "année"
#: _widgets.php:53
#: _widgets.php:130
msgid "from begining"
msgstr "depuis le début"
#: _widgets.php:68
#: _widgets.php:144
msgid "Limit:"
msgstr "Limite :"
#: _widgets.php:74
msgid "Exclude post writer from list"
msgstr "Exclure de la liste les auteurs de billets"
#: _widgets.php:99
msgid "Top Writer: top entries"
msgstr "Top Writer : top billets"
#: _widgets.php:111
msgid "Top entries"
msgstr "Top billets"
#: _widgets.php:106
msgid "List users who write more comments"
msgstr "Liste les utilisateurs qui ont écrit le plus de commentaires"
#: _widgets.php:230
#: _widgets.php:318
msgid "Author link"
msgstr "Lien vers l'auteur"
#: _widgets.php:244
msgid "one comment"
msgid_plural "%s comments"
msgstr[0] "un commentaire"
msgstr[1] "%s commentaires"
#: _widgets.php:314
msgid "Author posts"
msgstr "Billets de l'auteur"
#: _widgets.php:323
msgid "no post"
msgstr "pas de billet"
#: _widgets.php:326
msgid "one post"
msgid_plural "%s posts"
msgstr[0] "un billet"
msgstr[1] "%s billets"
msgid "Ranking of the most prolific writers and/or commentators"
msgstr "Classement des plus prolifiques rédacteurs et/ou commentateurs"