114 lines
3.5 KiB
PHP
Raw Normal View History

<?php
Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
{
public function Field($name, $field)
{
if($field != null) {
foreach($field['fields'] as $type => $valeur)
{
if($type == $field['type']) {
switch($type){
case 'select':
return ($this->structureHTML($field['label'], $this->selectHTML($name, $field)));
case 'selectMultiple':
return ($this->structureHTML($field['label'], $this->selectMultipleHTML($name, $field)));
case 'interval':
return ($this->structureHTML($field['label'], $this->intervalHTML($name, $field)));
case 'date':
return ($this->structureHTML($field['label'], $this->dateHTML($name, $field)));
case 'text':
return ($this->structureHTML($field['label'], $this->textHTML($name, $field)));
case 'textarea':
return ($this->structureHTML($field['label'], $this->textareaHTML($name, $field)));
case 'radio':
return ($this->structureHTML($field['label'], $this->radioHTML($name, $field)));
}
}
}
}
}
private function structureHTML($label, $html)
{
$return ='<div class="fieldgrp">
<label>'.$label.'</label>
<div class="field">
'.$html.'
<span><a href="">Switch type</a></span>
</div>
</div>';
return ($return);
}
/* Select */
private function selectMultipleHTML($name, $field)
{
$i = 0;
$return = '<select class="criteres" name="'.$name.'">';
$return .= '<option value="tous">Tous</option>';
foreach($field['fields'][$field['type']]['value'] as $option) {
$return .= '<option '.(($field['fields']['selected'] == $option)?'selected':'').' value="'.$i++.'">'.$option.'</option>';
}
$return .= '</select>';
return ($return);
}
/* Select Multiple */
private function selectHTML($name, $field)
{
$i = 0;
$return = '<select class="criteres" name="'.$name.'">';
$return .= '<option value="tous">Tous</option>';
foreach($field['fields'][$field['type']]['value'] as $option) {
$return .= '<option '.(($field['fields']['selected'] == $option)?'selected':'').' value="'.$i++.'">'.$option.'</option>';
}
$return .= '</select>';
return ($return);
}
/* Interval */
private function intervalHTML($name, $field)
{
$return = '<div class="mySlider" style="text-align:right;height:17px;">';
$return .= '<input style="display:none;" value="'.$field['fields'][$field['type']]['value'][0].','.$field['fields'][$field['type']]['value'][1].'" name="'.$name.'" class="range slider_Text" type="text" id="'.$name.'" min="0" max="1000" />';
$return .= '<div input="'.$name.'" class="slider-range"></div></div>';
return ($return);
}
/* Dates */
private function dateHTML($name, $field)
{
$return = '<input value="" type="text" class="datepicker" name="'.$name.'1" /> a ';
$return .= '<input type="text" class="datepicker" name="'.$name.'2" />';
return ($return);
}
/* Textes */
private function textHTML($name, $field)
{
$return = '<input style="border:1px inset silver;width:60%" class="criteres" type="text" name="'.$name.'" value="'.$field['fields'][$field['type']]['value'].'" /></div>';
return ($return);
}
/* Textarea */
private function textareaHTML($name, $field)
{
$return = '<textarea style="border:1px inset silver;width:60%;height:40px;" name="'.$name.'">'.$field['fields'][$field['type']]['value'].'</textarea>';
return ($return);
}
/* Radios */
private function radioHTML($name, $field, $item)
{
$return = '<input type="radio" name="'.$name.'" />';
return ($return);
}
}