| [0] | 1 | <?php |
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
|---|
| 3 | # |
|---|
| 4 | # This file is part of Dotclear 2. |
|---|
| 5 | # |
|---|
| [1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
|---|
| [0] | 7 | # Licensed under the GPL version 2.0 license. |
|---|
| 8 | # See LICENSE file or |
|---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|---|
| 10 | # |
|---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
|---|
| 12 | if (!defined('DC_RC_PATH')) { return; } |
|---|
| 13 | |
|---|
| [1909] | 14 | class dcPager extends pager |
|---|
| 15 | { |
|---|
| [1926] | 16 | protected $form_action; |
|---|
| 17 | protected $form_hidden; |
|---|
| [2566] | 18 | |
|---|
| [1917] | 19 | protected function getLink($li_class,$href,$img_src,$img_src_nolink,$img_alt,$enable_link) { |
|---|
| [1909] | 20 | if ($enable_link) { |
|---|
| [1917] | 21 | $formatter = '<li class="%s btn"><a href="%s"><img src="%s" alt="%s"/></a><span class="hidden">%s</span></li>'; |
|---|
| [1909] | 22 | return sprintf ($formatter, |
|---|
| 23 | $li_class,$href,$img_src,$img_alt,$img_alt); |
|---|
| 24 | } else { |
|---|
| [1917] | 25 | $formatter = '<li class="%s no-link btn"><img src="%s" alt="%s"/></li>'; |
|---|
| [1909] | 26 | return sprintf ($formatter, |
|---|
| [1917] | 27 | $li_class,$img_src_nolink,$img_alt,$img_alt); |
|---|
| [1909] | 28 | } |
|---|
| 29 | } |
|---|
| [1926] | 30 | public function setURL() { |
|---|
| 31 | parent::setURL(); |
|---|
| 32 | $url = parse_url($_SERVER['REQUEST_URI']); |
|---|
| 33 | if (isset($url['query'])) { |
|---|
| 34 | parse_str($url['query'],$args); |
|---|
| 35 | } else { |
|---|
| 36 | $args=array(); |
|---|
| 37 | } |
|---|
| 38 | # Removing session information |
|---|
| 39 | if (session_id()) |
|---|
| 40 | { |
|---|
| 41 | if (isset($args[session_name()])) |
|---|
| 42 | unset($args[session_name()]); |
|---|
| 43 | } |
|---|
| 44 | if (isset($args[$this->var_page])) { |
|---|
| 45 | unset($args[$this->var_page]); |
|---|
| 46 | } |
|---|
| 47 | if (isset($args['ok'])) { |
|---|
| 48 | unset($args['ok']); |
|---|
| 49 | } |
|---|
| 50 | $this->form_hidden = ''; |
|---|
| 51 | foreach ($args as $k=>$v) { |
|---|
| [1998] | 52 | if (is_array($v)) { |
|---|
| 53 | foreach ($v as $k2=>$v2) { |
|---|
| [3087] | 54 | $this->form_hidden .= form::hidden(array($k.'[]'),html::escapeHTML($v2)); |
|---|
| [1998] | 55 | } |
|---|
| 56 | } else { |
|---|
| [3087] | 57 | $this->form_hidden .= form::hidden(array($k),html::escapeHTML($v)); |
|---|
| [1998] | 58 | } |
|---|
| [1926] | 59 | } |
|---|
| 60 | $this->form_action = $url['path']; |
|---|
| 61 | } |
|---|
| [2566] | 62 | |
|---|
| [1909] | 63 | /** |
|---|
| 64 | * Pager Links |
|---|
| 65 | * |
|---|
| 66 | * Returns pager links |
|---|
| 67 | * |
|---|
| 68 | * @return string |
|---|
| 69 | */ |
|---|
| 70 | public function getLinks() |
|---|
| 71 | { |
|---|
| 72 | $this->setURL(); |
|---|
| 73 | $htmlFirst = $this->getLink( |
|---|
| 74 | "first", |
|---|
| 75 | sprintf($this->page_url,1), |
|---|
| [1917] | 76 | "images/pagination/first.png", |
|---|
| 77 | "images/pagination/no-first.png", |
|---|
| [1909] | 78 | __('First page'), |
|---|
| 79 | ($this->env > 1) |
|---|
| 80 | ); |
|---|
| 81 | $htmlPrev = $this->getLink( |
|---|
| 82 | "prev", |
|---|
| 83 | sprintf($this->page_url,$this->env-1), |
|---|
| [1917] | 84 | "images/pagination/previous.png", |
|---|
| 85 | "images/pagination/no-previous.png", |
|---|
| [1909] | 86 | __('Previous page'), |
|---|
| 87 | ($this->env > 1) |
|---|
| 88 | ); |
|---|
| 89 | $htmlNext = $this->getLink( |
|---|
| 90 | "next", |
|---|
| 91 | sprintf($this->page_url,$this->env+1), |
|---|
| [1917] | 92 | "images/pagination/next.png", |
|---|
| 93 | "images/pagination/no-next.png", |
|---|
| [1909] | 94 | __('Next page'), |
|---|
| 95 | ($this->env < $this->nb_pages) |
|---|
| 96 | ); |
|---|
| 97 | $htmlLast = $this->getLink( |
|---|
| 98 | "last", |
|---|
| 99 | sprintf($this->page_url,$this->nb_pages), |
|---|
| [1917] | 100 | "images/pagination/last.png", |
|---|
| 101 | "images/pagination/no-last.png", |
|---|
| [1909] | 102 | __('Last page'), |
|---|
| 103 | ($this->env < $this->nb_pages) |
|---|
| 104 | ); |
|---|
| [2566] | 105 | $htmlCurrent = |
|---|
| [1909] | 106 | '<li class="active"><strong>'. |
|---|
| 107 | sprintf(__('Page %s / %s'),$this->env,$this->nb_pages). |
|---|
| 108 | '</strong></li>'; |
|---|
| [2566] | 109 | |
|---|
| 110 | $htmlDirect = |
|---|
| [1931] | 111 | ($this->nb_pages > 1 ? |
|---|
| 112 | sprintf('<li class="direct-access">'.__('Direct access page %s'), |
|---|
| [2323] | 113 | form::field(array($this->var_page),3,10)). |
|---|
| [1931] | 114 | '<input type="submit" value="'.__('ok').'" class="reset" '. |
|---|
| 115 | 'name="ok" />'.$this->form_hidden.'</li>' : ''); |
|---|
| [2566] | 116 | |
|---|
| 117 | $res = |
|---|
| [1926] | 118 | '<form action="'.$this->form_action.'" method="get">'. |
|---|
| [1932] | 119 | '<div class="pager"><ul>'. |
|---|
| [1909] | 120 | $htmlFirst. |
|---|
| 121 | $htmlPrev. |
|---|
| 122 | $htmlCurrent. |
|---|
| 123 | $htmlNext. |
|---|
| 124 | $htmlLast. |
|---|
| [1917] | 125 | $htmlDirect. |
|---|
| [1909] | 126 | '</ul>'. |
|---|
| 127 | '</div>'. |
|---|
| 128 | '</form>' |
|---|
| 129 | ; |
|---|
| [2566] | 130 | |
|---|
| [1909] | 131 | return $this->nb_elements > 0 ? $res : ''; |
|---|
| 132 | } |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| [0] | 135 | class adminGenericList |
|---|
| 136 | { |
|---|
| 137 | protected $core; |
|---|
| 138 | protected $rs; |
|---|
| 139 | protected $rs_count; |
|---|
| [2566] | 140 | |
|---|
| [0] | 141 | public function __construct($core,$rs,$rs_count) |
|---|
| 142 | { |
|---|
| 143 | $this->core =& $core; |
|---|
| 144 | $this->rs =& $rs; |
|---|
| 145 | $this->rs_count = $rs_count; |
|---|
| [1600] | 146 | $this->html_prev = __('« prev.'); |
|---|
| 147 | $this->html_next = __('next »'); |
|---|
| [0] | 148 | } |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | class adminPostList extends adminGenericList |
|---|
| 152 | { |
|---|
| [2128] | 153 | public function display($page,$nb_per_page,$enclose_block='',$filter=false) |
|---|
| [0] | 154 | { |
|---|
| 155 | if ($this->rs->isEmpty()) |
|---|
| 156 | { |
|---|
| [2128] | 157 | if( $filter ) { |
|---|
| 158 | echo '<p><strong>'.__('No entry matches the filter').'</strong></p>'; |
|---|
| 159 | } else { |
|---|
| 160 | echo '<p><strong>'.__('No entry').'</strong></p>'; |
|---|
| 161 | } |
|---|
| [0] | 162 | } |
|---|
| 163 | else |
|---|
| 164 | { |
|---|
| [1909] | 165 | $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); |
|---|
| [1476] | 166 | $entries = array(); |
|---|
| 167 | if (isset($_REQUEST['entries'])) { |
|---|
| 168 | foreach ($_REQUEST['entries'] as $v) { |
|---|
| 169 | $entries[(integer)$v]=true; |
|---|
| 170 | } |
|---|
| 171 | } |
|---|
| [0] | 172 | $html_block = |
|---|
| [2002] | 173 | '<div class="table-outer">'. |
|---|
| [2135] | 174 | '<table>'; |
|---|
| [2566] | 175 | |
|---|
| [2131] | 176 | if( $filter ) { |
|---|
| 177 | $html_block .= '<caption>'.sprintf(__('List of %s entries match the filter.'), $this->rs_count).'</caption>'; |
|---|
| [2128] | 178 | } else { |
|---|
| [2131] | 179 | $html_block .= '<caption class="hidden">'.__('Entries list').'</caption>'; |
|---|
| [2128] | 180 | } |
|---|
| [2566] | 181 | |
|---|
| [2128] | 182 | $html_block .= '<tr>'. |
|---|
| [1508] | 183 | '<th colspan="2" class="first">'.__('Title').'</th>'. |
|---|
| [1600] | 184 | '<th scope="col">'.__('Date').'</th>'. |
|---|
| 185 | '<th scope="col">'.__('Category').'</th>'. |
|---|
| 186 | '<th scope="col">'.__('Author').'</th>'. |
|---|
| [2127] | 187 | '<th scope="col"><img src="images/comments.png" alt="" title="'.__('Comments').'" /><span class="hidden">'.__('Comments').'</span></th>'. |
|---|
| 188 | '<th scope="col"><img src="images/trackbacks.png" alt="" title="'.__('Trackbacks').'" /><span class="hidden">'.__('Trackbacks').'</span></th>'. |
|---|
| [1600] | 189 | '<th scope="col">'.__('Status').'</th>'. |
|---|
| [2002] | 190 | '</tr>%s</table></div>'; |
|---|
| [2566] | 191 | |
|---|
| [0] | 192 | if ($enclose_block) { |
|---|
| 193 | $html_block = sprintf($enclose_block,$html_block); |
|---|
| 194 | } |
|---|
| [2566] | 195 | |
|---|
| [1909] | 196 | echo $pager->getLinks(); |
|---|
| [2566] | 197 | |
|---|
| [0] | 198 | $blocks = explode('%s',$html_block); |
|---|
| [2566] | 199 | |
|---|
| [0] | 200 | echo $blocks[0]; |
|---|
| [2566] | 201 | |
|---|
| [0] | 202 | while ($this->rs->fetch()) |
|---|
| 203 | { |
|---|
| [1476] | 204 | echo $this->postLine(isset($entries[$this->rs->post_id])); |
|---|
| [0] | 205 | } |
|---|
| [2566] | 206 | |
|---|
| [0] | 207 | echo $blocks[1]; |
|---|
| [2566] | 208 | |
|---|
| [1909] | 209 | echo $pager->getLinks(); |
|---|
| [0] | 210 | } |
|---|
| 211 | } |
|---|
| [2566] | 212 | |
|---|
| [1476] | 213 | private function postLine($checked) |
|---|
| [0] | 214 | { |
|---|
| 215 | if ($this->core->auth->check('categories',$this->core->blog->id)) { |
|---|
| [2858] | 216 | $cat_link = '<a href="'.$this->core->adminurl->get('admin.category',array('id' => '%s'),'&',true).'">%s</a>'; |
|---|
| [0] | 217 | } else { |
|---|
| 218 | $cat_link = '%2$s'; |
|---|
| 219 | } |
|---|
| [2566] | 220 | |
|---|
| [0] | 221 | if ($this->rs->cat_title) { |
|---|
| 222 | $cat_title = sprintf($cat_link,$this->rs->cat_id, |
|---|
| 223 | html::escapeHTML($this->rs->cat_title)); |
|---|
| 224 | } else { |
|---|
| [1364] | 225 | $cat_title = __('(No cat)'); |
|---|
| [0] | 226 | } |
|---|
| [2566] | 227 | |
|---|
| [0] | 228 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
|---|
| 229 | switch ($this->rs->post_status) { |
|---|
| 230 | case 1: |
|---|
| [1353] | 231 | $img_status = sprintf($img,__('Published'),'check-on.png'); |
|---|
| [0] | 232 | break; |
|---|
| 233 | case 0: |
|---|
| [1353] | 234 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); |
|---|
| [0] | 235 | break; |
|---|
| 236 | case -1: |
|---|
| [1353] | 237 | $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); |
|---|
| [0] | 238 | break; |
|---|
| 239 | case -2: |
|---|
| [1353] | 240 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); |
|---|
| [0] | 241 | break; |
|---|
| 242 | } |
|---|
| [2566] | 243 | |
|---|
| [0] | 244 | $protected = ''; |
|---|
| 245 | if ($this->rs->post_password) { |
|---|
| [1353] | 246 | $protected = sprintf($img,__('Protected'),'locker.png'); |
|---|
| [0] | 247 | } |
|---|
| [2566] | 248 | |
|---|
| [0] | 249 | $selected = ''; |
|---|
| 250 | if ($this->rs->post_selected) { |
|---|
| [1353] | 251 | $selected = sprintf($img,__('Selected'),'selected.png'); |
|---|
| [0] | 252 | } |
|---|
| [2566] | 253 | |
|---|
| [0] | 254 | $attach = ''; |
|---|
| 255 | $nb_media = $this->rs->countMedia(); |
|---|
| 256 | if ($nb_media > 0) { |
|---|
| 257 | $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); |
|---|
| 258 | $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); |
|---|
| 259 | } |
|---|
| [2566] | 260 | |
|---|
| [0] | 261 | $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. |
|---|
| 262 | ' id="p'.$this->rs->post_id.'">'; |
|---|
| [2566] | 263 | |
|---|
| [0] | 264 | $res .= |
|---|
| 265 | '<td class="nowrap">'. |
|---|
| [1476] | 266 | form::checkbox(array('entries[]'),$this->rs->post_id,$checked,'','',!$this->rs->isEditable()).'</td>'. |
|---|
| [1600] | 267 | '<td class="maximal" scope="row"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. |
|---|
| [0] | 268 | html::escapeHTML($this->rs->post_title).'</a></td>'. |
|---|
| [1668] | 269 | '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. |
|---|
| [0] | 270 | '<td class="nowrap">'.$cat_title.'</td>'. |
|---|
| [1146] | 271 | '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>'. |
|---|
| [1668] | 272 | '<td class="nowrap count">'.$this->rs->nb_comment.'</td>'. |
|---|
| 273 | '<td class="nowrap count">'.$this->rs->nb_trackback.'</td>'. |
|---|
| [0] | 274 | '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. |
|---|
| 275 | '</tr>'; |
|---|
| [2566] | 276 | |
|---|
| [0] | 277 | return $res; |
|---|
| 278 | } |
|---|
| 279 | } |
|---|
| 280 | |
|---|
| 281 | class adminPostMiniList extends adminGenericList |
|---|
| 282 | { |
|---|
| 283 | public function display($page,$nb_per_page,$enclose_block='') |
|---|
| 284 | { |
|---|
| 285 | if ($this->rs->isEmpty()) |
|---|
| 286 | { |
|---|
| 287 | echo '<p><strong>'.__('No entry').'</strong></p>'; |
|---|
| 288 | } |
|---|
| 289 | else |
|---|
| 290 | { |
|---|
| [1910] | 291 | $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); |
|---|
| [2566] | 292 | |
|---|
| [0] | 293 | $html_block = |
|---|
| [2002] | 294 | '<div class="table-outer clear">'. |
|---|
| 295 | '<table><caption class="hidden">'.__('Entries list').'</caption><tr>'. |
|---|
| [1600] | 296 | '<th scope="col">'.__('Title').'</th>'. |
|---|
| 297 | '<th scope="col">'.__('Date').'</th>'. |
|---|
| 298 | '<th scope="col">'.__('Author').'</th>'. |
|---|
| 299 | '<th scope="col">'.__('Status').'</th>'. |
|---|
| [2002] | 300 | '</tr>%s</table></div>'; |
|---|
| [2566] | 301 | |
|---|
| [0] | 302 | if ($enclose_block) { |
|---|
| 303 | $html_block = sprintf($enclose_block,$html_block); |
|---|
| 304 | } |
|---|
| [2566] | 305 | |
|---|
| [1909] | 306 | echo $pager->getLinks(); |
|---|
| [2566] | 307 | |
|---|
| [0] | 308 | $blocks = explode('%s',$html_block); |
|---|
| [2566] | 309 | |
|---|
| [0] | 310 | echo $blocks[0]; |
|---|
| [2566] | 311 | |
|---|
| [0] | 312 | while ($this->rs->fetch()) |
|---|
| 313 | { |
|---|
| 314 | echo $this->postLine(); |
|---|
| 315 | } |
|---|
| [2566] | 316 | |
|---|
| [0] | 317 | echo $blocks[1]; |
|---|
| [2566] | 318 | |
|---|
| [1909] | 319 | echo $pager->getLinks(); |
|---|
| [0] | 320 | } |
|---|
| 321 | } |
|---|
| [2566] | 322 | |
|---|
| [0] | 323 | private function postLine() |
|---|
| 324 | { |
|---|
| 325 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
|---|
| 326 | switch ($this->rs->post_status) { |
|---|
| 327 | case 1: |
|---|
| [1353] | 328 | $img_status = sprintf($img,__('Published'),'check-on.png'); |
|---|
| [0] | 329 | break; |
|---|
| 330 | case 0: |
|---|
| [1353] | 331 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); |
|---|
| [0] | 332 | break; |
|---|
| 333 | case -1: |
|---|
| [1353] | 334 | $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); |
|---|
| [0] | 335 | break; |
|---|
| 336 | case -2: |
|---|
| [1353] | 337 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); |
|---|
| [0] | 338 | break; |
|---|
| 339 | } |
|---|
| [2566] | 340 | |
|---|
| [0] | 341 | $protected = ''; |
|---|
| 342 | if ($this->rs->post_password) { |
|---|
| [1353] | 343 | $protected = sprintf($img,__('Protected'),'locker.png'); |
|---|
| [0] | 344 | } |
|---|
| [2566] | 345 | |
|---|
| [0] | 346 | $selected = ''; |
|---|
| 347 | if ($this->rs->post_selected) { |
|---|
| [1353] | 348 | $selected = sprintf($img,__('Selected'),'selected.png'); |
|---|
| [0] | 349 | } |
|---|
| [2566] | 350 | |
|---|
| [0] | 351 | $attach = ''; |
|---|
| 352 | $nb_media = $this->rs->countMedia(); |
|---|
| 353 | if ($nb_media > 0) { |
|---|
| 354 | $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); |
|---|
| 355 | $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); |
|---|
| 356 | } |
|---|
| [2566] | 357 | |
|---|
| [0] | 358 | $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. |
|---|
| 359 | ' id="p'.$this->rs->post_id.'">'; |
|---|
| [2566] | 360 | |
|---|
| [0] | 361 | $res .= |
|---|
| [1600] | 362 | '<td scope="row" class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '. |
|---|
| [0] | 363 | 'title="'.html::escapeHTML($this->rs->getURL()).'">'. |
|---|
| 364 | html::escapeHTML($this->rs->post_title).'</a></td>'. |
|---|
| [1668] | 365 | '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. |
|---|
| [1146] | 366 | '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>'. |
|---|
| [0] | 367 | '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. |
|---|
| 368 | '</tr>'; |
|---|
| [2566] | 369 | |
|---|
| [0] | 370 | return $res; |
|---|
| 371 | } |
|---|
| 372 | } |
|---|
| 373 | |
|---|
| 374 | class adminCommentList extends adminGenericList |
|---|
| 375 | { |
|---|
| [3044] | 376 | public function display($page,$nb_per_page,$enclose_block='',$filter=false,$spam=false) |
|---|
| [0] | 377 | { |
|---|
| 378 | if ($this->rs->isEmpty()) |
|---|
| 379 | { |
|---|
| [2135] | 380 | if( $filter ) { |
|---|
| 381 | echo '<p><strong>'.__('No comments or trackbacks matches the filter').'</strong></p>'; |
|---|
| 382 | } else { |
|---|
| [2666] | 383 | echo '<p><strong>'.__('No comments').'</strong></p>'; |
|---|
| [2135] | 384 | } |
|---|
| [0] | 385 | } |
|---|
| 386 | else |
|---|
| 387 | { |
|---|
| [3044] | 388 | // Get antispam filters' name |
|---|
| 389 | $filters = array(); |
|---|
| 390 | if ($spam) { |
|---|
| [3048] | 391 | if (class_exists('dcAntispam')) { |
|---|
| [3044] | 392 | dcAntispam::initFilters(); |
|---|
| 393 | $fs = dcAntispam::$filters->getFilters(); |
|---|
| 394 | foreach ($fs as $fid => $f) |
|---|
| 395 | { |
|---|
| 396 | $filters[$fid] = $f->name; |
|---|
| 397 | } |
|---|
| 398 | } |
|---|
| 399 | } |
|---|
| 400 | |
|---|
| [1910] | 401 | $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); |
|---|
| [2566] | 402 | |
|---|
| [1905] | 403 | $comments = array(); |
|---|
| 404 | if (isset($_REQUEST['comments'])) { |
|---|
| 405 | foreach ($_REQUEST['comments'] as $v) { |
|---|
| 406 | $comments[(integer)$v]=true; |
|---|
| 407 | } |
|---|
| [2566] | 408 | } |
|---|
| [0] | 409 | $html_block = |
|---|
| [2002] | 410 | '<div class="table-outer">'. |
|---|
| [2135] | 411 | '<table>'; |
|---|
| [2566] | 412 | |
|---|
| [2135] | 413 | if( $filter ) { |
|---|
| [2386] | 414 | $html_block .= '<caption>'. |
|---|
| 415 | sprintf(__( |
|---|
| 416 | 'Comment or trackback matching the filter.', |
|---|
| 417 | 'List of %s comments or trackbacks matching the filter.', |
|---|
| 418 | $this->rs_count), $this->rs_count). |
|---|
| 419 | '</caption>'; |
|---|
| [2135] | 420 | } else { |
|---|
| 421 | $html_block .= '<caption class="hidden">'.__('Comments and trackbacks list').'</caption>'; |
|---|
| 422 | } |
|---|
| [2566] | 423 | |
|---|
| [2135] | 424 | $html_block .= '<tr>'. |
|---|
| [1668] | 425 | '<th colspan="2" scope="col" abbr="comm" class="first">'.__('Type').'</th>'. |
|---|
| 426 | '<th scope="col">'.__('Author').'</th>'. |
|---|
| [1587] | 427 | '<th scope="col">'.__('Date').'</th>'. |
|---|
| [3044] | 428 | '<th scope="col" class="txt-center">'.__('Status').'</th>'; |
|---|
| 429 | if ($spam) { |
|---|
| 430 | $html_block .= |
|---|
| 431 | '<th scope="col">'.__('IP').'</th>'. |
|---|
| 432 | '<th scope="col">'.__('Spam filter').'</th>'; |
|---|
| 433 | } |
|---|
| 434 | $html_block .= |
|---|
| [2152] | 435 | '<th scope="col" abbr="entry">'.__('Entry').'</th>'. |
|---|
| [2002] | 436 | '</tr>%s</table></div>'; |
|---|
| [1587] | 437 | |
|---|
| [0] | 438 | if ($enclose_block) { |
|---|
| 439 | $html_block = sprintf($enclose_block,$html_block); |
|---|
| 440 | } |
|---|
| [2566] | 441 | |
|---|
| [1909] | 442 | echo $pager->getLinks(); |
|---|
| [2566] | 443 | |
|---|
| [0] | 444 | $blocks = explode('%s',$html_block); |
|---|
| [2566] | 445 | |
|---|
| [0] | 446 | echo $blocks[0]; |
|---|
| [2566] | 447 | |
|---|
| [0] | 448 | while ($this->rs->fetch()) |
|---|
| 449 | { |
|---|
| [3044] | 450 | echo $this->commentLine(isset($comments[$this->rs->comment_id]),$spam,$filters); |
|---|
| [0] | 451 | } |
|---|
| [2566] | 452 | |
|---|
| [0] | 453 | echo $blocks[1]; |
|---|
| [2566] | 454 | |
|---|
| [1909] | 455 | echo $pager->getLinks(); |
|---|
| [0] | 456 | } |
|---|
| 457 | } |
|---|
| [2566] | 458 | |
|---|
| [3044] | 459 | private function commentLine($checked=false,$spam=false,$filters=array()) |
|---|
| [0] | 460 | { |
|---|
| [3044] | 461 | global $core, $author, $status, $sortby, $order, $nb_per_page; |
|---|
| [2566] | 462 | |
|---|
| [0] | 463 | $author_url = |
|---|
| [2817] | 464 | $this->core->adminurl->get('admin.comments',array( |
|---|
| 465 | 'n' => $nb_per_page, |
|---|
| 466 | 'status' => $status, |
|---|
| 467 | 'sortby' => $sortby, |
|---|
| 468 | 'order' => $order, |
|---|
| 469 | 'author' => $this->rs->comment_author |
|---|
| 470 | )); |
|---|
| [2566] | 471 | |
|---|
| [0] | 472 | $post_url = $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id); |
|---|
| [2566] | 473 | |
|---|
| [2817] | 474 | $comment_url = $this->core->adminurl->get('admin.comment',array('id' => $this->rs->comment_id)); |
|---|
| [2566] | 475 | |
|---|
| [0] | 476 | $comment_dt = |
|---|
| 477 | dt::dt2str($this->core->blog->settings->system->date_format.' - '. |
|---|
| 478 | $this->core->blog->settings->system->time_format,$this->rs->comment_dt); |
|---|
| [2566] | 479 | |
|---|
| [0] | 480 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
|---|
| 481 | switch ($this->rs->comment_status) { |
|---|
| 482 | case 1: |
|---|
| [1353] | 483 | $img_status = sprintf($img,__('Published'),'check-on.png'); |
|---|
| [0] | 484 | break; |
|---|
| 485 | case 0: |
|---|
| [1353] | 486 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); |
|---|
| [0] | 487 | break; |
|---|
| 488 | case -1: |
|---|
| [1353] | 489 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); |
|---|
| [0] | 490 | break; |
|---|
| 491 | case -2: |
|---|
| [1353] | 492 | $img_status = sprintf($img,__('Junk'),'junk.png'); |
|---|
| [0] | 493 | break; |
|---|
| 494 | } |
|---|
| [2566] | 495 | |
|---|
| [1508] | 496 | $post_title = html::escapeHTML($this->rs->post_title); |
|---|
| [2152] | 497 | if (mb_strlen($post_title) > 70) { |
|---|
| 498 | $post_title = mb_strcut($post_title,0,67).'...'; |
|---|
| [0] | 499 | } |
|---|
| [1668] | 500 | $comment_title = sprintf(__('Edit the %1$s from %2$s'), |
|---|
| 501 | $this->rs->comment_trackback ? __('trackback') : __('comment'), |
|---|
| 502 | html::escapeHTML($this->rs->comment_author)); |
|---|
| [2566] | 503 | |
|---|
| [0] | 504 | $res = '<tr class="line'.($this->rs->comment_status != 1 ? ' offline' : '').'"'. |
|---|
| 505 | ' id="c'.$this->rs->comment_id.'">'; |
|---|
| [2566] | 506 | |
|---|
| [0] | 507 | $res .= |
|---|
| 508 | '<td class="nowrap">'. |
|---|
| [2071] | 509 | form::checkbox(array('comments[]'),$this->rs->comment_id,$checked,'','',0).'</td>'. |
|---|
| [1929] | 510 | '<td class="nowrap" abbr="'.__('Type and author').'" scope="row">'. |
|---|
| [1668] | 511 | '<a href="'.$comment_url.'" title="'.$comment_title.'">'. |
|---|
| 512 | '<img src="images/edit-mini.png" alt="'.__('Edit').'"/> '. |
|---|
| 513 | ($this->rs->comment_trackback ? __('trackback') : __('comment')).' '.'</a></td>'. |
|---|
| 514 | '<td class="nowrap maximal"><a href="'.$author_url.'">'.html::escapeHTML($this->rs->comment_author).'</a></td>'. |
|---|
| 515 | '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'</td>'. |
|---|
| [3044] | 516 | '<td class="nowrap status txt-center">'.$img_status.'</td>'; |
|---|
| 517 | if ($spam) { |
|---|
| 518 | $filter_name = ''; |
|---|
| 519 | if ($this->rs->comment_spam_filter) { |
|---|
| 520 | if (isset($filters[$this->rs->comment_spam_filter])) { |
|---|
| 521 | $filter_name = $filters[$this->rs->comment_spam_filter]; |
|---|
| 522 | } else { |
|---|
| 523 | $filter_name = $this->rs->comment_spam_filter; |
|---|
| 524 | } |
|---|
| 525 | } |
|---|
| 526 | $res .= |
|---|
| 527 | '<td class="nowrap"><a href="'.$core->adminurl->get("admin.comments",array('ip' => $this->rs->comment_ip)).'">'.$this->rs->comment_ip.'</a></td>'. |
|---|
| 528 | '<td class="nowrap">'.$filter_name.'</td>'; |
|---|
| 529 | } |
|---|
| 530 | $res .= |
|---|
| [2152] | 531 | '<td class="nowrap discrete"><a href="'.$post_url.'">'. |
|---|
| [2777] | 532 | $post_title.'</a>'. |
|---|
| [1587] | 533 | ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').'</td>'; |
|---|
| [2566] | 534 | |
|---|
| [0] | 535 | $res .= '</tr>'; |
|---|
| [2566] | 536 | |
|---|
| [0] | 537 | return $res; |
|---|
| 538 | } |
|---|
| 539 | } |
|---|
| 540 | |
|---|
| 541 | class adminUserList extends adminGenericList |
|---|
| 542 | { |
|---|
| [2135] | 543 | public function display($page,$nb_per_page,$enclose_block='',$filter=false) |
|---|
| [0] | 544 | { |
|---|
| 545 | if ($this->rs->isEmpty()) |
|---|
| 546 | { |
|---|
| [2135] | 547 | if( $filter ) { |
|---|
| 548 | echo '<p><strong>'.__('No user matches the filter').'</strong></p>'; |
|---|
| 549 | } else { |
|---|
| 550 | echo '<p><strong>'.__('No user').'</strong></p>'; |
|---|
| 551 | } |
|---|
| [0] | 552 | } |
|---|
| 553 | else |
|---|
| 554 | { |
|---|
| [1910] | 555 | $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); |
|---|
| [2566] | 556 | |
|---|
| [0] | 557 | $html_block = |
|---|
| [2002] | 558 | '<div class="table-outer clear">'. |
|---|
| [2135] | 559 | '<table>'; |
|---|
| [2566] | 560 | |
|---|
| [2135] | 561 | if( $filter ) { |
|---|
| 562 | $html_block .= '<caption>'.sprintf(__('List of %s users match the filter.'), $this->rs_count).'</caption>'; |
|---|
| 563 | } else { |
|---|
| 564 | $html_block .= '<caption class="hidden">'.__('Users list').'</caption>'; |
|---|
| 565 | } |
|---|
| [2566] | 566 | |
|---|
| [2135] | 567 | $html_block .= '<tr>'. |
|---|
| [1600] | 568 | '<th colspan="2" scope="col" class="first">'.__('Username').'</th>'. |
|---|
| 569 | '<th scope="col">'.__('First Name').'</th>'. |
|---|
| 570 | '<th scope="col">'.__('Last Name').'</th>'. |
|---|
| 571 | '<th scope="col">'.__('Display name').'</th>'. |
|---|
| [1670] | 572 | '<th scope="col" class="nowrap">'.__('Entries (all types)').'</th>'. |
|---|
| [2002] | 573 | '</tr>%s</table></div>'; |
|---|
| [2566] | 574 | |
|---|
| [0] | 575 | if ($enclose_block) { |
|---|
| 576 | $html_block = sprintf($enclose_block,$html_block); |
|---|
| 577 | } |
|---|
| [2566] | 578 | |
|---|
| [1909] | 579 | echo $pager->getLinks(); |
|---|
| [2566] | 580 | |
|---|
| [0] | 581 | $blocks = explode('%s',$html_block); |
|---|
| [2566] | 582 | |
|---|
| [0] | 583 | echo $blocks[0]; |
|---|
| [2566] | 584 | |
|---|
| [0] | 585 | while ($this->rs->fetch()) |
|---|
| 586 | { |
|---|
| 587 | echo $this->userLine(); |
|---|
| 588 | } |
|---|
| [2566] | 589 | |
|---|
| [0] | 590 | echo $blocks[1]; |
|---|
| [2566] | 591 | |
|---|
| [1909] | 592 | echo $pager->getLinks(); |
|---|
| [0] | 593 | } |
|---|
| 594 | } |
|---|
| [2566] | 595 | |
|---|
| [0] | 596 | private function userLine() |
|---|
| 597 | { |
|---|
| 598 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
|---|
| 599 | $img_status = ''; |
|---|
| [2566] | 600 | |
|---|
| [0] | 601 | $p = $this->core->getUserPermissions($this->rs->user_id); |
|---|
| [2566] | 602 | |
|---|
| [0] | 603 | if (isset($p[$this->core->blog->id]['p']['admin'])) { |
|---|
| 604 | $img_status = sprintf($img,__('admin'),'admin.png'); |
|---|
| 605 | } |
|---|
| 606 | if ($this->rs->user_super) { |
|---|
| 607 | $img_status = sprintf($img,__('superadmin'),'superadmin.png'); |
|---|
| 608 | } |
|---|
| 609 | return |
|---|
| 610 | '<tr class="line">'. |
|---|
| 611 | '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post). |
|---|
| [860] | 612 | form::checkbox(array('users[]'),$this->rs->user_id).'</td>'. |
|---|
| [2817] | 613 | '<td class="maximal" scope="row"><a href="'.$this->core->adminurl->get('admin.user',array('id' => $this->rs->user_id)).'">'. |
|---|
| [0] | 614 | $this->rs->user_id.'</a> '.$img_status.'</td>'. |
|---|
| [1146] | 615 | '<td class="nowrap">'.html::escapeHTML($this->rs->user_firstname).'</td>'. |
|---|
| 616 | '<td class="nowrap">'.html::escapeHTML($this->rs->user_name).'</td>'. |
|---|
| 617 | '<td class="nowrap">'.html::escapeHTML($this->rs->user_displayname).'</td>'. |
|---|
| [2817] | 618 | '<td class="nowrap count"><a href="'.$this->core->adminurl->get('admin.posts',array('user_id' => $this->rs->user_id)).'">'. |
|---|
| [0] | 619 | $this->rs->nb_post.'</a></td>'. |
|---|
| 620 | '</tr>'; |
|---|
| 621 | } |
|---|
| 622 | } |
|---|