Changeset 242:57cb73269f1e for inc/admin/lib.pager.php
- Timestamp:
- 05/11/11 18:13:45 (14 years ago)
- Branch:
- formfilters
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/lib.pager.php
r238 r242 32 32 throw new Exception(__('Invalid column title')); 33 33 } 34 34 35 if (is_null($html) || !is_string($html)) { 35 36 $html = ''; 36 37 } 38 if (!empty($html)) { 39 $html = ' '.$html; 40 } 41 37 42 if (!is_int($order)) { 38 43 $order = null; … … 40 45 41 46 try { 47 if (!is_array($callback) || count($callback) < 2) { 48 throw new Exception(__('Callback parameter should be an array')); 49 } 42 50 $r = new ReflectionClass($callback[0]); 43 51 $f = $r->getMethod($callback[1]); 44 52 $p = $r->getParentClass(); 45 53 if (!$p || $p->name != 'adminGenericList') { 46 throw new Exception(__(' Invalid callback'));54 throw new Exception(__('Callback class should be inherited of adminGenericList class')); 47 55 } 48 56 } 49 57 catch (Exception $e) { 50 throw new Exception( __('Invalid callback'));58 throw new Exception(sprintf(__('Invalid column callback: %s'),$e->getMessage())); 51 59 } 52 60 … … 84 92 protected $columns; 85 93 86 87 94 public function __construct($core,$rs,$rs_count) 88 95 { … … 92 99 $this->context = get_class($this); 93 100 $this->columns = array(); 94 $this->column_pattern = 'c_%s'; 101 $this->form_prefix = 'col_%s'; 102 $this->form_trigger = 'add_filter'; 95 103 96 104 $this->html_prev = __('«prev.'); … … 120 128 $this->addColumn('adminCommentList','edit','',array('adminCommentList','getEdit')); 121 129 122 # Commentcolumns130 # User columns 123 131 $this->addColumn('adminUserList','username',__('Username'),array('adminUserList','getUserName')); 124 132 $this->addColumn('adminUserList','firstname',__('First name'),array('adminUserList','getFirstName')); … … 151 159 public function setColumnsVisibility() 152 160 { 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 153 179 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)) : ''; 159 188 } 160 189 … … 330 359 } 331 360 332 protected function getContent()333 {334 return335 '<tr class="line'.($this->rs->comment_status != 1 ? ' offline' : '').'"'.336 ' id="c'.$this->rs->comment_id.'">%s</tr>';337 }338 339 361 protected function getTitle() 340 362 { … … 342 364 343 365 return 344 '<td class="maximal"><a href="'.$post_url.'">'. 366 '<td class="maximal">'. 367 form::checkbox(array('comments[]'),$this->rs->comment_id,'','','',0).' '. 368 '<a href="'.$post_url.'">'. 345 369 html::escapeHTML($this->rs->post_title).'</a>'. 346 370 ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').'</td>'; … … 425 449 return 426 450 '<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).' '. 428 452 '<a href="user.php?id='.$this->rs->user_id.'">'. 429 453 $this->rs->user_id.'</a> '.$img_status.'</td>';
Note: See TracChangeset
for help on using the changeset viewer.