Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 964 → Rev 965

/trunk/scripts/modules/sauvages/Sauvages.php
136,7 → 136,7
foreach ($this->contenu_fichier as $id=>$taxon) {
$infos_taxon = $this->rechercherInfosTaxon($rest, $taxon[$criteres_label["nom scientifique"]]);
$xml .= '<TAXON id="'.$id.'" value="'.
ucfirst($taxon[$criteres_label["nom vernaculaire"]]).'" sciName="'.$taxon[$criteres_label["nom scientifique"]].'" groupe="1">
ucfirst($taxon[$criteres_label["nom vernaculaire"]]).'" sciName="'.trim($taxon[$criteres_label["nom scientifique"]]).'" groupe="1">
<DESCRIPTION>'.$infos_taxon["description"].'</DESCRIPTION>
<PICTURES>';
if ($infos_taxon["images"] != array()) {
158,37 → 158,55
private function rechercherInfosTaxon($rest, $ns) {
$info = array("description" => "", "images" => array());
$reponse = $this->consulterWebService($rest, "bdtfx", "taxons", "?masque=".urlencode(rtrim($ns)));
$reponse = $this->consulterWebService($rest, "bdtfx",
"noms", "?retour.champs=nom_retenu.id,num_taxonomique&retour.tri=retenu&masque=".urlencode(trim($ns)));
if (is_array($reponse["resultat"])) {
$id = key($reponse["resultat"]);
$num_nom = $reponse["resultat"][key($reponse["resultat"])]["nom_retenu.id"];
$num_taxon = $reponse["resultat"][key($reponse["resultat"])]['num_taxonomique'];
}
$url_wiki = "http://www.tela-botanica.org/wikini/eFloreRedaction/api/rest/0.5/pages/SmartFloreBDTFXnt".
$num_taxon."?txt.format=text/plain&txt.section.titre=Comment%20la%20reconnaître%20%3F";
$wiki = $rest->consulter($url_wiki); $wiki = json_decode($wiki, true);
if ($wiki['texte'] != ""){
$info["description"] = $this->formaterSmatflore($wiki['texte']);
} else {
$reponse = $this->consulterWebService($rest, "bdtfx", "noms", "?retour.champs=nom_retenu.id&masque=".urlencode(rtrim($ns)));
if (is_array($reponse["resultat"])) {
$id = $reponse["resultat"][key($reponse["resultat"])]["nom_retenu.id"];
$coste = $this->consulterWebService($rest, "coste", "textes", "/bdtfx.nn:".$num_nom);
if ($coste['resultats'] != array() && $coste['resultats'][key($coste["resultats"])]['texte'] != "") {
$texte = str_replace("**", "", $coste['resultats'][key($coste["resultats"])]['texte']);
$texte = str_replace("//", "", $texte);
$texte = explode(" – ", $texte);
unset($texte[0],$texte[1]);
if (strpos($texte[2], ";") === false) {unset($texte[2]);} //else {print_r($texte[2]);}
if (preg_match('/^[\w|\s|\-|,]*\.*\s*$/', $texte[2]) == true) {print_r($texte[2]); unset($texte[2]);}
$info["description"] = implode(" – ", $texte);
} else {
$baseflor = $this->consulterWebService($rest, "baseflor", "informations", "/bdtfx.nn:".$num_nom);
$info["description"] = $this->formaterBaseflor($baseflor);
}
}
$reponse = $this->consulterWebService($rest, "coste", "textes", "/bdtfx.nn:".$id);
if ($reponse['texte'] != ""){
$texte = str_replace("**", "", $reponse['texte']);
$texte = str_replace("//", "", $texte);
$texte = explode(" – ", $texte);
unset($texte[0],$texte[1]);
if (strpos($texte[2], ";") === false) {unset($texte[2]);} else {print_r($texte[2]);}
if (preg_match('/^[\w|\s|\-|,]*\.*\s*$/', $texte[2]) == true) {print_r($texte[2]); unset($texte[2]);}
$info["description"] = implode(" – ", $texte);
} else {
$reponse = $this->consulterWebService($rest, "baseflor", "informations", "/bdtfx.nn:".$id);
$info["description"] = $this->formaterBaseflor($reponse);
if ($info["description"] == "En cours de rédaction.") {echo $num_nom." ".$ns;
print_r($coste);
}
$reponse = $this->consulterWebService($rest, "cel", "images", "?navigation.limite=5&retour.format=CRS&masque.nn=".$id);
$reponse = $this->consulterWebService($rest, "cel", "images", "?navigation.limite=5&retour.format=CRS&masque.nn=".$num_nom);
$info["images"] = $reponse["resultats"];
return $info;
}
 
private function formaterSmatflore($texte) {
$a_enlever = array(Chr(10).'=', '='.Chr(10), Chr(10).''.Chr(10));
$texte = str_replace($a_enlever, '', $texte);
$texte = str_replace(Chr(10), '<br />', $texte);
return $texte;
}
private function formaterBaseflor($reponse) {
$description = "En cours de rédaction.";
if ($reponse["idiotaxon"] != "") {
if ($reponse["nom_sci"] != "") {
$description = "Formation végétale : ".$reponse["form_vegetale"]."; ".
"Inflorescence : ".$reponse["inflorescence"]."; ".
"Couleur de la fleur : ".$reponse["couleur_fleur"]."; ".