Changeset 1524:913f5a36bbb0
- Timestamp:
- 08/22/13 16:37:27 (12 years ago)
- Branch:
- twig
- Location:
- inc/admin
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/class.dc.filter.php
r1517 r1524 136 136 array())) 137 137 ->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'))))) 140 141 ->addField ( 141 142 new dcFieldSubmit($p.'clear_filters',__('Delete all filters'), … … 692 693 */ 693 694 public function appendFilterContext($ctx) { 694 foreach ($this->field->getValues() as $cur => $f) { 695 $cur=0; 696 foreach ($this->field->getValues() as $k => $f) { 695 697 /* 696 698 * each line of context has the following properties : … … 714 716 $this->appendContextLine($line,$cur); 715 717 $ctx[]=$line; 718 $cur++; 716 719 } 717 720 } … … 779 782 public function getFields() { 780 783 return $this->field; 784 } 785 786 public function getAppliedValues() { 787 return $this->avalues; 781 788 } 782 789 } -
inc/admin/class.dc.form.php
r1517 r1524 957 957 } 958 958 959 /**959 /** 960 960 * Returns whether can have multiple values or not 961 961 * … … 1039 1039 if (isset($this->values[$offset])) { 1040 1040 return $this->values[$offset]; 1041 } else { 1042 return NULL; 1041 1043 } 1042 1044 } … … 1101 1103 } 1102 1104 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(); 1107 1108 } 1108 1109 if ($offset==0 && !empty($this->id)) { … … 1270 1271 class dcFieldCheckbox extends dcField 1271 1272 { 1272 protected $checked;1273 //protected $checked; 1273 1274 1274 1275 public function __construct($name,$values,$options=array()) … … 1277 1278 if (!is_array($values) && $values !== null) { 1278 1279 $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); 1290 1282 } 1291 1283 … … 1299 1291 */ 1300 1292 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 1304 1303 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]]; 1308 1307 } else { 1309 1308 return false; … … 1313 1312 public function getAttributes($options=array()) 1314 1313 { 1314 $offset = 0; 1315 if (isset($options['offset'])) { 1316 $offset = $options['offset']; 1317 } 1315 1318 $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 } 1316 1327 1317 $val = $a['value'];1318 if (isset($this->checked[$val]) && $this->checked[$val]) {1319 $a['checked']='checked';1320 }1321 1328 return $a; 1322 1329 } 1323 1330 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) { 1329 1335 $v=false; 1330 1336 } 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 1336 1345 1337 1346 public function getWidgetBlock() -
inc/admin/class.dc.list.php
r1507 r1524 66 66 67 67 protected function setupFilterset() { 68 foreach ($this->columns as $c) { 69 $this->filterset->addfilter($c->getFilter()); 70 } 68 71 $this->sortby = new dcFilterCombo( 69 72 'sortby', … … 134 137 } 135 138 } 136 139 137 140 public function getContext() { 138 141 $ccontext = new ArrayObject(); 139 142 foreach ($this->columns as $c) { 140 $c->appendEditLines($ccontext); 143 if ($c->isEnabled()) { 144 $c->appendEditLines($ccontext); 145 } 141 146 } 142 147 $page = $this->page; … … 166 171 } 167 172 168 public function addColumn( $c) {173 public function addColumn(dcColumn $c) { 169 174 $this->columns[$c->getID()] = $c; 170 175 $c->setForm($this); … … 189 194 protected $sortable; 190 195 protected $col_id; 196 protected $filter; 197 protected $locked; 191 198 192 199 public function __construct($id, $name, $col_id,$attributes=array()) { … … 194 201 $this->name = $name; 195 202 $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 } 198 210 public function getName() { 199 211 return $this->name; … … 212 224 } 213 225 226 public function isEnabled() { 227 $v = $this->filter->getAppliedValues(); 228 return $v['values']['1']==1; 229 } 214 230 public function appendEditLines($line) { 215 231 $line[] = array ( … … 231 247 } 232 248 249 /** 250 * dcFilterText - basic single field text filter 251 * 252 * @uses dcFilter 253 * 254 */ 255 class 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 233 313 dcItemList::__init__($GLOBALS['core']->tpl); 234 314 -
inc/admin/default-templates/forms/formfilter_layout.html.twig
r1517 r1524 33 33 </div> 34 34 <div class="col30"> 35 <h3>{{__('Displayed information')}}</h3> 35 36 {%- for f in fenv.static_filters -%} 36 37 {{block(f.fwidget)}} … … 63 64 {% block filter_combo -%} 64 65 {% 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> 66 67 {%- else -%} 67 68 <td id='{{f.filter_id}}' title='{{f.desc}}' class="filter-title" colspan="2">{{f.desc}} : </td> … … 80 81 81 82 {% 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 %} 85 90 {%- endblock %} 86 91 87 92 88 93 {% 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 %} 91 97 {%- endblock %} 92 98 -
inc/admin/default-templates/forms/lists_layout.html.twig
r1517 r1524 24 24 {% for e in lenv.entries %} 25 25 {% 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> 27 27 {% for h in lenv.cols %} 28 28 <td>{{widget(h.widget,{'e':e,'offset':loop.parent.loop.index0})}}</td> -
inc/admin/default-templates/posts_cols.html.twig
r1507 r1524 25 25 {%- endblock %} 26 26 27 {% block col_status %}27 {% block col_status -%} 28 28 {% 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')}} 33 33 %} 34 34 <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 %} 36 39 37 40 {% block list_line_start %}
Note: See TracChangeset
for help on using the changeset viewer.