Browse foreign values did not work with inline edit
[phpmyadmin/crack.git] / libraries / config / config_functions.lib.php
blob6f9aabb344aecf9b25a61914ea1f9c12631a4dec
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)
20 static $search, $replace;
22 // some quick cache'ing
23 if ($search === null) {
24 $replace_pairs = array(
25 '<' => '&lt;',
26 '>' => '&gt;',
27 '[em]' => '<em>',
28 '[/em]' => '</em>',
29 '[strong]' => '<strong>',
30 '[/strong]' => '</strong>',
31 '[code]' => '<code>',
32 '[/code]' => '</code>',
33 '[kbd]' => '<kbd>',
34 '[/kbd]' => '</kbd>',
35 '[br]' => '<br />',
36 '[sup]' => '<sup>',
37 '[/sup]' => '</sup>');
38 if (defined('PMA_SETUP')) {
39 $replace_pairs['[a@Documentation.html'] = '[a@../Documentation.html';
41 $search = array_keys($replace_pairs);
42 $replace = array_values($replace_pairs);
44 $message = isset($GLOBALS["strConfig$lang_key"]) ? $GLOBALS["strConfig$lang_key"] : $lang_key;
45 $message = str_replace($search, $replace, $message);
46 // replace [a@"$1"]$2[/a] with <a href="$1">$2</a>
47 $message = preg_replace('#\[a@("?)([^\]]+)\1\]([^\[]+)\[/a\]#e',
48 "PMA_lang_link_replace('$2', '$3')", $message);
50 if (func_num_args() == 1) {
51 return $message;
52 } else {
53 $args = func_get_args();
54 array_shift($args);
55 return vsprintf($message, $args);
59 /**
60 * Returns translated field name/description or comment
62 * @param string $canonical_path
63 * @param string $type 'name', 'desc' or 'cmt'
64 * @param mixed $default
65 * @return string
67 function PMA_lang_name($canonical_path, $type = 'name', $default = 'key')
69 $lang_key = str_replace(
70 array('Servers/1/', '/'),
71 array('Servers/', '_'),
72 $canonical_path) . '_' . $type;
73 return isset($GLOBALS["strConfig$lang_key"])
74 ? ($type == 'desc' ? PMA_lang($lang_key) : $GLOBALS["strConfig$lang_key"])
75 : ($default == 'key' ? $lang_key : $default);
78 /**
79 * Wraps link in &lt;a&gt; tags and replaces argument separator in internal links
80 * to the one returned by PMA_get_arg_separator()
82 * @param string $link
83 * @param string $text
84 * @return string
86 function PMA_lang_link_replace($link, $text)
88 static $separator;
90 if (!isset($separator)) {
91 $separator = PMA_get_arg_separator('html');
94 if (!preg_match('#^http://#', $link)) {
95 $link = str_replace('&amp;', $separator, $link);
98 return '<a href="' . $link . '">' . $text . '</a>';