]> git.donarmstrong.com Git - roundcube.git/blob - debian/patches/changeset_r3170.patch
Fix link to jQuery, thanks to Niccolò Belli!
[roundcube.git] / debian / patches / changeset_r3170.patch
1 Use json_encode to ensure compatibility with JQuery 1.4.\r
2 \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
7 @@ -239,7 +239,7 @@
8          if (!empty($this->callbacks))
9            $response['callbacks'] = $this->callbacks;
10  
11 -        echo json_serialize($response);
12 +        echo json_encode($response);
13      }
14      
15      
16 @@ -255,7 +255,7 @@
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);
22              }
23  
24              $out .= sprintf(
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
29 @@ -109,97 +109,6 @@
30  
31  
32  /**
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
36 - */
37 -function is_js_reserved_word($str)
38 -{
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
50 -    'get','set',
51 -    // were reserved in ECMAScript ver 3
52 -    'boolean','byte','char','double','final','float','int','long','short','static'
53 -  ));
54 -}
55 -
56 -
57 -/**
58 - * Convert a variable into a javascript object notation
59 - *
60 - * @param mixed Input value
61 - * @return string Serialized JSON string
62 - */
63 -function json_serialize($var)
64 -{
65 -  if (is_object($var))
66 -    $var = get_object_vars($var);
67 -
68 -  if (is_array($var))
69 -  {
70 -    // empty array
71 -    if (!sizeof($var))
72 -      return '[]';
73 -    else
74 -    {
75 -      $keys_arr = array_keys($var);
76 -      $is_assoc = $have_numeric = 0;
77 -
78 -      for ($i=0; $i<sizeof($keys_arr); ++$i)
79 -      {
80 -        if (is_numeric($keys_arr[$i]))
81 -          $have_numeric = 1;
82 -        if (!is_numeric($keys_arr[$i]) || $keys_arr[$i] != $i)
83 -          $is_assoc = 1;
84 -        if ($is_assoc && $have_numeric)
85 -          break;
86 -      }
87 -      
88 -      $brackets = $is_assoc ? '{}' : '[]';
89 -      $pairs = array();
90 -
91 -      foreach ($var as $key => $value)
92 -      {
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))
95 -          $key = "'$key'";
96 -
97 -        $pairs[] = sprintf("%s%s", $is_assoc ? "$key:" : '', json_serialize($value));
98 -      }
99 -
100 -      return $brackets{0} . implode(',', $pairs) . $brackets{1};
101 -    }
102 -  }
103 -  else if (!is_string($var) && strval(intval($var)) === strval($var))
104 -    return $var;
105 -  else if (is_bool($var))
106 -    return $var ? '1' : '0';
107 -  else
108 -    return "'".JQ($var)."'";
109 -}
110 -
111 -
112 -/**
113 - * Function to convert an array to a javascript array
114 - * Actually an alias function for json_serialize()
115 - * @deprecated
116 - */
117 -function array2js($arr, $type='')
118 -{
119 -  return json_serialize($arr);
120 -}
121 -
122 -
123 -/**
124   * Similar function as in_array() but case-insensitive
125   *
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 @@
132      {
133          $out = '';
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";
137          }
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);
143              }
144              $parent = $this->framed || preg_match('/^parent\./', $method);
145              $out .= sprintf(
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
150 @@ -493,7 +493,7 @@
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),
156        $lang,
157        $attrib['id'],
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
163 @@ -522,7 +522,7 @@
164    
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');
169      $quota = '';
170      }
171