9,36 → 9,37 |
|
|
public function executerActionParDefaut() { |
if (isset($_GET['referentiel'])) { |
Registre::set('parametres.referentiel', $_GET['referentiel']); |
} |
$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'); |
|
$donnees['referentiel_titre'] = I18n::get('Referentiels-titres.'.Config::get('referentiel')); |
|
$donnees['form_nom'] = $this->executerFormulaireNom(); |
|
$this->setSortie(self::RENDU_CORPS, $this->getVue('recherche_accueil', $donnees)); |
} |
|
public function executerFormulaireNom() { |
$donnees['eflore_type_nom'] = 'nom_vernaculaire'; |
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'); |
$donnees['url_js'] = Config::get('url_js'); |
|
return $this->getVue('form_nom', $donnees); |
} |
|
public function executerRechercheNom() { |
if (strlen($_GET['eflore_nom']) < 3) { |
$donnees['type_nom'] = $_GET['type_nom']; |
$donnees['nom'] = $_GET['nom']; echo $donnees['nom']; |
if (strlen($donnees['nom']) < 3) { |
$donnees['information'] = 'Veuillez saisir un radical contenant au moins 3 caractères alphabétiques !'; |
} else { |
$noms = ($_GET['eflore_type_nom'] == 'nom_vernaculaire') |
$noms = ($donnees['type_nom'] == 'nom_vernaculaire') |
? new NomsVernaculaires(Config::get('referentielVerna')) |
: new Noms(Registre::get('parametres.referentiel')); |
$presence = $this->rechercherNom($noms); |
46,37 → 47,27 |
$donnees['information'] = 'Nom inconnu'; |
} elseif ($presence != 'ok') { |
$donnees['nom_approche'] = $presence; |
Debug::printr(Registre::get('eflore.urlCourrante')->getUrl()); // revoir à partir de appcontroleur |
//$donnees['url_nom_approche'] = str_replace($donnees['nom'], $donnees['nom_approche'], Registre::get('eflore.urlCourrante')); |
} |
} |
|
|
if (isset($donnees)) { |
$donnees['eflore_type_nom'] = $_GET['eflore_type_nom']; |
$donnees['i18n'] = I18n::get('Recherche-accueil'); |
$donnees['referentiel_titre'] = I18n::get('Referentiels-titres.'.Config::get('referentiel')); |
|
$donnees['i18n'] = I18n::get('Recherche-form-nom'); |
$donnees['url_js'] = Config::get('url_js'); |
$donnees['nom'] = $_GET['eflore_nom']; |
|
$donnees['form_nom'] = $this->getVue('form_nom', $donnees); |
$this->setSortie(self::RENDU_CORPS, $this->getVue('recherche_accueil', $donnees)); |
} else { |
print_r($_GET['eflore_nom']); |
// envoyerResultat; |
$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['eflore_nom']); //print_r($res); |
if ($res == false || $res->entete->total == 0) { |
$res = $noms->getRechercheFloue($_GET['eflore_nom']); |
if (!($res == false || $res->entete->total == 0)) { |
$liste = (array) $res->resultat; |
$nom_proche = array_shift($liste); |
$approche = ($_GET['eflore_type_nom'] == 'nom_vernaculaire') ? $nom_proche->nom : $nom_proche->nom_sci; |
$res = $noms->getRechercheEtendue($_GET['nom']); |
if ($res == false || $res['entete']['total'] == 0) { |
$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) { |
$approche = 'ok'; // envoyer à la fiche |
} else { |
$approche = 'ok'; |
} |