Changeset 1379 for plugins/topWriter/_widgets.php
- Timestamp:
- 08/10/09 23:33:28 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/topWriter/_widgets.php
r1304 r1379 11 11 # -- END LICENSE BLOCK ------------------------------------ 12 12 13 if (!defined('DC_RC_PATH')) return;13 if (!defined('DC_RC_PATH')){return;} 14 14 15 15 $core->addBehavior('initWidgets',array('topWriterWidget','init')); … … 17 17 class topWriterWidget 18 18 { 19 public static function init( &$w)19 public static function init($w) 20 20 { 21 21 $w->create('topcom',__('Top comments'), … … 31 31 __('Ascending') => 'asc',__('Descending') => 'desc')); 32 32 $w->topcom->setting('limit',__('Limit:'),'10','text'); 33 $w->topcom->setting('exclude',__('Exclude post writer from list'),0,'check'); 33 34 $w->topcom->setting('homeonly',__('Home page only'),1,'check'); 34 35 … … 48 49 } 49 50 50 public static function topCom( &$w)51 public static function topCom($w) 51 52 { 52 53 global $core; … … 54 55 if ($w->homeonly && $core->url->type != 'default') return; 55 56 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); 69 81 70 82 if ($rs->isEmpty()) return; 71 83 72 84 $content = ''; 73 $res = array();74 85 $i = 0; 75 86 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 76 93 $i++; 77 94 $rank = '<span class="topcomments-rank">'.$i.'</span>'; 78 95 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) 86 104 $count = __('no comment'); 87 elseif($rs->comment_count == 1) 105 106 elseif ($rs->count == 1) 88 107 $count = __('one comment'); 108 89 109 else 90 $count = sprintf(__('%s comments'),$rs->co mment_count);110 $count = sprintf(__('%s comments'),$rs->count); 91 111 92 112 $content .= '<li>'.str_replace( … … 97 117 } 98 118 119 if ($i < 1) return; 120 99 121 return 100 122 '<div class="topcomments">'. … … 104 126 } 105 127 106 public static function topPost( &$w)128 public static function topPost($w) 107 129 { 108 130 global $core; … … 111 133 112 134 $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 '. 115 136 "FROM ".$core->prefix."post P ". 116 137 'INNER JOIN '.$core->prefix.'user U ON U.user_id = P.user_id '. … … 119 140 self::period('post_dt',$w->period). 120 141 '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 '. 123 143 $core->con->limit(abs((integer) $w->limit))); 124 144 … … 128 148 $i = 0; 129 149 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 130 159 $i++; 131 160 $rank = '<span class="topentries-rank">'.$i.'</span>'; 132 161 133 $author = dcUtils::getUserCN($rs->user_id,$rs->user_name,134 $rs->user_firstname,$rs->user_displayname);135 136 162 if ($core->blog->settings->authormode_active) { 137 163 $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.'" '. 139 165 '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="'. 142 169 __('Author link').'">'.$author.'</a>'; 143 170 } 144 171 145 if ($rs-> post_count == 0)172 if ($rs->count == 0) 146 173 $count = __('no post'); 147 elseif($rs->post_count == 1) 174 175 elseif ($rs->count == 1) 148 176 $count = __('one post'); 177 149 178 else 150 $count = sprintf(__('%s posts'),$rs-> post_count);179 $count = sprintf(__('%s posts'),$rs->count); 151 180 152 181 $content .= '<li>'.str_replace( … … 156 185 ).'</li>'; 157 186 } 187 188 if ($i < 1) return; 158 189 159 190 return
Note: See TracChangeset
for help on using the changeset viewer.