author | Dan |
Sat, 20 Mar 2010 16:05:38 -0400 | |
changeset 1223 | 7dca925b0209 |
parent 784 | 72df14a56a03 |
permissions | -rw-r--r-- |
784
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
1 |
<?php |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
2 |
/** |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
3 |
* $Id: JSON.php 40 2007-06-18 11:43:15Z spocke $ |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
4 |
* |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
5 |
* @package MCManager.utils |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
6 |
* @author Moxiecode |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
7 |
* @copyright Copyright © 2007, Moxiecode Systems AB, All rights reserved. |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
8 |
*/ |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
9 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
10 |
define('JSON_BOOL', 1); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
11 |
define('JSON_INT', 2); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
12 |
define('JSON_STR', 3); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
13 |
define('JSON_FLOAT', 4); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
14 |
define('JSON_NULL', 5); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
15 |
define('JSON_START_OBJ', 6); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
16 |
define('JSON_END_OBJ', 7); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
17 |
define('JSON_START_ARRAY', 8); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
18 |
define('JSON_END_ARRAY', 9); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
19 |
define('JSON_KEY', 10); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
20 |
define('JSON_SKIP', 11); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
21 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
22 |
define('JSON_IN_ARRAY', 30); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
23 |
define('JSON_IN_OBJECT', 40); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
24 |
define('JSON_IN_BETWEEN', 50); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
25 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
26 |
class Moxiecode_JSONReader { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
27 |
var $_data, $_len, $_pos; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
28 |
var $_value, $_token; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
29 |
var $_location, $_lastLocations; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
30 |
var $_needProp; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
31 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
32 |
function Moxiecode_JSONReader($data) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
33 |
$this->_data = $data; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
34 |
$this->_len = strlen($data); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
35 |
$this->_pos = -1; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
36 |
$this->_location = JSON_IN_BETWEEN; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
37 |
$this->_lastLocations = array(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
38 |
$this->_needProp = false; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
39 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
40 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
41 |
function getToken() { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
42 |
return $this->_token; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
43 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
44 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
45 |
function getLocation() { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
46 |
return $this->_location; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
47 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
48 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
49 |
function getTokenName() { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
50 |
switch ($this->_token) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
51 |
case JSON_BOOL: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
52 |
return 'JSON_BOOL'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
53 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
54 |
case JSON_INT: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
55 |
return 'JSON_INT'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
56 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
57 |
case JSON_STR: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
58 |
return 'JSON_STR'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
59 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
60 |
case JSON_FLOAT: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
61 |
return 'JSON_FLOAT'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
62 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
63 |
case JSON_NULL: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
64 |
return 'JSON_NULL'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
65 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
66 |
case JSON_START_OBJ: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
67 |
return 'JSON_START_OBJ'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
68 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
69 |
case JSON_END_OBJ: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
70 |
return 'JSON_END_OBJ'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
71 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
72 |
case JSON_START_ARRAY: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
73 |
return 'JSON_START_ARRAY'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
74 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
75 |
case JSON_END_ARRAY: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
76 |
return 'JSON_END_ARRAY'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
77 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
78 |
case JSON_KEY: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
79 |
return 'JSON_KEY'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
80 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
81 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
82 |
return 'UNKNOWN'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
83 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
84 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
85 |
function getValue() { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
86 |
return $this->_value; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
87 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
88 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
89 |
function readToken() { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
90 |
$chr = $this->read(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
91 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
92 |
if ($chr != null) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
93 |
switch ($chr) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
94 |
case '[': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
95 |
$this->_lastLocation[] = $this->_location; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
96 |
$this->_location = JSON_IN_ARRAY; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
97 |
$this->_token = JSON_START_ARRAY; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
98 |
$this->_value = null; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
99 |
$this->readAway(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
100 |
return true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
101 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
102 |
case ']': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
103 |
$this->_location = array_pop($this->_lastLocation); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
104 |
$this->_token = JSON_END_ARRAY; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
105 |
$this->_value = null; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
106 |
$this->readAway(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
107 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
108 |
if ($this->_location == JSON_IN_OBJECT) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
109 |
$this->_needProp = true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
110 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
111 |
return true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
112 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
113 |
case '{': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
114 |
$this->_lastLocation[] = $this->_location; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
115 |
$this->_location = JSON_IN_OBJECT; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
116 |
$this->_needProp = true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
117 |
$this->_token = JSON_START_OBJ; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
118 |
$this->_value = null; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
119 |
$this->readAway(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
120 |
return true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
121 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
122 |
case '}': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
123 |
$this->_location = array_pop($this->_lastLocation); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
124 |
$this->_token = JSON_END_OBJ; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
125 |
$this->_value = null; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
126 |
$this->readAway(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
127 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
128 |
if ($this->_location == JSON_IN_OBJECT) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
129 |
$this->_needProp = true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
130 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
131 |
return true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
132 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
133 |
// String |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
134 |
case '"': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
135 |
case '\'': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
136 |
return $this->_readString($chr); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
137 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
138 |
// Null |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
139 |
case 'n': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
140 |
return $this->_readNull(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
141 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
142 |
// Bool |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
143 |
case 't': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
144 |
case 'f': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
145 |
return $this->_readBool($chr); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
146 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
147 |
default: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
148 |
// Is number |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
149 |
if (is_numeric($chr) || $chr == '-' || $chr == '.') |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
150 |
return $this->_readNumber($chr); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
151 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
152 |
return true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
153 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
154 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
155 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
156 |
return false; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
157 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
158 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
159 |
function _readBool($chr) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
160 |
$this->_token = JSON_BOOL; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
161 |
$this->_value = $chr == 't'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
162 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
163 |
if ($chr == 't') |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
164 |
$this->skip(3); // rue |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
165 |
else |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
166 |
$this->skip(4); // alse |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
167 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
168 |
$this->readAway(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
169 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
170 |
if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
171 |
$this->_needProp = true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
172 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
173 |
return true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
174 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
175 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
176 |
function _readNull() { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
177 |
$this->_token = JSON_NULL; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
178 |
$this->_value = null; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
179 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
180 |
$this->skip(3); // ull |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
181 |
$this->readAway(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
182 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
183 |
if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
184 |
$this->_needProp = true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
185 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
186 |
return true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
187 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
188 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
189 |
function _readString($quote) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
190 |
$output = ""; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
191 |
$this->_token = JSON_STR; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
192 |
$endString = false; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
193 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
194 |
while (($chr = $this->peek()) != -1) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
195 |
switch ($chr) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
196 |
case '\\': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
197 |
// Read away slash |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
198 |
$this->read(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
199 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
200 |
// Read escape code |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
201 |
$chr = $this->read(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
202 |
switch ($chr) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
203 |
case 't': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
204 |
$output .= "\t"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
205 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
206 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
207 |
case 'b': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
208 |
$output .= "\b"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
209 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
210 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
211 |
case 'f': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
212 |
$output .= "\f"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
213 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
214 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
215 |
case 'r': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
216 |
$output .= "\r"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
217 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
218 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
219 |
case 'n': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
220 |
$output .= "\n"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
221 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
222 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
223 |
case 'u': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
224 |
$output .= $this->_int2utf8(hexdec($this->read(4))); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
225 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
226 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
227 |
default: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
228 |
$output .= $chr; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
229 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
230 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
231 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
232 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
233 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
234 |
case '\'': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
235 |
case '"': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
236 |
if ($chr == $quote) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
237 |
$endString = true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
238 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
239 |
$chr = $this->read(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
240 |
if ($chr != -1 && $chr != $quote) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
241 |
$output .= $chr; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
242 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
243 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
244 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
245 |
default: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
246 |
$output .= $this->read(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
247 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
248 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
249 |
// String terminated |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
250 |
if ($endString) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
251 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
252 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
253 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
254 |
$this->readAway(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
255 |
$this->_value = $output; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
256 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
257 |
// Needed a property |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
258 |
if ($this->_needProp) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
259 |
$this->_token = JSON_KEY; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
260 |
$this->_needProp = false; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
261 |
return true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
262 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
263 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
264 |
if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
265 |
$this->_needProp = true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
266 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
267 |
return true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
268 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
269 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
270 |
function _int2utf8($int) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
271 |
$int = intval($int); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
272 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
273 |
switch ($int) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
274 |
case 0: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
275 |
return chr(0); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
276 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
277 |
case ($int & 0x7F): |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
278 |
return chr($int); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
279 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
280 |
case ($int & 0x7FF): |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
281 |
return chr(0xC0 | (($int >> 6) & 0x1F)) . chr(0x80 | ($int & 0x3F)); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
282 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
283 |
case ($int & 0xFFFF): |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
284 |
return chr(0xE0 | (($int >> 12) & 0x0F)) . chr(0x80 | (($int >> 6) & 0x3F)) . chr (0x80 | ($int & 0x3F)); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
285 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
286 |
case ($int & 0x1FFFFF): |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
287 |
return chr(0xF0 | ($int >> 18)) . chr(0x80 | (($int >> 12) & 0x3F)) . chr(0x80 | (($int >> 6) & 0x3F)) . chr(0x80 | ($int & 0x3F)); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
288 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
289 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
290 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
291 |
function _readNumber($start) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
292 |
$value = ""; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
293 |
$isFloat = false; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
294 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
295 |
$this->_token = JSON_INT; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
296 |
$value .= $start; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
297 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
298 |
while (($chr = $this->peek()) != -1) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
299 |
if (is_numeric($chr) || $chr == '-' || $chr == '.') { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
300 |
if ($chr == '.') |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
301 |
$isFloat = true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
302 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
303 |
$value .= $this->read(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
304 |
} else |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
305 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
306 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
307 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
308 |
$this->readAway(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
309 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
310 |
if ($isFloat) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
311 |
$this->_token = JSON_FLOAT; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
312 |
$this->_value = floatval($value); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
313 |
} else |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
314 |
$this->_value = intval($value); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
315 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
316 |
if ($this->_location == JSON_IN_OBJECT && !$this->_needProp) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
317 |
$this->_needProp = true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
318 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
319 |
return true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
320 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
321 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
322 |
function readAway() { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
323 |
while (($chr = $this->peek()) != null) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
324 |
if ($chr != ':' && $chr != ',' && $chr != ' ') |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
325 |
return; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
326 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
327 |
$this->read(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
328 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
329 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
330 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
331 |
function read($len = 1) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
332 |
if ($this->_pos < $this->_len) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
333 |
if ($len > 1) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
334 |
$str = substr($this->_data, $this->_pos + 1, $len); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
335 |
$this->_pos += $len; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
336 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
337 |
return $str; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
338 |
} else |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
339 |
return $this->_data[++$this->_pos]; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
340 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
341 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
342 |
return null; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
343 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
344 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
345 |
function skip($len) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
346 |
$this->_pos += $len; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
347 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
348 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
349 |
function peek() { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
350 |
if ($this->_pos < $this->_len) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
351 |
return $this->_data[$this->_pos + 1]; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
352 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
353 |
return null; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
354 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
355 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
356 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
357 |
/** |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
358 |
* This class handles JSON stuff. |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
359 |
* |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
360 |
* @package MCManager.utils |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
361 |
*/ |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
362 |
class Moxiecode_JSON { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
363 |
function Moxiecode_JSON() { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
364 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
365 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
366 |
function decode($input) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
367 |
$reader = new Moxiecode_JSONReader($input); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
368 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
369 |
return $this->readValue($reader); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
370 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
371 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
372 |
function readValue(&$reader) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
373 |
$this->data = array(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
374 |
$this->parents = array(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
375 |
$this->cur =& $this->data; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
376 |
$key = null; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
377 |
$loc = JSON_IN_ARRAY; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
378 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
379 |
while ($reader->readToken()) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
380 |
switch ($reader->getToken()) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
381 |
case JSON_STR: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
382 |
case JSON_INT: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
383 |
case JSON_BOOL: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
384 |
case JSON_FLOAT: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
385 |
case JSON_NULL: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
386 |
switch ($reader->getLocation()) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
387 |
case JSON_IN_OBJECT: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
388 |
$this->cur[$key] = $reader->getValue(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
389 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
390 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
391 |
case JSON_IN_ARRAY: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
392 |
$this->cur[] = $reader->getValue(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
393 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
394 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
395 |
default: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
396 |
return $reader->getValue(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
397 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
398 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
399 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
400 |
case JSON_KEY: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
401 |
$key = $reader->getValue(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
402 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
403 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
404 |
case JSON_START_OBJ: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
405 |
case JSON_START_ARRAY: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
406 |
if ($loc == JSON_IN_OBJECT) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
407 |
$this->addArray($key); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
408 |
else |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
409 |
$this->addArray(null); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
410 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
411 |
$cur =& $obj; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
412 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
413 |
$loc = $reader->getLocation(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
414 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
415 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
416 |
case JSON_END_OBJ: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
417 |
case JSON_END_ARRAY: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
418 |
$loc = $reader->getLocation(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
419 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
420 |
if (count($this->parents) > 0) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
421 |
$this->cur =& $this->parents[count($this->parents) - 1]; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
422 |
array_pop($this->parents); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
423 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
424 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
425 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
426 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
427 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
428 |
return $this->data[0]; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
429 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
430 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
431 |
// This method was needed since PHP is crapy and doesn't have pointers/references |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
432 |
function addArray($key) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
433 |
$this->parents[] =& $this->cur; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
434 |
$ar = array(); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
435 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
436 |
if ($key) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
437 |
$this->cur[$key] =& $ar; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
438 |
else |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
439 |
$this->cur[] =& $ar; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
440 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
441 |
$this->cur =& $ar; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
442 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
443 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
444 |
function getDelim($index, &$reader) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
445 |
switch ($reader->getLocation()) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
446 |
case JSON_IN_ARRAY: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
447 |
case JSON_IN_OBJECT: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
448 |
if ($index > 0) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
449 |
return ","; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
450 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
451 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
452 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
453 |
return ""; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
454 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
455 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
456 |
function encode($input) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
457 |
switch (gettype($input)) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
458 |
case 'boolean': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
459 |
return $input ? 'true' : 'false'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
460 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
461 |
case 'integer': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
462 |
return (int) $input; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
463 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
464 |
case 'float': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
465 |
case 'double': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
466 |
return (float) $input; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
467 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
468 |
case 'NULL': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
469 |
return 'null'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
470 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
471 |
case 'string': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
472 |
return $this->encodeString($input); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
473 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
474 |
case 'array': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
475 |
return $this->_encodeArray($input); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
476 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
477 |
case 'object': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
478 |
return $this->_encodeArray(get_object_vars($input)); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
479 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
480 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
481 |
return ''; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
482 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
483 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
484 |
function encodeString($input) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
485 |
// Needs to be escaped |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
486 |
if (preg_match('/[^a-zA-Z0-9]/', $input)) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
487 |
$output = ''; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
488 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
489 |
for ($i=0; $i<strlen($input); $i++) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
490 |
switch ($input[$i]) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
491 |
case "\b": |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
492 |
$output .= "\\b"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
493 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
494 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
495 |
case "\t": |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
496 |
$output .= "\\t"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
497 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
498 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
499 |
case "\f": |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
500 |
$output .= "\\f"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
501 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
502 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
503 |
case "\r": |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
504 |
$output .= "\\r"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
505 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
506 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
507 |
case "\n": |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
508 |
$output .= "\\n"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
509 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
510 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
511 |
case '\\': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
512 |
$output .= "\\\\"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
513 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
514 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
515 |
case '\'': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
516 |
$output .= "\\'"; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
517 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
518 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
519 |
case '"': |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
520 |
$output .= '\"'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
521 |
break; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
522 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
523 |
default: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
524 |
$byte = ord($input[$i]); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
525 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
526 |
if (($byte & 0xE0) == 0xC0) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
527 |
$char = pack('C*', $byte, ord($input[$i + 1])); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
528 |
$i += 1; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
529 |
$output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
530 |
} if (($byte & 0xF0) == 0xE0) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
531 |
$char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2])); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
532 |
$i += 2; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
533 |
$output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
534 |
} if (($byte & 0xF8) == 0xF0) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
535 |
$char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]))); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
536 |
$i += 3; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
537 |
$output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
538 |
} if (($byte & 0xFC) == 0xF8) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
539 |
$char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]), ord($input[$i + 4]))); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
540 |
$i += 4; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
541 |
$output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
542 |
} if (($byte & 0xFE) == 0xFC) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
543 |
$char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2], ord($input[$i + 3]), ord($input[$i + 4]), ord($input[$i + 5]))); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
544 |
$i += 5; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
545 |
$output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char))); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
546 |
} else if ($byte < 128) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
547 |
$output .= $input[$i]; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
548 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
549 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
550 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
551 |
return '"' . $output . '"'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
552 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
553 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
554 |
return '"' . $input . '"'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
555 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
556 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
557 |
function _utf82utf16($utf8) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
558 |
if (function_exists('mb_convert_encoding')) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
559 |
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
560 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
561 |
switch (strlen($utf8)) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
562 |
case 1: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
563 |
return $utf8; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
564 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
565 |
case 2: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
566 |
return chr(0x07 & (ord($utf8[0]) >> 2)) . chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1]))); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
567 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
568 |
case 3: |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
569 |
return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))) . chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2]))); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
570 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
571 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
572 |
return ''; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
573 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
574 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
575 |
function _encodeArray($input) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
576 |
$output = ''; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
577 |
$isIndexed = true; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
578 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
579 |
$keys = array_keys($input); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
580 |
for ($i=0; $i<count($keys); $i++) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
581 |
if (!is_int($keys[$i])) { |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
582 |
$output .= $this->encodeString($keys[$i]) . ':' . $this->encode($input[$keys[$i]]); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
583 |
$isIndexed = false; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
584 |
} else |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
585 |
$output .= $this->encode($input[$keys[$i]]); |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
586 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
587 |
if ($i != count($keys) - 1) |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
588 |
$output .= ','; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
589 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
590 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
591 |
return $isIndexed ? '[' . $output . ']' : '{' . $output . '}'; |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
592 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
593 |
} |
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
594 |
|
72df14a56a03
Added spell-checking support for TinyMCE on user request (see: http://forum.enanocms.org/topic/11/)
Dan
parents:
diff
changeset
|
595 |
?> |