Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 570 Rev 580
Line 20... Line 20...
20
	private $meta = null;
20
	private $meta = null;
21
	private $wikini = null;
21
	private $wikini = null;
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;
-
 
26
	private $CosteTexte;
Line 25... Line 27...
25
	
27
	
26
	public function __construct(Conteneur $conteneur) {
28
	public function __construct(Conteneur $conteneur) {
27
		$this->conteneur = $conteneur;
29
		$this->conteneur = $conteneur;
28
		$this->nomCourant = $this->conteneur->getNomCourant();
30
		$this->nomCourant = $this->conteneur->getNomCourant();
Line 147... Line 149...
147
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
149
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
148
		return $coste;
150
		return $coste;
149
	}
151
	}
Line 150... Line 152...
150
	
152
	
151
	public function MettreEnFormeCoste($texte){
153
	public function MettreEnFormeCoste($texte){
-
 
154
		$this->CosteFormate = array();
-
 
155
		$this->CosteTexte = $texte;
-
 
156
		//decouper elements remarquables avant le texte
-
 
157
		$this->separerNomScientifique_a_NomCommun();
-
 
158
		$this->CosteTexte = preg_replace('/\//','',$this->CosteTexte);
-
 
159
		//decouper elements remarquables  après le texte
-
 
160
		$this-> separerEcologie_a_Usages();
-
 
161
		//le morceau qui reste est le gros de la description
152
		$resultat = array();
162
		$this->CosteTexte = str_replace(';','</br> -','- '.$this->CosteTexte);
-
 
163
		$this->CosteTexte = str_replace('–','',$this->CosteTexte);
-
 
164
		$this->CosteFormate['texte'] = $this->CosteTexte;
-
 
165
		return $this->CosteFormate;
-
 
166
	}
153
		if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $texte, $retour)){
167
	
-
 
168
	
-
 
169
	public function separerNomScientifique_a_NomCommun(){
154
		
170
		if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $this->CosteTexte, $retour)){
155
			/* !! attention on enlève un tiret cadratin – pas un trait d'union - !! */
171
			/* !! attention on enlève un tiret cadratin – pas un trait d'union - !! */
156
			$a_enlever  = array('/–/','/[0-9]+/','/\./' );
172
			$a_enlever  = array('/–/','/\./' );
-
 
173
			$this->CosteFormate['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]);
-
 
174
			if(preg_match('/\((.+)\)/',$retour[2],$synonymes)){
-
 
175
				$this->CosteFormate['synonymes'] = $synonymes[1];
157
			$resultat['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]);
176
			} else {
-
 
177
				$this->CosteFormate['nom_scientifique'] .=  $retour[2];
158
			$resultat['nom_scientifique'] .= $retour[2];
178
			}
159
			$texte = str_replace($retour[0],'',$texte);
179
			$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte);
160
		}
180
		}
161
		/* !! attention il y a un espace avant les // du début !! */
181
		/* !! attention il y a un espace avant les // du début !! */
162
		if ( preg_match('/^ \/\/([^\/\/]+)\/\//', $texte, $retour)){
182
		if ( preg_match('/^ \/\/([^\/\/]+)\/\//', $this->CosteTexte, $retour)){
163
			$a_enlever = array('/–/','/\./' );
183
			$a_enlever = array('/–/','/\./' );
164
			$resultat['nom_commun'] = preg_replace($a_enlever,'',$retour[1]);
184
			$this->CosteFormate['nom_commun'] = preg_replace($a_enlever,'',$retour[1]);
165
			$texte = str_replace($retour[0],'',$texte);
185
			$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte);
-
 
186
		}
-
 
187
	}
-
 
188
	
166
		}
189
	
167
		$texte = preg_replace('/\//','',$texte);
190
	public function separerEcologie_a_Usages(){
168
		if ( preg_match('/\.[ ]*([A-ZÉÀÈ].+)$/', $texte, $retour)){
191
		if ( preg_match('/\.[ ]*([A-ZÉÀÈ].+)$/',$this->CosteTexte, $retour)){
169
			$resultat['ecologie'] = $retour[1];
192
			$this->CosteFormate['ecologie'] = $retour[1];
170
			$texte = str_replace($retour[0],'.',$texte);
193
			$this->CosteTexte = str_replace($retour[0],'.',$this->CosteTexte);
171
			if ( preg_match('/–(.+)/', $resultat['ecologie'] , $retour)){
194
			if ( preg_match('/–(.+)/', $this->CosteFormate['ecologie'] , $retour)){
172
				$resultat['repartition'] = $retour[1];
195
				$this->CosteFormate['repartition'] = $retour[1];
173
				$resultat['ecologie'] = str_replace($retour[0],'',$resultat['ecologie']);
196
				$this->CosteFormate['ecologie'] = str_replace($retour[0],'',$this->CosteFormate['ecologie']);
174
			}
197
			}
175
			if ( preg_match('/=(.+)$/', $resultat['repartition'], $retour)){
198
			if ( preg_match('/=(.+)$/', $this->CosteFormate['repartition'], $retour)){
176
				$resultat['floraison'] = $retour[1];
199
				$this->CosteFormate['floraison'] = $retour[1];
177
				$resultat['repartition'] = str_replace($retour[0],'',$resultat['repartition']);
200
				$this->CosteFormate['repartition'] = str_replace($retour[0],'',$this->CosteFormate['repartition']);
178
			}
201
			}
179
			if ( preg_match('/–(.+)$/',$resultat['floraison'], $retour)){
202
			if ( preg_match('/–(.+)$|\n(.+)$/',$this->CosteFormate['floraison'], $retour)){
180
				$resultat['consommation'] = $retour[1];
203
				$this->CosteFormate['usages'] = isset($retour[1]) ? $retour[1] : $retour[2];
181
				$resultat['floraison'] = str_replace($retour[0],'.',$resultat['floraison']);
204
				$this->CosteFormate['floraison'] = str_replace($retour[0],'.',$this->CosteFormate['floraison']);
-
 
205
			}
-
 
206
			if ( preg_match('/([Ff]l\.) (.+)/',$this->CosteFormate['floraison'], $retour)){
-
 
207
				$this->CosteFormate['floraison'] = $retour[2];
182
			}
208
				$this->CosteFormate['floraison'] = str_replace($retour[1],'',$this->CosteFormate['floraison']);
-
 
209
			}
183
		}
210
			if ( preg_match('/([Ff]r\.) (.+)/',$this->CosteFormate['floraison'], $retour)){
-
 
211
				$this->CosteFormate['fructification'] = $retour[2];
184
		$texte = str_replace(';','</br> -','- '.$texte);
212
				$this->CosteFormate['floraison'] = str_replace($retour[0],'',$this->CosteFormate['floraison']);
-
 
213
				$this->CosteFormate['floraison'] = str_replace(',','',$this->CosteFormate['floraison']);
185
		$texte = str_replace('–','',$texte);
214
				$this->CosteFormate['fructification'] = str_replace($retour[1],'',$this->CosteFormate['fructification']);
186
		$resultat['texte'] = $texte;
215
				$this->CosteFormate['fructification'] = str_replace('.','',$this->CosteFormate['fructification']);
-
 
216
			}
187
		return $resultat;
217
		}	
Line 188... Line 218...
188
	}
218
	}
189
	
219
	
190
	
220