summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/ajax.inc16
-rw-r--r--includes/batch.inc2
-rw-r--r--includes/common.inc8
-rw-r--r--includes/locale.inc2
4 files changed, 14 insertions, 14 deletions
diff --git a/includes/ajax.inc b/includes/ajax.inc
index 6bfd86d77..dca3cc76e 100644
--- a/includes/ajax.inc
+++ b/includes/ajax.inc
@@ -105,8 +105,8 @@
* A list of macro commands generated by the use of ajax_command_*()
* functions.
* @param $header
- * If set to FALSE the 'text/javascript' header used by drupal_json() will
- * not be used, which is necessary when using an IFRAME. If set to
+ * If set to FALSE the 'text/javascript' header used by drupal_json_output()
+ * will not be used, which is necessary when using an IFRAME. If set to
* 'multipart' the output will be wrapped in a textarea, which can also be
* used as an alternative method when uploading files.
*/
@@ -123,17 +123,17 @@ function ajax_render($commands = array(), $header = TRUE) {
// Use === here so that bool TRUE doesn't match 'multipart'.
if ($header === 'multipart') {
- // We do not use drupal_json() here because the header is not true. We are
- // not really returning JSON, strictly-speaking, but rather JSON content
- // wrapped in a textarea as per the "file uploads" example here:
+ // We do not use drupal_json_output() here because the header is not true.
+ // We are not really returning JSON, strictly-speaking, but rather JSON
+ // content wrapped in a textarea as per the "file uploads" example here:
// http://malsup.com/jquery/form/#code-samples
- print '<textarea>' . drupal_to_js($commands) . '</textarea>';
+ print '<textarea>' . drupal_json_encode($commands) . '</textarea>';
}
else if ($header) {
- drupal_json($commands);
+ drupal_json_output($commands);
}
else {
- print drupal_to_js($commands);
+ print drupal_json_encode($commands);
}
exit;
}
diff --git a/includes/batch.inc b/includes/batch.inc
index 5fe876f9d..5cdcec0bd 100644
--- a/includes/batch.inc
+++ b/includes/batch.inc
@@ -140,7 +140,7 @@ function _batch_do() {
// Perform actual processing.
list($percentage, $message) = _batch_process();
- drupal_json(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message));
+ drupal_json_output(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message));
}
/**
diff --git a/includes/common.inc b/includes/common.inc
index 479d0952e..9037365ff 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3167,7 +3167,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
foreach ($items as $item) {
switch ($item['type']) {
case 'setting':
- $output .= '<script type="text/javascript">' . $embed_prefix . 'jQuery.extend(Drupal.settings, ' . drupal_to_js(call_user_func_array('array_merge_recursive', $item['data'])) . ");" . $embed_suffix . "</script>\n";
+ $output .= '<script type="text/javascript">' . $embed_prefix . 'jQuery.extend(Drupal.settings, ' . drupal_json_encode(call_user_func_array('array_merge_recursive', $item['data'])) . ");" . $embed_suffix . "</script>\n";
break;
case 'inline':
@@ -3585,7 +3585,7 @@ function drupal_clear_js_cache() {
*
* We use HTML-safe strings, i.e. with <, > and & escaped.
*/
-function drupal_to_js($var) {
+function drupal_json_encode($var) {
// json_encode() does not escape <, > and &, so we do it with str_replace()
return str_replace(array("<", ">", "&"), array('\x3c', '\x3e', '\x26'), json_encode($var));
}
@@ -3599,12 +3599,12 @@ function drupal_to_js($var) {
* @param $var
* (optional) If set, the variable will be converted to JSON and output.
*/
-function drupal_json($var = NULL) {
+function drupal_json_output($var = NULL) {
// We are returning JavaScript, so tell the browser.
drupal_set_header('Content-Type', 'text/javascript; charset=utf-8');
if (isset($var)) {
- echo drupal_to_js($var);
+ echo drupal_json_encode($var);
}
}
diff --git a/includes/locale.inc b/includes/locale.inc
index 4962f2fd7..6ee5baa82 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -2425,7 +2425,7 @@ function _locale_rebuild_js($langcode = NULL) {
$data .= "'pluralFormula': function (\$n) { return Number({$language->formula}); }, ";
}
- $data .= "'strings': " . drupal_to_js($translations) . " };";
+ $data .= "'strings': " . drupal_json_encode($translations) . " };";
$data_hash = md5($data);
}