Rev 57 | Rev 74 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpclass RechercheSimple extends aControleur {//+----------------------------------------------------------------------------------------------------------------+// Méthodes/*** Fonction d'affichage par défaut*/public function executerActionParDefaut() {$this->executerAccueil();}public function executerAccueil() {$donnees = array();$donnees['form_nom'] = $this->executerFormulaireNom();$this->afficherAccueil($donnees);}private function afficherAccueil($donnees) {$donnees['i18n'] = I18n::get('Recherche-accueil');$this->setSortie(self::RENDU_CORPS, $this->getVue('recherche_accueil', $donnees));}public function executerFormulaireNom($donnees = array()) {if (!isset($donnees['type_nom'])) {$donnees['type_nom'] = (Registre::get('parametres.niveau') == 1) ? 'nom_vernaculaire' : 'nom_scientifique';}$donnees['i18n'] = I18n::get('Recherche-form-nom');return $this->getVue('form_nom', $donnees);}public function executerRechercheNom() {$donnees['type_nom'] = $_GET['type_nom'];$donnees['nom'] = $_GET['nom'];if (strlen($donnees['nom']) < 3) {$donnees['information'] = 'Veuillez saisir un radical contenant au moins 3 caractères alphabétiques !';} else {$noms = ($donnees['type_nom'] == 'nom_vernaculaire')? new NomsVernaculaires(Config::get('referentielVerna')): new Noms(Registre::get('parametres.referentiel'));$presence = $this->rechercherNom($noms);if ($presence == '') {$donnees['information'] = 'Nom inconnu';} elseif ($presence != 'ok') {$donnees['nom_approche'] = $presence;$donnees['url_nom_approche'] = $this->obtenirUrlRechercheSimple($presence, $donnees['type_nom']);}}$donnees['form_nom'] = $this->executerFormulaireNom($donnees);$this->afficherAccueil($donnees);}// regarde si il y a des résultats correspondant au nom recherché sinon recherche un nom approchéprivate function rechercherNom($noms) {$approche = '';$res = $noms->getRechercheEtendue($_GET['nom']);$form = I18n::get('Recherche-form-nom');if ($res == false || $res['entete']['total'] == 0) { // recherche nom approché$res = $noms->getRechercheFloue($_GET['nom']);if (!($res == false || $res['entete']['total'] == 0)) {$nom_proche = array_shift($res['resultat']);$approche = ($_GET['type_nom'] == 'nom_vernaculaire') ? $nom_proche['nom'] : $nom_proche['nom_sci'];}} elseif ($res['entete']['total'] == 1 || urldecode($_GET['submit']) == $form['fiche']) { // renvoie à la fiche$ids = array_keys($res['resultat']);$url = $this->obtenirUrlFiche($ids[0]);$this->redirigerVers($url);} else { // affiche les résultats$approche = 'ok';}return $approche;}}?>