Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 1092 → Rev 1093

/trunk/modules/fiche/formateurs/Description.php
191,7 → 191,7
$texte = array_pop($texte['resultats']);
if ($texte) {
$coste['titre'] = $texte['titre'];
$coste['description'] = $this->mettreEnFormeCoste($texte['texte']);
$coste['description'] = self::mettreEnFormeCoste($texte['texte']);
}
$this->meta->setProjet('coste');
$meta = $this->meta->getMetaDonnees();
201,69 → 201,68
$this->donnees['coste'] = $coste;
}
 
public function mettreEnFormeCoste($texte){
$this->CosteFormate = array();
$this->CosteTexte = $texte;
static function mettreEnFormeCoste($texte) {
$txt_fmt = array();
//decouper elements remarquables avant le texte
$this->separerNomScientifique_a_NomCommun();
$this->CosteTexte = preg_replace('/\//','',$this->CosteTexte);
self::separerNomScientifique_a_NomCommun($texte, $txt_fmt);
$texte = preg_replace('/\//','',$texte);
//decouper elements remarquables après le texte
$this-> separerEcologie_a_Usages();
self::separerEcologie_a_Usages($texte, $txt_fmt);
//le morceau qui reste est le gros de la description
$this->CosteTexte = str_replace(';','</br> -','- '.$this->CosteTexte);
$this->CosteTexte = str_replace('–','',$this->CosteTexte);
$this->CosteFormate['texte'] = $this->CosteTexte;
return $this->CosteFormate;
$texte = str_replace(';','</br> -','- '.$texte);
$texte = str_replace('–','',$texte);
$txt_fmt['texte'] = $texte;
return $txt_fmt;
}
 
 
public function separerNomScientifique_a_NomCommun(){
if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $this->CosteTexte, $retour)){
static function separerNomScientifique_a_NomCommun(&$txt, &$txt_fmt){
if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $txt, $retour)){
/* !! attention on enlève un tiret cadratin – pas un trait d'union - !! */
$a_enlever = array('/–/','/\./' );
$this->CosteFormate['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]);
$txt_fmt['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]);
if(preg_match('/\((.+)\)/',$retour[2],$synonymes)){
$this->CosteFormate['synonymes'] = $synonymes[1];
$txt_fmt['synonymes'] = $synonymes[1];
} else {
$this->CosteFormate['nom_scientifique'] .= $retour[2];
$txt_fmt['nom_scientifique'] .= $retour[2];
}
$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte);
$txt = str_replace($retour[0],'',$txt);
}
/* !! attention il y a un espace avant les // du début !! */
if ( preg_match('/^ \/\/([^\/\/]+)\/\//', $this->CosteTexte, $retour)){
if ( preg_match('/^ \/\/([^\/\/]+)\/\//', $txt, $retour)){
$a_enlever = array('/–/','/\./' );
$this->CosteFormate['nom_commun'] = preg_replace($a_enlever,'',$retour[1]);
$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte);
$txt_fmt['nom_commun'] = preg_replace($a_enlever,'',$retour[1]);
$txt = str_replace($retour[0],'',$txt);
}
}
 
 
public function separerEcologie_a_Usages(){
if ( preg_match('/\.\s*([A-ZÉÀÈ].+)$/',$this->CosteTexte, $retour)){
$this->CosteFormate['ecologie'] = $retour[1];
$this->CosteTexte = str_replace($retour[0],'.',$this->CosteTexte);
if (isset($this->CosteFormate['ecologie']) && preg_match('/–(.+)/', $this->CosteFormate['ecologie'] , $retour)){
$this->CosteFormate['repartition'] = $retour[1];
$this->CosteFormate['ecologie'] = str_replace($retour[0],'',$this->CosteFormate['ecologie']);
static function separerEcologie_a_Usages(&$txt, &$txt_fmt) {
if (preg_match('/\.\s*([A-ZÉÀÈ].+)$/',$txt, $retour)) {
$txt_fmt['ecologie'] = $retour[1];
$txt = str_replace($retour[0],'.',$txt);
if (isset($txt_fmt['ecologie']) && preg_match('/–(.+)/', $txt_fmt['ecologie'] , $retour)){
$txt_fmt['repartition'] = $retour[1];
$txt_fmt['ecologie'] = str_replace($retour[0],'',$txt_fmt['ecologie']);
}
if (isset($this->CosteFormate['repartition']) && preg_match('/=(.+)$/', $this->CosteFormate['repartition'], $retour)){
$this->CosteFormate['floraison'] = $retour[1];
$this->CosteFormate['repartition'] = str_replace($retour[0],'',$this->CosteFormate['repartition']);
if (isset($txt_fmt['repartition']) && preg_match('/=(.+)$/', $txt_fmt['repartition'], $retour)){
$txt_fmt['floraison'] = $retour[1];
$txt_fmt['repartition'] = str_replace($retour[0],'',$txt_fmt['repartition']);
}
if (isset($this->CosteFormate['floraison']) && preg_match('/–(.+)$|\n(.+)$/',$this->CosteFormate['floraison'], $retour)){
$this->CosteFormate['usages'] = isset($retour[1]) ? $retour[1] : $retour[2];
$this->CosteFormate['floraison'] = str_replace($retour[0],'.',$this->CosteFormate['floraison']);
if (isset($txt_fmt['floraison']) && preg_match('/–(.+)$|\n(.+)$/',$txt_fmt['floraison'], $retour)){
$txt_fmt['usages'] = isset($retour[1]) ? $retour[1] : $retour[2];
$txt_fmt['floraison'] = str_replace($retour[0],'.',$txt_fmt['floraison']);
}
if (isset($this->CosteFormate['floraison']) && preg_match('/([Ff]l\.) (.+)/',$this->CosteFormate['floraison'], $retour)){
$this->CosteFormate['floraison'] = $retour[2];
$this->CosteFormate['floraison'] = str_replace($retour[1],'',$this->CosteFormate['floraison']);
if (isset($txt_fmt['floraison']) && preg_match('/([Ff]l\.) (.+)/',$txt_fmt['floraison'], $retour)){
$txt_fmt['floraison'] = $retour[2];
$txt_fmt['floraison'] = str_replace($retour[1],'',$txt_fmt['floraison']);
}
if (isset($this->CosteFormate['floraison']) && preg_match('/([Ff]r\.) (.+)/',$this->CosteFormate['floraison'], $retour)){
$this->CosteFormate['fructification'] = $retour[2];
$this->CosteFormate['floraison'] = str_replace($retour[0],'',$this->CosteFormate['floraison']);
$this->CosteFormate['floraison'] = str_replace(',','',$this->CosteFormate['floraison']);
$this->CosteFormate['fructification'] = str_replace($retour[1],'',$this->CosteFormate['fructification']);
$this->CosteFormate['fructification'] = str_replace('.','',$this->CosteFormate['fructification']);
if (isset($txt_fmt['floraison']) && preg_match('/([Ff]r\.) (.+)/',$txt_fmt['floraison'], $retour)){
$txt_fmt['fructification'] = $retour[2];
$txt_fmt['floraison'] = str_replace($retour[0],'',$txt_fmt['floraison']);
$txt_fmt['floraison'] = str_replace(',','',$txt_fmt['floraison']);
$txt_fmt['fructification'] = str_replace($retour[1],'',$txt_fmt['fructification']);
$txt_fmt['fructification'] = str_replace('.','',$txt_fmt['fructification']);
}
}
}