Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 84 → Rev 85

/trunk/modules/recherche/Recherche.php
3,6 → 3,12
//+----------------------------------------------------------------------------------------------------------------+
// Méthodes
protected $nom = null;
protected $type_nom = 'nom_scientifique';
protected $submit = '';
public function initialiser() {
$this->capturerParametres();
}
/**
* Fonction d'affichage par défaut
*/
12,13 → 18,13
}
 
public function executerRechercheSimple() {
$donnees['type_nom'] = $_GET['type_nom'];
$donnees['nom'] = $_GET['nom'];
$donnees['type_nom'] = $this->type_nom;
$donnees['nom'] = $this->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 NomsVernaculaires(Config::get(Registre::get('parametres.referentiel').'.referentielVerna'))
: new Noms(Registre::get('parametres.referentiel'));
$presence = $this->rechercherNom($noms);
if ($presence == '') {
38,20 → 44,20
// 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']);
$res = $noms->getRechercheEtendue($this->nom);
$form = I18n::get('Recherche-form-nom');
if ($res == false || $res['entete']['total'] == 0) { // recherche nom approché
$res = $noms->getRechercheFloue($_GET['nom']);
$res = $noms->getRechercheFloue($this->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'];
$approche = ($this->type_nom == 'nom_vernaculaire') ? $nom_proche['nom'] : $nom_proche['nom_sci'];
}
} elseif ($res['entete']['total'] == 1 || urldecode($_GET['submit']) == $form['fiche']) { // renvoie à la fiche
} elseif ($res['entete']['total'] == 1 || $this->submit == $form['fiche']) { // renvoie à la fiche
$ids = array_keys($res['resultat']);
$url = $this->obtenirUrlFiche($ids[0]);
$this->redirigerVers($url);
} else { // affiche les résultats
$res['type'] = $_GET['type_nom'];
$res['type'] = $this->type_nom;
Registre::set('resultats', $res);
$approche = 'ok';
}
58,5 → 64,18
return $approche;
}
private function capturerParametres() {
if (isset($_GET['nom'])) {
$this->nom = $_GET['nom'];
}
if (isset($_GET['type_nom'])) {
$this->type_nom = $_GET['type_nom'];
}
if (isset($_GET['submit'])) {
$this->submit = urldecode($_GET['submit']);
}
}
}
?>