Changeset 7993 for extensions/PHP_Optimisateur/files/functions.php
- Timestamp:
- Dec 4, 2010, 3:43:02 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PHP_Optimisateur/files/functions.php
r7991 r7993 5 5 \***************************************/ 6 6 7 // Affiche les textes 8 function l10n($code){ 9 global $Lang; 10 if (isset($Lang[$code])) { 11 $args = func_get_args(); 12 if (count($args) > 1) { 13 array_shift($args); 14 return vsprintf($Lang[$code], $args); 15 } else { 16 return $Lang[$code]; 17 } 18 } else { 19 return $code; 20 } 21 } 22 23 // Trouve la langue 24 function GetLanguage(){ 25 // tableau avec les langues installées 26 $dh = opendir('language'); 27 while ($file = readdir($dh)) { 28 if ($file !== '.' && $file !== '..' && is_dir('language/'.$file)) 29 $languages[] = $file; 30 } 31 closedir($dh); 32 33 // recherche du paramètre get ou session, ou langue du navigateur 34 if(isset($_GET['Lang'])) 35 $_SESSION['Lang'] = $_GET['Lang']; 36 else if(!isset($_SESSION['Lang']) OR $_SESSION['Lang'] == NULL) 37 $_SESSION['Lang'] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2); 38 if(!in_array($_SESSION['Lang'], $languages)) 39 $_SESSION['Lang'] = 'en'; 40 41 return array('Lang' => $_SESSION['Lang'], 'languages' => $languages); 42 } 43 7 44 // Supprime les accents et tous caractères non conforme 8 45 function delete_special_car($string) { 9 46 global $renameORNOT; 10 $search = array ('#[éèêë]#','#[ÊËÈÉ]#','#[àâäã]#','#[ÂÄÁÀ]#','#[îïíì]#','#[ÎÏÍÌ]#','#[ûùüú]#','#[ÛÙÚÜ]#','#[ôóòõö]#','#[ÓÒÖÔÕ]#', 11 '#[ç]#','#[Ç]#','#[ñ]#','#[Ñ]#','#[ýÿ]#','#[Ý]#','#[ \&\!\#\"\(\)\{\}\'\=\+\~]#','#[^a-zA-Z0-9_\.\-]#'); 47 48 $search = array ('#[éèêë]#','#[ÊËÈÉ]#','#[àâäã]#','#[ÂÄÁÀ]#','#[îïíì]#','#[ÎÏÍÌ]#','#[ûùüúµ]#','#[ÛÙÚÜ]#','#[ôóòõö]#','#[ÓÒÖÔÕ]#', 49 '#[ç]#','#[Ç]#','#[ñ]#','#[Ñ]#','#[ýÿ]#','#[Ý]#','#[ \&\!\?\#\"\(\)\{\}\[\]\=\+\~\%]#','#[^a-zA-Z0-9_\.\-]#'); 12 50 $replace = array ('e','E','a','A','i','I','u','U','o','O','c','C',',n','N','y','Y','_',''); 13 51 14 return preg_replace($search, $replace, $string); 52 if ($renameORNOT) { 53 return preg_replace($search, $replace, $string); 54 } else { 55 return str_replace(array('%','$'), '_', $string); 56 } 15 57 } 16 58 … … 50 92 $dh = opendir($dir); 51 93 } else { 52 exit ;94 exit('Dossier inexistant'); 53 95 } 54 96 while (($file = readdir($dh)) !== false ) { … … 97 139 } 98 140 141 // Charge la configuration 142 function load_config() { 143 $config = simplexml_load_file('config.xml'); 144 $config = XMLParse($config); 145 $config = array_settype($config); 146 return $config; 147 } 148 99 149 // Convertit les booléens, entiers et flotants d'un tableau de 'string' 100 150 function array_settype($array) { … … 120 170 // Booléen vers français ou texte 121 171 function bool_to_string($bool, $just_echo=0) { 172 global $Lang; 122 173 # $just_echo pour pouvoir afficher un booléen tel quel 123 174 if (is_bool($bool)) { 124 175 if ($bool) { 125 176 if ($just_echo) return 'true'; 126 else return 'oui';177 else return l10n('yes'); 127 178 } else { 128 179 if ($just_echo) return 'false'; 129 else return 'non';180 else return l10n('no'); 130 181 } 131 182 } else {
Note: See TracChangeset
for help on using the changeset viewer.