Subversion Repositories eFlore/Applications.cel

Rev

Rev 3359 | Rev 3361 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3359 Rev 3360
Line 167... Line 167...
167
			$url     = $this->cel_url_tpl . '?projet=' . $this->parametres['projet'] . '&langue=' . $this->parametres['langue'];
167
			$url     = $this->cel_url_tpl . '?projet=' . $this->parametres['projet'] . '&langue=' . $this->parametres['langue'];
168
			$json    = $this->getDao()->consulter( $url );
168
			$json    = $this->getDao()->consulter( $url );
169
			$tableau = (array) json_decode( $json, true );
169
			$tableau = (array) json_decode( $json, true );
170
			$retour['squelette']         = 'creation';
170
			$retour['squelette']         = 'creation';
171
			$retour['donnees']['widget'] = $tableau[0];
171
			$retour['donnees']['widget'] = $tableau[0];
-
 
172
			// En prévision d'un service permettant la suppression/modification champs supp
-
 
173
			$retour['donnees']['widget']['chpSupp'] = $this->rechercherChampsSupp();
Line 172... Line 174...
172
 
174
 
173
			$urltype     = $this->cel_url_tpl .'?esttype=1';
175
			$urltype     = $this->cel_url_tpl .'?esttype=1';
174
			$jsontype    = $this->getDao()->consulter( $urltype );
176
			$jsontype    = $this->getDao()->consulter( $urltype );
175
			$tableautype = (array) json_decode( $jsontype, true );
177
			$tableautype = (array) json_decode( $jsontype, true );
Line 374... Line 376...
374
		} else {
376
		} else {
375
			return false;
377
			return false;
376
		}
378
		}
377
		return $format;
379
		return $format;
378
	}
380
	}
-
 
381
	// En prévision d'un service permettant la suppression/modification champs supp
-
 
382
	/* Recherche si un projet a des champs de saisie supplémentaire */
-
 
383
	private function rechercherChampsSupp() {
-
 
384
		$retour = array();
-
 
385
		$projet = $this->parametres['projet'];
-
 
386
		$url = $this->config['manager']['celChpSupTpl'] .'?projet=' . $projet . '&langue=' . $this->parametres['langue'];
-
 
387
		$json = $this->getDao()->consulter($url);
-
 
388
		$retour = (array) json_decode($json, true);
-
 
389
 
-
 
390
		foreach ( $retour[$projet]['champs-supp'] as $key => $chsup ) {
-
 
391
 
-
 
392
			$retour[$projet]['champs-supp'][$key]['name'] = $this->clean_string( $chsup['name'] );
-
 
393
			$retour[$projet]['champs-supp'][$key]['description'] = $this->clean_string( $chsup['description']);
-
 
394
			$retour[$projet]['champs-supp'][$key]['unit'] = $this->clean_string( $chsup['unit'] );
-
 
395
 
-
 
396
			if ( isset( $chsup['fieldValues'] ) ) {
-
 
397
				$retour[$projet]['champs-supp'][$key]['fieldValues'] = json_decode( $this->clean_string( $chsup['fieldValues'] ), true );
-
 
398
 
-
 
399
				if ( isset( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] ) ) {
-
 
400
					foreach( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] as $list_key => $list_value_array ) {
-
 
401
						// Obtenir une liste de valeurs utilisables dans les attributs for id ou name par exemple
-
 
402
						$retour[$projet]['champs-supp'][$key]['fieldValues']['cleanListValue'][] = ($list_value_array !== 'other') ? 'val-' . preg_replace( '/[^A-Za-z0-9_\-]/', '', $this->remove_accents( strtolower($list_value_array[0] ) ) ) : '';
-
 
403
					}
-
 
404
				}
-
 
405
			}
-
 
406
			$retour[$projet]['champs-supp'][$key]['mandatory'] = intval( $chsup['mandatory'] );
-
 
407
		}
-
 
408
		return $retour;
-
 
409
	}
-
 
410
 
-
 
411
	// En prévision d'un service permettant la suppression/modification champs supp
-
 
412
	private function clean_string( $string ) {
-
 
413
		// les fonctions de base de php ne parviennent pas à une conversion satisfaisante des codes ascii
-
 
414
		// qui ont été générés automatiquement lors de la transmission des chaines en json
-
 
415
		// dans le widget cel manager vers la base
-
 
416
		// Pour les mêmes raisons, @apos@ et @quot@ est une autre astuces utilisée dans ce même widget
-
 
417
		// pour permettre la transmission des apostrophes et guillements sans erreur
-
 
418
		$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/' );
-
 
419
		$replacements = array( ''', '"', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý','ÿ' );
-
 
420
 
-
 
421
		$clean_string = preg_replace( $patterns, $replacements, $string );
-
 
422
 
-
 
423
		return $clean_string;
-
 
424
	}
Line 379... Line 425...
379
 
425
 
380
	private function remove_accents( $string ) {
426
	private function remove_accents( $string ) {
Line 381... Line 427...
381
		if ( !preg_match( '/[\x80-\xff]/' , $string ) ) {
427
		if ( !preg_match( '/[\x80-\xff]/' , $string ) ) {