| 12 | 12 | $replace = array ('e','E','a','A','i','I','u','U','o','O','c','C',',n','N','y','Y','_',''); |
| 13 | 13 | |
| | 67 | |
| | 68 | // Parse le fichier de configuration |
| | 69 | function XMLParse($xml) { |
| | 70 | $content = array(); |
| | 71 | foreach ($xml as $nom => $elem) { |
| | 72 | if (trim($elem) == '') { |
| | 73 | $content[$nom] = XMLParse($elem->children()); |
| | 74 | } else { |
| | 75 | $content[$nom] = utf8_encode(utf8_decode($elem)); |
| | 76 | } |
| | 77 | } |
| | 78 | return $content; |
| | 79 | } |
| | 80 | |
| | 81 | // Crée le fichier de configuration |
| | 82 | function XMLCreate($array, $level) { |
| | 83 | $content = null; |
| | 84 | foreach ($array as $nom => $elem) { |
| | 85 | if (is_array($elem)) { |
| | 86 | for($i=0;$i<=$level;$i++) $content .= "\t"; |
| | 87 | $content .= '<'.$nom.'>'."\n"; |
| | 88 | $content .= XMLCreate($elem, $level+1); |
| | 89 | for($i=0;$i<=$level;$i++) $content .= "\t"; |
| | 90 | $content .= '</'.$nom.'>'."\n"; |
| | 91 | } else { |
| | 92 | for($i=0;$i<=$level;$i++) $content .= "\t"; |
| | 93 | $content .= '<'.$nom.'>'.$elem.'</'.$nom.'>'."\n"; |
| | 94 | } |
| | 95 | } |
| | 96 | return $content; |
| | 97 | } |
| | 98 | |
| | 99 | // Convertit les booléens, entiers et flotants d'un tableau de 'string' |
| | 100 | function array_settype($array) { |
| | 101 | foreach ($array as $key => $value) { |
| | 102 | if (is_array($value)) { |
| | 103 | $array[$key] = array_settype($value); |
| | 104 | } else { |
| | 105 | if ($value === 'true') { |
| | 106 | $array[$key] = true; |
| | 107 | } else if ($value === 'false') { |
| | 108 | $array[$key] = false; |
| | 109 | } else if (preg_match('#^([0-9]*)$#', $value)) { |
| | 110 | settype($array[$key], 'int'); |
| | 111 | } else if (preg_match('#^([0-9]*)(.|,)([0-9]*)$#', $value)) { |
| | 112 | settype($array[$key], 'float'); |
| | 113 | } |
| | 114 | } |
| | 115 | } |
| | 116 | |
| | 117 | return $array; |
| | 118 | } |
| | 119 | |
| | 120 | // Booléen vers français ou texte |
| | 121 | function bool_to_string($bool, $just_echo=0) { |
| | 122 | # $just_echo pour pouvoir afficher un booléen tel quel |
| | 123 | if (is_bool($bool)) { |
| | 124 | if ($bool) { |
| | 125 | if ($just_echo) return 'true'; |
| | 126 | else return 'oui'; |
| | 127 | } else { |
| | 128 | if ($just_echo) return 'false'; |
| | 129 | else return 'non'; |
| | 130 | } |
| | 131 | } else { |
| | 132 | return $bool; |
| | 133 | } |
| | 134 | } |