Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 611 Rev 625
Line 22... Line 22...
22
	private $informations = null;
22
	private $informations = null;
23
	private $mois = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août',
23
	private $mois = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août',
24
						'septembre', 'octobre', 'novembre', 'décembre');
24
						'septembre', 'octobre', 'novembre', 'décembre');
25
	private $CosteFormate;
25
	private $CosteFormate;
26
	private $CosteTexte;
26
	private $CosteTexte;
27
	
27
 
28
	public function __construct(Conteneur $conteneur) {
28
	public function __construct(Conteneur $conteneur) {
29
		$this->conteneur = $conteneur;
29
		$this->conteneur = $conteneur;
30
		$this->nomCourant = $this->conteneur->getNomCourant();
30
		$this->nomCourant = $this->conteneur->getNomCourant();
31
		$this->textes = $this->conteneur->getApiTextes();
31
		$this->textes = $this->conteneur->getApiTextes();
32
		$this->wikini = $this->conteneur->getApiWikini();
32
		$this->wikini = $this->conteneur->getApiWikini();
Line 41... Line 41...
41
		$donnees['coste'] = $this->getCoste();
41
		$donnees['coste'] = $this->getCoste();
42
		$donnees['wikini'] = $this->getWikini();
42
		$donnees['wikini'] = $this->getWikini();
43
		$donnees['baseflor'] = $this->getBaseflor();
43
		$donnees['baseflor'] = $this->getBaseflor();
44
		return $donnees;
44
		return $donnees;
45
	}
45
	}
46
	
46
 
47
	private function getBaseflor() {
47
	private function getBaseflor() {
48
		$baseflor = array();
48
		$baseflor = array();
49
		$this->informations ->setProjet('baseflor');
49
		$this->informations ->setProjet('baseflor');
50
		$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
50
		$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
51
		$this->informations ->setNum_nom($this->conteneur->getParametre('num_nom'));
51
		$this->informations ->setNum_nom($this->conteneur->getParametre('num_nom'));
Line 68... Line 68...
68
			$this->meta->setProjet('baseflor');
68
			$this->meta->setProjet('baseflor');
69
			$meta = $this->meta->getMetaDonnees();
69
			$meta = $this->meta->getMetaDonnees();
70
			$citation = $meta[0]['citation'];
70
			$citation = $meta[0]['citation'];
71
			$baseflor['meta']['citation'] = $citation;
71
			$baseflor['meta']['citation'] = $citation;
72
			$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
72
			$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
73
			
73
 
74
		}
74
		}
75
		return $baseflor;
75
		return $baseflor;
76
	}
76
	}
77
	
77
 
78
	public function changerFloraisonEnChaine($floraison){
78
	public function changerFloraisonEnChaine($floraison){
79
		$chaine = "";
79
		$chaine = "";
80
		if ($floraison != ""){
80
		if ($floraison != ""){
81
			$mois_fleurs=preg_match('/-/',$floraison) ? preg_split('/-/',$floraison) : $floraison;
81
			$mois_fleurs=preg_match('/-/',$floraison) ? preg_split('/-/',$floraison) : $floraison;
82
			if (is_array($mois_fleurs)){
82
			if (is_array($mois_fleurs)){
83
				$chaine = "de ".$this->mois[(int)$mois_fleurs[0]]." à ".$this->mois[(int)$mois_fleurs[1]];
83
				$chaine = "de ".$this->mois[(int)$mois_fleurs[0]]." à ".$this->mois[(int)$mois_fleurs[1]];
84
					
84
 
85
			}else { $chaine = "en ".$this->mois[(int)$mois_fleurs];
85
			}else { $chaine = "en ".$this->mois[(int)$mois_fleurs];
86
			}
86
			}
87
		}
87
		}
88
		return $chaine;
88
		return $chaine;
89
	}
89
	}
Line 109... Line 109...
109
		$this->textes->setProjet('wikipedia');
109
		$this->textes->setProjet('wikipedia');
110
		$this->textes->setId($this->getIdWp());
110
		$this->textes->setId($this->getIdWp());
111
		$wp['titre'] = $texte['titre'];
111
		$wp['titre'] = $texte['titre'];
112
		$wp['lien'] = $this->textes->getPageUrl();
112
		$wp['lien'] = $this->textes->getPageUrl();
113
		$wp['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('wikipedia');
113
		$wp['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('wikipedia');
114
		
114
 
115
		return $wp;
115
		return $wp;
116
	}
116
	}
Line 117... Line 117...
117
 
117
 
118
	private function getIdWp() {
118
	private function getIdWp() {
119
		$nomSci = $this->nomCourant->getNomRetenu()->get('nom_sci');
119
		$nomSci = $this->nomCourant->getNomRetenu()->get('nom_sci');
120
		$idWp = str_replace(' ', '_', $nomSci);
120
		$idWp = str_replace(' ', '_', $nomSci);
121
		$idWp = urlencode($idWp);
121
		$idWp = urlencode($idWp);
122
		return $idWp;
122
		return $idWp;
123
	}
123
	}
124
	
124
 
125
	private function getWikini() {	
125
	private function getWikini() {
126
		$wikini = array();
126
		$wikini = array();
127
		$wikini['titre'] = 'Wikini';
127
		$wikini['titre'] = 'Wikini';
128
		$referentiel = $this->conteneur->getParametre('referentiel');
128
		$referentiel = $this->conteneur->getParametre('referentiel');
129
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
129
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
130
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
130
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
131
		$wikini['description'] = $this->wikini->getTexteFormate($page_wiki, 'description');
131
		$wikini['description'] = $this->wikini->getTexteFormate($page_wiki, 'description');
132
		return $wikini;
132
		return $wikini;
133
	}
133
	}
