Line 89... |
Line 89... |
89 |
$contenu = '';
|
89 |
$contenu = '';
|
90 |
if (is_null($retour)) {
|
90 |
if (is_null($retour)) {
|
91 |
$this->messages[] = 'La ressource demandée a retourné une valeur nulle.';
|
91 |
$this->messages[] = 'La ressource demandée a retourné une valeur nulle.';
|
92 |
} else {
|
92 |
} else {
|
93 |
if (isset($retour['donnees'])) {
|
93 |
if (isset($retour['donnees'])) {
|
94 |
$retour['donnees']['prod'] = ($this->config['parametres']['modeServeur'] == "prod");
|
94 |
$retour['donnees']['prod'] = ($this->config['parametres']['modeServeur'] === 'prod');
|
95 |
$retour['donnees']['bar'] = $this->bar;
|
95 |
$retour['donnees']['bar'] = $this->bar;
|
96 |
$retour['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
|
96 |
$retour['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
|
97 |
$retour['donnees']['url_ws_annuaire'] = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], 'utilisateur/identite-par-courriel/');
|
97 |
$retour['donnees']['url_ws_annuaire'] = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], 'utilisateur/identite-par-courriel/');
|
98 |
$retour['donnees']['url_ws_saisie'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_SAISIE);
|
98 |
$retour['donnees']['url_ws_saisie'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_SAISIE);
|
99 |
$retour['donnees']['url_ws_obs'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_OBS);
|
99 |
$retour['donnees']['url_ws_obs'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_OBS);
|
Line 140... |
Line 140... |
140 |
$estProjetDefini = false;
|
140 |
$estProjetDefini = false;
|
141 |
}
|
141 |
}
|
142 |
$tableau = json_decode($json, true);
|
142 |
$tableau = json_decode($json, true);
|
143 |
$tableau = $this->traiterParametres($estProjetDefini, $tableau[0]);
|
143 |
$tableau = $this->traiterParametres($estProjetDefini, $tableau[0]);
|
144 |
$tableau['especes'] = $this->rechercherInfosEspeces($tableau);
|
144 |
$tableau['especes'] = $this->rechercherInfosEspeces($tableau);
|
145 |
if ($tableau['milieux'] != "") {
|
145 |
if ($tableau['milieux'] != '') {
|
146 |
$tableau['milieux'] = explode(";", $tableau['milieux']);
|
146 |
$tableau['milieux'] = explode(';', $tableau['milieux']);
|
147 |
} else {
|
147 |
} else {
|
148 |
$tableau['milieux'] = array();
|
148 |
$tableau['milieux'] = array();
|
149 |
}
|
149 |
}
|
150 |
$tableau['chpSupp'] = $tab;
|
150 |
$tableau['chpSupp'] = $tab;
|
151 |
$langue_projet_url = ( isset ( $this->parametres['langue'] ) && $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
|
151 |
$langue_projet_url = ( isset ( $this->parametres['langue'] ) && $this->parametres['langue'] !== 'fr' ) ? '_' . $this->parametres['langue'] : '';
|
152 |
$tableau['chemin_fichiers'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], $this->config['manager']['dossierTmp'] . $tableau["projet"] . $langue_projet_url . '/' );
|
152 |
$tableau['chemin_fichiers'] = sprintf( $this->config['chemins']['baseURLAbsoluDyn'], $this->config['manager']['dossierTmp'] . $tableau['projet'] . $langue_projet_url . '/' );
|
153 |
return $tableau;
|
153 |
return $tableau;
|
154 |
}
|
154 |
}
|
Line 155... |
Line 155... |
155 |
|
155 |
|
156 |
/* Recherche si un projet a des champs de saisie supplémentaire */
|
156 |
/* Recherche si un projet a des champs de saisie supplémentaire */
|
157 |
private function rechercherChampsSupp() {
|
157 |
private function rechercherChampsSupp() {
|
158 |
$retour = array();
|
158 |
$retour = array();
|
159 |
$projet = $this->parametres['projet'];
|
159 |
$projet = $this->parametres['projet'];
|
160 |
$url = $this->config['manager']['celChpSupTpl'] .'?projet=' . $projet . '&langue=' . $this->parametres['langue'];
|
160 |
$url = $this->config['manager']['celChpSupTpl'] .'?projet=' . $projet . '&langue=' . $this->parametres['langue'];
|
161 |
$json = $this->getDao()->consulter($url);
|
161 |
$json = $this->getDao()->consulter($url);
|
162 |
$retour = (array) json_decode($json, true);
|
- |
|
163 |
$patterns = array( '/\@apos\@/' , '/\@quot\@/' );
|
- |
|
- |
|
162 |
$retour = (array) json_decode($json, true);
|
164 |
$replacements = array( ''' , '"' );
|
163 |
|
Line 165... |
Line 164... |
165 |
foreach ( $retour[$projet]['champs-supp'] as $key => $chsup ) {
|
164 |
foreach ( $retour[$projet]['champs-supp'] as $key => $chsup ) {
|
166 |
|
165 |
|
167 |
|
166 |
|
Line 168... |
Line 167... |
168 |
$retour[$projet]['champs-supp'][$key]['name'] = preg_replace( $patterns, $replacements, $chsup['name'] );
|
167 |
$retour[$projet]['champs-supp'][$key]['name'] = $this->clean_string( $chsup['name'] );
|
169 |
$retour[$projet]['champs-supp'][$key]['description'] = preg_replace( $patterns, $replacements, $chsup['description']);
|
168 |
$retour[$projet]['champs-supp'][$key]['description'] = $this->clean_string( $chsup['description']);
|
170 |
$retour[$projet]['champs-supp'][$key]['unit'] = preg_replace( $patterns, $replacements, $chsup['unit'] );
|
169 |
$retour[$projet]['champs-supp'][$key]['unit'] = $this->clean_string( $chsup['unit'] );
|
171 |
|
170 |
|
172 |
if ( isset( $chsup['fieldValues'] ) ) {
|
171 |
if ( isset( $chsup['fieldValues'] ) ) {
|
Line 173... |
Line 172... |
173 |
$retour[$projet]['champs-supp'][$key]['fieldValues'] = json_decode( $chsup['fieldValues'], true );
|
172 |
$retour[$projet]['champs-supp'][$key]['fieldValues'] = json_decode( $chsup['fieldValues'], true );
|
174 |
if ( isset($retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] ) ) {
|
173 |
if ( isset($retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] ) ) {
|
175 |
$retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] = preg_replace( $patterns, $replacements, $retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] );
|
- |
|
176 |
}
|
174 |
$retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] = $this->clean_string( $retour[$projet]['champs-supp'][$key]['fieldValues']['placeholder'] );
|
177 |
|
175 |
}
|
178 |
if ( isset( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] ) ) {
|
176 |
|
179 |
foreach( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] as $list_key => $list_value ) {
|
177 |
if ( isset( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] ) ) {
|
180 |
$list_value = preg_replace( $patterns, $replacements, $list_value );
|
178 |
foreach( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] as $list_key => $list_value ) {
|
181 |
$retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'][$list_key] = $list_value;
|
179 |
$retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'][$list_key] = $this->clean_string( $list_value );
|
182 |
// Obtenir une liste de valeurs utilisables dans les attributs for id ou name par exemple
|
180 |
// Obtenir une liste de valeurs utilisables dans les attributs for id ou name par exemple
|
183 |
$retour[$projet]['champs-supp'][$key]['fieldValues']['cleanListValue'][] = 'val-' . preg_replace('/[^A-Za-z0-9_\-]/', '', $this->remove_accents($list_value));
|
181 |
$retour[$projet]['champs-supp'][$key]['fieldValues']['cleanListValue'][] = 'val-' . preg_replace( '/[^A-Za-z0-9_\-]/', '', $this->remove_accents( $list_value ) );
|
184 |
}
|
182 |
}
|
185 |
}
|
183 |
}
|
Line -... |
Line 184... |
- |
|
184 |
}
|
- |
|
185 |
$retour[$projet]['champs-supp'][$key]['mandatory'] = intval( $chsup['mandatory'] );
|
- |
|
186 |
}
|
- |
|
187 |
return $retour;
|
- |
|
188 |
}
|
- |
|
189 |
|
- |
|
190 |
private function clean_string( $string ) {
|
- |
|
191 |
// les fonctions de base de php ne parviennent pas à une conversion satisfaisante des codes ascii
|
- |
|
192 |
// qui ont été générés automatiquement lors de la transmission des chaines en json
|
- |
|
193 |
// dans le widget cel manager vers la base
|
- |
|
194 |
// Pour les mêmes raisons, @apos@ et @quot@ est une autre astuces utilisée dans ce même widget
|
- |
|
195 |
// pour permettre la transmission des apostrophes et guillements sans erreur
|
- |
|
196 |
$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/' );
|
- |
|
197 |
$replacements = array( ''', '"', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý','ÿ' );
|
186 |
}
|
198 |
|
187 |
$retour[$projet]['champs-supp'][$key]['mandatory'] = intval( $chsup['mandatory'] );
|
199 |
$clean_string = preg_replace( $patterns, $replacements, $string );
|
188 |
}
|
200 |
|
Line 189... |
Line 201... |
189 |
return $retour;
|
201 |
return $clean_string;
|
Line 298... |
Line 310... |
298 |
// remplace certains parametres définis en bd par les parametres définis dans l'url
|
310 |
// remplace certains parametres définis en bd par les parametres définis dans l'url
|
299 |
private function traiterParametres($estProjetDefini, $tableau) {
|
311 |
private function traiterParametres($estProjetDefini, $tableau) {
|
300 |
$criteres = array('tag', 'motcle', 'projet', 'titre', 'logo');
|
312 |
$criteres = array('tag', 'motcle', 'projet', 'titre', 'logo');
|
301 |
$criteresProjetNonDefini = array('commune', 'num_nom', 'referentiel');
|
313 |
$criteresProjetNonDefini = array('commune', 'num_nom', 'referentiel');
|
302 |
foreach($this->parametres as $nom_critere => $valeur_critere) {
|
314 |
foreach($this->parametres as $nom_critere => $valeur_critere) {
|
303 |
if (($estProjetDefini == false || $tableau['projet'] == "base") && in_array($nom_critere, $criteresProjetNonDefini)) {
|
315 |
if (($estProjetDefini == false || $tableau['projet'] == 'base') && in_array($nom_critere, $criteresProjetNonDefini)) {
|
304 |
$tableau[$nom_critere] = $valeur_critere;
|
316 |
$tableau[$nom_critere] = $valeur_critere;
|
305 |
} else if (in_array($nom_critere, $criteres)) {
|
317 |
} else if (in_array($nom_critere, $criteres)) {
|
306 |
$tableau[$nom_critere] = $valeur_critere;
|
318 |
$tableau[$nom_critere] = $valeur_critere;
|
307 |
}
|
319 |
}
|
308 |
}
|
320 |
}
|
Line 321... |
Line 333... |
321 |
$retour['ns_referentiel'] = $referentiel;
|
333 |
$retour['ns_referentiel'] = $referentiel;
|
Line 322... |
Line 334... |
322 |
|
334 |
|
Line 323... |
Line 335... |
323 |
if ( isset( $infos_projets['type_especes'] ) ) {
|
335 |
if ( isset( $infos_projets['type_especes'] ) ) {
|
324 |
|
336 |
|
325 |
switch ( $infos_projets['type_especes'] ) {
|
337 |
switch ( $infos_projets['type_especes'] ) {
|
326 |
case "fixe" :
|
338 |
case 'fixe' :
|
327 |
$retour['especes'] = $this->chargerInfosTaxon( $infos_projets['referentiel'], $infos_projets['especes'] );
|
339 |
$retour['especes'] = $this->chargerInfosTaxon( $infos_projets['referentiel'], $infos_projets['especes'] );
|
328 |
break;
|
340 |
break;
|
329 |
case "referentiel" :
|
341 |
case 'referentiel' :
|
330 |
case "liste" :
|
342 |
case 'liste' :
|
331 |
$referentiel = $infos_projets['referentiel'];
|
343 |
$referentiel = $infos_projets['referentiel'];
|
332 |
break;
|
344 |
break;
|
333 |
}
|
345 |
}
|
Line 366... |
Line 378... |
366 |
'famille','nom_retenu.id', 'nom_retenu_complet', 'num_taxonomique' );
|
378 |
'famille','nom_retenu.id', 'nom_retenu_complet', 'num_taxonomique' );
|
367 |
$resultat = array();
|
379 |
$resultat = array();
|
368 |
$retour = array();
|
380 |
$retour = array();
|
369 |
if ( isset( $infos ) && !empty( $infos ) ) {
|
381 |
if ( isset( $infos ) && !empty( $infos ) ) {
|
370 |
$infos = (array) $infos;
|
382 |
$infos = (array) $infos;
|
371 |
if ( isset( $infos['nom_sci'] ) && $infos['nom_sci'] != '' ) {
|
383 |
if ( isset( $infos['nom_sci'] ) && $infos['nom_sci'] !== '' ) {
|
372 |
$resultat = array_intersect_key( $infos, array_flip($champs_a_garder ) );
|
384 |
$resultat = array_intersect_key( $infos, array_flip($champs_a_garder ) );
|
373 |
$resultat['retenu'] = ( $infos['id'] == $infos['nom_retenu.id'] ) ? "true" : "false";
|
385 |
$resultat['retenu'] = ( $infos['id'] == $infos['nom_retenu.id'] ) ? 'true' : 'false';
|
374 |
$retour['espece_imposee'] = true;
|
386 |
$retour['espece_imposee'] = true;
|
375 |
$retour['nn_espece_defaut'] = $nnEspeceImposee;
|
387 |
$retour['nn_espece_defaut'] = $nnEspeceImposee;
|
376 |
$retour['nom_sci_espece_defaut'] = $resultat['nom_complet'];
|
388 |
$retour['nom_sci_espece_defaut'] = $resultat['nom_complet'];
|
377 |
$retour['infos_espece'] = $this->array2js( $resultat, true );
|
389 |
$retour['infos_espece'] = $this->array2js( $resultat, true );
|
378 |
}
|
390 |
}
|
Line 380... |
Line 392... |
380 |
return $retour;
|
392 |
return $retour;
|
381 |
}
|
393 |
}
|
Line 382... |
Line 394... |
382 |
|
394 |
|
383 |
protected function getReferentielImpose() {
|
395 |
protected function getReferentielImpose() {
|
384 |
$referentiel_impose = true;
|
396 |
$referentiel_impose = true;
|
385 |
if (!empty($_GET['referentiel']) && $_GET['referentiel'] != "autre") {
|
397 |
if (!empty($_GET['referentiel']) && $_GET['referentiel'] !== 'autre') {
|
386 |
$this->ns_referentiel = $_GET['referentiel'];
|
398 |
$this->ns_referentiel = $_GET['referentiel'];
|
387 |
} else if (isset($this->configProjet['referentiel'])) {
|
399 |
} else if (isset($this->configProjet['referentiel'])) {
|
388 |
$this->ns_referentiel = $this->configProjet['referentiel'];
|
400 |
$this->ns_referentiel = $this->configProjet['referentiel'];
|
389 |
} else if (isset($this->configMission['referentiel'])) {
|
401 |
} else if (isset($this->configMission['referentiel'])) {
|
Line 469... |
Line 481... |
469 |
}
|
481 |
}
|
Line 470... |
Line 482... |
470 |
|
482 |
|
471 |
/**
|
483 |
/**
|
472 |
* Découpe un fihcier tsv
|
484 |
* Découpe un fihcier tsv
|
473 |
*/
|
485 |
*/
|
474 |
protected function decomposerFichierTsv($fichier, $delimiter = "\t"){
|
486 |
protected function decomposerFichierTsv($fichier, $delimiter = '\t'){
|
475 |
$header = null;
|
487 |
$header = null;
|
476 |
$data = array();
|
488 |
$data = array();
|
477 |
if (($handle = fopen($fichier, 'r')) !== FALSE) {
|
489 |
if (($handle = fopen($fichier, 'r')) !== FALSE) {
|
478 |
while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
|
490 |
while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
|