Dotclear

source: inc/admin/lib.pager.php @ 3118:5c671c6fae8a

Revision 3118:5c671c6fae8a, 20.1 KB checked in by franck <carnet.franck.paul@…>, 10 years ago (diff)

Add class depending on status for posts, pages and comments, fixes #2135

RevLine 
[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 -----------------------------------------
12if (!defined('DC_RC_PATH')) { return; }
13
[1909]14class 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]135class 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 = __('&#171; prev.');
147          $this->html_next = __('next &#187;');
[0]148     }
149}
150
151class 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
[3089]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);
[2566]195
[3089]196               $html_block .= '<tr>'.implode(iterator_to_array($cols)).'</tr>%s</table></div>';
[0]197               if ($enclose_block) {
198                    $html_block = sprintf($enclose_block,$html_block);
199               }
[2566]200
[1909]201               echo $pager->getLinks();
[2566]202
[0]203               $blocks = explode('%s',$html_block);
[2566]204
[0]205               echo $blocks[0];
[2566]206
[0]207               while ($this->rs->fetch())
208               {
[1476]209                    echo $this->postLine(isset($entries[$this->rs->post_id]));
[0]210               }
[2566]211
[0]212               echo $blocks[1];
[2566]213
[1909]214               echo $pager->getLinks();
[0]215          }
216     }
[2566]217
[1476]218     private function postLine($checked)
[0]219     {
220          if ($this->core->auth->check('categories',$this->core->blog->id)) {
[2858]221               $cat_link = '<a href="'.$this->core->adminurl->get('admin.category',array('id' => '%s'),'&amp;',true).'">%s</a>';
[0]222          } else {
223               $cat_link = '%2$s';
224          }
[2566]225
[0]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 {
[1364]230               $cat_title = __('(No cat)');
[0]231          }
[2566]232
[0]233          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
[3118]234          $sts_class = '';
[0]235          switch ($this->rs->post_status) {
236               case 1:
[1353]237                    $img_status = sprintf($img,__('Published'),'check-on.png');
[3118]238                    $sts_class = 'sts-online';
[0]239                    break;
240               case 0:
[1353]241                    $img_status = sprintf($img,__('Unpublished'),'check-off.png');
[3118]242                    $sts_class = 'sts-offline';
[0]243                    break;
244               case -1:
[1353]245                    $img_status = sprintf($img,__('Scheduled'),'scheduled.png');
[3118]246                    $sts_class = 'sts-scheduled';
[0]247                    break;
248               case -2:
[1353]249                    $img_status = sprintf($img,__('Pending'),'check-wrn.png');
[3118]250                    $sts_class = 'sts-pending';
[0]251                    break;
252          }
[2566]253
[0]254          $protected = '';
255          if ($this->rs->post_password) {
[1353]256               $protected = sprintf($img,__('Protected'),'locker.png');
[0]257          }
[2566]258
[0]259          $selected = '';
260          if ($this->rs->post_selected) {
[1353]261               $selected = sprintf($img,__('Selected'),'selected.png');
[0]262          }
[2566]263
[0]264          $attach = '';
265          $nb_media = $this->rs->countMedia();
266          if ($nb_media > 0) {
267               $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
268               $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
269          }
[2566]270
[3118]271          $res = '<tr class="line '.($this->rs->post_status != 1 ? 'offline ' : '').$sts_class.'"'.
[0]272          ' id="p'.$this->rs->post_id.'">';
[2566]273
[3089]274          $cols = array(
275               'check' =>               '<td class="nowrap">'.
276                                        form::checkbox(array('entries[]'),$this->rs->post_id,$checked,'','',!$this->rs->isEditable()).
277                                        '</td>',
278               'title' =>               '<td class="maximal" scope="row"><a href="'.
279                                        $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'.
280                                        html::escapeHTML($this->rs->post_title).'</a></td>',
281               'date' =>           '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>',
282               'category' =>       '<td class="nowrap">'.$cat_title.'</td>',
283               'author' =>              '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>',
284               'comments' =>       '<td class="nowrap count">'.$this->rs->nb_comment.'</td>',
285               'trackbacks' =>          '<td class="nowrap count">'.$this->rs->nb_trackback.'</td>',
286               'status' =>              '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'
287          );
288          $cols = new ArrayObject($cols);
289          $this->core->callBehavior('adminPostListValue',$this->core,$this->rs,$cols);
290
291          $res .= implode(iterator_to_array($cols));
292          $res .= '</tr>';
[2566]293
[0]294          return $res;
295     }
296}
297
298class adminPostMiniList extends adminGenericList
299{
300     public function display($page,$nb_per_page,$enclose_block='')
301     {
302          if ($this->rs->isEmpty())
303          {
304               echo '<p><strong>'.__('No entry').'</strong></p>';
305          }
306          else
307          {
[1910]308               $pager = new dcPager($page,$this->rs_count,$nb_per_page,10);
[2566]309
[0]310               $html_block =
[2002]311               '<div class="table-outer clear">'.
[3089]312               '<table><caption class="hidden">'.__('Entries list').'</caption><tr>';
[2566]313
[3089]314               $cols = array(
315                    'title' =>          '<th scope="col">'.__('Title').'</th>',
316                    'date' =>      '<th scope="col">'.__('Date').'</th>',
317                    'author' =>         '<th scope="col">'.__('Author').'</th>',
318                    'status' =>         '<th scope="col">'.__('Status').'</th>'
319               );
320
321               $cols = new ArrayObject($cols);
322               $this->core->callBehavior('adminPostMiniListHeader',$this->core,$this->rs,$cols);
323
324               $html_block .= '<tr>'.implode(iterator_to_array($cols)).'</tr>%s</table></div>';
[0]325               if ($enclose_block) {
326                    $html_block = sprintf($enclose_block,$html_block);
327               }
[2566]328
[1909]329               echo $pager->getLinks();
[2566]330
[0]331               $blocks = explode('%s',$html_block);
[2566]332
[0]333               echo $blocks[0];
[2566]334
[0]335               while ($this->rs->fetch())
336               {
337                    echo $this->postLine();
338               }
[2566]339
[0]340               echo $blocks[1];
[2566]341
[1909]342               echo $pager->getLinks();
[0]343          }
344     }
[2566]345
[0]346     private function postLine()
347     {
348          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
[3118]349          $sts_class = '';
[0]350          switch ($this->rs->post_status) {
351               case 1:
[1353]352                    $img_status = sprintf($img,__('Published'),'check-on.png');
[3118]353                    $sts_class = 'sts-online';
[0]354                    break;
355               case 0:
[1353]356                    $img_status = sprintf($img,__('Unpublished'),'check-off.png');
[3118]357                    $sts_class = 'sts-offline';
[0]358                    break;
359               case -1:
[1353]360                    $img_status = sprintf($img,__('Scheduled'),'scheduled.png');
[3118]361                    $sts_class = 'sts-scheduled';
[0]362                    break;
363               case -2:
[1353]364                    $img_status = sprintf($img,__('Pending'),'check-wrn.png');
[3118]365                    $sts_class = 'sts-pending';
[0]366                    break;
367          }
[2566]368
[0]369          $protected = '';
370          if ($this->rs->post_password) {
[1353]371               $protected = sprintf($img,__('Protected'),'locker.png');
[0]372          }
[2566]373
[0]374          $selected = '';
375          if ($this->rs->post_selected) {
[1353]376               $selected = sprintf($img,__('Selected'),'selected.png');
[0]377          }
[2566]378
[0]379          $attach = '';
380          $nb_media = $this->rs->countMedia();
381          if ($nb_media > 0) {
382               $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
383               $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
384          }
[2566]385
[3118]386          $res = '<tr class="line '.($this->rs->post_status != 1 ? 'offline ' : '').$sts_class.'"'.
[0]387          ' id="p'.$this->rs->post_id.'">';
[2566]388
[3089]389          $cols = array(
390               'title' =>          '<td scope="row" class="maximal"><a href="'.
391                                   $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '.
392                                   'title="'.html::escapeHTML($this->rs->getURL()).'">'.
393                                   html::escapeHTML($this->rs->post_title).'</a></td>',
394               'date' =>      '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>',
395               'author' =>         '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>',
396               'status' =>         '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'
397          );
398
399          $cols = new ArrayObject($cols);
400          $this->core->callBehavior('adminPostMiniListValue',$this->core,$this->rs,$cols);
401
402          $res .= implode(iterator_to_array($cols));
403          $res .= '</tr>';
[2566]404
[0]405          return $res;
406     }
407}
408
409class adminCommentList extends adminGenericList
410{
[3044]411     public function display($page,$nb_per_page,$enclose_block='',$filter=false,$spam=false)
[0]412     {
413          if ($this->rs->isEmpty())
414          {
[2135]415               if( $filter ) {
416                    echo '<p><strong>'.__('No comments or trackbacks matches the filter').'</strong></p>';
417               } else {
[2666]418                    echo '<p><strong>'.__('No comments').'</strong></p>';
[2135]419               }
[0]420          }
421          else
422          {
[3044]423               // Get antispam filters' name
424               $filters = array();
425               if ($spam) {
[3048]426                    if (class_exists('dcAntispam')) {
[3044]427                         dcAntispam::initFilters();
428                         $fs = dcAntispam::$filters->getFilters();
429                         foreach ($fs as $fid => $f)
430                         {
431                              $filters[$fid] = $f->name;
432                         }
433                    }
434               }
435
[1910]436               $pager = new dcPager($page,$this->rs_count,$nb_per_page,10);
[2566]437
[1905]438               $comments = array();
439               if (isset($_REQUEST['comments'])) {
440                    foreach ($_REQUEST['comments'] as $v) {
441                         $comments[(integer)$v]=true;
442                    }
[2566]443               }
[0]444               $html_block =
[2002]445               '<div class="table-outer">'.
[2135]446               '<table>';
[2566]447
[2135]448               if( $filter ) {
[2386]449                    $html_block .= '<caption>'.
450                         sprintf(__(
451                              'Comment or trackback matching the filter.',
452                              'List of %s comments or trackbacks matching the filter.',
453                              $this->rs_count), $this->rs_count).
454                         '</caption>';
[2135]455               } else {
456                    $html_block .= '<caption class="hidden">'.__('Comments and trackbacks list').'</caption>';
457               }
[2566]458
[3089]459               $cols = array(
460                    'type' => '<th colspan="2" scope="col" abbr="comm" class="first">'.__('Type').'</th>',
461                    'author' =>    '<th scope="col">'.__('Author').'</th>',
462                    'date' => '<th scope="col">'.__('Date').'</th>',
463                    'status' =>    '<th scope="col" class="txt-center">'.__('Status').'</th>'
464               );
[3044]465               if ($spam) {
[3089]466                    $cols['ip'] = '<th scope="col">'.__('IP').'</th>';
467                    $cols['spam_filter'] = '<th scope="col">'.__('Spam filter').'</th>';
[3044]468               }
[3089]469               $cols['entry'] = '<th scope="col" abbr="entry">'.__('Entry').'</th>';
470
471               $cols = new ArrayObject($cols);
472               $this->core->callBehavior('adminCommentListHeader',$this->core,$this->rs,$cols);
473
474               $html_block .= '<tr>'.implode(iterator_to_array($cols)).'</tr>%s</table></div>';
[1587]475
[0]476               if ($enclose_block) {
477                    $html_block = sprintf($enclose_block,$html_block);
478               }
[2566]479
[1909]480               echo $pager->getLinks();
[2566]481
[0]482               $blocks = explode('%s',$html_block);
[2566]483
[0]484               echo $blocks[0];
[2566]485
[0]486               while ($this->rs->fetch())
487               {
[3044]488                    echo $this->commentLine(isset($comments[$this->rs->comment_id]),$spam,$filters);
[0]489               }
[2566]490
[0]491               echo $blocks[1];
[2566]492
[1909]493               echo $pager->getLinks();
[0]494          }
495     }
[2566]496
[3044]497     private function commentLine($checked=false,$spam=false,$filters=array())
[0]498     {
[3044]499          global $core, $author, $status, $sortby, $order, $nb_per_page;
[2566]500
[0]501          $author_url =
[2817]502          $this->core->adminurl->get('admin.comments',array(
503               'n' => $nb_per_page,
504               'status' => $status,
505               'sortby' => $sortby,
506               'order' => $order,
507               'author' => $this->rs->comment_author
508               ));
[2566]509
[0]510          $post_url = $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id);
[2566]511
[2817]512          $comment_url = $this->core->adminurl->get('admin.comment',array('id' => $this->rs->comment_id));
[2566]513
[0]514          $comment_dt =
515          dt::dt2str($this->core->blog->settings->system->date_format.' - '.
516          $this->core->blog->settings->system->time_format,$this->rs->comment_dt);
[2566]517
[0]518          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
[3118]519          $sts_class = '';
[0]520          switch ($this->rs->comment_status) {
521               case 1:
[1353]522                    $img_status = sprintf($img,__('Published'),'check-on.png');
[3118]523                    $sts_class = 'sts-online';
[0]524                    break;
525               case 0:
[1353]526                    $img_status = sprintf($img,__('Unpublished'),'check-off.png');
[3118]527                    $sts_class = 'sts-offline';
[0]528                    break;
529               case -1:
[1353]530                    $img_status = sprintf($img,__('Pending'),'check-wrn.png');
[3118]531                    $sts_class = 'sts-pending';
[0]532                    break;
533               case -2:
[1353]534                    $img_status = sprintf($img,__('Junk'),'junk.png');
[3118]535                    $sts_class = 'sts-junk';
[0]536                    break;
537          }
[2566]538
[1508]539          $post_title = html::escapeHTML($this->rs->post_title);
[2152]540          if (mb_strlen($post_title) > 70) {
541               $post_title = mb_strcut($post_title,0,67).'...';
[0]542          }
[1668]543          $comment_title = sprintf(__('Edit the %1$s from %2$s'),
544               $this->rs->comment_trackback ? __('trackback') : __('comment'),
545               html::escapeHTML($this->rs->comment_author));
[2566]546
[3118]547          $res = '<tr class="line '.($this->rs->comment_status != 1 ? 'offline ' : '').$sts_class.'"'.
[0]548          ' id="c'.$this->rs->comment_id.'">';
[2566]549
[3089]550          $cols = array(
551               'check' =>     '<td class="nowrap">'.
552                              form::checkbox(array('comments[]'),$this->rs->comment_id,$checked,'','',0).'</td>',
553               'type' => '<td class="nowrap" abbr="'.__('Type and author').'" scope="row">'.
554                              '<a href="'.$comment_url.'" title="'.$comment_title.'">'.
555                              '<img src="images/edit-mini.png" alt="'.__('Edit').'"/> '.
556                              ($this->rs->comment_trackback ? __('trackback') : __('comment')).' '.'</a></td>',
557               'author' =>    '<td class="nowrap maximal"><a href="'.$author_url.'">'.
558                              html::escapeHTML($this->rs->comment_author).'</a></td>',
559               'date'    =>   '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'</td>',
560               'status' =>    '<td class="nowrap status txt-center">'.$img_status.'</td>'
561          );
562
[3044]563          if ($spam) {
564               $filter_name = '';
565               if ($this->rs->comment_spam_filter) {
566                    if (isset($filters[$this->rs->comment_spam_filter])) {
567                         $filter_name = $filters[$this->rs->comment_spam_filter];
568                    } else {
569                         $filter_name = $this->rs->comment_spam_filter;
570                    }
571               }
[3089]572               $cols['ip'] = '<td class="nowrap"><a href="'.
573                    $core->adminurl->get("admin.comments",array('ip' => $this->rs->comment_ip)).'">'.
574                    $this->rs->comment_ip.'</a></td>';
575               $cols['spam_filter'] = '<td class="nowrap">'.$filter_name.'</td>';
[3044]576          }
[3089]577          $cols['entry'] = '<td class="nowrap discrete"><a href="'.$post_url.'">'.$post_title.'</a>'.
578               ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').'</td>';
[2566]579
[3089]580          $cols = new ArrayObject($cols);
581          $this->core->callBehavior('adminCommentListValue',$this->core,$this->rs,$cols);
582
583          $res .= implode(iterator_to_array($cols));
[0]584          $res .= '</tr>';
[2566]585
[0]586          return $res;
587     }
588}
589
590class adminUserList extends adminGenericList
591{
[2135]592     public function display($page,$nb_per_page,$enclose_block='',$filter=false)
[0]593     {
594          if ($this->rs->isEmpty())
595          {
[2135]596               if( $filter ) {
597                    echo '<p><strong>'.__('No user matches the filter').'</strong></p>';
598               } else {
599                    echo '<p><strong>'.__('No user').'</strong></p>';
600               }
[0]601          }
602          else
603          {
[1910]604               $pager = new dcPager($page,$this->rs_count,$nb_per_page,10);
[2566]605
[0]606               $html_block =
[2002]607               '<div class="table-outer clear">'.
[2135]608               '<table>';
[2566]609
[2135]610               if( $filter ) {
611                    $html_block .= '<caption>'.sprintf(__('List of %s users match the filter.'), $this->rs_count).'</caption>';
612               } else {
613                    $html_block .= '<caption class="hidden">'.__('Users list').'</caption>';
614               }
[2566]615
[3089]616               $cols = array(
617                    'username' =>       '<th colspan="2" scope="col" class="first">'.__('Username').'</th>',
618                    'first_name' =>          '<th scope="col">'.__('First Name').'</th>',
619                    'last_name' =>      '<th scope="col">'.__('Last Name').'</th>',
620                    'display_name' =>   '<th scope="col">'.__('Display name').'</th>',
621                    'entries' =>        '<th scope="col" class="nowrap">'.__('Entries (all types)').'</th>'
622               );
[2566]623
[3089]624               $cols = new ArrayObject($cols);
625               $this->core->callBehavior('adminUserListHeader',$this->core,$this->rs,$cols);
626
627               $html_block .= '<tr>'.implode(iterator_to_array($cols)).'</tr>%s</table></div>';
[0]628               if ($enclose_block) {
629                    $html_block = sprintf($enclose_block,$html_block);
630               }
[2566]631
[1909]632               echo $pager->getLinks();
[2566]633
[0]634               $blocks = explode('%s',$html_block);
[2566]635
[0]636               echo $blocks[0];
[2566]637
[0]638               while ($this->rs->fetch())
639               {
640                    echo $this->userLine();
641               }
[2566]642
[0]643               echo $blocks[1];
[2566]644
[1909]645               echo $pager->getLinks();
[0]646          }
647     }
[2566]648
[0]649     private function userLine()
650     {
651          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
652          $img_status = '';
[2566]653
[0]654          $p = $this->core->getUserPermissions($this->rs->user_id);
[2566]655
[0]656          if (isset($p[$this->core->blog->id]['p']['admin'])) {
657               $img_status = sprintf($img,__('admin'),'admin.png');
658          }
659          if ($this->rs->user_super) {
660               $img_status = sprintf($img,__('superadmin'),'superadmin.png');
661          }
[3089]662
663          $res = '<tr class="line">';
664
665          $cols = array(
666               'check' =>               '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post).
667                                        form::checkbox(array('users[]'),$this->rs->user_id).'</td>',
668               'username' =>       '<td class="maximal" scope="row"><a href="'.
669                                        $this->core->adminurl->get('admin.user',array('id' => $this->rs->user_id)).'">'.
670                                        $this->rs->user_id.'</a>&nbsp;'.$img_status.'</td>',
671               'first_name' =>          '<td class="nowrap">'.html::escapeHTML($this->rs->user_firstname).'</td>',
672               'last_name' =>      '<td class="nowrap">'.html::escapeHTML($this->rs->user_name).'</td>',
673               'display_name' =>   '<td class="nowrap">'.html::escapeHTML($this->rs->user_displayname).'</td>',
674               'entries' =>        '<td class="nowrap count"><a href="'.
675                                        $this->core->adminurl->get('admin.posts',array('user_id' => $this->rs->user_id)).'">'.
676                                        $this->rs->nb_post.'</a></td>'
677          );
678
679          $cols = new ArrayObject($cols);
680          $this->core->callBehavior('adminUserListValue',$this->core,$this->rs,$cols);
681
682          $res .= implode(iterator_to_array($cols));
683          $res .= '</tr>';
684
685          return $res;
[0]686     }
687}
Note: See TracBrowser for help on using the repository browser.

Sites map