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