Dotclear


Ignore:
Timestamp:
08/22/13 16:37:27 (12 years ago)
Author:
Dsls
Branch:
twig
Message:

columns selection is now functional in admin lists

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/class.dc.list.php

    r1507 r1524  
    6666      
    6767     protected function setupFilterset() { 
     68          foreach ($this->columns as $c) { 
     69               $this->filterset->addfilter($c->getFilter()); 
     70          } 
    6871          $this->sortby = new dcFilterCombo( 
    6972               'sortby', 
     
    134137          } 
    135138     } 
    136  
     139      
    137140     public function getContext() { 
    138141          $ccontext = new ArrayObject(); 
    139142          foreach ($this->columns as $c) { 
    140                $c->appendEditLines($ccontext); 
     143               if ($c->isEnabled()) { 
     144                    $c->appendEditLines($ccontext); 
     145               } 
    141146          } 
    142147          $page = $this->page; 
     
    166171     } 
    167172 
    168      public function addColumn($c) { 
     173     public function addColumn(dcColumn $c) { 
    169174          $this->columns[$c->getID()] = $c; 
    170175          $c->setForm($this); 
     
    189194     protected $sortable; 
    190195     protected $col_id; 
     196     protected $filter; 
     197     protected $locked; 
    191198 
    192199     public function __construct($id, $name, $col_id,$attributes=array()) { 
     
    194201          $this->name = $name; 
    195202          $this->col_id = $col_id; 
    196      } 
    197  
     203          $this->locked = isset($attributes['locked']) && $attributes['locked']; 
     204          $this->filter = new dcFilterCheckbox('col'.$id,$name,$name,'',array('static'=>true,'locked'=>$this->locked)); 
     205     } 
     206 
     207     public function getFilter () { 
     208          return $this->filter; 
     209     } 
    198210     public function getName() { 
    199211          return $this->name; 
     
    212224     } 
    213225 
     226     public function isEnabled() { 
     227          $v = $this->filter->getAppliedValues(); 
     228          return $v['values']['1']==1; 
     229     } 
    214230     public function appendEditLines($line) { 
    215231          $line[] = array ( 
     
    231247} 
    232248 
     249/** 
     250* dcFilterText - basic single field text filter 
     251* 
     252* @uses     dcFilter 
     253* 
     254*/ 
     255class dcFilterCheckbox extends dcFilter { 
     256 
     257    /** 
     258     * @see dcFilter::init() 
     259     */ 
     260     public function init() { 
     261          $foptions = array('label' => $this->name); 
     262          if (isset($this->options['locked']) && $this->options['locked']){ 
     263               $foptions['read_only']= true; 
     264          } 
     265          $this->field = new dcFieldCheckbox($this->filter_id,false,$foptions); 
     266          $this->filterset->addField($this->field); 
     267          $this->multiple = false; 
     268     } 
     269 
     270     protected function parseData($data) { 
     271          return parent::parseData($data); 
     272     } 
     273    /** 
     274     * @see dcFilter::appendContextLine() 
     275     */ 
     276     public function appendContextLine($line,$pos) { 
     277          /* 
     278          Extra data provided by this filter : 
     279          * ffield : field name 
     280          * display_inline : true if the field is static 
     281          * fwidget : name of the widget (filter_text) 
     282          * desc : filter description 
     283           */ 
     284          $line['ffield'] = $this->field->getName(); 
     285          if ($this->static) { 
     286               $line['display_inline'] = true; 
     287          } 
     288          if ($pos == 0) { 
     289 
     290               $line['fwidget']='filter_boolean'; 
     291               $line['desc']=$this->desc; 
     292          }; 
     293     } 
     294 
     295    /** 
     296     * @see dcFilter::addValue() 
     297     */ 
     298    protected function addValue($value=NULL) { 
     299          $this->field->addValue($value,true); 
     300     } 
     301 
     302    /** 
     303     * @see dcFilter::applyFilter() 
     304     */ 
     305     public function applyFilter($params) { 
     306     } 
     307      
     308     public function getAppliedFilterText() { 
     309          return ""; 
     310     } 
     311} 
     312 
    233313dcItemList::__init__($GLOBALS['core']->tpl); 
    234314 
Note: See TracChangeset for help on using the changeset viewer.

Sites map