Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 852 → Rev 853

/trunk/scripts/modules/sauvages/Sauvages.php
6,6 → 6,35
private $contenu_fichier = array();
protected $parametres_autorises = array(
'-f' => array(true, true, 'Nom du fichier ou du dossier à traiter'));
private $caracteresAccentues = array(
'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î',
'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß',
'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î',
'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Ā',
'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď',
'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ',
'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ',
'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ',
'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ',
'ŏ', 'Ő', 'ő', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ',
'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ',
'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż',
'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ',
'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ', 'ǿ');
private $caracteresNormaux = array(
'A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I',
'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's',
'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i',
'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a',
'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd',
'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g',
'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i',
'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l',
'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R',
'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't',
'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y',
'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I',
'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o');
 
public function executer() {
// Lancement de l'action demandée
34,17 → 63,19
 
public function creerXmlCriteres() {
$this->recupererContenuFichier();
$criteres_label = $this->contenu_fichier[0];
unset($this->contenu_fichier[0]);
$description_label = $this->contenu_fichier[1];
$criteres_nom = $this->contenu_fichier[0];
unset($this->contenu_fichier[0]);
$criteres_label = $this->contenu_fichier[1];
unset($this->contenu_fichier[1]);
$description_label = $this->contenu_fichier[2];
unset($this->contenu_fichier[2]);
$criteres_valeurs = $this->extraireValeurs();
$xml = $this->$formerXmlCriteres($criteres_label, $description_label, $criteres_valeurs);//print_r($xml);
$xml = $this->formerXmlCriteres($criteres_nom, $criteres_label, $description_label, $criteres_valeurs);//print_r($xml);
file_put_contents("./xml_criteres.xml", $xml);
}
public function formerXmlCriteres($label, $description, $valeurs) {
public function formerXmlCriteres($nom, $label, $description, $valeurs) {
$xml='<keys>
<groupe id="1">
<nom>Arbres</nom>
58,9 → 89,9
<valeurs>';
foreach ($valeurs[$id] as $id_val=>$valeur) {
if ($valeur != "0") {
$crit = explode(" ", $criteres);
$val = explode(" ", $valeur);
$image = $crit[0]."_".$val[0];
$crit = str_replace(" ", "_", $this->supprimerAccents($nom[$id]));
$val = str_replace(" ", "_", $this->supprimerAccents($valeur));
$image = $crit."_".$val;
$xml .= '<valeur code="1.'.$id.'.'.$id_val.'" media="images/pictos/'.$image.'.png">'.$valeur.'</valeur>';
}
}
93,6 → 124,7
$criteres_label = array_flip($this->contenu_fichier[0]);
unset($this->contenu_fichier[0]);
unset($this->contenu_fichier[1]);
unset($this->contenu_fichier[2]);
$criteres_valeurs = $this->extraireValeurs();
$xml = $this->formerXmlTaxons($criteres_label, $criteres_valeurs); //print_r($xml);
file_put_contents("./xml_taxons.xml", $xml);
130,7 → 162,7
if (is_array($reponse["resultat"])) {
$id = key($reponse["resultat"]);
} else {
$reponse = $this->consulterWebService($rest, "bdtfx", "noms", "??retour.champs=nom_retenu.id&masque=".urlencode(rtrim($ns)));
$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"];
}
137,8 → 169,14
}
$reponse = $this->consulterWebService($rest, "coste", "textes", "/bdtfx.nn:".$id);
if ($reponse['texte'] != ""){
$info["description"] = str_replace("**", "", $reponse['texte']);
$info["description"] = str_replace("//", "", $info["description"]);
$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);
151,8 → 189,7
private function formaterBaseflor($reponse) {
$description = "En cours de rédaction.";
if ($reponse["idiotaxon"] != "") {
$description = $reponse["idiotaxon"]." – ".
"Formation végétale : ".$reponse["form_vegetale"]."; ".
$description = "Formation végétale : ".$reponse["form_vegetale"]."; ".
"Inflorescence : ".$reponse["inflorescence"]."; ".
"Couleur de la fleur : ".$reponse["couleur_fleur"]."; ".
"Sexualité : ".$reponse["sexualite"]."; ".
195,5 → 232,9
$this->traiterErreur("Le fichier : $nomFichier n'existe pas.");
}
}
public function supprimerAccents($chaine) {
return str_replace($this->caracteresAccentues, $this->caracteresNormaux, $chaine);
}
}
?>