Dotclear

Changeset 1379


Ignore:
Timestamp:
08/10/09 23:33:28 (14 years ago)
Author:
JcDenis
Message:

topWriter 0.2:

  • Fixed php 5.3 compatibility
  • Fixed PostGreSQL compatibility
  • Added option to exclude post authors from comment list
Location:
plugins/topWriter
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • plugins/topWriter/_define.php

    r1304 r1379  
    1717     /* Description*/         "Widgets to list users who write more posts or comments", 
    1818     /* Author */             "JC Denis", 
    19      /* Version */            '0.1', 
     19     /* Version */            '0.2', 
    2020     /* Permissions */        'admin' 
    2121); 
    22      /* date */          #20090705 
     22     /* date */          #20090810 
    2323?> 
  • plugins/topWriter/_widgets.php

    r1304 r1379  
    1111# -- END LICENSE BLOCK ------------------------------------ 
    1212 
    13 if (!defined('DC_RC_PATH')) return; 
     13if (!defined('DC_RC_PATH')){return;} 
    1414 
    1515$core->addBehavior('initWidgets',array('topWriterWidget','init')); 
     
    1717class topWriterWidget 
    1818{ 
    19      public static function init(&$w) 
     19     public static function init($w) 
    2020     { 
    2121          $w->create('topcom',__('Top comments'), 
     
    3131               __('Ascending') => 'asc',__('Descending') => 'desc')); 
    3232          $w->topcom->setting('limit',__('Limit:'),'10','text'); 
     33          $w->topcom->setting('exclude',__('Exclude post writer from list'),0,'check'); 
    3334          $w->topcom->setting('homeonly',__('Home page only'),1,'check'); 
    3435 
     
    4849     } 
    4950 
    50      public static function topCom(&$w) 
     51     public static function topCom($w) 
    5152     { 
    5253          global $core; 
     
    5455          if ($w->homeonly && $core->url->type != 'default') return; 
    5556 
    56           $rs = $core->con->select(  
    57                'SELECT COUNT(comment_id) AS comment_count, '. 
    58                'comment_author, comment_email, comment_site '. 
    59                "FROM ".$core->prefix."post P,  ".$core->prefix."comment C ". 
    60                'WHERE P.post_id=C.post_id '. 
    61                "AND blog_id='".$core->con->escape($core->blog->id)."' ". 
    62                'AND post_status=1 AND comment_status=1 '. 
    63                self::period('comment_dt',$w->period). 
    64                'GROUP BY C.comment_email '. 
    65                'ORDER BY  comment_count '.($w->sort == 'asc' ? 'ASC' : 'DESC'). 
    66                ', comment_dt DESC '. 
    67                $core->con->limit(abs((integer) $w->limit)) 
    68           ); 
     57          $req = 
     58          'SELECT COUNT(*) AS count, comment_email '. 
     59          "FROM ".$core->prefix."post P,  ".$core->prefix."comment C ". 
     60          'WHERE P.post_id=C.post_id '. 
     61          "AND blog_id='".$core->con->escape($core->blog->id)."' ". 
     62          'AND post_status=1 AND comment_status=1 '. 
     63          self::period('comment_dt',$w->period); 
     64 
     65          if ($w->exclude) { 
     66               $req .=  
     67               'AND comment_email NOT IN ('. 
     68               ' SELECT U.user_email '. 
     69               ' FROM '.$core->prefix.'user U'. 
     70               ' INNER JOIN '.$core->prefix.'post P ON P.user_id = U.user_id '. 
     71               " WHERE blog_id='".$core->con->escape($core->blog->id)."' ". 
     72               ' GROUP BY U.user_email) '; 
     73          } 
     74 
     75          $req .= 
     76          'GROUP BY comment_email '. 
     77          'ORDER BY count '.($w->sort == 'asc' ? 'ASC' : 'DESC').' '. 
     78          $core->con->limit(abs((integer) $w->limit)); 
     79           
     80          $rs = $core->con->select($req); 
    6981 
    7082          if ($rs->isEmpty()) return; 
    7183 
    7284          $content = ''; 
    73           $res = array(); 
    7485          $i = 0; 
    7586          while($rs->fetch()){ 
     87               $user = $core->con->select( 
     88                    "SELECT * FROM ".$core->prefix."comment WHERE comment_email='".$rs->comment_email."' " 
     89               ); 
     90 
     91               if (!$user->comment_author) continue; 
     92 
    7693               $i++; 
    7794               $rank = '<span class="topcomments-rank">'.$i.'</span>'; 
    7895 
    79                if ($rs->comment_site) { 
    80                     $author = '<a href="'.$rs->comment_site.'" title="'. 
    81                          __('Author link').'">'.$rs->comment_author.'</a>'; 
    82                } else 
    83                     $author = $rs->comment_author; 
    84  
    85                if ($rs->comment_count == 0) 
     96               if ($user->comment_site) { 
     97                    $author = '<a href="'.$user->comment_site.'" title="'. 
     98                         __('Author link').'">'.$user->comment_author.'</a>'; 
     99               } 
     100               else 
     101                    $author = $user->comment_author; 
     102 
     103               if ($rs->count == 0) 
    86104                    $count = __('no comment'); 
    87                elseif($rs->comment_count == 1) 
     105 
     106               elseif ($rs->count == 1) 
    88107                    $count = __('one comment'); 
     108 
    89109               else 
    90                     $count = sprintf(__('%s comments'),$rs->comment_count); 
     110                    $count = sprintf(__('%s comments'),$rs->count); 
    91111 
    92112               $content .= '<li>'.str_replace( 
     
    97117          } 
    98118 
     119          if ($i < 1) return; 
     120 
    99121          return  
    100122          '<div class="topcomments">'. 
     
    104126     } 
    105127 
    106      public static function topPost(&$w) 
     128     public static function topPost($w) 
    107129     { 
    108130          global $core; 
     
    111133 
    112134          $rs = $core->con->select( 
    113           'SELECT COUNT(P.post_id) AS post_count, '. 
    114           'U.user_id, U.user_name, U.user_firstname, U.user_displayname, U.user_email '. 
     135          'SELECT COUNT(*) AS count, U.user_id '. 
    115136          "FROM ".$core->prefix."post P ". 
    116137          'INNER JOIN '.$core->prefix.'user U ON U.user_id = P.user_id '. 
     
    119140          self::period('post_dt',$w->period). 
    120141          'GROUP BY U.user_id '. 
    121           'ORDER BY post_count '.($w->sort == 'asc' ? 'ASC' : 'DESC'). 
    122           ', post_dt DESC '. 
     142          'ORDER BY count '.($w->sort == 'asc' ? 'ASC' : 'DESC').', U.user_id ASC '. 
    123143          $core->con->limit(abs((integer) $w->limit))); 
    124144 
     
    128148          $i = 0; 
    129149          while($rs->fetch()){ 
     150               $user = $core->con->select( 
     151                    "SELECT * FROM ".$core->prefix."user WHERE user_id='".$rs->user_id."' " 
     152               ); 
     153 
     154               $author = dcUtils::getUserCN($user->user_id,$user->user_name, 
     155                    $user->user_firstname,$user->user_displayname); 
     156 
     157               if (empty($author)) continue; 
     158 
    130159               $i++; 
    131160               $rank = '<span class="topentries-rank">'.$i.'</span>'; 
    132161 
    133                $author = dcUtils::getUserCN($rs->user_id,$rs->user_name, 
    134                     $rs->user_firstname,$rs->user_displayname); 
    135  
    136162               if ($core->blog->settings->authormode_active) { 
    137163                    $author = '<a href="'. 
    138                          $core->blog->url.$core->url->getBase("author").'/'.$rs->user_id.'" '. 
     164                         $core->blog->url.$core->url->getBase("author").'/'.$user->user_id.'" '. 
    139165                         'title="'.__('Author posts').'">'.$author.'</a>'; 
    140                } elseif ($rs->user_url) { 
    141                     $author = '<a href="'.$rs->user_url.'" title="'. 
     166               } 
     167               elseif ($user->user_url) { 
     168                    $author = '<a href="'.$user->user_url.'" title="'. 
    142169                         __('Author link').'">'.$author.'</a>'; 
    143170               } 
    144171 
    145                if ($rs->post_count == 0) 
     172               if ($rs->count == 0) 
    146173                    $count = __('no post'); 
    147                elseif($rs->post_count == 1) 
     174 
     175               elseif ($rs->count == 1) 
    148176                    $count = __('one post'); 
     177 
    149178               else 
    150                     $count = sprintf(__('%s posts'),$rs->post_count); 
     179                    $count = sprintf(__('%s posts'),$rs->count); 
    151180 
    152181               $content .= '<li>'.str_replace( 
     
    156185               ).'</li>'; 
    157186          } 
     187 
     188          if ($i < 1) return; 
    158189 
    159190          return  
  • plugins/topWriter/locales/fr/main.lang.php

    r1304 r1379  
    11<?php 
    22// Language: français  
    3 // Module: topWriter - 0.1 
    4 // Date: 2009-07-05 20:41:31  
    5 // Author: JC Denis, http://blog.jcdenis.com 
     3// Module: topWriter - 0.2 
     4// Date: 2009-08-10 21:13:57  
     5// Author: JC Denis, jcdenis@gdwd.com 
    66// Translated with dcTranslater - 0.2.4  
    77 
     
    99$GLOBALS['__l10n']['Top comments'] = 'Top commentaires'; 
    1010 
    11 #_widgets.php:41 
     11#_widgets.php:42 
    1212$GLOBALS['__l10n']['Period:'] = 'Période :'; 
    1313 
    14 #_widgets.php:42 
     14#_widgets.php:43 
    1515$GLOBALS['__l10n']['day'] = 'jour'; 
    1616 
    17 #_widgets.php:42 
     17#_widgets.php:43 
    1818$GLOBALS['__l10n']['week'] = 'semaine'; 
    1919 
    20 #_widgets.php:42 
     20#_widgets.php:43 
    2121$GLOBALS['__l10n']['month'] = 'mois'; 
    2222 
    23 #_widgets.php:43 
     23#_widgets.php:44 
    2424$GLOBALS['__l10n']['year'] = 'année'; 
    2525 
    26 #_widgets.php:43 
     26#_widgets.php:44 
    2727$GLOBALS['__l10n']['from begining'] = 'depuis le début'; 
    2828 
    29 #_widgets.php:46 
     29#_widgets.php:47 
    3030$GLOBALS['__l10n']['Limit:'] = 'Limite :'; 
    3131 
    32 #_widgets.php:38 
     32#_widgets.php:33 
     33$GLOBALS['__l10n']['Exclude post writer from list'] = 'Exclure de la liste les auteurs de billets'; 
     34 
     35#_widgets.php:39 
    3336$GLOBALS['__l10n']['Top entries'] = 'Top billets'; 
    3437 
    35 #_widgets.php:142 
     38#_widgets.php:161 
    3639$GLOBALS['__l10n']['Author link'] = 'Lien vers l\'auteur'; 
    3740 
    38 #_widgets.php:90 
     41#_widgets.php:106 
    3942$GLOBALS['__l10n']['%s comments'] = '%s commentaires'; 
    4043 
    41 #_widgets.php:139 
     44#_widgets.php:157 
    4245$GLOBALS['__l10n']['Author posts'] = 'Billets de l\'auteur'; 
    4346 
    44 #_widgets.php:146 
     47#_widgets.php:165 
    4548$GLOBALS['__l10n']['no post'] = 'pas de billet'; 
    4649 
    47 #_widgets.php:148 
     50#_widgets.php:167 
    4851$GLOBALS['__l10n']['one post'] = 'un billet'; 
    4952 
    50 #_widgets.php:150 
     53#_widgets.php:169 
    5154$GLOBALS['__l10n']['%s posts'] = '%s billets'; 
    5255 
  • plugins/topWriter/locales/fr/main.po

    r1304 r1379  
    11# Language: français 
    2 # Module: topWriter - 0.1 
    3 # Date: 2009-07-05 20:41:31 
    4 # Author: JC Denis, http://blog.jcdenis.com 
     2# Module: topWriter - 0.2 
     3# Date: 2009-08-10 21:13:57 
     4# Author: JC Denis, jcdenis@gdwd.com 
    55# Translated with dcTranslater - 0.2.4 
    66 
     
    1212msgstr "Top commentaires" 
    1313 
    14 #: _widgets.php:41 
     14#: _widgets.php:42 
    1515msgid "Period:" 
    1616msgstr "Période :" 
    1717 
    18 #: _widgets.php:42 
     18#: _widgets.php:43 
    1919msgid "day" 
    2020msgstr "jour" 
    2121 
    22 #: _widgets.php:42 
     22#: _widgets.php:43 
    2323msgid "week" 
    2424msgstr "semaine" 
    2525 
    26 #: _widgets.php:42 
     26#: _widgets.php:43 
    2727msgid "month" 
    2828msgstr "mois" 
    2929 
    30 #: _widgets.php:43 
     30#: _widgets.php:44 
    3131msgid "year" 
    3232msgstr "année" 
    3333 
    34 #: _widgets.php:43 
     34#: _widgets.php:44 
    3535msgid "from begining" 
    3636msgstr "depuis le début" 
    3737 
    38 #: _widgets.php:46 
     38#: _widgets.php:47 
    3939msgid "Limit:" 
    4040msgstr "Limite :" 
    4141 
    42 #: _widgets.php:38 
     42#: _widgets.php:33 
     43msgid "Exclude post writer from list" 
     44msgstr "Exclure de la liste les auteurs de billets" 
     45 
     46#: _widgets.php:39 
    4347msgid "Top entries" 
    4448msgstr "Top billets" 
    4549 
    46 #: _widgets.php:142 
     50#: _widgets.php:161 
    4751msgid "Author link" 
    4852msgstr "Lien vers l'auteur" 
    4953 
    50 #: _widgets.php:90 
     54#: _widgets.php:106 
    5155msgid "%s comments" 
    5256msgstr "%s commentaires" 
    5357 
    54 #: _widgets.php:139 
     58#: _widgets.php:157 
    5559msgid "Author posts" 
    5660msgstr "Billets de l'auteur" 
    5761 
    58 #: _widgets.php:146 
     62#: _widgets.php:165 
    5963msgid "no post" 
    6064msgstr "pas de billet" 
    6165 
    62 #: _widgets.php:148 
     66#: _widgets.php:167 
    6367msgid "one post" 
    6468msgstr "un billet" 
    6569 
    66 #: _widgets.php:150 
     70#: _widgets.php:169 
    6771msgid "%s posts" 
    6872msgstr "%s billets" 
Note: See TracChangeset for help on using the changeset viewer.

Sites map