Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 54 Rev 57
Line 7... Line 7...
7
	 * Fonction d'affichage par défaut
7
	 * Fonction d'affichage par défaut
8
	 */
8
	 */
Line 9... Line 9...
9
	
9
	
10
	
-
 
11
	public function executerActionParDefaut() {
-
 
12
		if (isset($_GET['referentiel'])) {
-
 
13
			Registre::set('parametres.referentiel', $_GET['referentiel']);
10
	
14
		}
11
	public function executerActionParDefaut() {
Line 15... Line 12...
15
		$this->executerAccueil();
12
		$this->executerAccueil();
16
	}
13
	}
17
	
-
 
18
	public function executerAccueil() {
-
 
19
		$donnees = array();
-
 
20
		$donnees['i18n'] = I18n::get('Recherche-accueil');
-
 
21
		
14
	
-
 
15
	public function executerAccueil() {
-
 
16
		$donnees = array();
-
 
17
		$donnees['form_nom'] = $this->executerFormulaireNom();
-
 
18
		$this->afficherAccueil($donnees);
-
 
19
	}
Line 22... Line 20...
22
		$donnees['referentiel_titre'] = I18n::get('Referentiels-titres.'.Config::get('referentiel'));
20
	
23
		
21
	private function afficherAccueil($donnees) {
Line 24... Line 22...
24
		$donnees['form_nom'] = $this->executerFormulaireNom();
22
		$donnees['i18n'] = I18n::get('Recherche-accueil');
-
 
23
		
25
		
24
		$this->setSortie(self::RENDU_CORPS, $this->getVue('recherche_accueil', $donnees));
-
 
25
	}
26
		$this->setSortie(self::RENDU_CORPS, $this->getVue('recherche_accueil', $donnees));
26
	
27
	}
-
 
Line 28... Line 27...
28
	
27
	public function executerFormulaireNom($donnees = array()) {
29
	public function executerFormulaireNom() {
28
		if (!isset($donnees['type_nom'])) {
Line 30... Line 29...
30
		$donnees['eflore_type_nom'] = 'nom_vernaculaire';
29
			$donnees['type_nom'] = (Registre::get('parametres.niveau') == 1) ? 'nom_vernaculaire' : 'nom_scientifique';
-
 
30
		}
-
 
31
		$donnees['i18n'] = I18n::get('Recherche-form-nom');
31
		$donnees['i18n'] = I18n::get('Recherche-form-nom');
32
		
32
		$donnees['url_js'] = Config::get('url_js');
33
		return $this->getVue('form_nom', $donnees);
33
		
34
	}
34
		return $this->getVue('form_nom', $donnees);
35
	
35
	}
36
	public function executerRechercheNom() {
36
	
37
		$donnees['type_nom'] = $_GET['type_nom'];
37
	public function executerRechercheNom() {
38
		$donnees['nom'] = $_GET['nom']; echo $donnees['nom'];
38
		if (strlen($_GET['eflore_nom']) < 3) {
39
		if (strlen($donnees['nom']) < 3) {
39
			$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 !';
40
		} else {
41
		} else {
41
			$noms = ($_GET['eflore_type_nom'] == 'nom_vernaculaire') 
42
			$noms = ($donnees['type_nom'] == 'nom_vernaculaire') 
-
 
43
				? new NomsVernaculaires(Config::get('referentielVerna')) 
-
 
44
				: new Noms(Registre::get('parametres.referentiel'));
42
				? new NomsVernaculaires(Config::get('referentielVerna')) 
45
			$presence = $this->rechercherNom($noms);
43
				: new Noms(Registre::get('parametres.referentiel'));
46
			if ($presence == '') {
Line 44... Line -...
44
			$presence = $this->rechercherNom($noms);
-
 
45
			if ($presence == '') {
-
 
46
				$donnees['information'] = 'Nom inconnu';
-
 
47
			} elseif ($presence != 'ok') {
-
 
48
				$donnees['nom_approche'] = $presence;
-
 
49
			}
-
 
50
		}
-
 
51
		
-
 
52
		
-
 
53
		if (isset($donnees)) {
-
 
54
			$donnees['eflore_type_nom'] = $_GET['eflore_type_nom'];
47
				$donnees['information'] = 'Nom inconnu';
55
			$donnees['i18n'] = I18n::get('Recherche-accueil');
-
 
56
			$donnees['referentiel_titre'] = I18n::get('Referentiels-titres.'.Config::get('referentiel'));
-
 
57
			
48
			} elseif ($presence != 'ok') {
58
			$donnees['i18n'] = I18n::get('Recherche-form-nom');
-
 
59
			$donnees['url_js'] = Config::get('url_js');
-
 
60
			$donnees['nom'] = $_GET['eflore_nom'];
49
				$donnees['nom_approche'] = $presence;
Line -... Line 50...
-
 
50
				Debug::printr(Registre::get('eflore.urlCourrante')->getUrl()); // revoir à partir de appcontroleur
61
			
51
				//$donnees['url_nom_approche'] = str_replace($donnees['nom'], $donnees['nom_approche'], Registre::get('eflore.urlCourrante'));
62
			$donnees['form_nom'] = $this->getVue('form_nom', $donnees);
52
			}
63
			$this->setSortie(self::RENDU_CORPS, $this->getVue('recherche_accueil', $donnees));
53
		}
64
		} else {
54
		
65
			print_r($_GET['eflore_nom']);
55
		$donnees['form_nom'] = $this->executerFormulaireNom($donnees);
66
			// envoyerResultat;
56
		$this->afficherAccueil($donnees);
67
		}
-
 
68
	}
57
	}
69
	
58
	
70
	private function rechercherNom($noms) {
59
	// regarde si il y a des résultats correspondant au nom recherché sinon recherche un nom approché
-
 
60
	private function rechercherNom($noms) {
-
 
61
		$approche = '';
71
		$approche = '';
62
		$res = $noms->getRechercheEtendue($_GET['nom']);
72
		$res = $noms->getRechercheEtendue($_GET['eflore_nom']); //print_r($res);
63
		if ($res == false || $res['entete']['total'] == 0) {
73
		if ($res == false || $res->entete->total == 0) {
64
			$res = $noms->getRechercheFloue($_GET['nom']);
74
			$res = $noms->getRechercheFloue($_GET['eflore_nom']);
65
			if (!($res == false || $res['entete']['total'] == 0)) {
75
			if (!($res == false || $res->entete->total == 0)) {
66
				$nom_proche = array_shift($res['resultat']);