Dotclear


Ignore:
Timestamp:
12/06/11 11:43:14 (14 years ago)
Author:
Dsls <dsls@…>
Branch:
formfilters
Parents:
781:b509ac00bf4a (diff), 779:58c45f1b96e5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged last default changes with formfilter branch

File:
1 edited

Legend:

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

    r270 r782  
    1212if (!defined('DC_RC_PATH')) { return; } 
    1313 
     14/** 
     15@ingroup DC_CORE 
     16@nosubgrouping 
     17@brief Dotclear generic list class. 
     18@deprecated Please use class adminItemslist to create admin lists 
     19 
     20Dotclear generic list handles every admin list. 
     21*/ 
    1422class adminGenericList 
    1523{ 
     
    1826     protected $rs_count; 
    1927      
     28     /** 
     29     @deprecated Please use class adminItemslist to create admin lists 
     30      
     31     @param    core      <b>dcCore</b>       dcCore object 
     32     @param    rs        <b>recordSet</b>    Items recordSet to display 
     33     @param    rs_count  <b>int</b>          Total items number 
     34     */ 
    2035     public function __construct($core,$rs,$rs_count) 
    2136     { 
     37          // For backward compatibility only: the developer tried to create 
     38          // a list with the old constructor. 
     39          ob_start($this->raiseDeprecated(get_class($this))); 
     40           
    2241          $this->core =& $core; 
    2342          $this->rs =& $rs; 
     
    2645          $this->html_next = __('next&#187;'); 
    2746     } 
    28 } 
    29  
    30 class adminPostList extends adminGenericList 
    31 { 
    32      public function display($page,$nb_per_page,$enclose_block='') 
     47      
     48     /** 
     49     Raises a E_USER_NOTICE error for deprecated classes.  
     50     This allows the developer to know he's been using deprecated classes. 
     51      
     52     @param    name <b>string</b>  Name of the deprecated classes that was called. 
     53     */ 
     54     private function raiseDeprecated($name) 
    3355     { 
    34           if ($this->rs->isEmpty()) 
    35           { 
    36                echo '<p><strong>'.__('No entry').'</strong></p>'; 
     56          if (DC_DEBUG) { 
     57               $trace = debug_backtrace(); 
     58               array_shift($trace); 
     59               $grand = array_shift($trace); 
     60               $msg = 'Deprecated class called. ('; 
     61               $msg .= $name.' was called from '.$grand['file'].' ['.$grand['line'].'])'; 
     62               trigger_error($msg, E_USER_NOTICE); 
    3763          } 
    38           else 
    39           { 
    40                $pager = new pager($page,$this->rs_count,$nb_per_page,10); 
    41                $pager->html_prev = $this->html_prev; 
    42                $pager->html_next = $this->html_next; 
    43                $pager->var_page = 'page'; 
    44                 
    45                $html_block = 
    46                '<table class="clear"><tr>'. 
    47                '<th colspan="2">'.__('Title').'</th>'. 
    48                '<th>'.__('Date').'</th>'. 
    49                '<th>'.__('Category').'</th>'. 
    50                '<th>'.__('Author').'</th>'. 
    51                '<th>'.__('Comments').'</th>'. 
    52                '<th>'.__('Trackbacks').'</th>'. 
    53                '<th>'.__('Status').'</th>'. 
    54                '</tr>%s</table>'; 
    55                 
    56                if ($enclose_block) { 
    57                     $html_block = sprintf($enclose_block,$html_block); 
    58                } 
    59                 
    60                echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
    61                 
    62                $blocks = explode('%s',$html_block); 
    63                 
    64                echo $blocks[0]; 
    65                 
    66                while ($this->rs->fetch()) 
    67                { 
    68                     echo $this->postLine(); 
    69                } 
    70                 
    71                echo $blocks[1]; 
    72                 
    73                echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
    74           } 
    75      } 
    76       
    77      private function postLine() 
    78      { 
    79           if ($this->core->auth->check('categories',$this->core->blog->id)) { 
    80                $cat_link = '<a href="category.php?id=%s">%s</a>'; 
    81           } else { 
    82                $cat_link = '%2$s'; 
    83           } 
    84            
    85           if ($this->rs->cat_title) { 
    86                $cat_title = sprintf($cat_link,$this->rs->cat_id, 
    87                html::escapeHTML($this->rs->cat_title)); 
    88           } else { 
    89                $cat_title = __('None'); 
    90           } 
    91            
    92           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    93           switch ($this->rs->post_status) { 
    94                case 1: 
    95                     $img_status = sprintf($img,__('published'),'check-on.png'); 
    96                     break; 
    97                case 0: 
    98                     $img_status = sprintf($img,__('unpublished'),'check-off.png'); 
    99                     break; 
    100                case -1: 
    101                     $img_status = sprintf($img,__('scheduled'),'scheduled.png'); 
    102                     break; 
    103                case -2: 
    104                     $img_status = sprintf($img,__('pending'),'check-wrn.png'); 
    105                     break; 
    106           } 
    107            
    108           $protected = ''; 
    109           if ($this->rs->post_password) { 
    110                $protected = sprintf($img,__('protected'),'locker.png'); 
    111           } 
    112            
    113           $selected = ''; 
    114           if ($this->rs->post_selected) { 
    115                $selected = sprintf($img,__('selected'),'selected.png'); 
    116           } 
    117            
    118           $attach = ''; 
    119           $nb_media = $this->rs->countMedia(); 
    120           if ($nb_media > 0) { 
    121                $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); 
    122                $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); 
    123           } 
    124            
    125           $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. 
    126           ' id="p'.$this->rs->post_id.'">'; 
    127            
    128           $res .= 
    129           '<td class="nowrap">'. 
    130           form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).'</td>'. 
    131           '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. 
    132           html::escapeHTML($this->rs->post_title).'</a></td>'. 
    133           '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. 
    134           '<td class="nowrap">'.$cat_title.'</td>'. 
    135           '<td class="nowrap">'.$this->rs->user_id.'</td>'. 
    136           '<td class="nowrap">'.$this->rs->nb_comment.'</td>'. 
    137           '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'. 
    138           '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. 
    139           '</tr>'; 
    140            
    141           return $res; 
    14264     } 
    14365} 
    14466 
    145 class adminPostMiniList extends adminGenericList 
    146 { 
    147      public function display($page,$nb_per_page,$enclose_block='') 
    148      { 
    149           if ($this->rs->isEmpty()) 
    150           { 
    151                echo '<p><strong>'.__('No entry').'</strong></p>'; 
    152           } 
    153           else 
    154           { 
    155                $pager = new pager($page,$this->rs_count,$nb_per_page,10); 
    156                $pager->html_prev = $this->html_prev; 
    157                $pager->html_next = $this->html_next; 
    158                $pager->var_page = 'page'; 
    159                 
    160                $html_block = 
    161                '<table class="clear"><tr>'. 
    162                '<th>'.__('Title').'</th>'. 
    163                '<th>'.__('Date').'</th>'. 
    164                '<th>'.__('Author').'</th>'. 
    165                '<th>'.__('Status').'</th>'. 
    166                '</tr>%s</table>'; 
    167                 
    168                if ($enclose_block) { 
    169                     $html_block = sprintf($enclose_block,$html_block); 
    170                } 
    171                 
    172                echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
    173                 
    174                $blocks = explode('%s',$html_block); 
    175                 
    176                echo $blocks[0]; 
    177                 
    178                while ($this->rs->fetch()) 
    179                { 
    180                     echo $this->postLine(); 
    181                } 
    182                 
    183                echo $blocks[1]; 
    184                 
    185                echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
    186           } 
    187      } 
    188       
    189      private function postLine() 
    190      { 
    191           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    192           switch ($this->rs->post_status) { 
    193                case 1: 
    194                     $img_status = sprintf($img,__('published'),'check-on.png'); 
    195                     break; 
    196                case 0: 
    197                     $img_status = sprintf($img,__('unpublished'),'check-off.png'); 
    198                     break; 
    199                case -1: 
    200                     $img_status = sprintf($img,__('scheduled'),'scheduled.png'); 
    201                     break; 
    202                case -2: 
    203                     $img_status = sprintf($img,__('pending'),'check-wrn.png'); 
    204                     break; 
    205           } 
    206            
    207           $protected = ''; 
    208           if ($this->rs->post_password) { 
    209                $protected = sprintf($img,__('protected'),'locker.png'); 
    210           } 
    211            
    212           $selected = ''; 
    213           if ($this->rs->post_selected) { 
    214                $selected = sprintf($img,__('selected'),'selected.png'); 
    215           } 
    216            
    217           $attach = ''; 
    218           $nb_media = $this->rs->countMedia(); 
    219           if ($nb_media > 0) { 
    220                $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); 
    221                $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); 
    222           } 
    223            
    224           $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. 
    225           ' id="p'.$this->rs->post_id.'">'; 
    226            
    227           $res .= 
    228           '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '. 
    229           'title="'.html::escapeHTML($this->rs->getURL()).'">'. 
    230           html::escapeHTML($this->rs->post_title).'</a></td>'. 
    231           '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. 
    232           '<td class="nowrap">'.$this->rs->user_id.'</td>'. 
    233           '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. 
    234           '</tr>'; 
    235            
    236           return $res; 
    237      } 
    238 } 
    239  
    240 class adminCommentList extends adminGenericList 
    241 { 
    242      public function display($page,$nb_per_page,$enclose_block='') 
    243      { 
    244           if ($this->rs->isEmpty()) 
    245           { 
    246                echo '<p><strong>'.__('No comment').'</strong></p>'; 
    247           } 
    248           else 
    249           { 
    250                $pager = new pager($page,$this->rs_count,$nb_per_page,10); 
    251                $pager->html_prev = $this->html_prev; 
    252                $pager->html_next = $this->html_next; 
    253                $pager->var_page = 'page'; 
    254                 
    255                $html_block = 
    256                '<table><tr>'. 
    257                '<th colspan="2">'.__('Title').'</th>'. 
    258                '<th>'.__('Date').'</th>'. 
    259                '<th>'.__('Author').'</th>'. 
    260                '<th>'.__('Type').'</th>'. 
    261                '<th>'.__('Status').'</th>'. 
    262                '<th>&nbsp;</th>'. 
    263                '</tr>%s</table>'; 
    264                 
    265                if ($enclose_block) { 
    266                     $html_block = sprintf($enclose_block,$html_block); 
    267                } 
    268                 
    269                echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
    270                 
    271                $blocks = explode('%s',$html_block); 
    272                 
    273                echo $blocks[0]; 
    274                 
    275                while ($this->rs->fetch()) 
    276                { 
    277                     echo $this->commentLine(); 
    278                } 
    279                 
    280                echo $blocks[1]; 
    281                 
    282                echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
    283           } 
    284      } 
    285       
    286      private function commentLine() 
    287      { 
    288           global $author, $status, $sortby, $order, $nb_per_page; 
    289            
    290           $author_url = 
    291           'comments.php?n='.$nb_per_page. 
    292           '&amp;status='.$status. 
    293           '&amp;sortby='.$sortby. 
    294           '&amp;order='.$order. 
    295           '&amp;author='.rawurlencode($this->rs->comment_author); 
    296            
    297           $post_url = $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id); 
    298            
    299           $comment_url = 'comment.php?id='.$this->rs->comment_id; 
    300            
    301           $comment_dt = 
    302           dt::dt2str($this->core->blog->settings->system->date_format.' - '. 
    303           $this->core->blog->settings->system->time_format,$this->rs->comment_dt); 
    304            
    305           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    306           switch ($this->rs->comment_status) { 
    307                case 1: 
    308                     $img_status = sprintf($img,__('published'),'check-on.png'); 
    309                     break; 
    310                case 0: 
    311                     $img_status = sprintf($img,__('unpublished'),'check-off.png'); 
    312                     break; 
    313                case -1: 
    314                     $img_status = sprintf($img,__('pending'),'check-wrn.png'); 
    315                     break; 
    316                case -2: 
    317                     $img_status = sprintf($img,__('junk'),'junk.png'); 
    318                     break; 
    319           } 
    320            
    321           $comment_author = html::escapeHTML($this->rs->comment_author); 
    322           if (mb_strlen($comment_author) > 20) { 
    323                $comment_author = mb_strcut($comment_author,0,17).'...'; 
    324           } 
    325            
    326           $res = '<tr class="line'.($this->rs->comment_status != 1 ? ' offline' : '').'"'. 
    327           ' id="c'.$this->rs->comment_id.'">'; 
    328            
    329           $res .= 
    330           '<td class="nowrap">'. 
    331           form::checkbox(array('comments[]'),$this->rs->comment_id,'','','',0).'</td>'. 
    332           '<td class="maximal"><a href="'.$post_url.'">'. 
    333           html::escapeHTML($this->rs->post_title).'</a>'. 
    334           ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').'</td>'. 
    335           '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'</td>'. 
    336           '<td class="nowrap"><a href="'.$author_url.'">'.$comment_author.'</a></td>'. 
    337           '<td class="nowrap">'.($this->rs->comment_trackback ? __('trackback') : __('comment')).'</td>'. 
    338           '<td class="nowrap status">'.$img_status.'</td>'. 
    339           '<td class="nowrap status"><a href="'.$comment_url.'">'. 
    340           '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'; 
    341            
    342           $res .= '</tr>'; 
    343            
    344           return $res; 
    345      } 
    346 } 
    347  
    348 class adminUserList extends adminGenericList 
    349 { 
    350      public function display($page,$nb_per_page,$enclose_block='') 
    351      { 
    352           if ($this->rs->isEmpty()) 
    353           { 
    354                echo '<p><strong>'.__('No user').'</strong></p>'; 
    355           } 
    356           else 
    357           { 
    358                $pager = new pager($page,$this->rs_count,$nb_per_page,10); 
    359                $pager->html_prev = $this->html_prev; 
    360                $pager->html_next = $this->html_next; 
    361                $pager->var_page = 'page'; 
    362                 
    363                $html_block = 
    364                '<table class="clear"><tr>'. 
    365                '<th colspan="2">'.__('Username').'</th>'. 
    366                '<th>'.__('First Name').'</th>'. 
    367                '<th>'.__('Last Name').'</th>'. 
    368                '<th>'.__('Display name').'</th>'. 
    369                '<th class="nowrap">'.__('Entries').'</th>'. 
    370                '</tr>%s</table>'; 
    371                 
    372                if ($enclose_block) { 
    373                     $html_block = sprintf($enclose_block,$html_block); 
    374                } 
    375                 
    376                echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
    377                 
    378                $blocks = explode('%s',$html_block); 
    379                 
    380                echo $blocks[0]; 
    381                 
    382                while ($this->rs->fetch()) 
    383                { 
    384                     echo $this->userLine(); 
    385                } 
    386                 
    387                echo $blocks[1]; 
    388                 
    389                echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
    390           } 
    391      } 
    392       
    393      private function userLine() 
    394      { 
    395           $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    396           $img_status = ''; 
    397            
    398           $p = $this->core->getUserPermissions($this->rs->user_id); 
    399            
    400           if (isset($p[$this->core->blog->id]['p']['admin'])) { 
    401                $img_status = sprintf($img,__('admin'),'admin.png'); 
    402           } 
    403           if ($this->rs->user_super) { 
    404                $img_status = sprintf($img,__('superadmin'),'superadmin.png'); 
    405           } 
    406           return 
    407           '<tr class="line">'. 
    408           '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post). 
    409           form::checkbox(array('user_id[]'),$this->rs->user_id).'</td>'. 
    410           '<td class="maximal"><a href="user.php?id='.$this->rs->user_id.'">'. 
    411           $this->rs->user_id.'</a>&nbsp;'.$img_status.'</td>'. 
    412           '<td class="nowrap">'.$this->rs->user_firstname.'</td>'. 
    413           '<td class="nowrap">'.$this->rs->user_name.'</td>'. 
    414           '<td class="nowrap">'.$this->rs->user_displayname.'</td>'. 
    415           '<td class="nowrap"><a href="posts.php?user_id='.$this->rs->user_id.'">'. 
    416           $this->rs->nb_post.'</a></td>'. 
    417           '</tr>'; 
    418      } 
    419 } 
    42067?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map