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