Dotclear


Ignore:
Timestamp:
05/11/11 18:13:45 (14 years ago)
Author:
Tomtom33 <tbouron@…>
Branch:
formfilters
Message:

Makes custom lists work

File:
1 edited

Legend:

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

    r238 r242  
    3232               throw new Exception(__('Invalid column title')); 
    3333          } 
     34           
    3435          if (is_null($html) || !is_string($html)) { 
    3536               $html = ''; 
    3637          } 
     38          if (!empty($html)) { 
     39               $html = ' '.$html; 
     40          } 
     41           
    3742          if (!is_int($order)) { 
    3843               $order = null; 
     
    4045           
    4146          try { 
     47               if (!is_array($callback) || count($callback) < 2) { 
     48                    throw new Exception(__('Callback parameter should be an array')); 
     49               } 
    4250               $r = new ReflectionClass($callback[0]); 
    4351               $f = $r->getMethod($callback[1]); 
    4452               $p = $r->getParentClass(); 
    4553               if (!$p || $p->name != 'adminGenericList') { 
    46                     throw new Exception(__('Invalid callback')); 
     54                    throw new Exception(__('Callback class should be inherited of adminGenericList class')); 
    4755               } 
    4856          } 
    4957          catch (Exception $e) { 
    50                throw new Exception(__('Invalid callback')); 
     58               throw new Exception(sprintf(__('Invalid column callback: %s'),$e->getMessage())); 
    5159          } 
    5260           
     
    8492     protected $columns; 
    8593      
    86       
    8794     public function __construct($core,$rs,$rs_count) 
    8895     { 
     
    9299          $this->context = get_class($this); 
    93100          $this->columns = array(); 
    94           $this->column_pattern = 'c_%s'; 
     101          $this->form_prefix = 'col_%s'; 
     102          $this->form_trigger = 'add_filter'; 
    95103           
    96104          $this->html_prev = __('&#171;prev.'); 
     
    120128          $this->addColumn('adminCommentList','edit','',array('adminCommentList','getEdit')); 
    121129           
    122           # Comment columns 
     130          # User columns 
    123131          $this->addColumn('adminUserList','username',__('Username'),array('adminUserList','getUserName')); 
    124132          $this->addColumn('adminUserList','firstname',__('First name'),array('adminUserList','getFirstName')); 
     
    151159     public function setColumnsVisibility() 
    152160     { 
     161          if (array_key_exists($this->form_trigger,$_REQUEST)) { 
     162               foreach ($this->columns[$this->context] as $k => $v) { 
     163                    $key = sprintf($this->form_prefix,$k); 
     164                    if (!array_key_exists($key,$_REQUEST)) { 
     165                         $v->setVisibility(false); 
     166                    } 
     167               } 
     168          } 
     169     } 
     170      
     171     public function getColumnsForm() 
     172     { 
     173          $block =  
     174          '<h3>'.__('Displayed information').'</h3>'. 
     175          '<ul>%s</ul>'; 
     176           
     177          $list = array(); 
     178           
    153179          foreach ($this->columns[$this->context] as $k => $v) { 
    154                $key = sprintf($this->column_pattern,$k); 
    155                if (array_key_exists($key,$_REQUEST)) { 
    156                     $v->setVisibility((bool) $key); 
    157                } 
    158           } 
     180               $col_id = sprintf($this->form_prefix,$k); 
     181               $col_label = sprintf('<label for="%s">%s</label>',$col_id,$v->getInfo('title')); 
     182               $col_html = sprintf('<li class="line">%s</li>',$col_label.form::checkbox($col_id,1,$v->isVisible())); 
     183                
     184               array_push($list,$col_html); 
     185          } 
     186           
     187          return !empty($list) ? sprintf($block,implode('',$list)) : ''; 
    159188     } 
    160189      
     
    330359     } 
    331360      
    332      protected function getContent() 
    333      { 
    334           return 
    335           '<tr class="line'.($this->rs->comment_status != 1 ? ' offline' : '').'"'. 
    336           ' id="c'.$this->rs->comment_id.'">%s</tr>'; 
    337      } 
    338       
    339361     protected function getTitle() 
    340362     { 
     
    342364           
    343365          return 
    344           '<td class="maximal"><a href="'.$post_url.'">'. 
     366          '<td class="maximal">'. 
     367          form::checkbox(array('comments[]'),$this->rs->comment_id,'','','',0).'&nbsp'. 
     368          '<a href="'.$post_url.'">'. 
    345369          html::escapeHTML($this->rs->post_title).'</a>'. 
    346370          ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').'</td>'; 
     
    425449          return 
    426450          '<td class="maximal">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post). 
    427           form::checkbox(array('user_id[]'),$this->rs->user_id). 
     451          form::checkbox(array('user_id[]'),$this->rs->user_id).'&nbsp;'. 
    428452          '<a href="user.php?id='.$this->rs->user_id.'">'. 
    429453          $this->rs->user_id.'</a>&nbsp;'.$img_status.'</td>'; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map