diff --git a/cake/libs/view/helpers/js.php b/cake/libs/view/helpers/js.php index ea488b9b0..46a6bf5aa 100644 --- a/cake/libs/view/helpers/js.php +++ b/cake/libs/view/helpers/js.php @@ -350,23 +350,6 @@ class JsHelper extends AppHelper { function redirect_($url = null) { return 'window.location = "' . Router::url($url) . '";'; } -/** - * Escape a string to be JavaScript friendly. - * - * List of escaped ellements: - * + "\r\n" => '\n' - * + "\r" => '\n' - * + "\n" => '\n' - * + '"' => '\"' - * + "'" => "\\'" - * - * @param string $script String that needs to get escaped. - * @return string Escaped string. - */ - function escape($string) { - $escape = array("\r\n" => '\n', "\r" => '\n', "\n" => '\n', '"' => '\"', "'" => "\\'"); - return str_replace(array_keys($escape), array_values($escape), $string); - } /* function get__($name) { return $this->__object($name, 'id'); @@ -387,76 +370,157 @@ class JsHelper extends AppHelper { } return $this->__objects[$name]; } + + +} + +/** + * JsEngineBaseClass + * + * Abstract Base Class for All JsEngines to extend. Provides generic methods. + * + * @package cake.view.helpers + */ +class JsBaseEngineHelper extends AppHelper { +/** + * Determines whether native JSON extension is used for encoding. Set by object constructor. + * + * @var boolean + * @access public + */ + var $useNative = false; +/** + * Constructor. + * + * @return void + **/ + function __construct() { + $this->useNative = function_exists('json_encode'); + } /** * Generates a JavaScript object in JavaScript Object Notation (JSON) * from an array * - * @param array $data Data to be converted - * @param boolean $block Wraps return value in a