Changeset 2395:5f4a14700462 for plugins/widgets/class.widgets.php
- Timestamp:
- 09/28/13 10:04:12 (12 years ago)
- Branch:
- widgets
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/widgets/class.widgets.php
r1474 r2395 139 139 public $append_callback = null; 140 140 private $settings = array(); 141 private $advance_id; 142 private $advanced_settings = array(); 141 143 142 144 public function serialize($order) { … … 144 146 foreach ($this->settings as $k=>$v) 145 147 $values[$k]=$v['value']; 148 foreach ($this->advanced_settings as $k=>$v) 149 $values[$k]=$v['value']; 146 150 $values['id']=$this->id; 147 151 $values['order']=$order; … … 189 193 public function __get($n) 190 194 { 195 $setting = null; 191 196 if (isset($this->settings[$n])) { 192 return $this->settings[$n]['value']; 193 } 194 return null; 197 $setting = $this->settings[$n]['value']; 198 } else if (isset($this->advanced_settings[$n])) { 199 $setting = $this->advanced_settings[$n]['value']; 200 } 201 return $setting; 195 202 } 196 203 … … 199 206 if (isset($this->settings[$n])) { 200 207 $this->settings[$n]['value'] = $v; 208 } else if (isset($this->advanced_settings[$n])) { 209 $this->advanced_settings[$n]['value'] = $v; 201 210 } 202 211 } … … 222 231 } 223 232 233 public function advanced_setting($name,$title,$value,$type='text') 234 { 235 if ($type == 'combo' || $type == 'radio') { 236 $options = @func_get_arg(4); 237 if (!is_array($options)) { 238 return false; 239 } 240 } 241 242 $this->advanced_settings[$name] = array( 243 'title' => $title, 244 'type' => $type, 245 'value' => $value 246 ); 247 248 if (isset($options)) { 249 $this->advanced_settings[$name]['options'] = $options; 250 } 251 } 252 253 public function advance_settings() 254 { 255 return $this->advanced_settings; 256 } 257 224 258 public function settings() 225 259 { … … 232 266 foreach ($this->settings as $id => $s) 233 267 { 234 $wfid = "wf-".$i; 235 $iname = $pr ? $pr.'['.$id.']' : $id; 236 switch ($s['type']) 268 $res .= $this->formSetting($id,$s,$pr,$i=0); 269 $i++; 270 } 271 272 if ( count($this->advanced_settings) > 0 ) 273 { 274 $res .= '<div class="widgetAdvancedSettings">'; 275 $res .= '<h5>'.__('Réglages avancés').'</h5>'; 276 277 foreach ($this->advanced_settings as $id => $s) 237 278 { 238 case 'text': 239 $res .= 240 '<p><label for="'.$wfid.'">'.$s['title'].'</label> '. 241 form::field(array($iname,$wfid),20,255,html::escapeHTML($s['value']),'maximal'). 242 '</p>'; 243 break; 244 case 'textarea': 245 $res .= 246 '<p><label for="'.$wfid.'">'.$s['title'].'</label> '. 247 form::textarea(array($iname,$wfid),30,5,html::escapeHTML($s['value']),'maximal'). 248 '</p>'; 249 break; 250 case 'check': 251 $res .= 252 '<p>'.form::hidden(array($iname),'0'). 253 '<label class="classic" for="'.$wfid.'">'. 254 form::checkbox(array($iname,$wfid),'1',$s['value']).' '.$s['title']. 255 '</label></p>'; 256 break; 257 case 'combo': 258 $res .= 259 '<p><label for="'.$wfid.'">'.$s['title'].'</label> '. 260 form::combo(array($iname,$wfid),$s['options'],$s['value']). 261 '</p>'; 262 break; 263 } 264 $i++; 279 $res .= $this->formSetting($id,$s,$pr,$i); 280 $i++; 281 } 282 283 $res .= '</div>'; 284 } 285 286 return $res; 287 } 288 289 public function formSetting($id,$s,$pr='',&$i=0) 290 { 291 $res = ''; 292 $wfid = "wf-".$i; 293 $iname = $pr ? $pr.'['.$id.']' : $id; 294 switch ($s['type']) 295 { 296 case 'text': 297 $res .= 298 '<p><label for="'.$wfid.'">'.$s['title'].'</label> '. 299 form::field(array($iname,$wfid),20,255,html::escapeHTML($s['value']),'maximal'). 300 '</p>'; 301 break; 302 case 'textarea': 303 $res .= 304 '<p><label for="'.$wfid.'">'.$s['title'].'</label> '. 305 form::textarea(array($iname,$wfid),30,5,html::escapeHTML($s['value']),'maximal'). 306 '</p>'; 307 break; 308 case 'check': 309 $res .= 310 '<p>'.form::hidden(array($iname),'0'). 311 '<label class="classic" for="'.$wfid.'">'. 312 form::checkbox(array($iname,$wfid),'1',$s['value']).' '.$s['title']. 313 '</label></p>'; 314 break; 315 case 'radio': 316 $res .= '<p>'.($s['title'] ? '<label class="classic">'.$s['title'].'</label><br/>' : ''); 317 if(!empty($s['options'])) { 318 foreach ($s['options'] as $k => $v) { 319 $res .= $k > 0 ? '<br/>' : ''; 320 $res .= 321 '<label class="classic" for="'.$wfid.'-'.$k.'">'. 322 form::radio(array($iname,$wfid.'-'.$k),$v[1],$s['value'] == $v[1]).' '.$v[0]. 323 '</label>'; 324 } 325 } 326 $res .= '</p>'; 327 break; 328 case 'combo': 329 $res .= 330 '<p><label for="'.$wfid.'">'.$s['title'].'</label> '. 331 form::combo(array($iname,$wfid),$s['options'],$s['value']). 332 '</p>'; 333 break; 265 334 } 266 335
Note: See TracChangeset
for help on using the changeset viewer.