134
	
134
 
135
	private function getCoste() {
135
	private function getCoste() {
136
		$coste = array();
136
		$coste = array();
137
		$this->textes->setProjet('coste');
137
		$this->textes->setProjet('coste');
138
		$this->textes->setId('bdtfx.nn:'.$this->nomCourant->getNnr());
138
		$this->textes->setId('bdtfx.nn:'.$this->nomCourant->getNnr());
139
		$texte = $this->textes->getTexte();
139
		$texte = $this->textes->getTexte();
140
		if ($texte) {
140
		if ($texte) {
141
			$coste['titre'] = $texte['titre'];
141
			$coste['titre'] = $texte['titre'];
142
			$texte = $this->MettreEnFormeCoste($texte['texte']);
-
 
143
			$coste['description'] = $texte ;
142
			$coste['description'] = $this->mettreEnFormeCoste($texte['texte']);
144
		}
143
		}
145
		$this->meta->setProjet('coste');
144
		$this->meta->setProjet('coste');
146
		$meta = $this->meta->getMetaDonnees();
145
		$meta = $this->meta->getMetaDonnees();
147
		$citation = $meta[0]['citation'];
146
		$citation = $meta[0]['citation'];
148
		$coste['meta']['citation'] = $citation;
147
		$coste['meta']['citation'] = $citation;
149
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
148
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
150
		return $coste;
149
		return $coste;
151
	}
150
	}
152
	
151
 
153
	public function MettreEnFormeCoste($texte){
152
	public function mettreEnFormeCoste($texte){
154
		$this->CosteFormate = array();
153
		$this->CosteFormate = array();
155
		$this->CosteTexte = $texte;
154
		$this->CosteTexte = $texte;
156
		//decouper elements remarquables avant le texte
155
		//decouper elements remarquables avant le texte
157
		$this->separerNomScientifique_a_NomCommun();
156
		$this->separerNomScientifique_a_NomCommun();
Line 162... Line 161...
162
		$this->CosteTexte = str_replace(';','</br> -','- '.$this->CosteTexte);
161
		$this->CosteTexte = str_replace(';','</br> -','- '.$this->CosteTexte);
163
		$this->CosteTexte = str_replace('–','',$this->CosteTexte);
162
		$this->CosteTexte = str_replace('–','',$this->CosteTexte);
164
		$this->CosteFormate['texte'] = $this->CosteTexte;
163
		$this->CosteFormate['texte'] = $this->CosteTexte;
165
		return $this->CosteFormate;
164
		return $this->CosteFormate;
166
	}
165
	}
167
	
166
 
168
	
167
 
169
	public function separerNomScientifique_a_NomCommun(){
168
	public function separerNomScientifique_a_NomCommun(){
170
		if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $this->CosteTexte, $retour)){
169
		if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $this->CosteTexte, $retour)){
171
			/* !! attention on enlève un tiret cadratin – pas un trait d'union - !! */
170
			/* !! attention on enlève un tiret cadratin – pas un trait d'union - !! */
172
			$a_enlever  = array('/–/','/\./' );
171
			$a_enlever  = array('/–/','/\./' );
173
			$this->CosteFormate['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]);
172
			$this->CosteFormate['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]);
Line 183... Line 182...
183
			$a_enlever = array('/–/','/\./' );
182
			$a_enlever = array('/–/','/\./' );
184
			$this->CosteFormate['nom_commun'] = preg_replace($a_enlever,'',$retour[1]);
183
			$this->CosteFormate['nom_commun'] = preg_replace($a_enlever,'',$retour[1]);
185
			$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte);
184
			$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte);
186
		}
185
		}
187
	}
186
	}
188
	
187
 
189
	
188
 
190
	public function separerEcologie_a_Usages(){
189
	public function separerEcologie_a_Usages(){
191
		if ( preg_match('/\.[ ]*([A-ZÉÀÈ].+)$/',$this->CosteTexte, $retour)){
190
		if ( preg_match('/\.[ ]*([A-ZÉÀÈ].+)$/',$this->CosteTexte, $retour)){
192
			$this->CosteFormate['ecologie'] = $retour[1];
191
			$this->CosteFormate['ecologie'] = $retour[1];
193
			$this->CosteTexte = str_replace($retour[0],'.',$this->CosteTexte);
192
			$this->CosteTexte = str_replace($retour[0],'.',$this->CosteTexte);
194
			if ( preg_match('/–(.+)/', $this->CosteFormate['ecologie'] , $retour)){
193
			if ( preg_match('/–(.+)/', $this->CosteFormate['ecologie'] , $retour)){
Line 212... Line 211...
212
				$this->CosteFormate['floraison'] = str_replace($retour[0],'',$this->CosteFormate['floraison']);
211
				$this->CosteFormate['floraison'] = str_replace($retour[0],'',$this->CosteFormate['floraison']);
213
				$this->CosteFormate['floraison'] = str_replace(',','',$this->CosteFormate['floraison']);
212
				$this->CosteFormate['floraison'] = str_replace(',','',$this->CosteFormate['floraison']);
214
				$this->CosteFormate['fructification'] = str_replace($retour[1],'',$this->CosteFormate['fructification']);
213
				$this->CosteFormate['fructification'] = str_replace($retour[1],'',$this->CosteFormate['fructification']);
215
				$this->CosteFormate['fructification'] = str_replace('.','',$this->CosteFormate['fructification']);
214
				$this->CosteFormate['fructification'] = str_replace('.','',$this->CosteFormate['fructification']);
216
			}
215
			}
217
		}	
216
		}
218
	}
217
	}
219
	
218
 
220
	
219
 
221
}
220
}
222
?>
221
?>
223
222