getCritere('cj')); foreach($valeurs as $valeur) { if($valeur != '') $return[] = $valeur; } if(is_array($return)) return ($return); return (array($valeurs)); } protected function _jstree_undetermined() { return (array()); } public function _getClass($valeur) { if(in_array($valeur, $this->_jstree_checked())) return ('jstree-checked'); else if (in_array($valeur, $this->_jstree_undetermined())) return ('jstree-undetermined'); } public function _getParents() { $formes = new Table_Formejuridiques(); $formes = $formes->fetchAll($formes->select()->where('LENGTH(fjCode) = 1'))->toArray(); $structure = array(); foreach($formes as $forme) { $structure[] = array( 'data' => $forme['fjCode'].' : '.$forme['fjLibelle'], 'attr' => array('id' => $forme['fjCode'], 'class' => $this->_getClass($forme['fjCode'])), 'state' => 'closed', 'children' => array($this->_getFils($forme['fjCode'])), ); } return (json_encode($structure)); } public function _getFils($fjcode) { $lenth = ((strlen($fjcode) == 2)?4:2); $formes = new Table_Formejuridiques(); $sql = $formes->select()->from('formejuridique', array( 'size' => new Zend_Db_Expr('LENGTH(fjCode)'), 'fjCode', 'fjLibelle')) ->where('fjCode LIKE "'.$fjcode.'%"') ->having('size = ?', $lenth); $formes = $formes->fetchAll($sql)->toArray(); $structure = array(); foreach($formes as $forme) { $structure = array( 'data' => $forme['fjCode'].' : '.$forme['fjLibelle'], 'attr' => array('id' => $forme['fjCode'], 'class' => $this->_getClass($forme['fjCode'])), 'state' => 'close', 'children' => (($lenth < 6)?$this->_getFils($forme['fjCode']):array()) ); $tabfj[] = $structure; } return ($tabfj); } }