/trunk/modules/recherche/Recherche.php |
---|
New file |
0,0 → 1,57 |
<?php |
class Recherche extends aControleur { |
//+----------------------------------------------------------------------------------------------------------------+ |
// Méthodes |
/** |
* Fonction d'affichage par défaut |
*/ |
public function executerActionParDefaut() { |
$rechercheAccueil = $this->executerAction('recherche-simple', 'accueil'); |
$this->setSortie(self::RENDU_CORPS, $rechercheAccueil); |
} |
public function executerRechercheSimple() { |
$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']); |
} |
} |
Registre::set('donnees', $donnees); |
$this->executerAction('recherche_simple', 'executerForm'); |
} |
// 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; |
} |
} |
?> |
/trunk/modules/recherche_simple/RechercheSimple.php |
---|
33,48 → 33,13 |
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']); |
} |
} |
public function executerForm() { |
$donnees = Registre::get('donnees'); |
$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; |
} |
} |
?> |
/trunk/modules/recherche_simple/squelettes/form_nom.tpl.html |
---|
23,8 → 23,8 |
<td> |
<input id="referentiel" name="referentiel" type="hidden" value="<?=Registre::get('parametres.referentiel')?>" /> |
<input id="module" name="module" type="hidden" value="recherche-simple" /> |
<input id="action" name="action" type="hidden" value="rechercheNom" /> |
<input id="module" name="module" type="hidden" value="recherche" /> |
<input id="action" name="action" type="hidden" value="rechercheSimple" /> |
<input id="eflore_nomenclature_submit" name="submit" type="submit" value="<?=$i18n['recherche'];?>" /> |
<input id="eflore_nomenclature_fiche" name="submit" type="submit" value="<?=$i18n['fiche'];?>" /> |
</td> |