169,6 → 169,8 |
$tableau = (array) json_decode( $json, true ); |
$retour['squelette'] = 'creation'; |
$retour['donnees']['widget'] = $tableau[0]; |
// En prévision d'un service permettant la suppression/modification champs supp |
$retour['donnees']['widget']['chpSupp'] = $this->rechercherChampsSupp(); |
|
$urltype = $this->cel_url_tpl .'?esttype=1'; |
$jsontype = $this->getDao()->consulter( $urltype ); |
376,7 → 378,51 |
} |
return $format; |
} |
// En prévision d'un service permettant la suppression/modification champs supp |
/* Recherche si un projet a des champs de saisie supplémentaire */ |
private function rechercherChampsSupp() { |
$retour = array(); |
$projet = $this->parametres['projet']; |
$url = $this->config['manager']['celChpSupTpl'] .'?projet=' . $projet . '&langue=' . $this->parametres['langue']; |
$json = $this->getDao()->consulter($url); |
$retour = (array) json_decode($json, true); |
|
foreach ( $retour[$projet]['champs-supp'] as $key => $chsup ) { |
|
$retour[$projet]['champs-supp'][$key]['name'] = $this->clean_string( $chsup['name'] ); |
$retour[$projet]['champs-supp'][$key]['description'] = $this->clean_string( $chsup['description']); |
$retour[$projet]['champs-supp'][$key]['unit'] = $this->clean_string( $chsup['unit'] ); |
|
if ( isset( $chsup['fieldValues'] ) ) { |
$retour[$projet]['champs-supp'][$key]['fieldValues'] = json_decode( $this->clean_string( $chsup['fieldValues'] ), true ); |
|
if ( isset( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] ) ) { |
foreach( $retour[$projet]['champs-supp'][$key]['fieldValues']['listValue'] as $list_key => $list_value_array ) { |
// Obtenir une liste de valeurs utilisables dans les attributs for id ou name par exemple |
$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] ) ) ) : ''; |
} |
} |
} |
$retour[$projet]['champs-supp'][$key]['mandatory'] = intval( $chsup['mandatory'] ); |
} |
return $retour; |
} |
|
// En prévision d'un service permettant la suppression/modification champs supp |
private function clean_string( $string ) { |
// les fonctions de base de php ne parviennent pas à une conversion satisfaisante des codes ascii |
// qui ont été générés automatiquement lors de la transmission des chaines en json |
// dans le widget cel manager vers la base |
// Pour les mêmes raisons, @apos@ et @quot@ est une autre astuces utilisée dans ce même widget |
// pour permettre la transmission des apostrophes et guillements sans erreur |
$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/' ); |
$replacements = array( ''', '"', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý','ÿ' ); |
|
$clean_string = preg_replace( $patterns, $replacements, $string ); |
|
return $clean_string; |
} |
|
private function remove_accents( $string ) { |
if ( !preg_match( '/[\x80-\xff]/' , $string ) ) { |
|