Dotclear


Ignore:
Timestamp:
02/17/18 18:03:29 (8 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Use array form of optionnal parameters for form::checkbox() where is relevant, code formatting (PSR-2)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/lib.pager.php

    r3522 r3707  
    1010# 
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    12 if (!defined('DC_RC_PATH')) { return; } 
     12if (!defined('DC_RC_PATH')) {return;} 
    1313 
    1414class dcPager extends pager 
    1515{ 
    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      } 
     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    { 
     21        if ($enable_link) { 
     22            $formatter = '<li class="%s btn"><a href="%s"><img src="%s" alt="%s"/></a><span class="hidden">%s</span></li>'; 
     23            return sprintf($formatter, 
     24                $li_class, $href, $img_src, $img_alt, $img_alt); 
     25        } else { 
     26            $formatter = '<li class="%s no-link btn"><img src="%s" alt="%s"/></li>'; 
     27            return sprintf($formatter, 
     28                $li_class, $img_src_nolink, $img_alt, $img_alt); 
     29        } 
     30    } 
     31    public function setURL() 
     32    { 
     33        parent::setURL(); 
     34        $url = parse_url($_SERVER['REQUEST_URI']); 
     35        if (isset($url['query'])) { 
     36            parse_str($url['query'], $args); 
     37        } else { 
     38            $args = array(); 
     39        } 
     40        # Removing session information 
     41        if (session_id()) { 
     42            if (isset($args[session_name()])) { 
     43                unset($args[session_name()]); 
     44            } 
     45 
     46        } 
     47        if (isset($args[$this->var_page])) { 
     48            unset($args[$this->var_page]); 
     49        } 
     50        if (isset($args['ok'])) { 
     51            unset($args['ok']); 
     52        } 
     53        $this->form_hidden = ''; 
     54        foreach ($args as $k => $v) { 
     55            if (is_array($v)) { 
     56                foreach ($v as $k2 => $v2) { 
     57                    $this->form_hidden .= form::hidden(array($k . '[]'), html::escapeHTML($v2)); 
     58                } 
     59            } else { 
     60                $this->form_hidden .= form::hidden(array($k), html::escapeHTML($v)); 
     61            } 
     62        } 
     63        $this->form_action = $url['path']; 
     64    } 
     65 
     66    /** 
     67     * Pager Links 
     68     * 
     69     * Returns pager links 
     70     * 
     71     * @return string 
     72     */ 
     73    public function getLinks() 
     74    { 
     75        $this->setURL(); 
     76        $htmlFirst = $this->getLink( 
     77            "first", 
     78            sprintf($this->page_url, 1), 
     79            "images/pagination/first.png", 
     80            "images/pagination/no-first.png", 
     81            __('First page'), 
     82            ($this->env > 1) 
     83        ); 
     84        $htmlPrev = $this->getLink( 
     85            "prev", 
     86            sprintf($this->page_url, $this->env - 1), 
     87            "images/pagination/previous.png", 
     88            "images/pagination/no-previous.png", 
     89            __('Previous page'), 
     90            ($this->env > 1) 
     91        ); 
     92        $htmlNext = $this->getLink( 
     93            "next", 
     94            sprintf($this->page_url, $this->env + 1), 
     95            "images/pagination/next.png", 
     96            "images/pagination/no-next.png", 
     97            __('Next page'), 
     98            ($this->env < $this->nb_pages) 
     99        ); 
     100        $htmlLast = $this->getLink( 
     101            "last", 
     102            sprintf($this->page_url, $this->nb_pages), 
     103            "images/pagination/last.png", 
     104            "images/pagination/no-last.png", 
     105            __('Last page'), 
     106            ($this->env < $this->nb_pages) 
     107        ); 
     108        $htmlCurrent = 
     109        '<li class="active"><strong>' . 
     110        sprintf(__('Page %s / %s'), $this->env, $this->nb_pages) . 
     111            '</strong></li>'; 
     112 
     113        $htmlDirect = 
     114            ($this->nb_pages > 1 ? 
     115            sprintf('<li class="direct-access">' . __('Direct access page %s'), 
     116                form::field(array($this->var_page), 3, 10)) . 
     117            '<input type="submit" value="' . __('ok') . '" class="reset" ' . 
     118            'name="ok" />' . $this->form_hidden . '</li>' : ''); 
     119 
     120        $res = 
     121        '<form action="' . $this->form_action . '" method="get">' . 
     122            '<div class="pager"><ul>' . 
     123            $htmlFirst . 
     124            $htmlPrev . 
     125            $htmlCurrent . 
     126            $htmlNext . 
     127            $htmlLast . 
     128            $htmlDirect . 
     129            '</ul>' . 
     130            '</div>' . 
     131            '</form>' 
     132        ; 
     133 
     134        return $this->nb_elements > 0 ? $res : ''; 
     135    } 
    133136} 
    134137 
    135138class adminGenericList 
    136139{ 
    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 = __('&#171; prev.'); 
    147           $this->html_next = __('next &#187;'); 
    148      } 
    149  
    150      public function userColumns($type,$cols) 
    151      { 
    152           $cols_user = @$this->core->auth->user_prefs->interface->cols; 
    153           if (is_array($cols_user)) { 
    154                if (isset($cols_user[$type])) { 
    155                     foreach ($cols_user[$type] as $cn => $cd) { 
    156                          if (!$cd && isset($cols[$cn])) { 
    157                               unset($cols[$cn]); 
    158                          } 
    159                     } 
    160                } 
    161           } 
    162      } 
     140    protected $core; 
     141    protected $rs; 
     142    protected $rs_count; 
     143 
     144    public function __construct($core, $rs, $rs_count) 
     145    { 
     146        $this->core      = &$core; 
     147        $this->rs        = &$rs; 
     148        $this->rs_count = $rs_count; 
     149        $this->html_prev = __('&#171; prev.'); 
     150        $this->html_next = __('next &#187;'); 
     151    } 
     152 
     153    public function userColumns($type, $cols) 
     154    { 
     155        $cols_user = @$this->core->auth->user_prefs->interface->cols; 
     156        if (is_array($cols_user)) { 
     157            if (isset($cols_user[$type])) { 
     158                foreach ($cols_user[$type] as $cn => $cd) { 
     159                    if (!$cd && isset($cols[$cn])) { 
     160                        unset($cols[$cn]); 
     161                    } 
     162                } 
     163            } 
     164        } 
     165    } 
    163166} 
    164167 
    165168class adminPostList extends adminGenericList 
    166169{ 
    167      public function display($page,$nb_per_page,$enclose_block='',$filter=false) 
    168      { 
    169           if ($this->rs->isEmpty()) 
    170           { 
    171                if( $filter ) { 
    172                     echo '<p><strong>'.__('No entry matches the filter').'</strong></p>'; 
    173                } else { 
    174                     echo '<p><strong>'.__('No entry').'</strong></p>'; 
    175                } 
    176           } 
    177           else 
    178           { 
    179                $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); 
    180                $entries = array(); 
    181                if (isset($_REQUEST['entries'])) { 
    182                     foreach ($_REQUEST['entries'] as $v) { 
    183                          $entries[(integer)$v]=true; 
    184                     } 
    185                } 
    186                $html_block = 
    187                '<div class="table-outer">'. 
    188                '<table>'; 
    189  
    190                if( $filter ) { 
    191                     $html_block .= '<caption>'.sprintf(__('List of %s entries matching the filter.'), $this->rs_count).'</caption>'; 
    192                } else { 
    193                     $nb_published = $this->core->blog->getPosts(array('post_status' => 1),true)->f(0); 
    194                     $nb_pending = $this->core->blog->getPosts(array('post_status' => -2),true)->f(0); 
    195                     $nb_programmed = $this->core->blog->getPosts(array('post_status' => -1),true)->f(0); 
    196                     $nb_unpublished = $this->core->blog->getPosts(array('post_status' => 0),true)->f(0); 
    197                     $html_block .= '<caption>'. 
    198                          sprintf(__('List of entries (%s)'),$this->rs_count). 
    199                          ($nb_published ? 
    200                               sprintf( 
    201                               __(', <a href="%s">published</a> (1)',', <a href="%s">published</a> (%s)',$nb_published), 
    202                               $this->core->adminurl->get('admin.posts',array('status' => 1)), 
    203                               $nb_published) : ''). 
    204                          ($nb_pending ? 
    205                               sprintf( 
    206                               __(', <a href="%s">pending</a> (1)',', <a href="%s">pending</a> (%s)',$nb_pending), 
    207                               $this->core->adminurl->get('admin.posts',array('status' => -2)), 
    208                               $nb_pending) : ''). 
    209                          ($nb_programmed ? 
    210                               sprintf(__(', <a href="%s">programmed</a> (1)',', <a href="%s">programmed</a> (%s)',$nb_programmed), 
    211                               $this->core->adminurl->get('admin.posts',array('status' => -1)), 
    212                               $nb_programmed) : ''). 
    213                          ($nb_unpublished ? 
    214                               sprintf(__(', <a href="%s">unpublished</a> (1)',', <a href="%s">unpublished</a> (%s)',$nb_unpublished), 
    215                               $this->core->adminurl->get('admin.posts',array('status' => 0)), 
    216                               $nb_unpublished) : ''). 
    217                          '</caption>'; 
    218                } 
    219  
    220                $cols = array( 
    221                     'title' =>               '<th colspan="2" class="first">'.__('Title').'</th>', 
    222                     'date' =>           '<th scope="col">'.__('Date').'</th>', 
    223                     'category' =>       '<th scope="col">'.__('Category').'</th>', 
    224                     'author' =>              '<th scope="col">'.__('Author').'</th>', 
    225                     'comments' =>       '<th scope="col"><img src="images/comments.png" alt="" title="'.__('Comments'). 
    226                                              '" /><span class="hidden">'.__('Comments').'</span></th>', 
    227                     'trackbacks' =>          '<th scope="col"><img src="images/trackbacks.png" alt="" title="'.__('Trackbacks'). 
    228                                              '" /><span class="hidden">'.__('Trackbacks').'</span></th>', 
    229                     'status' =>              '<th scope="col">'.__('Status').'</th>' 
    230                ); 
    231                $cols = new ArrayObject($cols); 
    232                $this->core->callBehavior('adminPostListHeader',$this->core,$this->rs,$cols); 
    233  
    234                // Cope with optional columns 
    235                $this->userColumns('posts',$cols); 
    236  
    237                $html_block .= '<tr>'.implode(iterator_to_array($cols)).'</tr>%s</table></div>'; 
    238                if ($enclose_block) { 
    239                     $html_block = sprintf($enclose_block,$html_block); 
    240                } 
    241  
    242                echo $pager->getLinks(); 
    243  
    244                $blocks = explode('%s',$html_block); 
    245  
    246                echo $blocks[0]; 
    247  
    248                while ($this->rs->fetch()) 
    249                { 
    250                     echo $this->postLine(isset($entries[$this->rs->post_id])); 
    251                } 
    252  
    253                echo $blocks[1]; 
    254  
    255                echo $pager->getLinks(); 
    256           } 
    257      } 
    258  
    259      private function postLine($checked) 
    260      { 
    261           if ($this->core->auth->check('categories',$this->core->blog->id)) { 
    262                $cat_link = '<a href="'.$this->core->adminurl->get('admin.category',array('id' => '%s'),'&amp;',true).'">%s</a>'; 
    263           } else { 
    264                $cat_link = '%2$s'; 
    265           } 
    266  
    267           if ($this->rs->cat_title) { 
    268                $cat_title = sprintf($cat_link,$this->rs->cat_id, 
    269                html::escapeHTML($this->rs->cat_title)); 
    270           } else { 
    271                $cat_title = __('(No cat)'); 
    272           } 
    273  
    274           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    275           $sts_class = ''; 
    276           switch ($this->rs->post_status) { 
    277                case 1: 
    278                     $img_status = sprintf($img,__('Published'),'check-on.png'); 
    279                     $sts_class = 'sts-online'; 
    280                     break; 
    281                case 0: 
    282                     $img_status = sprintf($img,__('Unpublished'),'check-off.png'); 
    283                     $sts_class = 'sts-offline'; 
    284                     break; 
    285                case -1: 
    286                     $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); 
    287                     $sts_class = 'sts-scheduled'; 
    288                     break; 
    289                case -2: 
    290                     $img_status = sprintf($img,__('Pending'),'check-wrn.png'); 
    291                     $sts_class = 'sts-pending'; 
    292                     break; 
    293           } 
    294  
    295           $protected = ''; 
    296           if ($this->rs->post_password) { 
    297                $protected = sprintf($img,__('Protected'),'locker.png'); 
    298           } 
    299  
    300           $selected = ''; 
    301           if ($this->rs->post_selected) { 
    302                $selected = sprintf($img,__('Selected'),'selected.png'); 
    303           } 
    304  
    305           $attach = ''; 
    306           $nb_media = $this->rs->countMedia(); 
    307           if ($nb_media > 0) { 
    308                $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); 
    309                $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); 
    310           } 
    311  
    312           $res = '<tr class="line '.($this->rs->post_status != 1 ? 'offline ' : '').$sts_class.'"'. 
    313           ' id="p'.$this->rs->post_id.'">'; 
    314  
    315           $cols = array( 
    316                'check' =>               '<td class="nowrap">'. 
    317                                         form::checkbox(array('entries[]'),$this->rs->post_id,$checked,'','',!$this->rs->isEditable()). 
    318                                         '</td>', 
    319                'title' =>               '<td class="maximal" scope="row"><a href="'. 
    320                                         $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. 
    321                                         html::escapeHTML($this->rs->post_title).'</a></td>', 
    322                'date' =>           '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>', 
    323                'category' =>       '<td class="nowrap">'.$cat_title.'</td>', 
    324                'author' =>              '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>', 
    325                'comments' =>       '<td class="nowrap count">'.$this->rs->nb_comment.'</td>', 
    326                'trackbacks' =>          '<td class="nowrap count">'.$this->rs->nb_trackback.'</td>', 
    327                'status' =>              '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>' 
    328           ); 
    329           $cols = new ArrayObject($cols); 
    330           $this->core->callBehavior('adminPostListValue',$this->core,$this->rs,$cols); 
    331  
    332           // Cope with optional columns 
    333           $this->userColumns('posts',$cols); 
    334  
    335           $res .= implode(iterator_to_array($cols)); 
    336           $res .= '</tr>'; 
    337  
    338           return $res; 
    339      } 
     170    public function display($page, $nb_per_page, $enclose_block = '', $filter = false) 
     171    { 
     172        if ($this->rs->isEmpty()) { 
     173            if ($filter) { 
     174                echo '<p><strong>' . __('No entry matches the filter') . '</strong></p>'; 
     175            } else { 
     176                echo '<p><strong>' . __('No entry') . '</strong></p>'; 
     177            } 
     178        } else { 
     179            $pager   = new dcPager($page, $this->rs_count, $nb_per_page, 10); 
     180            $entries = array(); 
     181            if (isset($_REQUEST['entries'])) { 
     182                foreach ($_REQUEST['entries'] as $v) { 
     183                    $entries[(integer) $v] = true; 
     184                } 
     185            } 
     186            $html_block = 
     187                '<div class="table-outer">' . 
     188                '<table>'; 
     189 
     190            if ($filter) { 
     191                $html_block .= '<caption>' . sprintf(__('List of %s entries matching the filter.'), $this->rs_count) . '</caption>'; 
     192            } else { 
     193                $nb_published   = $this->core->blog->getPosts(array('post_status' => 1), true)->f(0); 
     194                $nb_pending     = $this->core->blog->getPosts(array('post_status' => -2), true)->f(0); 
     195                $nb_programmed  = $this->core->blog->getPosts(array('post_status' => -1), true)->f(0); 
     196                $nb_unpublished = $this->core->blog->getPosts(array('post_status' => 0), true)->f(0); 
     197                $html_block .= '<caption>' . 
     198                sprintf(__('List of entries (%s)'), $this->rs_count) . 
     199                    ($nb_published ? 
     200                    sprintf( 
     201                        __(', <a href="%s">published</a> (1)', ', <a href="%s">published</a> (%s)', $nb_published), 
     202                        $this->core->adminurl->get('admin.posts', array('status' => 1)), 
     203                        $nb_published) : '') . 
     204                    ($nb_pending ? 
     205                    sprintf( 
     206                        __(', <a href="%s">pending</a> (1)', ', <a href="%s">pending</a> (%s)', $nb_pending), 
     207                        $this->core->adminurl->get('admin.posts', array('status' => -2)), 
     208                        $nb_pending) : '') . 
     209                    ($nb_programmed ? 
     210                    sprintf(__(', <a href="%s">programmed</a> (1)', ', <a href="%s">programmed</a> (%s)', $nb_programmed), 
     211                        $this->core->adminurl->get('admin.posts', array('status' => -1)), 
     212                        $nb_programmed) : '') . 
     213                    ($nb_unpublished ? 
     214                    sprintf(__(', <a href="%s">unpublished</a> (1)', ', <a href="%s">unpublished</a> (%s)', $nb_unpublished), 
     215                        $this->core->adminurl->get('admin.posts', array('status' => 0)), 
     216                        $nb_unpublished) : '') . 
     217                    '</caption>'; 
     218            } 
     219 
     220            $cols = array( 
     221                'title'      => '<th colspan="2" class="first">' . __('Title') . '</th>', 
     222                'date'       => '<th scope="col">' . __('Date') . '</th>', 
     223                'category'   => '<th scope="col">' . __('Category') . '</th>', 
     224                'author'     => '<th scope="col">' . __('Author') . '</th>', 
     225                'comments'   => '<th scope="col"><img src="images/comments.png" alt="" title="' . __('Comments') . 
     226                '" /><span class="hidden">' . __('Comments') . '</span></th>', 
     227                'trackbacks' => '<th scope="col"><img src="images/trackbacks.png" alt="" title="' . __('Trackbacks') . 
     228                '" /><span class="hidden">' . __('Trackbacks') . '</span></th>', 
     229                'status'     => '<th scope="col">' . __('Status') . '</th>' 
     230            ); 
     231            $cols = new ArrayObject($cols); 
     232            $this->core->callBehavior('adminPostListHeader', $this->core, $this->rs, $cols); 
     233 
     234            // Cope with optional columns 
     235            $this->userColumns('posts', $cols); 
     236 
     237            $html_block .= '<tr>' . implode(iterator_to_array($cols)) . '</tr>%s</table></div>'; 
     238            if ($enclose_block) { 
     239                $html_block = sprintf($enclose_block, $html_block); 
     240            } 
     241 
     242            echo $pager->getLinks(); 
     243 
     244            $blocks = explode('%s', $html_block); 
     245 
     246            echo $blocks[0]; 
     247 
     248            while ($this->rs->fetch()) { 
     249                echo $this->postLine(isset($entries[$this->rs->post_id])); 
     250            } 
     251 
     252            echo $blocks[1]; 
     253 
     254            echo $pager->getLinks(); 
     255        } 
     256    } 
     257 
     258    private function postLine($checked) 
     259    { 
     260        if ($this->core->auth->check('categories', $this->core->blog->id)) { 
     261            $cat_link = '<a href="' . $this->core->adminurl->get('admin.category', array('id' => '%s'), '&amp;', true) . '">%s</a>'; 
     262        } else { 
     263            $cat_link = '%2$s'; 
     264        } 
     265 
     266        if ($this->rs->cat_title) { 
     267            $cat_title = sprintf($cat_link, $this->rs->cat_id, 
     268                html::escapeHTML($this->rs->cat_title)); 
     269        } else { 
     270            $cat_title = __('(No cat)'); 
     271        } 
     272 
     273        $img       = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
     274        $sts_class = ''; 
     275        switch ($this->rs->post_status) { 
     276            case 1: 
     277                $img_status = sprintf($img, __('Published'), 'check-on.png'); 
     278                $sts_class  = 'sts-online'; 
     279                break; 
     280            case 0: 
     281                $img_status = sprintf($img, __('Unpublished'), 'check-off.png'); 
     282                $sts_class  = 'sts-offline'; 
     283                break; 
     284            case -1: 
     285                $img_status = sprintf($img, __('Scheduled'), 'scheduled.png'); 
     286                $sts_class  = 'sts-scheduled'; 
     287                break; 
     288            case -2: 
     289                $img_status = sprintf($img, __('Pending'), 'check-wrn.png'); 
     290                $sts_class  = 'sts-pending'; 
     291                break; 
     292        } 
     293 
     294        $protected = ''; 
     295        if ($this->rs->post_password) { 
     296            $protected = sprintf($img, __('Protected'), 'locker.png'); 
     297        } 
     298 
     299        $selected = ''; 
     300        if ($this->rs->post_selected) { 
     301            $selected = sprintf($img, __('Selected'), 'selected.png'); 
     302        } 
     303 
     304        $attach   = ''; 
     305        $nb_media = $this->rs->countMedia(); 
     306        if ($nb_media > 0) { 
     307            $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); 
     308            $attach     = sprintf($img, sprintf($attach_str, $nb_media), 'attach.png'); 
     309        } 
     310 
     311        $res = '<tr class="line ' . ($this->rs->post_status != 1 ? 'offline ' : '') . $sts_class . '"' . 
     312        ' id="p' . $this->rs->post_id . '">'; 
     313 
     314        $cols = array( 
     315            'check'      => '<td class="nowrap">' . 
     316            form::checkbox(array('entries[]'), $this->rs->post_id, 
     317                array( 
     318                    'checked'  => $checked, 
     319                    'disabled' => !$this->rs->isEditable() 
     320                )) . 
     321            '</td>', 
     322            'title'      => '<td class="maximal" scope="row"><a href="' . 
     323            $this->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id) . '">' . 
     324            html::escapeHTML($this->rs->post_title) . '</a></td>', 
     325            'date'       => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt) . '</td>', 
     326            'category'   => '<td class="nowrap">' . $cat_title . '</td>', 
     327            'author'     => '<td class="nowrap">' . html::escapeHTML($this->rs->user_id) . '</td>', 
     328            'comments'   => '<td class="nowrap count">' . $this->rs->nb_comment . '</td>', 
     329            'trackbacks' => '<td class="nowrap count">' . $this->rs->nb_trackback . '</td>', 
     330            'status'     => '<td class="nowrap status">' . $img_status . ' ' . $selected . ' ' . $protected . ' ' . $attach . '</td>' 
     331        ); 
     332        $cols = new ArrayObject($cols); 
     333        $this->core->callBehavior('adminPostListValue', $this->core, $this->rs, $cols); 
     334 
     335        // Cope with optional columns 
     336        $this->userColumns('posts', $cols); 
     337 
     338        $res .= implode(iterator_to_array($cols)); 
     339        $res .= '</tr>'; 
     340 
     341        return $res; 
     342    } 
    340343} 
    341344 
    342345class adminPostMiniList extends adminGenericList 
    343346{ 
    344      public function display($page,$nb_per_page,$enclose_block='') 
    345      { 
    346           if ($this->rs->isEmpty()) 
    347           { 
    348                echo '<p><strong>'.__('No entry').'</strong></p>'; 
    349           } 
    350           else 
    351           { 
    352                $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); 
    353  
    354                $html_block = 
    355                '<div class="table-outer clear">'. 
    356                '<table><caption class="hidden">'.__('Entries list').'</caption><tr>'; 
    357  
    358                $cols = array( 
    359                     'title' =>          '<th scope="col">'.__('Title').'</th>', 
    360                     'date' =>      '<th scope="col">'.__('Date').'</th>', 
    361                     'author' =>         '<th scope="col">'.__('Author').'</th>', 
    362                     'status' =>         '<th scope="col">'.__('Status').'</th>' 
    363                ); 
    364  
    365                $cols = new ArrayObject($cols); 
    366                $this->core->callBehavior('adminPostMiniListHeader',$this->core,$this->rs,$cols); 
    367  
    368                // Cope with optional columns 
    369                $this->userColumns('posts',$cols); 
    370  
    371                $html_block .= '<tr>'.implode(iterator_to_array($cols)).'</tr>%s</table></div>'; 
    372                if ($enclose_block) { 
    373                     $html_block = sprintf($enclose_block,$html_block); 
    374                } 
    375  
    376                echo $pager->getLinks(); 
    377  
    378                $blocks = explode('%s',$html_block); 
    379  
    380                echo $blocks[0]; 
    381  
    382                while ($this->rs->fetch()) 
    383                { 
    384                     echo $this->postLine(); 
    385                } 
    386  
    387                echo $blocks[1]; 
    388  
    389                echo $pager->getLinks(); 
    390           } 
    391      } 
    392  
    393      private function postLine() 
    394      { 
    395           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    396           $sts_class = ''; 
    397           switch ($this->rs->post_status) { 
    398                case 1: 
    399                     $img_status = sprintf($img,__('Published'),'check-on.png'); 
    400                     $sts_class = 'sts-online'; 
    401                     break; 
    402                case 0: 
    403                     $img_status = sprintf($img,__('Unpublished'),'check-off.png'); 
    404                     $sts_class = 'sts-offline'; 
    405                     break; 
    406                case -1: 
    407                     $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); 
    408                     $sts_class = 'sts-scheduled'; 
    409                     break; 
    410                case -2: 
    411                     $img_status = sprintf($img,__('Pending'),'check-wrn.png'); 
    412                     $sts_class = 'sts-pending'; 
    413                     break; 
    414           } 
    415  
    416           $protected = ''; 
    417           if ($this->rs->post_password) { 
    418                $protected = sprintf($img,__('Protected'),'locker.png'); 
    419           } 
    420  
    421           $selected = ''; 
    422           if ($this->rs->post_selected) { 
    423                $selected = sprintf($img,__('Selected'),'selected.png'); 
    424           } 
    425  
    426           $attach = ''; 
    427           $nb_media = $this->rs->countMedia(); 
    428           if ($nb_media > 0) { 
    429                $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); 
    430                $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); 
    431           } 
    432  
    433           $res = '<tr class="line '.($this->rs->post_status != 1 ? 'offline ' : '').$sts_class.'"'. 
    434           ' id="p'.$this->rs->post_id.'">'; 
    435  
    436           $cols = array( 
    437                'title' =>          '<td scope="row" class="maximal"><a href="'. 
    438                                    $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '. 
    439                                    'title="'.html::escapeHTML($this->rs->getURL()).'">'. 
    440                                    html::escapeHTML($this->rs->post_title).'</a></td>', 
    441                'date' =>      '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>', 
    442                'author' =>         '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>', 
    443                'status' =>         '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>' 
    444           ); 
    445  
    446           $cols = new ArrayObject($cols); 
    447           $this->core->callBehavior('adminPostMiniListValue',$this->core,$this->rs,$cols); 
    448  
    449           // Cope with optional columns 
    450           $this->userColumns('posts',$cols); 
    451  
    452           $res .= implode(iterator_to_array($cols)); 
    453           $res .= '</tr>'; 
    454  
    455           return $res; 
    456      } 
     347    public function display($page, $nb_per_page, $enclose_block = '') 
     348    { 
     349        if ($this->rs->isEmpty()) { 
     350            echo '<p><strong>' . __('No entry') . '</strong></p>'; 
     351        } else { 
     352            $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10); 
     353 
     354            $html_block = 
     355            '<div class="table-outer clear">' . 
     356            '<table><caption class="hidden">' . __('Entries list') . '</caption><tr>'; 
     357 
     358            $cols = array( 
     359                'title'  => '<th scope="col">' . __('Title') . '</th>', 
     360                'date'   => '<th scope="col">' . __('Date') . '</th>', 
     361                'author' => '<th scope="col">' . __('Author') . '</th>', 
     362                'status' => '<th scope="col">' . __('Status') . '</th>' 
     363            ); 
     364 
     365            $cols = new ArrayObject($cols); 
     366            $this->core->callBehavior('adminPostMiniListHeader', $this->core, $this->rs, $cols); 
     367 
     368            // Cope with optional columns 
     369            $this->userColumns('posts', $cols); 
     370 
     371            $html_block .= '<tr>' . implode(iterator_to_array($cols)) . '</tr>%s</table></div>'; 
     372            if ($enclose_block) { 
     373                $html_block = sprintf($enclose_block, $html_block); 
     374            } 
     375 
     376            echo $pager->getLinks(); 
     377 
     378            $blocks = explode('%s', $html_block); 
     379 
     380            echo $blocks[0]; 
     381 
     382            while ($this->rs->fetch()) { 
     383                echo $this->postLine(); 
     384            } 
     385 
     386            echo $blocks[1]; 
     387 
     388            echo $pager->getLinks(); 
     389        } 
     390    } 
     391 
     392    private function postLine() 
     393    { 
     394        $img       = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
     395        $sts_class = ''; 
     396        switch ($this->rs->post_status) { 
     397            case 1: 
     398                $img_status = sprintf($img, __('Published'), 'check-on.png'); 
     399                $sts_class  = 'sts-online'; 
     400                break; 
     401            case 0: 
     402                $img_status = sprintf($img, __('Unpublished'), 'check-off.png'); 
     403                $sts_class  = 'sts-offline'; 
     404                break; 
     405            case -1: 
     406                $img_status = sprintf($img, __('Scheduled'), 'scheduled.png'); 
     407                $sts_class  = 'sts-scheduled'; 
     408                break; 
     409            case -2: 
     410                $img_status = sprintf($img, __('Pending'), 'check-wrn.png'); 
     411                $sts_class  = 'sts-pending'; 
     412                break; 
     413        } 
     414 
     415        $protected = ''; 
     416        if ($this->rs->post_password) { 
     417            $protected = sprintf($img, __('Protected'), 'locker.png'); 
     418        } 
     419 
     420        $selected = ''; 
     421        if ($this->rs->post_selected) { 
     422            $selected = sprintf($img, __('Selected'), 'selected.png'); 
     423        } 
     424 
     425        $attach   = ''; 
     426        $nb_media = $this->rs->countMedia(); 
     427        if ($nb_media > 0) { 
     428            $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); 
     429            $attach     = sprintf($img, sprintf($attach_str, $nb_media), 'attach.png'); 
     430        } 
     431 
     432        $res = '<tr class="line ' . ($this->rs->post_status != 1 ? 'offline ' : '') . $sts_class . '"' . 
     433        ' id="p' . $this->rs->post_id . '">'; 
     434 
     435        $cols = array( 
     436            'title'  => '<td scope="row" class="maximal"><a href="' . 
     437            $this->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id) . '" ' . 
     438            'title="' . html::escapeHTML($this->rs->getURL()) . '">' . 
     439            html::escapeHTML($this->rs->post_title) . '</a></td>', 
     440            'date'   => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt) . '</td>', 
     441            'author' => '<td class="nowrap">' . html::escapeHTML($this->rs->user_id) . '</td>', 
     442            'status' => '<td class="nowrap status">' . $img_status . ' ' . $selected . ' ' . $protected . ' ' . $attach . '</td>' 
     443        ); 
     444 
     445        $cols = new ArrayObject($cols); 
     446        $this->core->callBehavior('adminPostMiniListValue', $this->core, $this->rs, $cols); 
     447 
     448        // Cope with optional columns 
     449        $this->userColumns('posts', $cols); 
     450 
     451        $res .= implode(iterator_to_array($cols)); 
     452        $res .= '</tr>'; 
     453 
     454        return $res; 
     455    } 
    457456} 
    458457 
    459458class adminCommentList extends adminGenericList 
    460459{ 
    461      public function display($page,$nb_per_page,$enclose_block='',$filter=false,$spam=false) 
    462      { 
    463           if ($this->rs->isEmpty()) 
    464           { 
    465                if( $filter ) { 
    466                     echo '<p><strong>'.__('No comments or trackbacks matches the filter').'</strong></p>'; 
    467                } else { 
    468                     echo '<p><strong>'.__('No comments').'</strong></p>'; 
    469                } 
    470           } 
    471           else 
    472           { 
    473                // Get antispam filters' name 
    474                $filters = array(); 
    475                if ($spam) { 
    476                     if (class_exists('dcAntispam')) { 
    477                          dcAntispam::initFilters(); 
    478                          $fs = dcAntispam::$filters->getFilters(); 
    479                          foreach ($fs as $fid => $f) 
    480                          { 
    481                               $filters[$fid] = $f->name; 
    482                          } 
    483                     } 
    484                } 
    485  
    486                $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); 
    487  
    488                $comments = array(); 
    489                if (isset($_REQUEST['comments'])) { 
    490                     foreach ($_REQUEST['comments'] as $v) { 
    491                          $comments[(integer)$v]=true; 
    492                     } 
    493                } 
    494                $html_block = 
    495                '<div class="table-outer">'. 
    496                '<table>'; 
    497  
    498                if( $filter ) { 
    499                     $html_block .= '<caption>'. 
    500                          sprintf(__( 
    501                               'Comment or trackback matching the filter.', 
    502                               'List of %s comments or trackbacks matching the filter.', 
    503                               $this->rs_count), $this->rs_count). 
    504                          '</caption>'; 
    505                } else { 
    506                     $nb_published = $this->core->blog->getComments(array('comment_status' => 1),true)->f(0); 
    507                     $nb_spam = $this->core->blog->getComments(array('comment_status' => -2),true)->f(0); 
    508                     $nb_pending = $this->core->blog->getComments(array('comment_status' => -1),true)->f(0); 
    509                     $nb_unpublished = $this->core->blog->getComments(array('comment_status' => 0),true)->f(0); 
    510                     $html_block .= '<caption>'. 
    511                          sprintf(__('List of comments and trackbacks (%s)'),$this->rs_count). 
    512                          ($nb_published ? 
    513                               sprintf( 
    514                               __(', <a href="%s">published</a> (1)',', <a href="%s">published</a> (%s)',$nb_published), 
    515                               $this->core->adminurl->get('admin.comments',array('status' => 1)), 
    516                               $nb_published) : ''). 
    517                          ($nb_spam ? 
    518                               sprintf( 
    519                               __(', <a href="%s">spam</a> (1)',', <a href="%s">spam</a> (%s)',$nb_spam), 
    520                               $this->core->adminurl->get('admin.comments',array('status' => -2)), 
    521                               $nb_spam) : ''). 
    522                          ($nb_pending ? 
    523                               sprintf(__(', <a href="%s">pending</a> (1)',', <a href="%s">pending</a> (%s)',$nb_pending), 
    524                               $this->core->adminurl->get('admin.comments',array('status' => -1)), 
    525                               $nb_pending) : ''). 
    526                          ($nb_unpublished ? 
    527                               sprintf(__(', <a href="%s">unpublished</a> (1)',', <a href="%s">unpublished</a> (%s)',$nb_unpublished), 
    528                               $this->core->adminurl->get('admin.comments',array('status' => 0)), 
    529                               $nb_unpublished) : ''). 
    530                          '</caption>'; 
    531                } 
    532  
    533                $cols = array( 
    534                     'type' => '<th colspan="2" scope="col" abbr="comm" class="first">'.__('Type').'</th>', 
    535                     'author' =>    '<th scope="col">'.__('Author').'</th>', 
    536                     'date' => '<th scope="col">'.__('Date').'</th>', 
    537                     'status' =>    '<th scope="col" class="txt-center">'.__('Status').'</th>' 
    538                ); 
    539                if ($spam) { 
    540                     $cols['ip'] = '<th scope="col">'.__('IP').'</th>'; 
    541                     $cols['spam_filter'] = '<th scope="col">'.__('Spam filter').'</th>'; 
    542                } 
    543                $cols['entry'] = '<th scope="col" abbr="entry">'.__('Entry').'</th>'; 
    544  
    545                $cols = new ArrayObject($cols); 
    546                $this->core->callBehavior('adminCommentListHeader',$this->core,$this->rs,$cols); 
    547  
    548                $html_block .= '<tr>'.implode(iterator_to_array($cols)).'</tr>%s</table></div>'; 
    549  
    550                if ($enclose_block) { 
    551                     $html_block = sprintf($enclose_block,$html_block); 
    552                } 
    553  
    554                echo $pager->getLinks(); 
    555  
    556                $blocks = explode('%s',$html_block); 
    557  
    558                echo $blocks[0]; 
    559  
    560                while ($this->rs->fetch()) 
    561                { 
    562                     echo $this->commentLine(isset($comments[$this->rs->comment_id]),$spam,$filters); 
    563                } 
    564  
    565                echo $blocks[1]; 
    566  
    567                echo $pager->getLinks(); 
    568           } 
    569      } 
    570  
    571      private function commentLine($checked=false,$spam=false,$filters=array()) 
    572      { 
    573           global $core, $author, $status, $sortby, $order, $nb_per_page; 
    574  
    575           $author_url = 
    576           $this->core->adminurl->get('admin.comments',array( 
    577                'n' => $nb_per_page, 
    578                'status' => $status, 
    579                'sortby' => $sortby, 
    580                'order' => $order, 
    581                'author' => $this->rs->comment_author 
    582                )); 
    583  
    584           $post_url = $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id); 
    585  
    586           $comment_url = $this->core->adminurl->get('admin.comment',array('id' => $this->rs->comment_id)); 
    587  
    588           $comment_dt = 
    589           dt::dt2str($this->core->blog->settings->system->date_format.' - '. 
    590           $this->core->blog->settings->system->time_format,$this->rs->comment_dt); 
    591  
    592           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    593           $sts_class = ''; 
    594           switch ($this->rs->comment_status) { 
    595                case 1: 
    596                     $img_status = sprintf($img,__('Published'),'check-on.png'); 
    597                     $sts_class = 'sts-online'; 
    598                     break; 
    599                case 0: 
    600                     $img_status = sprintf($img,__('Unpublished'),'check-off.png'); 
    601                     $sts_class = 'sts-offline'; 
    602                     break; 
    603                case -1: 
    604                     $img_status = sprintf($img,__('Pending'),'check-wrn.png'); 
    605                     $sts_class = 'sts-pending'; 
    606                     break; 
    607                case -2: 
    608                     $img_status = sprintf($img,__('Junk'),'junk.png'); 
    609                     $sts_class = 'sts-junk'; 
    610                     break; 
    611           } 
    612  
    613           $post_title = html::escapeHTML($this->rs->post_title); 
    614           if (mb_strlen($post_title) > 70) { 
    615                $post_title = mb_strcut($post_title,0,67).'...'; 
    616           } 
    617           $comment_title = sprintf(__('Edit the %1$s from %2$s'), 
    618                $this->rs->comment_trackback ? __('trackback') : __('comment'), 
    619                html::escapeHTML($this->rs->comment_author)); 
    620  
    621           $res = '<tr class="line '.($this->rs->comment_status != 1 ? 'offline ' : '').$sts_class.'"'. 
    622           ' id="c'.$this->rs->comment_id.'">'; 
    623  
    624           $cols = array( 
    625                'check' =>     '<td class="nowrap">'. 
    626                               form::checkbox(array('comments[]'),$this->rs->comment_id,$checked,'','',0).'</td>', 
    627                'type' => '<td class="nowrap" abbr="'.__('Type and author').'" scope="row">'. 
    628                               '<a href="'.$comment_url.'" title="'.$comment_title.'">'. 
    629                               '<img src="images/edit-mini.png" alt="'.__('Edit').'"/> '. 
    630                               ($this->rs->comment_trackback ? __('trackback') : __('comment')).' '.'</a></td>', 
    631                'author' =>    '<td class="nowrap maximal"><a href="'.$author_url.'">'. 
    632                               html::escapeHTML($this->rs->comment_author).'</a></td>', 
    633                'date'    =>   '<td class="nowrap count">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'</td>', 
    634                'status' =>    '<td class="nowrap status txt-center">'.$img_status.'</td>' 
    635           ); 
    636  
    637           if ($spam) { 
    638                $filter_name = ''; 
    639                if ($this->rs->comment_spam_filter) { 
    640                     if (isset($filters[$this->rs->comment_spam_filter])) { 
    641                          $filter_name = $filters[$this->rs->comment_spam_filter]; 
    642                     } else { 
    643                          $filter_name = $this->rs->comment_spam_filter; 
    644                     } 
    645                } 
    646                $cols['ip'] = '<td class="nowrap"><a href="'. 
    647                     $core->adminurl->get("admin.comments",array('ip' => $this->rs->comment_ip)).'">'. 
    648                     $this->rs->comment_ip.'</a></td>'; 
    649                $cols['spam_filter'] = '<td class="nowrap">'.$filter_name.'</td>'; 
    650           } 
    651           $cols['entry'] = '<td class="nowrap discrete"><a href="'.$post_url.'">'.$post_title.'</a>'. 
    652                ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').'</td>'; 
    653  
    654           $cols = new ArrayObject($cols); 
    655           $this->core->callBehavior('adminCommentListValue',$this->core,$this->rs,$cols); 
    656  
    657           $res .= implode(iterator_to_array($cols)); 
    658           $res .= '</tr>'; 
    659  
    660           return $res; 
    661      } 
     460    public function display($page, $nb_per_page, $enclose_block = '', $filter = false, $spam = false) 
     461    { 
     462        if ($this->rs->isEmpty()) { 
     463            if ($filter) { 
     464                echo '<p><strong>' . __('No comments or trackbacks matches the filter') . '</strong></p>'; 
     465            } else { 
     466                echo '<p><strong>' . __('No comments') . '</strong></p>'; 
     467            } 
     468        } else { 
     469            // Get antispam filters' name 
     470            $filters = array(); 
     471            if ($spam) { 
     472                if (class_exists('dcAntispam')) { 
     473                    dcAntispam::initFilters(); 
     474                    $fs = dcAntispam::$filters->getFilters(); 
     475                    foreach ($fs as $fid => $f) { 
     476                        $filters[$fid] = $f->name; 
     477                    } 
     478                } 
     479            } 
     480 
     481            $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10); 
     482 
     483            $comments = array(); 
     484            if (isset($_REQUEST['comments'])) { 
     485                foreach ($_REQUEST['comments'] as $v) { 
     486                    $comments[(integer) $v] = true; 
     487                } 
     488            } 
     489            $html_block = 
     490                '<div class="table-outer">' . 
     491                '<table>'; 
     492 
     493            if ($filter) { 
     494                $html_block .= '<caption>' . 
     495                sprintf(__( 
     496                    'Comment or trackback matching the filter.', 
     497                    'List of %s comments or trackbacks matching the filter.', 
     498                    $this->rs_count), $this->rs_count) . 
     499                    '</caption>'; 
     500            } else { 
     501                $nb_published   = $this->core->blog->getComments(array('comment_status' => 1), true)->f(0); 
     502                $nb_spam        = $this->core->blog->getComments(array('comment_status' => -2), true)->f(0); 
     503                $nb_pending     = $this->core->blog->getComments(array('comment_status' => -1), true)->f(0); 
     504                $nb_unpublished = $this->core->blog->getComments(array('comment_status' => 0), true)->f(0); 
     505                $html_block .= '<caption>' . 
     506                sprintf(__('List of comments and trackbacks (%s)'), $this->rs_count) . 
     507                    ($nb_published ? 
     508                    sprintf( 
     509                        __(', <a href="%s">published</a> (1)', ', <a href="%s">published</a> (%s)', $nb_published), 
     510                        $this->core->adminurl->get('admin.comments', array('status' => 1)), 
     511                        $nb_published) : '') . 
     512                    ($nb_spam ? 
     513                    sprintf( 
     514                        __(', <a href="%s">spam</a> (1)', ', <a href="%s">spam</a> (%s)', $nb_spam), 
     515                        $this->core->adminurl->get('admin.comments', array('status' => -2)), 
     516                        $nb_spam) : '') . 
     517                    ($nb_pending ? 
     518                    sprintf(__(', <a href="%s">pending</a> (1)', ', <a href="%s">pending</a> (%s)', $nb_pending), 
     519                        $this->core->adminurl->get('admin.comments', array('status' => -1)), 
     520                        $nb_pending) : '') . 
     521                    ($nb_unpublished ? 
     522                    sprintf(__(', <a href="%s">unpublished</a> (1)', ', <a href="%s">unpublished</a> (%s)', $nb_unpublished), 
     523                        $this->core->adminurl->get('admin.comments', array('status' => 0)), 
     524                        $nb_unpublished) : '') . 
     525                    '</caption>'; 
     526            } 
     527 
     528            $cols = array( 
     529                'type'   => '<th colspan="2" scope="col" abbr="comm" class="first">' . __('Type') . '</th>', 
     530                'author' => '<th scope="col">' . __('Author') . '</th>', 
     531                'date'   => '<th scope="col">' . __('Date') . '</th>', 
     532                'status' => '<th scope="col" class="txt-center">' . __('Status') . '</th>' 
     533            ); 
     534            if ($spam) { 
     535                $cols['ip']          = '<th scope="col">' . __('IP') . '</th>'; 
     536                $cols['spam_filter'] = '<th scope="col">' . __('Spam filter') . '</th>'; 
     537            } 
     538            $cols['entry'] = '<th scope="col" abbr="entry">' . __('Entry') . '</th>'; 
     539 
     540            $cols = new ArrayObject($cols); 
     541            $this->core->callBehavior('adminCommentListHeader', $this->core, $this->rs, $cols); 
     542 
     543            $html_block .= '<tr>' . implode(iterator_to_array($cols)) . '</tr>%s</table></div>'; 
     544 
     545            if ($enclose_block) { 
     546                $html_block = sprintf($enclose_block, $html_block); 
     547            } 
     548 
     549            echo $pager->getLinks(); 
     550 
     551            $blocks = explode('%s', $html_block); 
     552 
     553            echo $blocks[0]; 
     554 
     555            while ($this->rs->fetch()) { 
     556                echo $this->commentLine(isset($comments[$this->rs->comment_id]), $spam, $filters); 
     557            } 
     558 
     559            echo $blocks[1]; 
     560 
     561            echo $pager->getLinks(); 
     562        } 
     563    } 
     564 
     565    private function commentLine($checked = false, $spam = false, $filters = array()) 
     566    { 
     567        global $core, $author, $status, $sortby, $order, $nb_per_page; 
     568 
     569        $author_url = 
     570        $this->core->adminurl->get('admin.comments', array( 
     571            'n'      => $nb_per_page, 
     572            'status' => $status, 
     573            'sortby' => $sortby, 
     574            'order'  => $order, 
     575            'author' => $this->rs->comment_author 
     576        )); 
     577 
     578        $post_url = $this->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id); 
     579 
     580        $comment_url = $this->core->adminurl->get('admin.comment', array('id' => $this->rs->comment_id)); 
     581 
     582        $comment_dt = 
     583        dt::dt2str($this->core->blog->settings->system->date_format . ' - ' . 
     584            $this->core->blog->settings->system->time_format, $this->rs->comment_dt); 
     585 
     586        $img       = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
     587        $sts_class = ''; 
     588        switch ($this->rs->comment_status) { 
     589            case 1: 
     590                $img_status = sprintf($img, __('Published'), 'check-on.png'); 
     591                $sts_class  = 'sts-online'; 
     592                break; 
     593            case 0: 
     594                $img_status = sprintf($img, __('Unpublished'), 'check-off.png'); 
     595                $sts_class  = 'sts-offline'; 
     596                break; 
     597            case -1: 
     598                $img_status = sprintf($img, __('Pending'), 'check-wrn.png'); 
     599                $sts_class  = 'sts-pending'; 
     600                break; 
     601            case -2: 
     602                $img_status = sprintf($img, __('Junk'), 'junk.png'); 
     603                $sts_class  = 'sts-junk'; 
     604                break; 
     605        } 
     606 
     607        $post_title = html::escapeHTML($this->rs->post_title); 
     608        if (mb_strlen($post_title) > 70) { 
     609            $post_title = mb_strcut($post_title, 0, 67) . '...'; 
     610        } 
     611        $comment_title = sprintf(__('Edit the %1$s from %2$s'), 
     612            $this->rs->comment_trackback ? __('trackback') : __('comment'), 
     613            html::escapeHTML($this->rs->comment_author)); 
     614 
     615        $res = '<tr class="line ' . ($this->rs->comment_status != 1 ? 'offline ' : '') . $sts_class . '"' . 
     616        ' id="c' . $this->rs->comment_id . '">'; 
     617 
     618        $cols = array( 
     619            'check'  => '<td class="nowrap">' . 
     620            form::checkbox(array('comments[]'), $this->rs->comment_id, $checked) . 
     621            '</td>', 
     622            'type'   => '<td class="nowrap" abbr="' . __('Type and author') . '" scope="row">' . 
     623            '<a href="' . $comment_url . '" title="' . $comment_title . '">' . 
     624            '<img src="images/edit-mini.png" alt="' . __('Edit') . '"/> ' . 
     625            ($this->rs->comment_trackback ? __('trackback') : __('comment')) . ' ' . '</a></td>', 
     626            'author' => '<td class="nowrap maximal"><a href="' . $author_url . '">' . 
     627            html::escapeHTML($this->rs->comment_author) . '</a></td>', 
     628            'date'   => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->comment_dt) . '</td>', 
     629            'status' => '<td class="nowrap status txt-center">' . $img_status . '</td>' 
     630        ); 
     631 
     632        if ($spam) { 
     633            $filter_name = ''; 
     634            if ($this->rs->comment_spam_filter) { 
     635                if (isset($filters[$this->rs->comment_spam_filter])) { 
     636                    $filter_name = $filters[$this->rs->comment_spam_filter]; 
     637                } else { 
     638                    $filter_name = $this->rs->comment_spam_filter; 
     639                } 
     640            } 
     641            $cols['ip'] = '<td class="nowrap"><a href="' . 
     642            $core->adminurl->get("admin.comments", array('ip' => $this->rs->comment_ip)) . '">' . 
     643            $this->rs->comment_ip . '</a></td>'; 
     644            $cols['spam_filter'] = '<td class="nowrap">' . $filter_name . '</td>'; 
     645        } 
     646        $cols['entry'] = '<td class="nowrap discrete"><a href="' . $post_url . '">' . $post_title . '</a>' . 
     647            ($this->rs->post_type != 'post' ? ' (' . html::escapeHTML($this->rs->post_type) . ')' : '') . '</td>'; 
     648 
     649        $cols = new ArrayObject($cols); 
     650        $this->core->callBehavior('adminCommentListValue', $this->core, $this->rs, $cols); 
     651 
     652        $res .= implode(iterator_to_array($cols)); 
     653        $res .= '</tr>'; 
     654 
     655        return $res; 
     656    } 
    662657} 
    663658 
    664659class adminBlogList extends adminGenericList 
    665660{ 
    666      public function display($page,$nb_per_page,$enclose_block='',$filter=false) 
    667      { 
    668           if ($this->rs->isEmpty()) 
    669           { 
    670                if($filter) { 
    671                     echo '<p><strong>'.__('No blog matches the filter').'</strong></p>'; 
    672                } else { 
    673                     echo '<p><strong>'.__('No blog').'</strong></p>'; 
    674                } 
    675           } 
    676           else 
    677           { 
    678                $blogs = array(); 
    679                if (isset($_REQUEST['blogs'])) { 
    680                     foreach ($_REQUEST['blogs'] as $v) { 
    681                          $blogs[$v]=true; 
    682                     } 
    683                } 
    684  
    685                $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); 
    686  
    687                $cols = array( 
    688                     'blog' => '<th'. 
    689                          ($this->core->auth->isSuperAdmin() ? ' colspan="2"' : ''). 
    690                          ' scope="col" abbr="comm" class="first nowrap">'.__('Blog id').'</th>', 
    691                     'name' => '<th scope="col" abbr="name">'.__('Blog name').'</th>', 
    692                     'url' => '<th scope="col" class="nowrap">'.__('URL').'</th>', 
    693                     'posts' => '<th scope="col" class="nowrap">'.__('Entries (all types)').'</th>', 
    694                     'upddt' => '<th scope="col" class="nowrap">'.__('Last update').'</th>', 
    695                     'status' => '<th scope="col" class="txt-center">'.__('Status').'</th>' 
    696                ); 
    697  
    698                $cols = new ArrayObject($cols); 
    699                $this->core->callBehavior('adminBlogListHeader',$this->core,$this->rs,$cols); 
    700  
    701                $html_block = 
    702                '<div class="table-outer"><table>'. 
    703                ($filter ? 
    704                     '<caption>'. 
    705                     sprintf(__('%d blog matches the filter.','%d blogs match the filter.',$this->rs_count),$this->rs_count). 
    706                     '</caption>' 
    707                : 
    708                     '<caption class="hidden">'.__('Blogs list').'</caption>' 
    709                ). 
    710                '<tr>'.implode(iterator_to_array($cols)).'</tr>%s</table></div>'; 
    711  
    712                if ($enclose_block) { 
    713                     $html_block = sprintf($enclose_block,$html_block); 
    714                } 
    715  
    716                $blocks = explode('%s',$html_block); 
    717  
    718                echo $pager->getLinks(); 
    719  
    720                echo $blocks[0]; 
    721  
    722                while ($this->rs->fetch()) { 
    723                     echo $this->blogLine(isset($blogs[$this->rs->blog_id])); 
    724                } 
    725  
    726                echo $blocks[1]; 
    727  
    728                echo $pager->getLinks(); 
    729           } 
    730      } 
    731  
    732      private function blogLine($checked=false) 
    733      { 
    734           $blog_id = html::escapeHTML($this->rs->blog_id); 
    735  
    736           $cols = array( 
    737                'check' => 
    738                     ($this->core->auth->isSuperAdmin() ? 
    739                     '<td class="nowrap">'. 
    740                     form::checkbox(array('blogs[]'),$this->rs->blog_id,$checked,'','',0). 
    741                     '</td>' : ''), 
    742                'blog' => 
    743                     '<td class="nowrap">'. 
    744                     ($this->core->auth->isSuperAdmin() ? 
    745                          '<a href="'.$this->core->adminurl->get("admin.blog",array('id' => $blog_id)).'"  '. 
    746                               'title="'.sprintf(__('Edit blog settings for %s'),$blog_id).'">'. 
    747                               '<img src="images/edit-mini.png" alt="'.__('Edit blog settings').'" /> '.$blog_id.'</a> ' : 
    748                          $blog_id.' '). 
    749                     '</td>', 
    750                'name' => 
    751                     '<td class="maximal">'. 
    752                     '<a href="'.$this->core->adminurl->get("admin.home",array('switchblog' => $this->rs->blog_id)).'" '. 
    753                     'title="'.sprintf(__('Switch to blog %s'),$this->rs->blog_id).'">'. 
    754                     html::escapeHTML($this->rs->blog_name).'</a>'. 
    755                     '</td>', 
    756                'url' => 
    757                     '<td class="nowrap">'. 
    758                     '<a class="outgoing" href="'. 
    759                     html::escapeHTML($this->rs->blog_url).'">'.html::escapeHTML($this->rs->blog_url). 
    760                     ' <img src="images/outgoing-blue.png" alt="" /></a></td>', 
    761                'posts' => 
    762                     '<td class="nowrap count">'. 
    763                     $this->core->countBlogPosts($this->rs->blog_id). 
    764                     '</td>', 
    765                'upddt' => 
    766                     '<td class="nowrap count">'. 
    767                     dt::str(__('%Y-%m-%d %H:%M'),strtotime($this->rs->blog_upddt) + dt::getTimeOffset($this->core->auth->getInfo('user_tz'))). 
    768                     '</td>', 
    769                'status' => 
    770                     '<td class="nowrap status txt-center">'. 
    771                     sprintf( 
    772                          '<img src="images/%1$s.png" alt="%2$s" title="%2$s" />', 
    773                          ($this->rs->blog_status == 1 ? 'check-on' : ($this->rs->blog_status == 0 ? 'check-off' : 'check-wrn')), 
    774                          $this->core->getBlogStatus($this->rs->blog_status) 
    775                     ). 
    776                     '</td>' 
    777           ); 
    778  
    779           $cols = new ArrayObject($cols); 
    780           $this->core->callBehavior('adminBlogListValue',$this->core,$this->rs,$cols); 
    781  
    782           return 
    783           '<tr class="line" id="b'.$blog_id.'">'. 
    784           implode(iterator_to_array($cols)). 
    785           '</tr>'; 
    786      } 
     661    public function display($page, $nb_per_page, $enclose_block = '', $filter = false) 
     662    { 
     663        if ($this->rs->isEmpty()) { 
     664            if ($filter) { 
     665                echo '<p><strong>' . __('No blog matches the filter') . '</strong></p>'; 
     666            } else { 
     667                echo '<p><strong>' . __('No blog') . '</strong></p>'; 
     668            } 
     669        } else { 
     670            $blogs = array(); 
     671            if (isset($_REQUEST['blogs'])) { 
     672                foreach ($_REQUEST['blogs'] as $v) { 
     673                    $blogs[$v] = true; 
     674                } 
     675            } 
     676 
     677            $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10); 
     678 
     679            $cols = array( 
     680                'blog'   => '<th' . 
     681                ($this->core->auth->isSuperAdmin() ? ' colspan="2"' : '') . 
     682                ' scope="col" abbr="comm" class="first nowrap">' . __('Blog id') . '</th>', 
     683                'name'   => '<th scope="col" abbr="name">' . __('Blog name') . '</th>', 
     684                'url'    => '<th scope="col" class="nowrap">' . __('URL') . '</th>', 
     685                'posts'  => '<th scope="col" class="nowrap">' . __('Entries (all types)') . '</th>', 
     686                'upddt'  => '<th scope="col" class="nowrap">' . __('Last update') . '</th>', 
     687                'status' => '<th scope="col" class="txt-center">' . __('Status') . '</th>' 
     688            ); 
     689 
     690            $cols = new ArrayObject($cols); 
     691            $this->core->callBehavior('adminBlogListHeader', $this->core, $this->rs, $cols); 
     692 
     693            $html_block = 
     694            '<div class="table-outer"><table>' . 
     695            ($filter ? 
     696                '<caption>' . 
     697                sprintf(__('%d blog matches the filter.', '%d blogs match the filter.', $this->rs_count), $this->rs_count) . 
     698                '</caption>' 
     699                : 
     700                '<caption class="hidden">' . __('Blogs list') . '</caption>' 
     701            ) . 
     702            '<tr>' . implode(iterator_to_array($cols)) . '</tr>%s</table></div>'; 
     703 
     704            if ($enclose_block) { 
     705                $html_block = sprintf($enclose_block, $html_block); 
     706            } 
     707 
     708            $blocks = explode('%s', $html_block); 
     709 
     710            echo $pager->getLinks(); 
     711 
     712            echo $blocks[0]; 
     713 
     714            while ($this->rs->fetch()) { 
     715                echo $this->blogLine(isset($blogs[$this->rs->blog_id])); 
     716            } 
     717 
     718            echo $blocks[1]; 
     719 
     720            echo $pager->getLinks(); 
     721        } 
     722    } 
     723 
     724    private function blogLine($checked = false) 
     725    { 
     726        $blog_id = html::escapeHTML($this->rs->blog_id); 
     727 
     728        $cols = array( 
     729            'check'  => 
     730            ($this->core->auth->isSuperAdmin() ? 
     731                '<td class="nowrap">' . 
     732                form::checkbox(array('blogs[]'), $this->rs->blog_id, $checked) . 
     733                '</td>' : ''), 
     734            'blog'   => 
     735            '<td class="nowrap">' . 
     736            ($this->core->auth->isSuperAdmin() ? 
     737                '<a href="' . $this->core->adminurl->get("admin.blog", array('id' => $blog_id)) . '"  ' . 
     738                'title="' . sprintf(__('Edit blog settings for %s'), $blog_id) . '">' . 
     739                '<img src="images/edit-mini.png" alt="' . __('Edit blog settings') . '" /> ' . $blog_id . '</a> ' : 
     740                $blog_id . ' ') . 
     741            '</td>', 
     742            'name'   => 
     743            '<td class="maximal">' . 
     744            '<a href="' . $this->core->adminurl->get("admin.home", array('switchblog' => $this->rs->blog_id)) . '" ' . 
     745            'title="' . sprintf(__('Switch to blog %s'), $this->rs->blog_id) . '">' . 
     746            html::escapeHTML($this->rs->blog_name) . '</a>' . 
     747            '</td>', 
     748            'url'    => 
     749            '<td class="nowrap">' . 
     750            '<a class="outgoing" href="' . 
     751            html::escapeHTML($this->rs->blog_url) . '">' . html::escapeHTML($this->rs->blog_url) . 
     752            ' <img src="images/outgoing-blue.png" alt="" /></a></td>', 
     753            'posts'  => 
     754            '<td class="nowrap count">' . 
     755            $this->core->countBlogPosts($this->rs->blog_id) . 
     756            '</td>', 
     757            'upddt'  => 
     758            '<td class="nowrap count">' . 
     759            dt::str(__('%Y-%m-%d %H:%M'), strtotime($this->rs->blog_upddt) + dt::getTimeOffset($this->core->auth->getInfo('user_tz'))) . 
     760            '</td>', 
     761            'status' => 
     762            '<td class="nowrap status txt-center">' . 
     763            sprintf( 
     764                '<img src="images/%1$s.png" alt="%2$s" title="%2$s" />', 
     765                ($this->rs->blog_status == 1 ? 'check-on' : ($this->rs->blog_status == 0 ? 'check-off' : 'check-wrn')), 
     766                $this->core->getBlogStatus($this->rs->blog_status) 
     767            ) . 
     768            '</td>' 
     769        ); 
     770 
     771        $cols = new ArrayObject($cols); 
     772        $this->core->callBehavior('adminBlogListValue', $this->core, $this->rs, $cols); 
     773 
     774        return 
     775        '<tr class="line" id="b' . $blog_id . '">' . 
     776        implode(iterator_to_array($cols)) . 
     777            '</tr>'; 
     778    } 
    787779} 
    788780 
    789781class adminUserList extends adminGenericList 
    790782{ 
    791      public function display($page,$nb_per_page,$enclose_block='',$filter=false) 
    792      { 
    793           if ($this->rs->isEmpty()) 
    794           { 
    795                if( $filter ) { 
    796                     echo '<p><strong>'.__('No user matches the filter').'</strong></p>'; 
    797                } else { 
    798                     echo '<p><strong>'.__('No user').'</strong></p>'; 
    799                } 
    800           } 
    801           else 
    802           { 
    803                $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); 
    804  
    805                $html_block = 
    806                '<div class="table-outer clear">'. 
    807                '<table>'; 
    808  
    809                if( $filter ) { 
    810                     $html_block .= '<caption>'.sprintf(__('List of %s users match the filter.'), $this->rs_count).'</caption>'; 
    811                } else { 
    812                     $html_block .= '<caption class="hidden">'.__('Users list').'</caption>'; 
    813                } 
    814  
    815                $cols = array( 
    816                     'username' =>       '<th colspan="2" scope="col" class="first">'.__('Username').'</th>', 
    817                     'first_name' =>          '<th scope="col">'.__('First Name').'</th>', 
    818                     'last_name' =>      '<th scope="col">'.__('Last Name').'</th>', 
    819                     'display_name' =>   '<th scope="col">'.__('Display name').'</th>', 
    820                     'entries' =>        '<th scope="col" class="nowrap">'.__('Entries (all types)').'</th>' 
    821                ); 
    822  
    823                $cols = new ArrayObject($cols); 
    824                $this->core->callBehavior('adminUserListHeader',$this->core,$this->rs,$cols); 
    825  
    826                $html_block .= '<tr>'.implode(iterator_to_array($cols)).'</tr>%s</table></div>'; 
    827                if ($enclose_block) { 
    828                     $html_block = sprintf($enclose_block,$html_block); 
    829                } 
    830  
    831                echo $pager->getLinks(); 
    832  
    833                $blocks = explode('%s',$html_block); 
    834  
    835                echo $blocks[0]; 
    836  
    837                while ($this->rs->fetch()) 
    838                { 
    839                     echo $this->userLine(); 
    840                } 
    841  
    842                echo $blocks[1]; 
    843  
    844                echo $pager->getLinks(); 
    845           } 
    846      } 
    847  
    848      private function userLine() 
    849      { 
    850           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    851           $img_status = ''; 
    852  
    853           $p = $this->core->getUserPermissions($this->rs->user_id); 
    854  
    855           if (isset($p[$this->core->blog->id]['p']['admin'])) { 
    856                $img_status = sprintf($img,__('admin'),'admin.png'); 
    857           } 
    858           if ($this->rs->user_super) { 
    859                $img_status = sprintf($img,__('superadmin'),'superadmin.png'); 
    860           } 
    861  
    862           $res = '<tr class="line">'; 
    863  
    864           $cols = array( 
    865                'check' =>               '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post). 
    866                                         form::checkbox(array('users[]'),$this->rs->user_id).'</td>', 
    867                'username' =>       '<td class="maximal" scope="row"><a href="'. 
    868                                         $this->core->adminurl->get('admin.user',array('id' => $this->rs->user_id)).'">'. 
    869                                         $this->rs->user_id.'</a>&nbsp;'.$img_status.'</td>', 
    870                'first_name' =>          '<td class="nowrap">'.html::escapeHTML($this->rs->user_firstname).'</td>', 
    871                'last_name' =>      '<td class="nowrap">'.html::escapeHTML($this->rs->user_name).'</td>', 
    872                'display_name' =>   '<td class="nowrap">'.html::escapeHTML($this->rs->user_displayname).'</td>', 
    873                'entries' =>        '<td class="nowrap count"><a href="'. 
    874                                         $this->core->adminurl->get('admin.posts',array('user_id' => $this->rs->user_id)).'">'. 
    875                                         $this->rs->nb_post.'</a></td>' 
    876           ); 
    877  
    878           $cols = new ArrayObject($cols); 
    879           $this->core->callBehavior('adminUserListValue',$this->core,$this->rs,$cols); 
    880  
    881           $res .= implode(iterator_to_array($cols)); 
    882           $res .= '</tr>'; 
    883  
    884           return $res; 
    885      } 
     783    public function display($page, $nb_per_page, $enclose_block = '', $filter = false) 
     784    { 
     785        if ($this->rs->isEmpty()) { 
     786            if ($filter) { 
     787                echo '<p><strong>' . __('No user matches the filter') . '</strong></p>'; 
     788            } else { 
     789                echo '<p><strong>' . __('No user') . '</strong></p>'; 
     790            } 
     791        } else { 
     792            $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10); 
     793 
     794            $html_block = 
     795                '<div class="table-outer clear">' . 
     796                '<table>'; 
     797 
     798            if ($filter) { 
     799                $html_block .= '<caption>' . sprintf(__('List of %s users match the filter.'), $this->rs_count) . '</caption>'; 
     800            } else { 
     801                $html_block .= '<caption class="hidden">' . __('Users list') . '</caption>'; 
     802            } 
     803 
     804            $cols = array( 
     805                'username'     => '<th colspan="2" scope="col" class="first">' . __('Username') . '</th>', 
     806                'first_name'   => '<th scope="col">' . __('First Name') . '</th>', 
     807                'last_name'    => '<th scope="col">' . __('Last Name') . '</th>', 
     808                'display_name' => '<th scope="col">' . __('Display name') . '</th>', 
     809                'entries'      => '<th scope="col" class="nowrap">' . __('Entries (all types)') . '</th>' 
     810            ); 
     811 
     812            $cols = new ArrayObject($cols); 
     813            $this->core->callBehavior('adminUserListHeader', $this->core, $this->rs, $cols); 
     814 
     815            $html_block .= '<tr>' . implode(iterator_to_array($cols)) . '</tr>%s</table></div>'; 
     816            if ($enclose_block) { 
     817                $html_block = sprintf($enclose_block, $html_block); 
     818            } 
     819 
     820            echo $pager->getLinks(); 
     821 
     822            $blocks = explode('%s', $html_block); 
     823 
     824            echo $blocks[0]; 
     825 
     826            while ($this->rs->fetch()) { 
     827                echo $this->userLine(); 
     828            } 
     829 
     830            echo $blocks[1]; 
     831 
     832            echo $pager->getLinks(); 
     833        } 
     834    } 
     835 
     836    private function userLine() 
     837    { 
     838        $img        = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
     839        $img_status = ''; 
     840 
     841        $p = $this->core->getUserPermissions($this->rs->user_id); 
     842 
     843        if (isset($p[$this->core->blog->id]['p']['admin'])) { 
     844            $img_status = sprintf($img, __('admin'), 'admin.png'); 
     845        } 
     846        if ($this->rs->user_super) { 
     847            $img_status = sprintf($img, __('superadmin'), 'superadmin.png'); 
     848        } 
     849 
     850        $res = '<tr class="line">'; 
     851 
     852        $cols = array( 
     853            'check'        => '<td class="nowrap">' . form::hidden(array('nb_post[]'), (integer) $this->rs->nb_post) . 
     854            form::checkbox(array('users[]'), $this->rs->user_id) . '</td>', 
     855            'username'     => '<td class="maximal" scope="row"><a href="' . 
     856            $this->core->adminurl->get('admin.user', array('id' => $this->rs->user_id)) . '">' . 
     857            $this->rs->user_id . '</a>&nbsp;' . $img_status . '</td>', 
     858            'first_name'   => '<td class="nowrap">' . html::escapeHTML($this->rs->user_firstname) . '</td>', 
     859            'last_name'    => '<td class="nowrap">' . html::escapeHTML($this->rs->user_name) . '</td>', 
     860            'display_name' => '<td class="nowrap">' . html::escapeHTML($this->rs->user_displayname) . '</td>', 
     861            'entries'      => '<td class="nowrap count"><a href="' . 
     862            $this->core->adminurl->get('admin.posts', array('user_id' => $this->rs->user_id)) . '">' . 
     863            $this->rs->nb_post . '</a></td>' 
     864        ); 
     865 
     866        $cols = new ArrayObject($cols); 
     867        $this->core->callBehavior('adminUserListValue', $this->core, $this->rs, $cols); 
     868 
     869        $res .= implode(iterator_to_array($cols)); 
     870        $res .= '</tr>'; 
     871 
     872        return $res; 
     873    } 
    886874} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map