Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 1092 Rev 1093
Line 189... Line 189...
189
		$this->textes->setId('bdtfx.nn:'.$this->nomCourant->getNnr());
189
		$this->textes->setId('bdtfx.nn:'.$this->nomCourant->getNnr());
190
		$texte = $this->textes->getTexte();
190
		$texte = $this->textes->getTexte();
191
		$texte = array_pop($texte['resultats']);
191
		$texte = array_pop($texte['resultats']);
192
		if ($texte) {
192
		if ($texte) {
193
			$coste['titre'] = $texte['titre'];
193
			$coste['titre'] = $texte['titre'];
194
			$coste['description'] = $this->mettreEnFormeCoste($texte['texte']);
194
			$coste['description'] = self::mettreEnFormeCoste($texte['texte']);
195
		}
195
		}
196
		$this->meta->setProjet('coste');
196
		$this->meta->setProjet('coste');
197
		$meta = $this->meta->getMetaDonnees();
197
		$meta = $this->meta->getMetaDonnees();
198
		$citation = $meta[0]['citation'];
198
		$citation = $meta[0]['citation'];
199
		$coste['meta']['citation'] = $citation;
199
		$coste['meta']['citation'] = $citation;
200
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
200
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
201
		$this->donnees['coste'] = $coste;
201
		$this->donnees['coste'] = $coste;
202
	}
202
	}
Line 203... Line 203...
203
 
203
 
204
	public function mettreEnFormeCoste($texte){
204
	static function mettreEnFormeCoste($texte) {
205
		$this->CosteFormate = array();
-
 
206
		$this->CosteTexte = $texte;
205
		$txt_fmt = array();
207
		//decouper elements remarquables avant le texte
206
		//decouper elements remarquables avant le texte
208
		$this->separerNomScientifique_a_NomCommun();
207
		self::separerNomScientifique_a_NomCommun($texte, $txt_fmt);
209
		$this->CosteTexte = preg_replace('/\//','',$this->CosteTexte);
208
		$texte = preg_replace('/\//','',$texte);
210
		//decouper elements remarquables  après le texte
209
		//decouper elements remarquables  après le texte
211
		$this-> separerEcologie_a_Usages();
210
		self::separerEcologie_a_Usages($texte, $txt_fmt);
212
		//le morceau qui reste est le gros de la description
211
		//le morceau qui reste est le gros de la description
213
		$this->CosteTexte = str_replace(';','</br> -','- '.$this->CosteTexte);
212
		$texte = str_replace(';','</br> -','- '.$texte);
214
		$this->CosteTexte = str_replace('–','',$this->CosteTexte);
213
		$texte = str_replace('–','',$texte);
215
		$this->CosteFormate['texte'] = $this->CosteTexte;
214
		$txt_fmt['texte'] = $texte;
216
		return $this->CosteFormate;
215
		return $txt_fmt;
Line 217... Line 216...
217
	}
216
	}
218
 
217
 
219
 
218
 
220
	public function separerNomScientifique_a_NomCommun(){
219
	static function separerNomScientifique_a_NomCommun(&$txt, &$txt_fmt){
221
		if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $this->CosteTexte, $retour)){
220
		if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $txt, $retour)){
222
			/* !! attention on enlève un tiret cadratin – pas un trait d'union - !! */
221
			/* !! attention on enlève un tiret cadratin – pas un trait d'union - !! */
223
			$a_enlever  = array('/–/','/\./' );
222
			$a_enlever  = array('/–/','/\./' );
224
			$this->CosteFormate['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]);
223
			$txt_fmt['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]);
225
			if(preg_match('/\((.+)\)/',$retour[2],$synonymes)){
224
			if(preg_match('/\((.+)\)/',$retour[2],$synonymes)){
226
				$this->CosteFormate['synonymes'] = $synonymes[1];
225
				$txt_fmt['synonymes'] = $synonymes[1];
227
			} else {
226
			} else {
228
				$this->CosteFormate['nom_scientifique'] .=  $retour[2];
227
				$txt_fmt['nom_scientifique'] .=  $retour[2];
229
			}
228
			}
230
			$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte);
229
			$txt = str_replace($retour[0],'',$txt);
231
		}
230
		}
232
		/* !! attention il y a un espace avant les // du début !! */
231
		/* !! attention il y a un espace avant les // du début !! */
233
		if ( preg_match('/^ \/\/([^\/\/]+)\/\//', $this->CosteTexte, $retour)){
232
		if ( preg_match('/^ \/\/([^\/\/]+)\/\//', $txt, $retour)){
234
			$a_enlever = array('/–/','/\./' );
233
			$a_enlever = array('/–/','/\./' );
235
			$this->CosteFormate['nom_commun'] = preg_replace($a_enlever,'',$retour[1]);
234
			$txt_fmt['nom_commun'] = preg_replace($a_enlever,'',$retour[1]);
Line 236... Line 235...
236
			$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte);
235
			$txt = str_replace($retour[0],'',$txt);
237
		}
