Dotclear


Ignore:
Timestamp:
08/14/12 15:43:05 (13 years ago)
Author:
Dsls <dsls@…>
Branch:
sexy
Message:

Turned db fetches into foreach, upgraded jquery

File:
1 edited

Legend:

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

    r852 r873  
    1515{ 
    1616     protected $core; 
    17      protected $rs; 
    18      protected $rs_count; 
    19       
    20      public function __construct($core,$rs,$rs_count) 
     17     protected $items; 
     18     protected $item_count; 
     19      
     20     public function __construct($core,$items,$item_count) 
    2121     { 
    2222          $this->core =& $core; 
    23           $this->rs =& $rs; 
    24           $this->rs_count = $rs_count; 
     23          $this->items =& $items; 
     24          $this->item_count = $item_count; 
    2525          $this->html_prev = __('&#171;prev.'); 
    2626          $this->html_next = __('next&#187;'); 
     
    3232     public function display($page,$nb_per_page,$enclose_block='') 
    3333     { 
    34           if ($this->rs->isEmpty()) 
     34          if (count($this->items) == 0) 
    3535          { 
    3636               echo '<p><strong>'.__('No entry').'</strong></p>'; 
     
    3838          else 
    3939          { 
    40                $pager = new pager($page,$this->rs_count,$nb_per_page,10); 
     40               $pager = new pager($page,$this->item_count,$nb_per_page,10); 
    4141               $pager->html_prev = $this->html_prev; 
    4242               $pager->html_next = $this->html_next; 
     
    6161               echo $blocks[0]; 
    6262                
    63                while ($this->rs->fetch()) 
     63               foreach ($this->items as $item) 
    6464               { 
    65                     echo $this->postLine(); 
     65                    echo $this->postLine($item); 
    6666               } 
    6767                
     
    7272     } 
    7373      
    74      private function postLine() 
     74     private function postLine($item) 
    7575     { 
    7676          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    77           switch ($this->rs->post_status) { 
     77          switch ($item->post_status) { 
    7878               case 1: 
    7979                    $img_status = sprintf($img,__('published'),'check-on.png'); 
     
    9191           
    9292          $protected = ''; 
    93           if ($this->rs->post_password) { 
     93          if ($item->post_password) { 
    9494               $protected = sprintf($img,__('protected'),'locker.png'); 
    9595          } 
    9696           
    9797          $selected = ''; 
    98           if ($this->rs->post_selected) { 
     98          if ($item->post_selected) { 
    9999               $selected = sprintf($img,__('selected'),'selected.png'); 
    100100          } 
    101101           
    102102           
    103           $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. 
    104           ' id="p'.$this->rs->post_id.'">'; 
     103          $res = '<tr class="line'.($item->post_status != 1 ? ' offline' : '').'"'. 
     104          ' id="p'.$item->post_id.'">'; 
    105105           
    106106          $res .= 
    107107          '<td class="nowrap">'. 
    108           form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).'</td>'. 
    109           '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. 
    110           html::escapeHTML($this->rs->post_title).'</a></td>'. 
    111           '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. 
    112           '<td class="nowrap">'.$this->rs->user_id.'</td>'. 
     108          form::checkbox(array('entries[]'),$item->post_id,'','','',!$item->isEditable()).'</td>'. 
     109          '<td class="maximal"><a href="'.$this->core->getPostAdminURL($item->post_type,$item->post_id).'">'. 
     110          html::escapeHTML($item->post_title).'</a></td>'. 
     111          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$item->post_dt).'</td>'. 
     112          '<td class="nowrap">'.$item->user_id.'</td>'. 
    113113          '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.'</td>'. 
    114114          '</tr>'; 
     
    122122     public function display($page,$nb_per_page,$enclose_block='') 
    123123     { 
    124           if ($this->rs->isEmpty()) 
     124          if (count($this->items) == 0) 
    125125          { 
    126126               echo '<p><strong>'.__('No entry').'</strong></p>'; 
     
    128128          else 
    129129          { 
    130                $pager = new pager($page,$this->rs_count,$nb_per_page,10); 
     130               $pager = new pager($page,$this->item_count,$nb_per_page,10); 
    131131               $pager->html_prev = $this->html_prev; 
    132132               $pager->html_next = $this->html_next; 
     
    151151               echo $blocks[0]; 
    152152                
    153                while ($this->rs->fetch()) 
     153               foreach ($this->items as $item) 
    154154               { 
    155                     echo $this->postLine(); 
     155                    echo $this->postLine($item); 
    156156               } 
    157157                
     
    162162     } 
    163163      
    164      private function postLine() 
     164     private function postLine($item) 
    165165     { 
    166166          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    167           switch ($this->rs->post_status) { 
     167          switch ($item->post_status) { 
    168168               case 1: 
    169169                    $img_status = sprintf($img,__('published'),'check-on.png'); 
     
    181181           
    182182          $protected = ''; 
    183           if ($this->rs->post_password) { 
     183          if ($item->post_password) { 
    184184               $protected = sprintf($img,__('protected'),'locker.png'); 
    185185          } 
    186186           
    187187          $selected = ''; 
    188           if ($this->rs->post_selected) { 
     188          if ($item->post_selected) { 
    189189               $selected = sprintf($img,__('selected'),'selected.png'); 
    190190          } 
    191191           
    192192           
    193           $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. 
    194           ' id="p'.$this->rs->post_id.'">'; 
     193          $res = '<tr class="line'.($item->post_status != 1 ? ' offline' : '').'"'. 
     194          ' id="p'.$item->post_id.'">'; 
    195195           
    196196          $res .= 
    197           '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '. 
    198           'title="'.html::escapeHTML($this->rs->getURL()).'">'. 
    199           html::escapeHTML($this->rs->post_title).'</a></td>'. 
    200           '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. 
    201           '<td class="nowrap">'.$this->rs->user_id.'</td>'. 
     197          '<td class="maximal"><a href="'.$this->core->getPostAdminURL($item->post_type,$item->post_id).'" '. 
     198          'title="'.html::escapeHTML($item->getURL()).'">'. 
     199          html::escapeHTML($item->post_title).'</a></td>'. 
     200          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$item->post_dt).'</td>'. 
     201          '<td class="nowrap">'.$item->user_id.'</td>'. 
    202202          '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.'</td>'. 
    203203          '</tr>'; 
     
    211211     public function display($page,$nb_per_page,$enclose_block='') 
    212212     { 
    213           if ($this->rs->isEmpty()) 
     213          if (count($this->items) == 0) 
    214214          { 
    215215               echo '<p><strong>'.__('No user').'</strong></p>'; 
     
    217217          else 
    218218          { 
    219                $pager = new pager($page,$this->rs_count,$nb_per_page,10); 
     219               $pager = new pager($page,$this->item_count,$nb_per_page,10); 
    220220               $pager->html_prev = $this->html_prev; 
    221221               $pager->html_next = $this->html_next; 
     
    241241               echo $blocks[0]; 
    242242                
    243                while ($this->rs->fetch()) 
     243               foreach ($this->items as $item) 
    244244               { 
    245                     echo $this->userLine(); 
     245                    echo $this->userLine($item); 
    246246               } 
    247247                
     
    252252     } 
    253253      
    254      private function userLine() 
     254     private function userLine($item) 
    255255     { 
    256256          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; 
    257257          $img_status = ''; 
    258258           
    259           $p = $this->core->getUserPermissions($this->rs->user_id); 
     259          $p = $this->core->getUserPermissions($item->user_id); 
    260260           
    261261          if (isset($p[$this->core->blog->id]['p']['admin'])) { 
    262262               $img_status = sprintf($img,__('admin'),'admin.png'); 
    263263          } 
    264           if ($this->rs->user_super) { 
     264          if ($item->user_super) { 
    265265               $img_status = sprintf($img,__('superadmin'),'superadmin.png'); 
    266266          } 
    267267          return 
    268268          '<tr class="line">'. 
    269           '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post). 
    270           form::checkbox(array('user_id[]'),$this->rs->user_id).'</td>'. 
    271           '<td class="maximal"><a href="user.php?id='.$this->rs->user_id.'">'. 
    272           $this->rs->user_id.'</a>&nbsp;'.$img_status.'</td>'. 
    273           '<td class="nowrap">'.$this->rs->user_firstname.'</td>'. 
    274           '<td class="nowrap">'.$this->rs->user_name.'</td>'. 
    275           '<td class="nowrap">'.$this->rs->user_displayname.'</td>'. 
    276           '<td class="nowrap"><a href="posts.php?user_id='.$this->rs->user_id.'">'. 
    277           $this->rs->nb_post.'</a></td>'. 
     269          '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $item->nb_post). 
     270          form::checkbox(array('user_id[]'),$item->user_id).'</td>'. 
     271          '<td class="maximal"><a href="user.php?id='.$item->user_id.'">'. 
     272          $item->user_id.'</a>&nbsp;'.$img_status.'</td>'. 
     273          '<td class="nowrap">'.$item->user_firstname.'</td>'. 
     274          '<td class="nowrap">'.$item->user_name.'</td>'. 
     275          '<td class="nowrap">'.$item->user_displayname.'</td>'. 
     276          '<td class="nowrap"><a href="posts.php?user_id='.$item->user_id.'">'. 
     277          $item->nb_post.'</a></td>'. 
    278278          '</tr>'; 
    279279     } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map