Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 791 Rev 798
Line 38... Line 38...
38
	
38
	
39
	private function supprimerCodeReftaxAvecNn($nn) {
39
	private function supprimerCodeReftaxAvecNn($nn) {
40
		$codeReftax = $this->parametres->reftaxCourant.'.nn:';
40
		$codeReftax = $this->parametres->reftaxCourant.'.nn:';
41
		return str_replace($codeReftax, '', $nn);
41
		return str_replace($codeReftax, '', $nn);
-
 
42
	}
-
 
43
	
-
 
44
	
-
 
45
	private function renvoyerInfoVerna($nn, $valeurs) {
-
 
46
		$infosDuNom = array();
-
 
47
		$infosDuNom['nomSci'] = $valeurs['taxon'];
-
 
48
		$infosDuNom['nomVerna'] = $valeurs['nom_vernaculaire'];
-
 
49
		$infosDuNom['langue'] = $valeurs['code_langue'];
-
 
50
		$infosDuNom['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom,  $this->parametres->masqueRecherche);
-
 
51
		return $infosDuNom ;
Line -... Line 52...
-
 
52
	}
-
 
53
 
-
 
54
	function supprimerAccents($chaine){
-
 
55
		return strtr($chaine,array('à' => 'a','á' => 'a','â' => 'a','ã' => 'a','ä' => 'a',
-
 
56
									'ç' => 'c',
-
 
57
									'è' => 'e','é' => 'e','ê' => 'e','ë' => 'e',
-
 
58
									'ì' => 'i','í' => 'i','î' => 'i','ï' => 'i',
-
 
59
									'ñ' => 'n',
-
 
60
									'ò' => 'o', 'ó' => 'o' , 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 
-
 
61
									'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 
-
 
62
									'ý' => 'y', 'ÿ' => 'y'));
42
	}
63
	}
-
 
64
	
43
 
65
	public function formater() {
44
	public function formater() {
66
	$nomVerna = array();
45
	foreach ($this->noms as $id => $nom) {
67
	foreach ($this->noms as $id => $nom) {
46
			$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
68
			$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
47
			$infosDuNom = array();
69
			$nom_min = strtolower($nom['nom_vernaculaire']);
48
			$infosDuNom['nomSci'] = $nom['taxon'];
70
			$nom_ss_accent = $this->supprimerAccents($nom_min); 
49
			$infosDuNom['nomVerna'] = $nom['nom_vernaculaire'];
71
			if (preg_match('/^'.strtolower($this->parametres->masqueRecherche).' |^'.strtolower($this->parametres->masqueRecherche).'$/',  $nom_ss_accent)) {
50
			$infosDuNom['langue'] = $nom['code_langue'];
-
 
51
			$infosDuNom['geo'] = $nom['zone_usage'];
72
				$nomVerna[0][$id] = $this->renvoyerInfoVerna($nn, $nom);
-
 
73
			} else {
52
			$infosDuNom['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom,  $this->parametres->masqueRecherche);
74
				$nomVerna[1][$id] = $this->renvoyerInfoVerna($nn, $nom);
-
 
75
			}
-
 
76
		}
53
			$this->infosPourTpl['noms'][$nn] = $infosDuNom;
77
		ksort($nomVerna);
Line 54... Line 78...
54
		}
78
		$this->infosPourTpl['noms'] = isset($nomVerna)  ? $nomVerna : false;
-
 
79
	}
-
 
80
 
-
 
81
		public function trier() {
-
 
82
			$verna = array();
-
 
83
			foreach ($this->infosPourTpl['noms'] as $categorie => $valeurs) {
-
 
84
				$verna += $this->classerAlphabetiquement('nomVerna', $valeurs);
-
 
85
			}
-
 
86
			$this->infosPourTpl['noms'] = $verna;
55
	}
87
	}
56
 
88
	
57
	public function trier() {
89
	private function classerAlphabetiquement($champs, $valeurs) {
58
		$this->trieur->setTableau($this->infosPourTpl['noms']);
90
		$this->trieur->setTableau($valeurs);
Line 59... Line 91...
59
		$this->trieur->setChampsEtOrdres(array('nomVerna'=> SORT_NATURAL));
91
		$this->trieur->setChampsEtOrdres(array($champs => SORT_NATURAL));
-
 
92
		return $this->trieur->trier();
-
 
93
	}
-
 
94
 
-
 
95
	public function surligner() {
-
 
96
		$this->definirMotsASurligner();
-
 
97
		foreach ($this->infosPourTpl['noms'] as $idNom => $nom) {
-
 
98
			$this->infosPourTpl['noms'][$idNom]['nomVerna'] = $this->surlignerMotsMasqueRecherche($nom['nomVerna']);
-
 
99
		}
-
 
100
	}
-
 
101
 
Line -... Line 102...
-
 
102
	private function definirMotsASurligner() {
-
 
103
		$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
-
 
104
 
-
 
105
	}
60
		$this->infosPourTpl['noms'] = $this->trieur->trier();
106
 
61
	}
107
	private function surlignerMotsMasqueRecherche($nom) {
62
 
108
		$this->surligneur->setTexte($nom);
63
	public function surligner() {
109
		$nom = $this->surligneur->surlignerMots($this->motsASurligner);