JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.3
[ckeditor.git] / ckeditor_php5.php
index 6b9d6df..f5840a4 100644 (file)
@@ -20,11 +20,11 @@ class CKEditor
        /**\r
         * The version of %CKEditor.\r
         */\r
-       const version = '3.5.2';\r
+       const version = '3.5.3';\r
        /**\r
         * A constant string unique for each release of %CKEditor.\r
         */\r
-       const timestamp = 'B1GG4Z6';\r
+       const timestamp = 'B37D54V';\r
 \r
        /**\r
         * URL to the %CKEditor installation directory (absolute or relative to document root).\r
@@ -78,7 +78,7 @@ class CKEditor
         * A string indicating the creation date of %CKEditor.\r
         * Do not change it unless you want to force browsers to not use previously cached version of %CKEditor.\r
         */\r
-       public $timestamp = "B1GG4Z6";\r
+       public $timestamp = "B37D54V";\r
        /**\r
         * An array that holds event listeners.\r
         */\r
@@ -517,7 +517,6 @@ class CKEditor
 \r
        /**\r
         * This little function provides a basic JSON support.\r
-        * http://php.net/manual/en/function.json-encode.php\r
         *\r
         * @param mixed $val\r
         * @return string\r
@@ -527,60 +526,31 @@ class CKEditor
                if (is_null($val)) {\r
                        return 'null';\r
                }\r
-               if ($val === false) {\r
-                       return 'false';\r
+               if (is_bool($val)) {\r
+                       return $val ? 'true' : 'false';\r
                }\r
-               if ($val === true) {\r
-                       return 'true';\r
+               if (is_int($val)) {\r
+                       return $val;\r
                }\r
-               if (is_scalar($val))\r
-               {\r
-                       if (is_float($val))\r
-                       {\r
-                               // Always use "." for floats.\r
-                               $val = str_replace(",", ".", strval($val));\r
-                       }\r
-\r
-                       // Use @@ to not use quotes when outputting string value\r
-                       if (strpos($val, '@@') === 0) {\r
-                               return substr($val, 2);\r
-                       }\r
-                       else {\r
-                               // All scalars are converted to strings to avoid indeterminism.\r
-                               // PHP's "1" and 1 are equal for all PHP operators, but\r
-                               // JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend,\r
-                               // we should get the same result in the JS frontend (string).\r
-                               // Character replacements for JSON.\r
-                               static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'),\r
-                               array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));\r
-\r
-                               $val = str_replace($jsonReplaces[0], $jsonReplaces[1], $val);\r
-                               if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') {\r
-                                       return $val;\r
-                               }\r
-\r
-                               return '"' . $val . '"';\r
-                       }\r
+               if (is_float($val)) {\r
+                       return str_replace(',', '.', $val);\r
                }\r
-               $isList = true;\r
-               for ($i = 0, reset($val); $i < count($val); $i++, next($val))\r
-               {\r
-                       if (key($val) !== $i)\r
-                       {\r
-                               $isList = false;\r
-                               break;\r
+               if (is_array($val) || is_object($val)) {\r
+                       if (is_array($val) && (array_keys($val) === range(0,count($val)-1))) {\r
+                               return '[' . implode(',', array_map(array($this, 'jsEncode'), $val)) . ']';\r
                        }\r
+                       $temp = array();\r
+                       foreach ($val as $k => $v){\r
+                               $temp[] = $this->jsEncode("{$k}") . ':' . $this->jsEncode($v);\r
+                       }\r
+                       return '{' . implode(',', $temp) . '}';\r
                }\r
-               $result = array();\r
-               if ($isList)\r
-               {\r
-                       foreach ($val as $v) $result[] = $this->jsEncode($v);\r
-                       return '[ ' . join(', ', $result) . ' ]';\r
-               }\r
-               else\r
-               {\r
-                       foreach ($val as $k => $v) $result[] = $this->jsEncode($k).': '.$this->jsEncode($v);\r
-                       return '{ ' . join(', ', $result) . ' }';\r
-               }\r
+               // String otherwise\r
+               if (strpos($val, '@@') === 0)\r
+                       return substr($val, 2);\r
+               if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.')\r
+                       return $val;\r
+\r
+               return '"' . str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val) . '"';\r
        }\r
 }\r