* @copyright 2010 Tela-Botanica * @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL * @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL * @version SVN: $Id$ */ class Arbre extends AppliControleur { private $referentiel = null; private $rechercheDao = null; public function __construct() { parent::__construct(); // Récupération de paramètres if (isset($_GET['ref'])) { // code du projet courant $this->referentiel = strtolower($_GET['ref']); } } //+----------------------------------------------------------------------------------------------------------------+ // Méthodes /** * Fonction d'affichage par défaut */ public function executerActionParDefaut() { $this->definirCommeModulePrincipal(get_class($this)); $this->construireMenu($this->referentiel); $this->construireFilAriane($this->referentiel); $this->executerActionReferentiel('Arbre', 'afficherArbre', $this->referentiel, false); } public function afficherArbre() { $donnees = array(); $donnees['resultats'] = $this->chercherFamilles(); $nns = array(); foreach($donnees['resultats'] as $resultat) { $nns[] = $resultat['num_nom']; } $donnees['resultats_nb_infra'] = $this->chercherNombreInfras($nns); $donnees['resultats_nb_syn'] = $this->chercherNombreSynonymes($nns); $donnees['url_service_tpl'] = Config::get('url_jrest'); $donnees['url_sous_taxons_tpl'] = $this->obtenirUrlMenuBranche($this->referentiel, ''); $donnees['url_synonymes_tpl'] = $this->obtenirUrlMenuBrancheSynonyme($this->referentiel, ''); $donnees['url_fiche_taxon_tpl'] = $this->obtenirUrlFicheTaxon($this->referentiel, '%s'); $donnees['referentiel'] = $this->referentiel; $resultat = $this->getVue('arbre_taxon', $donnees); $this->setSortie(self::RENDU_CORPS, $resultat); } public function afficherBranche() { $donnees = array(); $donnees['resultats_infra'] = $this->chercherInfras($_GET['num_nom']); foreach($donnees['resultats_infra'] as $resultat) { $nns[] = $resultat['num_nom']; } $donnees['resultats_nb_infra'] = $this->chercherNombreInfras($nns); $donnees['resultats_nb_syn'] = $this->chercherNombreSynonymes($nns); $resultat = json_encode($donnees); header('Content-type: application/json'); echo $resultat; exit; } public function afficherBrancheSynonyme() { $donnees['resultats_syn'] = $this->chercherSynonymes($_GET['num_nom']); $resultat = json_encode($donnees); header('Content-type: application/json'); echo $resultat; exit; } private function getDao() { if($this->rechercheDao == null) { $this->rechercheDao = new RechercheDao(); } return $this->rechercheDao; } private function chercherFamilles() { $rechercheDao = $this->getDao(); $rechercheDao->setLimitation(0,10000); $parametres = array('mots' => '*', 'ref' => $this->referentiel, 'rg' => 180); $resultats = $rechercheDao->chercher('ParDefaut', $parametres , 500); return $resultats; } private function chercherNombreSynonymes($tableau_nn) { $rechercheDao = $this->getDao(); $parametres_syn = array('mots' => '*', 'ref' => $this->referentiel, 'nn' => implode(',', $tableau_nn)); $resultats_nb_syn = $rechercheDao->chercher('NombreSynonymeParTaxon', $parametres_syn); return $resultats_nb_syn; } private function chercherSynonymes($num_nom) { $rechercheDao = $this->getDao(); $parametres_syn = array('mots' => '*', 'ref' => $this->referentiel, 'nn' => $num_nom); $resultats_syn = $rechercheDao->chercher('ParTaxon', $parametres_syn); return $resultats_syn; } private function chercherNombreInfras($tableau_nn) { $rechercheDao = $this->getDao(); $parametres_infra = array('mots' => '*', 'ref' => $this->referentiel, 'classif' => 'infra', 'nn' => implode(',', $tableau_nn)); $resultats_nb_infra = $rechercheDao->chercher('NombreClassifParTaxon', $parametres_infra); return $resultats_nb_infra; } private function chercherInfras($num_nom) { $rechercheDao = $this->getDao(); $parametres = array('mots' => '*', 'ref' => $this->referentiel, 'classif' => 'infra', 'nn' => $num_nom); $resultats_infra = $rechercheDao->chercher('Classification', $parametres); return $resultats_infra; } } ?>