Restructuration
This commit is contained in:
parent
59ace9293e
commit
6b4547a0c8
@ -1,57 +1,108 @@
|
||||
<?php
|
||||
Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
{
|
||||
|
||||
{
|
||||
public function Field($name, $field)
|
||||
{
|
||||
$html = '';
|
||||
if($field != null) {
|
||||
foreach($field['fields'] as $type => $valeur)
|
||||
$html.= '<div class="fieldgrp">';
|
||||
$type = $field['type'];
|
||||
switch($type)
|
||||
{
|
||||
if($type == $field['type']) {
|
||||
switch($type){
|
||||
case 'select':
|
||||
return ($this->structureHTML($field['label'], $this->selectHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'selectMultiple':
|
||||
return ($this->structureHTML($field['label'], $this->selectMultipleHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'interval':
|
||||
return ($this->structureHTML($field['label'], $this->intervalHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'date':
|
||||
return ($this->structureHTML($field['label'], $this->dateHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'text':
|
||||
return ($this->structureHTML($field['label'], $this->textHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'textarea':
|
||||
return ($this->structureHTML($field['label'], $this->textareaHTML($name, $field), $this->createValidate($type, $name)));
|
||||
case 'radio':
|
||||
return ($this->structureHTML($field['label'], $this->radioHTML($name, $field), $this->createValidate($type, $name)));
|
||||
}
|
||||
}
|
||||
case 'select':
|
||||
$html.= $this->structureHTML(
|
||||
$field['label'],
|
||||
$this->selectHTML($name, $field),
|
||||
$this->createValidate($type, $name));
|
||||
break;
|
||||
case 'selectMultiple':
|
||||
$html.= $this->structureHTML(
|
||||
$field['label'],
|
||||
$this->selectMultipleHTML($name, $field),
|
||||
$this->createValidate($type, $name));
|
||||
break;
|
||||
case 'interval':
|
||||
$html.= $this->structureHTML(
|
||||
$field['label'],
|
||||
$this->intervalHTML($name, $field),
|
||||
$this->createValidate($type, $name));
|
||||
break;
|
||||
case 'date':
|
||||
$html.= $this->structureHTML(
|
||||
$field['label'],
|
||||
$this->dateHTML($name, $field),
|
||||
$this->createValidate($type, $name));
|
||||
break;
|
||||
case 'text':
|
||||
$html.= $this->structureHTML(
|
||||
$field['label'],
|
||||
$this->textHTML($name, $field),
|
||||
$this->createValidate($type, $name));
|
||||
break;
|
||||
case 'textarea':
|
||||
$html.= $this->structureHTML(
|
||||
$field['label'],
|
||||
$this->textareaHTML($name, $field),
|
||||
$this->createValidate($type, $name));
|
||||
break;
|
||||
case 'radio':
|
||||
$html.= $this->structureHTML(
|
||||
$field['label'],
|
||||
$this->radioHTML($name, $field),
|
||||
$this->createValidate($type, $name));
|
||||
break;
|
||||
}
|
||||
$html.= '</div>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function createValidate($type, $name)
|
||||
{
|
||||
$return = array();
|
||||
switch($type) {
|
||||
case 'textarea':
|
||||
case 'date':
|
||||
$return = ('<a href="">Valider</a>');
|
||||
//$return[] = array('lib'=>'Valider', 'url'=>'#');
|
||||
break;
|
||||
}
|
||||
$return .= ' <a href="">Switch de champ</a>';
|
||||
return ($return);
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function structureHTML($label, $html, $lien = null)
|
||||
private function structureHTML($label, $html, $liens = array())
|
||||
{
|
||||
$return='<div class="fieldgrp">
|
||||
<label>'.$label.'</label>
|
||||
<div class="field">
|
||||
'.$html.'
|
||||
</div>
|
||||
<span></span>
|
||||
</div>';
|
||||
|
||||
return ($return);
|
||||
$out = '';
|
||||
$out.= $this->structureLabel($label);
|
||||
$out.= '<div class="field">'.$html.$this->structureLink($liens).'</div>';
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Définition du label
|
||||
* @param unknown_type $label
|
||||
*/
|
||||
private function structureLabel($label)
|
||||
{
|
||||
return '<label>'.$label.'</label>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Définition des liens
|
||||
*/
|
||||
private function structureLink($liens = array())
|
||||
{
|
||||
$html = '';
|
||||
if (count($liens)>0) {
|
||||
foreach($liens as $lien){
|
||||
$html.= '<a href="'.$lien['url'].'">'.$lien['lib'].'</a>';
|
||||
}
|
||||
}
|
||||
if (!empty($html)) {
|
||||
return '<span>'.$html.'</span>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/* Select */
|
||||
private function selectMultipleHTML($name, $field)
|
||||
{
|
||||
@ -130,12 +181,6 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
/* Textarea */
|
||||
private function textareaHTML($name, $field)
|
||||
{
|
||||
/*$session = new SessionCiblage();
|
||||
$valeur = $session->getCritere($name);
|
||||
$return = '<div class="textarea" >';
|
||||
$return .= '<textarea name="'.$name.'">'.(($valeur != null)?implode(',', $valeur):null).'</textarea>';
|
||||
$return .= '</div>';*/
|
||||
|
||||
$return = '<a class="arborescence" title="'.$field['title'].'" href="'.$this->view->url(array('controller' => 'arborescence', 'action' => $field['action'], 'key' => $name)).'">Selection dans une arborescence</a>';
|
||||
return ($return);
|
||||
}
|
||||
@ -143,10 +188,7 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
|
||||
/* Radios */
|
||||
private function radioHTML($name, $field, $item)
|
||||
{
|
||||
$session = new SessionCiblage();
|
||||
|
||||
$return = '<input type="radio" name="'.$name.'" />';
|
||||
|
||||
$return = '<input type="radio" name="'.$name.'" />';
|
||||
return ($return);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user