Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 57 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 57 Rev 70
Line 33... Line 33...
33
		return $this->getVue('form_nom', $donnees);
33
		return $this->getVue('form_nom', $donnees);
34
	}
34
	}
Line 35... Line 35...
35
	
35
	
36
	public function executerRechercheNom() {
36
	public function executerRechercheNom() {
37
		$donnees['type_nom'] = $_GET['type_nom'];
37
		$donnees['type_nom'] = $_GET['type_nom'];
38
		$donnees['nom'] = $_GET['nom']; echo $donnees['nom'];
38
		$donnees['nom'] = $_GET['nom'];
39
		if (strlen($donnees['nom']) < 3) {
39
		if (strlen($donnees['nom']) < 3) {
40
			$donnees['information'] = 'Veuillez saisir un radical contenant au moins 3 caractères alphabétiques !';
40
			$donnees['information'] = 'Veuillez saisir un radical contenant au moins 3 caractères alphabétiques !';
41
		} else {
41
		} else {
42
			$noms = ($donnees['type_nom'] == 'nom_vernaculaire') 
42
			$noms = ($donnees['type_nom'] == 'nom_vernaculaire') 
Line 45... Line 45...
45
			$presence = $this->rechercherNom($noms);
45
			$presence = $this->rechercherNom($noms);
46
			if ($presence == '') {
46
			if ($presence == '') {
47
				$donnees['information'] = 'Nom inconnu';
47
				$donnees['information'] = 'Nom inconnu';
48
			} elseif ($presence != 'ok') {
48
			} elseif ($presence != 'ok') {
49
				$donnees['nom_approche'] = $presence;
49
				$donnees['nom_approche'] = $presence;
50
				Debug::printr(Registre::get('eflore.urlCourrante')->getUrl()); // revoir à partir de appcontroleur
-
 
51
				//$donnees['url_nom_approche'] = str_replace($donnees['nom'], $donnees['nom_approche'], Registre::get('eflore.urlCourrante'));
50
				$donnees['url_nom_approche'] = $this->obtenirUrlRechercheSimple($presence, $donnees['type_nom']);
52
			}
51
			}
53
		}
52
		}
Line 54... Line 53...
54
		
53
		
55
		$donnees['form_nom'] = $this->executerFormulaireNom($donnees);
54
		$donnees['form_nom'] = $this->executerFormulaireNom($donnees);
Line 58... Line 57...
58
	
57
	
59
	// regarde si il y a des résultats correspondant au nom recherché sinon recherche un nom approché
58
	// regarde si il y a des résultats correspondant au nom recherché sinon recherche un nom approché
60
	private function rechercherNom($noms) {
59
	private function rechercherNom($noms) {
61
		$approche = '';
60
		$approche = '';
-
 
61
		$res = $noms->getRechercheEtendue($_GET['nom']);
62
		$res = $noms->getRechercheEtendue($_GET['nom']);
62
		$form = I18n::get('Recherche-form-nom');
63
		if ($res == false || $res['entete']['total'] == 0) {
63
		if ($res == false || $res['entete']['total'] == 0) { // recherche nom approché
64
			$res = $noms->getRechercheFloue($_GET['nom']);
64
			$res = $noms->getRechercheFloue($_GET['nom']);
65
			if (!($res == false || $res['entete']['total'] == 0)) {
65
			if (!($res == false || $res['entete']['total'] == 0)) {
66
				$nom_proche = array_shift($res['resultat']); 
66
				$nom_proche = array_shift($res['resultat']);
67
				$approche = ($_GET['type_nom'] == 'nom_vernaculaire') ? $nom_proche['nom'] : $nom_proche['nom_sci'];
67
				$approche = ($_GET['type_nom'] == 'nom_vernaculaire') ? $nom_proche['nom'] : $nom_proche['nom_sci'];
-
 
68
			}
68
			}
69
		} elseif ($res['entete']['total'] == 1 || urldecode($_GET['submit']) == $form['fiche']) { // renvoie à la fiche
69
		} elseif ($res['entete']['total'] == 1) {
70
			$ids = array_keys($res['resultat']);
-
 
71
			$url = $this->obtenirUrlFiche($ids[0]);
70
			$approche = 'ok'; // envoyer à la fiche
72
			$this->redirigerVers($url);
71
		} else {
73
		} else { // affiche les résultats
72
			$approche = 'ok';
74
			$approche = 'ok';
73
		}
75
		}
74
		return $approche;
76
		return $approche;