1 Use json_encode to ensure compatibility with JQuery 1.4.
\r
3 Index: b/program/include/rcube_json_output.php
4 ===================================================================
5 --- a/program/include/rcube_json_output.php 2009-09-01 17:13:45.000000000 +0200
6 +++ b/program/include/rcube_json_output.php 2010-07-17 17:33:24.000000000 +0200
8 if (!empty($this->callbacks))
9 $response['callbacks'] = $this->callbacks;
11 - echo json_serialize($response);
12 + echo json_encode($response);
17 foreach ($this->commands as $i => $args) {
18 $method = array_shift($args);
19 foreach ($args as $i => $arg) {
20 - $args[$i] = json_serialize($arg);
21 + $args[$i] = json_encode($arg);
25 Index: b/program/include/rcube_shared.inc
26 ===================================================================
27 --- a/program/include/rcube_shared.inc 2009-10-27 10:43:39.000000000 +0100
28 +++ b/program/include/rcube_shared.inc 2010-07-17 17:33:24.000000000 +0200
33 - * Returns whether an $str is a reserved word for any of the version of Javascript or ECMAScript
34 - * @param str String to check
35 - * @return boolean True if $str is a reserver word, False if not
37 -function is_js_reserved_word($str)
39 - return in_array($str, array(
40 - // ECMASript ver 4 reserved words
41 - 'as','break','case','catch','class','const','continue',
42 - 'default','delete','do','else','export','extends','false','finally','for','function',
43 - 'if','import','in','instanceof','is','namespace','new','null','package','private',
44 - 'public','return','super','switch','this','throw','true','try','typeof','use','var',
45 - 'void','while','with',
46 - // ECMAScript ver 4 future reserved words
47 - 'abstract','debugger','enum','goto','implements','interface','native','protected',
48 - 'synchronized','throws','transient','volatile',
49 - // special meaning in some contexts
51 - // were reserved in ECMAScript ver 3
52 - 'boolean','byte','char','double','final','float','int','long','short','static'
58 - * Convert a variable into a javascript object notation
60 - * @param mixed Input value
61 - * @return string Serialized JSON string
63 -function json_serialize($var)
65 - if (is_object($var))
66 - $var = get_object_vars($var);
75 - $keys_arr = array_keys($var);
76 - $is_assoc = $have_numeric = 0;
78 - for ($i=0; $i<sizeof($keys_arr); ++$i)
80 - if (is_numeric($keys_arr[$i]))
82 - if (!is_numeric($keys_arr[$i]) || $keys_arr[$i] != $i)
84 - if ($is_assoc && $have_numeric)
88 - $brackets = $is_assoc ? '{}' : '[]';
91 - foreach ($var as $key => $value)
93 - // enclose key with quotes if it is not variable-name conform
94 - if (!preg_match('/^[_a-zA-Z]{1}[_a-zA-Z0-9]*$/', $key) || is_js_reserved_word($key))
97 - $pairs[] = sprintf("%s%s", $is_assoc ? "$key:" : '', json_serialize($value));
100 - return $brackets{0} . implode(',', $pairs) . $brackets{1};
103 - else if (!is_string($var) && strval(intval($var)) === strval($var))
105 - else if (is_bool($var))
106 - return $var ? '1' : '0';
108 - return "'".JQ($var)."'";
113 - * Function to convert an array to a javascript array
114 - * Actually an alias function for json_serialize()
117 -function array2js($arr, $type='')
119 - return json_serialize($arr);
124 * Similar function as in_array() but case-insensitive
126 * @param mixed Needle value
127 Index: b/program/include/rcube_template.php
128 ===================================================================
129 --- a/program/include/rcube_template.php 2009-09-22 20:08:45.000000000 +0200
130 +++ b/program/include/rcube_template.php 2010-07-17 17:33:24.000000000 +0200
131 @@ -414,12 +414,12 @@
134 if (!$this->framed && !empty($this->js_env)) {
135 - $out .= JS_OBJECT_NAME . '.set_env('.json_serialize($this->js_env).");\n";
136 + $out .= JS_OBJECT_NAME . '.set_env('.json_encode($this->js_env).");\n";
138 foreach ($this->js_commands as $i => $args) {
139 $method = array_shift($args);
140 foreach ($args as $i => $arg) {
141 - $args[$i] = json_serialize($arg);
142 + $args[$i] = json_encode($arg);
144 $parent = $this->framed || preg_match('/^parent\./', $method);
146 Index: b/program/steps/mail/compose.inc
147 ===================================================================
148 --- a/program/steps/mail/compose.inc 2009-10-06 08:55:08.000000000 +0200
149 +++ b/program/steps/mail/compose.inc 2010-07-17 17:33:24.000000000 +0200
151 JQ(Q(rcube_label('close'))),
152 JQ(Q(rcube_label('revertto'))),
153 JQ(Q(rcube_label('nospellerrors'))),
154 - json_serialize($spellcheck_langs),
155 + json_encode($spellcheck_langs),
158 JS_OBJECT_NAME), 'foot');
159 Index: b/program/steps/mail/func.inc
160 ===================================================================
161 --- a/program/steps/mail/func.inc 2009-10-24 21:09:23.000000000 +0200
162 +++ b/program/steps/mail/func.inc 2010-07-17 17:33:24.000000000 +0200
165 if (is_array($quota)) {
166 $OUTPUT->add_script('$(document).ready(function(){
167 - rcmail.set_quota('.json_serialize($quota).')});', 'foot');
168 + rcmail.set_quota('.json_encode($quota).')});', 'foot');