87 lines
2.9 KiB
PHP
87 lines
2.9 KiB
PHP
<?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 '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></span>
|
|
</div>
|
|
</div>');
|
|
}
|
|
|
|
private function selectHTML($name, $field)
|
|
{
|
|
$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="'.$option.'">'.$option.'</option>';
|
|
}
|
|
$return .= '</select>';
|
|
return ($return);
|
|
}
|
|
|
|
private function intervalHTML($name, $field)
|
|
{
|
|
$return .= '<div style="text-align:right;height:17px;">';
|
|
$return .= '<input value="'.$field['fields'][$field['type']]['value'][0].','.$field['fields'][$field['type']]['value'][1].'" name="'.$name.'" class="range slider_Text" type="text" id="'.$name.'" min="'.$field['fields'][$field['type']]['default'][0].'" max="'.$field['fields'][$field['type']]['default'][1].'" style="margin-left:10px;margin-top:3px;float:left;border:0; color:black; font-weight:bold;" />';
|
|
$return .= '<div input="'.$name.'" class="slider-range"></div></div>';
|
|
|
|
return ($return);
|
|
}
|
|
|
|
private function dateHTML($name, $field)
|
|
{
|
|
$return .= '<input value="" type="text" class="from" name="'.$name.'1" /> a ';
|
|
$return .= '<input type="text" class="to" name="'.$name.'2" />';
|
|
|
|
return ($return);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
private function textareaHTML($name, $field, $item)
|
|
{
|
|
$return .= '<textarea style="border:1px inset silver;width:60%;height:40px;" name="'.$name.'">'.$field['fields'][$field['type']]['value'].'</textarea>';
|
|
|
|
return ($return);
|
|
}
|
|
|
|
private function radioHTML($name, $field, $item)
|
|
{
|
|
// en cours.
|
|
}
|
|
} |