Merge remote-tracking branch 'origin/master' into drizzle
[phpmyadmin/crack.git] / libraries / config / config_functions.lib.php
blobdaa335fcf7debe45f99f1973b83a09a26d586416
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Common config manipulation functions
6 * @package phpMyAdmin
7 */
9 /**
10 * Returns sanitized language string, taking into account our special codes
11 * for formatting. Takes variable number of arguments.
12 * Based on PMA_sanitize from sanitize.lib.php.
14 * @param string $lang_key key in $GLOBALS WITHOUT 'strSetup' prefix
15 * @param mixed $args,... arguments for sprintf
16 * @return string
18 function PMA_lang($lang_key, $args = null)
20 $message = isset($GLOBALS["strConfig$lang_key"]) ? $GLOBALS["strConfig$lang_key"] : $lang_key;
22 $message = PMA_sanitize($message);
24 if (func_num_args() == 1) {
25 return $message;
26 } else {
27 $args = func_get_args();
28 array_shift($args);
29 return vsprintf($message, $args);
33 /**
34 * Returns translated field name/description or comment
36 * @param string $canonical_path
37 * @param string $type 'name', 'desc' or 'cmt'
38 * @param mixed $default
39 * @return string
41 function PMA_lang_name($canonical_path, $type = 'name', $default = 'key')
43 $lang_key = str_replace(
44 array('Servers/1/', '/'),
45 array('Servers/', '_'),
46 $canonical_path) . '_' . $type;
47 return isset($GLOBALS["strConfig$lang_key"])
48 ? ($type == 'desc' ? PMA_lang($lang_key) : $GLOBALS["strConfig$lang_key"])
49 : ($default == 'key' ? $lang_key : $default);