name = $name; //Read the dico $fields = new Scores_Fields(); $params = $fields->get($name); $html = ''; $label = $labelG = $fields->getLabel($name); $title = ''; if ( array_key_exists('title', $params) && !empty($params['title']) ) { $title = $params['title']; } //How many type of fields is defined $nbFields = count($params['fields']); $display = true; //If more than one field exist we need to make a special display if ( $nbFields > 1) { $out.= '
'; $out.= $this->structureLabel($label); $out.= '
'; foreach ( $params['fields'] as $type => $options ) { switch ($type) { case 'tree': $href = $this->view->url(array('controller' => 'arborescence', 'action' => $options['action'], 'key' => $name)); $out.= ''; $out.= 'Arborescence'; $out.= ''; break; case 'text': $out.= ''; $out.= 'Recherche'; $out.= ''; break; case 'list': $out.= ''; $out.= 'Liste'; $out.= ''; break; } $out.= ' '; } $out.= '
'; $out.= '
'; //Masquer les champs $display = false; } //Draw fields foreach ( $params['fields'] as $type => $options ) { switch($type) { case 'select': $html = $this->selectHTML($name, $options); break; case 'selectMultiple': $html = $this->selectMultipleHTML($name, $options); break; case 'intervalSelect': $html = $this->intervalSelectHTML($name, $options); break; case 'checkbox': $html = $this->checkboxHTML($name, $options); break; case 'intervalDate': $html = $this->intervalDateHTML($name, $options); break; case 'interval': $html = $this->intervalHTML($name, $field); break; case 'date': $html = $this->dateHTML($name, $field); break; case 'text': $html = $this->textHTML($name, $options); break; case 'textarea': $html = $this->textareaHTML($name, $field); break; case 'radio': $html = $this->radioHTML($name, $field); break; case 'file': $html = $this->fileuploadHtml($name, $field); break; case 'tree': //Do nothing break; case 'list': $html = $this->textareaHTML($name, $options); break; default: $html = $this->structureHTML($name, ''); break; } $label = $labelG; if ( array_key_exists('label', $options) ) { $label = $options['label']; } $style = ''; $class = ' class="fieldgrp"'; if ( $display===false ) { $style = ' style="display:none;"'; } if ( !empty($title) ) { $title = ' title="'.$title.'"'; } $out.= '
'; $out.= $this->structureLabel($label); $out.= '
'.$html.'
'; $out.= '
'; } return $out; } /** * Définition du label * @param unknown_type $label */ private function structureLabel($label) { $return = ''; return $return; } protected function getMinMax($name, $valeur) { if(!empty($name)) { //$fields = new Scores_Fields(); //$default = $fields->getMinMax($name); if(empty($valeur[0])){$valeur[0] = $default[0]['min'];} if(empty($valeur[1])){$valeur[1] = $default[0]['max'];} } return ($valeur); } private function intervalSelectHTML($name, $options) { $session = new Scores_Fields(); $sessionValeur = explode(',', $session->getCritere($name)); $minMax = $this->getMinMax($name, array(0,0)); $return = ' à '; $return .= ''; $return .= ' Valider'; return ($return); } /** * * @param unknown_type $name * @param unknown_type $options */ protected function checkboxHTML($name, $options) { $session = new Scores_Fields(); $sessionValeur = $session->getCritere($name); $select = ''; if ($sessionValeur==1) $select = ' checked'; $return = ''; return $return; } /** * * @param unknown_type $name * @param unknown_type $options * @return string */ protected function selectMultipleHTML($name, $options) { $session = new Scores_Fields(); $sessionValeur = $session->getCritere($name); $return = ''; $return .= 'Sélectionner'; $return .= ' Exclure'; return $return; } /** * * @param unknown_type $name * @param unknown_type $options * @return string */ protected function selectHTML($name, $options) { $session = new Scores_Fields(); $sessionValeur = $session->getCritere($name); if( is_array($sessionValeur) ) { $sessionValeur = implode(',', $sessionValeur); } $return = ''; return $return; } protected function intervalDateHTML($name, $options) { $session = new Scores_Fields(); $sessionValeur = $session->getCritere($name); $return = ''; $return.= ''; $return.= ''; $return.= ''; $return.= ' au '; $return.= ''; $return.= ''; $return.= ''; $return .= '
Valider'; return $return; } /* Interval */ private function intervalHTML($name, $field) { $session = new Scores_Fields(); $valeur = $session->getCritere($name); $return = '
'; $return .= ' à '; $return .= ''; $return .= ' Valider'; $return .= '
'; return $return; } /* Dates */ private function dateHTML($name, $field) { $session = new Scores_Fields(); $return = '
'; $return .= ' a '; $return .= ''; $return .= '
'; return ($return); } /* Textes */ protected function textHTML($name, $options) { $return = ''; $return.= ''; $return.= 'Sélectionner'; $return.= ' Exclure'; return $return; } /* Textarea */ protected function textareaHTML($name, $field) { $return = ''; $return.= 'Sélectionner'; $return.= ' Exclure'; return $return; } private function fileuploadHtml($name, $field) { $return = ' '; return ($return); } /* Radios */ private function radioHTML($name, $field, $item) { $return = ''; return ($return); } }