| Line 148... |
Line 148... |
| 148 |
$estProjetDefini = false;
|
148 |
$estProjetDefini = false;
|
| 149 |
}
|
149 |
}
|
| 150 |
$tableau = json_decode($json, true);
|
150 |
$tableau = json_decode($json, true);
|
| 151 |
$tableau = $this->traiterParametres($estProjetDefini, $tableau[0]);
|
151 |
$tableau = $this->traiterParametres($estProjetDefini, $tableau[0]);
|
| 152 |
$tableau['especes'] = $this->rechercherInfosEspeces($tableau);
|
152 |
$tableau['especes'] = $this->rechercherInfosEspeces($tableau);
|
| 153 |
if ($tableau['milieux'] != '') {
|
153 |
if (isset($tableau['type_especes']) && 'fixe' === $tableau['type_especes']) {
|
| 154 |
$tableau['milieux'] = explode(';', $tableau['milieux']);
|
154 |
// si on trouve ":" dans referentiel, referentiel = première partie
|
| 155 |
} else {
|
- |
|
| 156 |
$tableau['milieux'] = array();
|
155 |
$tableau['referentiel'] = (strstr($tableau['referentiel'],':',true)) ?: $tableau['referentiel'];
|
| 157 |
}
|
156 |
}
|
| - |
|
157 |
$tableau['milieux'] = ($tableau['milieux'] != '') ? explode(';', $tableau['milieux']) : [];
|
| 158 |
if (isset($tableau['motscles'])) {
|
158 |
if (isset($tableau['motscles'])) {
|
| 159 |
$tableau['tag-obs'] = $tableau['tag-img'] = $tableau['motscles'];
|
159 |
$tableau['tag-obs'] = $tableau['tag-img'] = $tableau['motscles'];
|
| 160 |
}
|
160 |
}
|
| 161 |
$tableau['chpSupp'] = $tab;
|
161 |
$tableau['chpSupp'] = $tab;
|
| 162 |
$langue_projet_url = ( isset ( $this->parametres['langue'] ) && $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
|
162 |
$langue_projet_url = ( isset ( $this->parametres['langue'] ) && $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
|
| Line 191... |
Line 191... |
| 191 |
$retour[$projet]['champs-supp'][$key]['mandatory'] = intval( $chsup['mandatory'] );
|
191 |
$retour[$projet]['champs-supp'][$key]['mandatory'] = intval( $chsup['mandatory'] );
|
| 192 |
}
|
192 |
}
|
| 193 |
return $retour;
|
193 |
return $retour;
|
| 194 |
}
|
194 |
}
|
| Line 195... |
Line -... |
| 195 |
|
- |
|
| 196 |
private function clean_string( $string ) {
|
- |
|
| 197 |
// les fonctions de base de php ne parviennent pas à une conversion satisfaisante des codes ascii
|
- |
|
| 198 |
// qui ont été générés automatiquement lors de la transmission des chaines en json
|
- |
|
| 199 |
// dans le widget cel manager vers la base
|
- |
|
| 200 |
// Pour les mêmes raisons, @apos@ et @quot@ est une autre astuces utilisée dans ce même widget
|
- |
|
| 201 |
// pour permettre la transmission des apostrophes et guillements sans erreur
|
- |
|
| 202 |
$patterns = array( '/\@apos\@/', '/\@quot\@/', '/u00c0/', '/u00c1/', '/u00c2/', '/u00c3/', '/u00c4/', '/u00c5/', '/u00c6/', '/u00c7/', '/u00c8/', '/u00c9/', '/u00ca/', '/u00cb/', '/u00cc/', '/u00cd/', '/u00ce/', '/u00cf/', '/u00d1/', '/u00d2/', '/u00d3/', '/u00d4/', '/u00d5/', '/u00d6/', '/u00d8/', '/u00d9/', '/u00da/', '/u00db/', '/u00dc/', '/u00dd/', '/u00df/', '/u00e0/', '/u00e1/', '/u00e2/', '/u00e3/', '/u00e4/', '/u00e5/', '/u00e6/', '/u00e7/', '/u00e8/', '/u00e9/', '/u00ea/', '/u00eb/', '/u00ec/', '/u00ed/', '/u00ee/', '/u00ef/', '/u00f0/', '/u00f1/', '/u00f2/', '/u00f3/', '/u00f4/', '/u00f5/', '/u00f6/', '/u00f8/', '/u00f9/', '/u00fa/', '/u00fb/', '/u00fc/', '/u00fd/', '/u00ff/' );
|
- |
|
| 203 |
$replacements = array( ''', '"', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý','ÿ' );
|
- |
|
| 204 |
|
- |
|
| 205 |
$clean_string = preg_replace( $patterns, $replacements, $string );
|
- |
|
| 206 |
|
- |
|
| 207 |
return $clean_string;
|
- |
|
| 208 |
}
|
- |
|
| 209 |
|
195 |
|
| 210 |
// remplace certains parametres définis en bd par les parametres définis dans l'url
|
196 |
// remplace certains parametres définis en bd par les parametres définis dans l'url
|
| 211 |
private function traiterParametres($estProjetDefini, $tableau) {
|
197 |
private function traiterParametres($estProjetDefini, $tableau) {
|
| 212 |
$criteres = array('tag-obs', 'tag-img', 'projet', 'titre', 'logo');
|
198 |
$criteres = array('tag-obs', 'tag-img', 'projet', 'titre', 'logo');
|
| 213 |
$criteresProjetNonDefini = array('commune', 'num_nom', 'referentiel');
|
199 |
$criteresProjetNonDefini = array('commune', 'num_nom', 'referentiel');
|
| Line 231... |
Line 217... |
| 231 |
|
217 |
|
| Line 232... |
Line 218... |
| 232 |
if ( isset( $infos_projets['type_especes'] ) ) {
|
218 |
if ( isset( $infos_projets['type_especes'] ) ) {
|
| 233 |
|
219 |
|
| - |
|
220 |
switch ( $infos_projets['type_especes'] ) {
|
| - |
|
221 |
case 'fixe' :
|
| 234 |
switch ( $infos_projets['type_especes'] ) {
|
222 |
$info_taxon = explode(':', $referentiel);
|
| - |
|
223 |
if (!empty($info_taxon) && count((array) $info_taxon) === 2) {
|
| 235 |
case 'fixe' :
|
224 |
$retour = $this->chargerInfosTaxon( $info_taxon[0], $info_taxon[1] );
|
| 236 |
$retour = $this->chargerInfosTaxon( $infos_projets['referentiel'], $infos_projets['especes'] );
|
225 |
}
|
| 237 |
break;
|
226 |
break;
|
| 238 |
case 'referentiel' : break;
|
- |
|
| 239 |
case 'liste' :
|
- |
|
| 240 |
$referentiel = $infos_projets['referentiel'];
|
227 |
case 'referentiel' : break;
|
| 241 |
////////////////////// temporaire test transmission liste taxons
|
228 |
case 'liste' :
|
| 242 |
$retour['taxons'] = $this->recupererListeNomsSci();
|
229 |
$retour['taxons'] = $this->recupererListeNomsSci();
|
| 243 |
break;
|
230 |
break;
|
| 244 |
}
|
- |
|
| 245 |
} else if ( isset( $infos_projets['referentiel'] ) ) {
|
231 |
}
|
| 246 |
$referentiel = $infos_projets['referentiel'];
|
232 |
} else if ( isset( $referentiel ) ) {
|
| 247 |
if ( isset($infos_projets['num_nom'] ) ) {
|
233 |
if ( isset($infos_projets['num_nom'] ) ) {
|
| 248 |
$retour = $this->chargerInfosTaxon( $infos_projets['referentiel'], $infos_projets['num_nom'] );
|
234 |
$retour = $this->chargerInfosTaxon( $referentiel, $infos_projets['num_nom'] );
|
| 249 |
}
|
235 |
}
|
| 250 |
}
|
236 |
}
|
| Line 293... |
Line 279... |
| 293 |
}
|
279 |
}
|
| 294 |
return $referentiel_impose;
|
280 |
return $referentiel_impose;
|
| 295 |
}
|
281 |
}
|
| Line 296... |
Line 282... |
| 296 |
|
282 |
|
| 297 |
/**
|
283 |
/**
|
| 298 |
* Trie par nom français les taxons lus dans le fichier csv
|
284 |
* Trie par nom français les taxons lus dans le fichier csv/tsv
|
| 299 |
*/
|
285 |
*/
|
| 300 |
protected function recupererListeNomsSci() {
|
286 |
protected function recupererListeNomsSci() {
|
| 301 |
$taxons = $this->recupererListeTaxon();
|
287 |
$taxons = $this->recupererListeTaxon();
|
| 302 |
if (is_array($taxons)) {
|
288 |
if (is_array($taxons)) {
|
| Line 349... |
Line 335... |
| 349 |
}
|
335 |
}
|
| 350 |
return array('speciaux' => $nomsSpeciaux, 'sci-et-fr' => $nomsAAfficher);
|
336 |
return array('speciaux' => $nomsSpeciaux, 'sci-et-fr' => $nomsAAfficher);
|
| 351 |
}
|
337 |
}
|
| Line 352... |
Line 338... |
| 352 |
|
338 |
|
| 353 |
/**
|
339 |
/**
|
| 354 |
* Lit une liste de taxons depuis un fichier csv fourni
|
340 |
* Lit une liste de taxons depuis un fichier csv ou tsv fourni
|
| 355 |
*/
|
341 |
*/
|
| 356 |
protected function recupererListeTaxon() {
|
342 |
protected function recupererListeTaxon() {
|
| 357 |
$taxons = array();
|
343 |
$taxons = array();
|
| 358 |
$langue_projet_url = ( isset ( $this->parametres['langue'] ) && $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
|
344 |
$langue_projet_url = ( isset ( $this->parametres['langue'] ) && $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
|
| 359 |
$chemin_images = dirname(__FILE__) . self::DS . '..' . self::DS . 'manager' . self::DS . 'squelettes' . self::DS . 'img' . self::DS . 'images_projets' . self::DS;
|
345 |
$chemin_images = dirname(__FILE__) . self::DS . '..' . self::DS . 'manager' . self::DS . 'squelettes' . self::DS . 'img' . self::DS . 'images_projets' . self::DS;
|
| Line 360... |
Line 346... |
| 360 |
$fichier_csv = $chemin_images . $this->parametres['projet'] . $langue_projet_url . self::DS . 'especes.csv';
|
346 |
$chemin_taxon = $chemin_images . $this->parametres['projet'] . $langue_projet_url . self::DS . 'especes.';
|
| 361 |
|
347 |
|
| - |
|
348 |
if ( file_exists( $chemin_taxon . 'csv' ) && is_readable( $chemin_taxon . 'csv' ) ) {
|
| - |
|
349 |
$taxons = $this->decomposerFichierCsv( $chemin_taxon . 'csv' );
|
| 362 |
if ( file_exists( $fichier_csv ) && is_readable( $fichier_csv ) ) {
|
350 |
} else if ( file_exists( $chemin_taxon . 'tsv' ) && is_readable( $chemin_taxon . 'tsv' ) ) {
|
| 363 |
$taxons = $this->decomposerFichierCsv( $fichier_csv );
|
351 |
$taxons = $this->decomposerFichierCsv( $chemin_taxon . 'tsv' );
|
| 364 |
} else {
|
352 |
} else {
|
| 365 |
$this->debug[] = "Impossible d'ouvrir le fichier '$fichier_csv'.";
|
353 |
$this->debug[] = "Impossible d'ouvrir le fichier '$fichier_taxon'.";
|
| 366 |
}
|
354 |
}
|
| Line 367... |
Line 355... |
| 367 |
return $taxons;
|
355 |
return $taxons;
|
| 368 |
}
|
356 |
}
|
| 369 |
|
357 |
|
| 370 |
/**
|
358 |
/**
|
| 371 |
* Découpe un fihcier csv
|
359 |
* Découpe un fihcier csv/tsv
|
| 372 |
*/
|
360 |
*/
|
| 373 |
protected function decomposerFichierCsv($fichier, $delimiter = "\t"){
|
361 |
protected function decomposerFichierCsv($fichier, $delimiter = "\t"){
|
| Line 420... |
Line 408... |
| 420 |
}
|
408 |
}
|
| 421 |
$tableauJs = implode(',', $dimensions);
|
409 |
$tableauJs = implode(',', $dimensions);
|
| 422 |
}
|
410 |
}
|
| 423 |
return $tableauJs;
|
411 |
return $tableauJs;
|
| 424 |
}
|
412 |
}
|
| 425 |
|
- |
|
| 426 |
private function remove_accents($string) {
|
- |
|
| 427 |
if ( !preg_match('/[\x80-\xff]/', $string) )
|
- |
|
| 428 |
return $string;
|
- |
|
| 429 |
|
- |
|
| 430 |
$chars = array(
|
- |
|
| 431 |
// Decompositions for Latin-1 Supplement
|
- |
|
| 432 |
chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
|
- |
|
| 433 |
chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
|
- |
|
| 434 |
chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
|
- |
|
| 435 |
chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
|
- |
|
| 436 |
chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
|
- |
|
| 437 |
chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
|
- |
|
| 438 |
chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
|
- |
|
| 439 |
chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
|
- |
|
| 440 |
chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
|
- |
|
| 441 |
chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
|
- |
|
| 442 |
chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
|
- |
|
| 443 |
chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
|
- |
|
| 444 |
chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
|
- |
|
| 445 |
chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
|
- |
|
| 446 |
chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
|
- |
|
| 447 |
chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
|
- |
|
| 448 |
chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
|
- |
|
| 449 |
chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
|
- |
|
| 450 |
chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
|
- |
|
| 451 |
chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
|
- |
|
| 452 |
chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
|
- |
|
| 453 |
chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
|
- |
|
| 454 |
chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
|
- |
|
| 455 |
chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
|
- |
|
| 456 |
chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
|
- |
|
| 457 |
chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
|
- |
|
| 458 |
chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
|
- |
|
| 459 |
chr(195).chr(191) => 'y',
|
- |
|
| 460 |
// Decompositions for Latin Extended-A
|
- |
|
| 461 |
chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
|
- |
|
| 462 |
chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
|
- |
|
| 463 |
chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
|
- |
|
| 464 |
chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
|
- |
|
| 465 |
chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
|
- |
|
| 466 |
chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
|
- |
|
| 467 |
chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
|
- |
|
| 468 |
chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
|
- |
|
| 469 |
chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
|
- |
|
| 470 |
chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
|
- |
|
| 471 |
chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
|
- |
|
| 472 |
chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
|
- |
|
| 473 |
chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
|
- |
|
| 474 |
chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
|
- |
|
| 475 |
chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
|
- |
|
| 476 |
chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
|
- |
|
| 477 |
chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
|
- |
|
| 478 |
chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
|
- |
|
| 479 |
chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
|
- |
|
| 480 |
chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
|
- |
|
| 481 |
chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
|
- |
|
| 482 |
chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
|
- |
|
| 483 |
chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
|
- |
|
| 484 |
chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
|
- |
|
| 485 |
chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
|
- |
|
| 486 |
chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
|
- |
|
| 487 |
chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
|
- |
|
| 488 |
chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
|
- |
|
| 489 |
chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
|
- |
|
| 490 |
chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
|
- |
|
| 491 |
chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
|
- |
|
| 492 |
chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
|
- |
|
| 493 |
chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
|
- |
|
| 494 |
chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
|
- |
|
| 495 |
chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
|
- |
|
| 496 |
chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
|
- |
|
| 497 |
chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
|
- |
|
| 498 |
chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
|
- |
|
| 499 |
chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
|
- |
|
| 500 |
chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
|
- |
|
| 501 |
chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
|
- |
|
| 502 |
chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
|
- |
|
| 503 |
chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
|
- |
|
| 504 |
chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
|
- |
|
| 505 |
chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
|
- |
|
| 506 |
chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
|
- |
|
| 507 |
chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
|
- |
|
| 508 |
chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
|
- |
|
| 509 |
chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
|
- |
|
| 510 |
chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
|
- |
|
| 511 |
chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
|
- |
|
| 512 |
chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
|
- |
|
| 513 |
chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
|
- |
|
| 514 |
chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
|
- |
|
| 515 |
chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
|
- |
|
| 516 |
chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
|
- |
|
| 517 |
chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
|
- |
|
| 518 |
chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
|
- |
|
| 519 |
chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
|
- |
|
| 520 |
chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
|
- |
|
| 521 |
chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
|
- |
|
| 522 |
chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
|
- |
|
| 523 |
chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
|
- |
|
| 524 |
chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
|
- |
|
| 525 |
);
|
- |
|
| 526 |
|
- |
|
| 527 |
$string = strtr($string, $chars);
|
- |
|
| 528 |
|
- |
|
| 529 |
return $string;
|
- |
|
| 530 |
}
|
- |
|
| 531 |
}
|
413 |
}
|
| 532 |
?>
|
414 |
?>
|