Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 85 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 85 Rev 88
Line 21... Line 21...
21
		$donnees['type_nom'] = $this->type_nom;
21
		$donnees['type_nom'] = $this->type_nom;
22
		$donnees['nom'] = $this->nom;
22
		$donnees['nom'] = $this->nom;
23
		if (strlen($donnees['nom']) < 3) {
23
		if (strlen($donnees['nom']) < 3) {
24
			$donnees['information'] = 'Veuillez saisir un radical contenant au moins 3 caractères alphabétiques !';
24
			$donnees['information'] = 'Veuillez saisir un radical contenant au moins 3 caractères alphabétiques !';
25
		} else {
25
		} else {
26
			$noms = ($donnees['type_nom'] == 'nom_vernaculaire') 
-
 
27
				? new NomsVernaculaires(Config::get(Registre::get('parametres.referentiel').'.referentielVerna')) 
-
 
28
				: new Noms(Registre::get('parametres.referentiel'));
-
 
29
			$presence = $this->rechercherNom($noms);
26
			$presence = $this->rechercherNom();
30
			if ($presence == '') {
27
			if ($presence == '') {
31
				$donnees['information'] = 'Nom inconnu';
28
				$donnees['information'] = 'Nom inconnu';
32
			} elseif ($presence != 'ok') {
29
			} elseif ($presence != 'ok') {
33
				$donnees['nom_approche'] = $presence;
30
				$donnees['nom_approche'] = $presence;
34
				$donnees['url_nom_approche'] = $this->obtenirUrlRechercheSimple($presence, $donnees['type_nom']);
31
				$donnees['url_nom_approche'] = $this->obtenirUrlRechercheSimple($presence, $donnees['type_nom']);
35
			}
32
			}
36
		}
33
		}
37
		Registre::set('donneesMoteur', $donnees);
34
		Registre::set('donneesMoteur', $donnees);
38
		$this->executerAction('RechercheSimple', 'executerForm');
35
		$this->executerAction('RechercheSimple', 'executerForm');
39
		if ($presence == 'ok') {
36
		if (Registre::get('resultats')) {
40
			$this->executerAction('Resultat', 'executerResultat');
37
			$this->executerAction('Resultat', 'executerResultat');
41
		}
38
		}
42
	}
39
	}
Line 43... Line 40...
43
	
40
	
-
 
41
	// regarde si il y a des résultats correspondant au nom recherché sinon recherche un nom approché
44
	// regarde si il y a des résultats correspondant au nom recherché sinon recherche un nom approché
42
	// $noms classe métier nom ou nom
-
 
43
	private function rechercherNom() {
-
 
44
		$noms = ($this->type_nom == 'nom_vernaculaire') 
-
 
45
				? new NomsVernaculaires(Config::get(Registre::get('parametres.referentiel').'.referentielVerna')) 
45
	private function rechercherNom($noms) {
46
				: new Noms(Registre::get('parametres.referentiel'));
46
		$approche = '';
47
		$approche = '';
47
		$res = $noms->getRechercheEtendue($this->nom);
48
		$res = $noms->getRechercheEtendue($this->nom);
48
		$form = I18n::get('Recherche-form-nom');
49
		$form = I18n::get('Recherche-form-nom');
49
		if ($res == false || $res['entete']['total'] == 0) { // recherche nom approché
50
		if ($res == false || $res['entete']['total'] == 0) { // recherche nom approché
50
			$res = $noms->getRechercheFloue($this->nom);
-
 
51
			if (!($res == false || $res['entete']['total'] == 0)) {
-
 
52
				$nom_proche = array_shift($res['resultat']);
-
 
53
				$approche = ($this->type_nom == 'nom_vernaculaire') ? $nom_proche['nom'] : $nom_proche['nom_sci'];
-
 
54
			}
51
			$approche = $this->rechercherNomApproche($noms);
55
		} elseif ($res['entete']['total'] == 1 || $this->submit == $form['fiche']) { // renvoie à la fiche
52
		} elseif ($res['entete']['total'] == 1 || $this->submit == $form['fiche']) { // renvoie à la fiche
56
			$ids = array_keys($res['resultat']);
53
			$ids = array_keys($res['resultat']);
57
			$url = $this->obtenirUrlFiche($ids[0]);
54
			$url = $this->obtenirUrlFiche($ids[0]);
58
			$this->redirigerVers($url);
55
			$this->redirigerVers($url);
59
		} else { // affiche les résultats
56
		} else { // affiche les résultats
60
			$res['type'] = $this->type_nom;
57
			$res['type'] = $this->type_nom;
61
			Registre::set('resultats', $res);
58
			Registre::set('resultats', $res);
-
 
59
			$approche = 'ok';
-
 
60
			if ($res['entete']['total'] < 16) { // si moins de 16 noms affiche en plus un nom approché
-
 
61
				$approche = $this->rechercherNomApproche($noms);
-
 
62
			}
-
 
63
		}
-
 
64
		return $approche;
-
 
65
	}
-
 
66
	
-
 
67
	private function rechercherNomApproche($noms) {
-
 
68
		$approche = '';
-
 
69
		$res = $noms->getRechercheFloue($this->nom);
-
 
70
		if (!($res == false || $res['entete']['total'] == 0)) {
-
 
71
			$nom_proche = array_shift($res['resultat']);
62
			$approche = 'ok';
72
			$approche = ($this->type_nom == 'nom_vernaculaire') ? $nom_proche['nom'] : $nom_proche['nom_sci'];
63
		}
73
		}
64
		return $approche;
74
		return $approche;
Line 65... Line 75...
65
	}
75
	}