Move function to js escaping library.
This commit is contained in:
@@ -22,19 +22,6 @@ require_once './libraries/common.inc.php';
|
||||
// But this one is needed for PMA_escapeJsString()
|
||||
require_once './libraries/js_escape.lib.php';
|
||||
|
||||
function PMA_printJsValue($key, $value) {
|
||||
echo $key . ' = ';
|
||||
if (is_array($value)) {
|
||||
echo '[';
|
||||
foreach ($value as $id => $val) {
|
||||
echo "'" . PMA_escapeJsString($val) . "',\n";
|
||||
}
|
||||
echo "];\n";
|
||||
} else {
|
||||
echo "'" . PMA_escapeJsString($value) . "';\n";
|
||||
}
|
||||
}
|
||||
|
||||
$js_messages['strFormEmpty'] = $GLOBALS['strFormEmpty'];
|
||||
$js_messages['strNotNumber'] = $GLOBALS['strNotNumber'];
|
||||
$js_messages['strClickToSelect'] = $GLOBALS['strClickToSelect'];
|
||||
|
@@ -64,4 +64,24 @@ function PMA_escapeJsString($string)
|
||||
"\r" => '\r')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints an javascript assignment with proper escaping of a value
|
||||
* and support for assigning array of strings.
|
||||
*
|
||||
* @param string $key Name of value to set
|
||||
* @param mixed $value Value to set, can be either string or array of strings
|
||||
*/
|
||||
function PMA_printJsValue($key, $value) {
|
||||
echo $key . ' = ';
|
||||
if (is_array($value)) {
|
||||
echo '[';
|
||||
foreach ($value as $id => $val) {
|
||||
echo "'" . PMA_escapeJsString($val) . "',\n";
|
||||
}
|
||||
echo "];\n";
|
||||
} else {
|
||||
echo "'" . PMA_escapeJsString($value) . "';\n";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user