Dotclear

Changeset 1524:913f5a36bbb0


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

columns selection is now functional in admin lists

Location:
inc/admin
Files:
6 edited

Legend:

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

    r1517 r1524  
    136136                         array())) 
    137137               ->addField ( 
    138                     new  dcFieldSubmit($p.'add',__('Add this filter'), 
    139                          array())) 
     138                    new  dcFieldSubmit($p.'add',' + ', 
     139                         array( 
     140                              'attr' => array('title' => __('Add this filter'))))) 
    140141               ->addField ( 
    141142                    new dcFieldSubmit($p.'clear_filters',__('Delete all filters'), 
     
    692693     */ 
    693694     public function appendFilterContext($ctx) { 
    694           foreach ($this->field->getValues() as $cur => $f) { 
     695          $cur=0; 
     696          foreach ($this->field->getValues() as $k => $f) { 
    695697               /* 
    696698               * each line of context has the following properties : 
     
    714716               $this->appendContextLine($line,$cur); 
    715717               $ctx[]=$line; 
     718               $cur++; 
    716719          } 
    717720     } 
     
    779782     public function getFields() { 
    780783          return $this->field; 
     784     } 
     785      
     786     public function getAppliedValues() { 
     787          return $this->avalues; 
    781788     } 
    782789} 
  • inc/admin/class.dc.form.php

    r1517 r1524  
    957957     } 
    958958      
    959     /** 
     959         /** 
    960960     * Returns whether can have multiple values or not 
    961961     * 
     
    10391039          if (isset($this->values[$offset])) { 
    10401040               return $this->values[$offset]; 
     1041          } else { 
     1042               return NULL; 
    10411043          } 
    10421044     } 
     
    11011103          } 
    11021104           
    1103           if (isset($this->values[$offset])) { 
    1104                $attr['value'] = $this->values[$offset]; 
    1105           } else { 
    1106                $attr['value'] = $this->getDefaultValue(); 
     1105          $attr['value'] = $this->getValue($offset); 
     1106          if ($attr['value'] == NULL) { 
     1107               $attr['value']= $this->getDefaultValue(); 
    11071108          } 
    11081109          if ($offset==0 && !empty($this->id)) { 
     
    12701271class dcFieldCheckbox extends dcField 
    12711272{ 
    1272      protected $checked; 
     1273     //protected $checked; 
    12731274      
    12741275     public function __construct($name,$values,$options=array()) 
     
    12771278          if (!is_array($values) && $values !== null) { 
    12781279               $values = array("1" => !empty($values)); 
    1279           } 
    1280  
    1281           if (is_array($values)) { 
    1282                $keys = array_keys($values); 
    1283                $this->checked = $values; 
    1284           } else { 
    1285                $keys = array(); 
    1286                $this->checked = array(); 
    1287           } 
    1288            
    1289           parent::__construct($name,$keys,$options); 
     1280          }          
     1281          parent::__construct($name,$values,$options); 
    12901282     } 
    12911283 
     
    12991291     */ 
    13001292     public function setValue($value,$offset=0) { 
    1301           $this->checked[$this->values[0]] = $value; 
    1302      } 
    1303       
     1293          $keys = array_keys($this->values); 
     1294          if (isset($keys[$offset])) { 
     1295               $this->values[$keys[$offset]] = $value; 
     1296          } 
     1297     } 
     1298      
     1299     public function addValue ($value,$checked=false) { 
     1300          $this->values[$value] = $checked; 
     1301     } 
     1302 
    13041303     public function getValue($offset=0) { 
    1305           $val = parent::getValue($offset); 
    1306           if (isset($this->checked[$val])) { 
    1307                return $this->checked[$val]?$val:false; 
     1304          $keys = array_keys($this->values); 
     1305          if (isset($keys[$offset])) { 
     1306               return $this->values[$keys[$offset]]; 
    13081307          } else { 
    13091308               return false; 
     
    13131312     public function getAttributes($options=array()) 
    13141313     { 
     1314          $offset = 0; 
     1315          if (isset($options['offset'])) { 
     1316               $offset = $options['offset']; 
     1317          } 
    13151318          $a = parent::getAttributes($options); 
     1319          $keys = array_keys($this->values); 
     1320          if (isset( $keys[$offset])) { 
     1321               $val = $keys[$offset]; 
     1322               $a['value'] = $val; 
     1323               if (isset($this->values[$val]) && $this->values[$val]) { 
     1324                    $a['checked']='checked'; 
     1325               } 
     1326          } 
    13161327           
    1317           $val = $a['value']; 
    1318           if (isset($this->checked[$val]) && $this->checked[$val]) { 
    1319                $a['checked']='checked'; 
    1320           } 
    13211328          return $a; 
    13221329     } 
    13231330 
    1324      public function setup($from) 
    1325      { 
    1326           $this->defined = true; 
    1327           $values = $this->parseValues($from); 
    1328           foreach ($this->checked as $k=>&$v) { 
     1331     public function parseValues($from) { 
     1332          $val = parent::parseValues($from); 
     1333          $arr = $this->values; 
     1334          foreach ($arr as $k=>&$v) { 
    13291335               $v=false; 
    13301336          } 
    1331           foreach ($values as $v) { 
    1332                $this->checked[$v] = true; 
    1333           } 
    1334           $this->setValues(array_keys($this->checked)); 
    1335      } 
     1337          foreach ($val as $v) { 
     1338               if (isset($arr[$v])) { 
     1339                    $arr[$v]=true; 
     1340               } 
     1341          } 
     1342          return $arr; 
     1343     } 
     1344 
    13361345 
    13371346     public function getWidgetBlock() 
  • 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 
  • inc/admin/default-templates/forms/formfilter_layout.html.twig

    r1517 r1524  
    3333     </div> 
    3434     <div class="col30"> 
     35          <h3>{{__('Displayed information')}}</h3> 
    3536          {%- for f in fenv.static_filters -%} 
    3637               {{block(f.fwidget)}} 
     
    6364{% block filter_combo -%} 
    6465     {% if f.display_inline is defined -%} 
    65           <p id='{{f.filter_id}}'>{{form_field(f.ffield,{'offset':f.foffset},{'label':f.desc,'nestedlabel': true, 'labelclass':'classic' })}}</p> 
     66          <p>{{form_field(f.ffield,{'offset':f.foffset},{'label':f.desc,'nestedlabel': true, 'labelclass':'classic' })}}</p> 
    6667     {%- else -%} 
    6768          <td id='{{f.filter_id}}' title='{{f.desc}}' class="filter-title" colspan="2">{{f.desc}} : </td> 
     
    8081 
    8182{% block filter_richcombo -%} 
    82      <td id='{{filterd_id}}' title='{{f.desc}}' class="filter-title">{{f.desc}} : </td> 
    83      <td>{{ form_field(f.fverb)}}</td> 
    84      <td>{{ form_field(f.ffield,{'offset':f.foffset}) }}</td> 
     83     {% if f.display_inline is defined -%} 
     84          <p id='{{f.filter_id}}'>{{ form_field(f.fverb)}}{{form_field(f.ffield,{'offset':f.foffset},{'label':f.desc,'nestedlabel': true, 'labelclass':'classic' })}}</p> 
     85     {% else %} 
     86          <td id='{{filterd_id}}' title='{{f.desc}}' class="filter-title">{{f.desc}} : </td> 
     87          <td>{{ form_field(f.fverb)}}</td> 
     88          <td>{{ form_field(f.ffield,{'offset':f.foffset}) }}</td> 
     89     {% endif %} 
    8590{%- endblock %} 
    8691 
    8792 
    8893{% block filter_boolean -%} 
    89      <td id='{{filterd_id}}' title='{{f.desc}}' class="filter-title" colspan="2">{{f.desc}}</td> 
    90      <td>{{ form_field(f.ffield,{'offset':f.foffset}) }}</td> 
     94     {% if f.display_inline is defined -%} 
     95          <p>{{form_field(f.ffield)}}</p> 
     96     {% endif %}     
    9197{%- endblock %} 
    9298 
  • inc/admin/default-templates/forms/lists_layout.html.twig

    r1517 r1524  
    2424          {% for e in lenv.entries %} 
    2525               {% block list_line_start %}<tr class="line">{% endblock %} 
    26                <td>{{widget('col_ref',{'e':e,'offset':loop.parent.loop.index0})}}</td> 
     26               <td>{{widget('col_ref',{'e':e,'offset':loop.index0})}}</td> 
    2727               {% for h in lenv.cols %} 
    2828                    <td>{{widget(h.widget,{'e':e,'offset':loop.parent.loop.index0})}}</td> 
  • inc/admin/default-templates/posts_cols.html.twig

    r1507 r1524  
    2525{%- endblock %} 
    2626 
    27 {% block col_status %} 
     27{% block col_status -%} 
    2828{% set statuses = { 
    29      "0": {'img' : 'check-off.png', 'name':__('unpublished')}, 
    30      "1": {'img' : 'check-on.png', 'name':__('published')}, 
    31      "-1": {'img' : 'scheduled.png', 'name':__('scheduled')}, 
    32      "-2": {'img' : 'check-wrn.png', 'name':__('pending')}} 
     29     "0": {'img' : 'check-off.png', 'name':__('Unpublished')}, 
     30     "1": {'img' : 'check-on.png', 'name':__('Published')}, 
     31     "-1": {'img' : 'scheduled.png', 'name':__('Scheduled')}, 
     32     "-2": {'img' : 'check-wrn.png', 'name':__('Pending')}} 
    3333%} 
    3434<img alt="{{statuses[e.post_status].name}}" src="images/{{statuses[e.post_status].img}}" /> 
    35 {% endblock %} 
     35{% if e.post_selected -%} 
     36     <img alt="{{__('Selected')}}" src="images/selected.png" /> 
     37{%- endif %} 
     38{%- endblock %} 
    3639 
    3740{% block list_line_start %}  
Note: See TracChangeset for help on using the changeset viewer.

Sites map