236
		}
238
	}
237
	}
239
 
238
 
240
 
239
 
241
	public function separerEcologie_a_Usages(){
240
	static function separerEcologie_a_Usages(&$txt, &$txt_fmt) {
242
		if ( preg_match('/\.\s*([A-ZÉÀÈ].+)$/',$this->CosteTexte, $retour)){
241
		if (preg_match('/\.\s*([A-ZÉÀÈ].+)$/',$txt, $retour)) {
243
			$this->CosteFormate['ecologie'] = $retour[1];
242
			$txt_fmt['ecologie'] = $retour[1];
244
			$this->CosteTexte = str_replace($retour[0],'.',$this->CosteTexte);
243
			$txt = str_replace($retour[0],'.',$txt);
245
			if (isset($this->CosteFormate['ecologie']) && preg_match('/–(.+)/', $this->CosteFormate['ecologie'] , $retour)){
244
			if (isset($txt_fmt['ecologie']) && preg_match('/–(.+)/', $txt_fmt['ecologie'] , $retour)){
246
				$this->CosteFormate['repartition'] = $retour[1];
245
				$txt_fmt['repartition'] = $retour[1];
247
				$this->CosteFormate['ecologie'] = str_replace($retour[0],'',$this->CosteFormate['ecologie']);
246
				$txt_fmt['ecologie'] = str_replace($retour[0],'',$txt_fmt['ecologie']);
248
			}
247
			}
249
			if (isset($this->CosteFormate['repartition']) &&  preg_match('/=(.+)$/', $this->CosteFormate['repartition'], $retour)){
248
			if (isset($txt_fmt['repartition']) &&  preg_match('/=(.+)$/', $txt_fmt['repartition'], $retour)){
250
				$this->CosteFormate['floraison'] = $retour[1];
249
				$txt_fmt['floraison'] = $retour[1];
251
				$this->CosteFormate['repartition'] = str_replace($retour[0],'',$this->CosteFormate['repartition']);
250
				$txt_fmt['repartition'] = str_replace($retour[0],'',$txt_fmt['repartition']);
252
			}
251
			}
253
			if (isset($this->CosteFormate['floraison']) &&  preg_match('/–(.+)$|\n(.+)$/',$this->CosteFormate['floraison'], $retour)){
252
			if (isset($txt_fmt['floraison']) &&  preg_match('/–(.+)$|\n(.+)$/',$txt_fmt['floraison'], $retour)){
254
				$this->CosteFormate['usages'] = isset($retour[1]) ? $retour[1] : $retour[2];
253
				$txt_fmt['usages'] = isset($retour[1]) ? $retour[1] : $retour[2];
255
				$this->CosteFormate['floraison'] = str_replace($retour[0],'.',$this->CosteFormate['floraison']);
254
				$txt_fmt['floraison'] = str_replace($retour[0],'.',$txt_fmt['floraison']);
256
			}
255
			}
257
			if (isset($this->CosteFormate['floraison']) &&  preg_match('/([Ff]l\.) (.+)/',$this->CosteFormate['floraison'], $retour)){
256
			if (isset($txt_fmt['floraison']) &&  preg_match('/([Ff]l\.) (.+)/',$txt_fmt['floraison'], $retour)){
258
				$this->CosteFormate['floraison'] = $retour[2];
257
				$txt_fmt['floraison'] = $retour[2];
259
				$this->CosteFormate['floraison'] = str_replace($retour[1],'',$this->CosteFormate['floraison']);
258
				$txt_fmt['floraison'] = str_replace($retour[1],'',$txt_fmt['floraison']);
260
			}
259
			}
261
			if (isset($this->CosteFormate['floraison']) &&  preg_match('/([Ff]r\.) (.+)/',$this->CosteFormate['floraison'], $retour)){
260
			if (isset($txt_fmt['floraison']) &&  preg_match('/([Ff]r\.) (.+)/',$txt_fmt['floraison'], $retour)){
262
				$this->CosteFormate['fructification'] = $retour[2];
261
				$txt_fmt['fructification'] = $retour[2];
263
				$this->CosteFormate['floraison'] = str_replace($retour[0],'',$this->CosteFormate['floraison']);
262
				$txt_fmt['floraison'] = str_replace($retour[0],'',$txt_fmt['floraison']);
264
				$this->CosteFormate['floraison'] = str_replace(',','',$this->CosteFormate['floraison']);
263
				$txt_fmt['floraison'] = str_replace(',','',$txt_fmt['floraison']);
265
				$this->CosteFormate['fructification'] = str_replace($retour[1],'',$this->CosteFormate['fructification']);
264
				$txt_fmt['fructification'] = str_replace($retour[1],'',$txt_fmt['fructification']);
266
				$this->CosteFormate['fructification'] = str_replace('.','',$this->CosteFormate['fructification']);
265
				$txt_fmt['fructification'] = str_replace('.','',$txt_fmt['fructification']);
267
			}
266
			}