X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=ckeditor_php4.php;h=2e51439a5250ca67c172af014c91e4380f21ddcb;hp=8ca63a047cae7e2e61427e7e86263e9714b31601;hb=4e90e78dc97789709ee7404359a5517540c27553;hpb=8f6c203fdaa543c3bca40baea6ae4ddcdf1a77f5 diff --git a/ckeditor_php4.php b/ckeditor_php4.php index 8ca63a0..2e51439 100644 --- a/ckeditor_php4.php +++ b/ckeditor_php4.php @@ -21,12 +21,12 @@ class CKEditor * The version of %CKEditor. * \private */ - var $version = '3.5.2'; + var $version = '3.5.3'; /** * A constant string unique for each release of %CKEditor. * \private */ - var $_timestamp = 'B1GG4Z6'; + var $_timestamp = 'B37D54V'; /** * URL to the %CKEditor installation directory (absolute or relative to document root). @@ -80,7 +80,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. */ - var $timestamp = "B1GG4Z6"; + var $timestamp = "B37D54V"; /** * An array that holds event listeners. * \private @@ -526,7 +526,6 @@ class CKEditor /** * This little function provides a basic JSON support. - * http://php.net/manual/en/function.json-encode.php * \private * * @param mixed $val @@ -537,60 +536,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) . '"'; } }