Inheritance diagram for JavascriptHelper:

Public Member Functions | |
| __construct ($options=array()) | |
| _utf8ToHex ($string) | |
| afterRender () | |
| blockEnd () | |
| cacheEvents ($file=false, $all=false) | |
| codeBlock ($script=null, $options=array()) | |
| escapeScript ($script) | |
| escapeString ($string) | |
| event ($object, $event, $observer=null, $options=array()) | |
| getCache ($clear=true) | |
| includeScript ($script="", $options=array()) | |
| link ($url, $inline=true) | |
| object ($data=array(), $options=array(), $prefix=null, $postfix=null, $stringKeys=null, $quoteKeys=null, $q=null) | |
| value ($val, $quoteStrings=true) | |
| writeEvents ($inline=true, $options=array()) | |
Public Attributes | |
| $__scriptBuffer = null | |
| $_blockOptions = array() | |
| $_cacheAll = false | |
| $_cachedEvents = array() | |
| $_cacheEvents = false | |
| $_cacheToFile = false | |
| $_rules = array() | |
| $enabled = true | |
| $safe = false | |
| $tags | |
| $useNative = false | |
Definition at line 33 of file javascript.php.
| JavascriptHelper::__construct | ( | $ | options = array() |
) |
Constructor. Checks for presence of native PHP JSON extension to use for object encoding
public
Definition at line 132 of file javascript.php.
References __construct(), cache(), and safe().
| JavascriptHelper::_utf8ToHex | ( | $ | string | ) |
Encode a string into JSON. Converts and escapes necessary characters.
Definition at line 315 of file javascript.php.
References Multibyte::utf8().
| JavascriptHelper::afterRender | ( | ) |
AfterRender callback. Writes any cached events to the view, or to a temp file.
Reimplemented from Helper.
Definition at line 700 of file javascript.php.
| JavascriptHelper::blockEnd | ( | ) |
Ends a block of cached JavaScript code
Definition at line 205 of file javascript.php.
References codeBlock().
Cache JavaScript events created with event()
| boolean | $file If true, code will be written to a file | |
| boolean | $all If true, all code written with JavascriptHelper will be sent to a file |
Definition at line 473 of file javascript.php.
| JavascriptHelper::codeBlock | ( | $ | script = null, |
|
| $ | options = array() | |||
| ) |
Returns a JavaScript script tag.
Options:
| string | $script The JavaScript to be wrapped in SCRIPT tags. | |
| array | $options Set of options: |
Definition at line 169 of file javascript.php.
References ClassRegistry::getObject(), and safe().
Referenced by blockEnd().
| JavascriptHelper::escapeScript | ( | $ | script | ) |
Escape carriage returns and single and double quotes for JavaScript segments.
| string | $script string that might have javascript elements |
Definition at line 286 of file javascript.php.
| JavascriptHelper::escapeString | ( | $ | string | ) |
Escape a string to be JavaScript friendly.
List of escaped ellements: + "\r\n" => '
' + "\r" => '
' + "\n" => '
' + '"' => '\"' + "'" => "\\'"
| string | $script String that needs to get escaped. |
Definition at line 304 of file javascript.php.
References App::import().
| JavascriptHelper::event | ( | $ | object, | |
| $ | event, | |||
| $ | observer = null, |
|||
| $ | options = array() | |||
| ) |
Attach an event to an element. Used with the Prototype library.
| string | $object Object to be observed | |
| string | $event event to observe | |
| string | $observer function to call | |
| array | $options Set options: useCapture, allowCache, safe |
Definition at line 413 of file javascript.php.
| JavascriptHelper::getCache | ( | $ | clear = true |
) |
Gets (and clears) the current JavaScript event cache
| boolean | $clear |
Definition at line 484 of file javascript.php.
References $out.
| JavascriptHelper::includeScript | ( | $ | script = "", |
|
| $ | options = array() | |||
| ) |
Includes the Prototype Javascript library (and anything else) inside a single script tag.
Note: The recommended approach is to copy the contents of javascripts into your application's public/javascripts/ directory, and use
| string | $script Script file to include | |
| array | $options Set options for codeBlock |
Definition at line 556 of file javascript.php.
| JavascriptHelper::link | ( | $ | url, | |
| $ | inline = true | |||
| ) |
Returns a JavaScript include tag (SCRIPT element). If the filename is prefixed with "/", the path will be relative to the base path of your application. Otherwise, the path will be relative to your JavaScript path, usually webroot/js.
| mixed | $url String URL to JavaScript file, or an array of URLs. | |
| boolean | $inline If true, the <script> tag will be printed inline, otherwise it will be printed in the <head>, using $scripts_for_layout |
Definition at line 235 of file javascript.php.
References $out, $url, Configure::read(), and Helper::webroot().
| JavascriptHelper::object | ( | $ | data = array(), |
|
| $ | options = array(), |
|||
| $ | prefix = null, |
|||
| $ | postfix = null, |
|||
| $ | stringKeys = null, |
|||
| $ | quoteKeys = null, |
|||
| $ | q = null | |||
| ) |
Generates a JavaScript object in JavaScript Object Notation (JSON) from an array
### Options
| array | $data Data to be converted | |
| array | $options Set of options: block, prefix, postfix, stringKeys, quoteKeys, q | |
| string | $prefix DEPRECATED, use $options['prefix'] instead. Prepends the string to the returned data | |
| string | $postfix DEPRECATED, use $options['postfix'] instead. Appends the string to the returned data | |
| array | $stringKeys DEPRECATED, use $options['stringKeys'] instead. A list of array keys to be treated as a string | |
| boolean | $quoteKeys DEPRECATED, use $options['quoteKeys'] instead. If false, treats $stringKey as a list of keys *not* to be quoted | |
| string | $q DEPRECATED, use $options['q'] instead. The type of quote to use |
Definition at line 593 of file javascript.php.
References $out.
| JavascriptHelper::value | ( | $ | val, | |
| $ | quoteStrings = true | |||
| ) |
Converts a PHP-native variable of any type to a JSON-equivalent representation
| mixed | $val A PHP variable to be converted to JSON | |
| boolean | $quoteStrings If false, leaves string values unquoted |
Definition at line 669 of file javascript.php.
References ife().
| JavascriptHelper::writeEvents | ( | $ | inline = true, |
|
| $ | options = array() | |||
| ) |
Write cached JavaScript events
| boolean | $inline If true, returns JavaScript event code. Otherwise it is added to the output of $scripts_for_layout in the layout. | |
| array | $options Set options for codeBlock |
Definition at line 514 of file javascript.php.
References $filename, $out, cache(), ClassRegistry::getObject(), and md5().
| JavascriptHelper::$__scriptBuffer = null |
Definition at line 126 of file javascript.php.
| JavascriptHelper::$_blockOptions = array() |
Definition at line 75 of file javascript.php.
| JavascriptHelper::$_cacheAll = false |
Definition at line 111 of file javascript.php.
| JavascriptHelper::$_cachedEvents = array() |
Definition at line 83 of file javascript.php.
| JavascriptHelper::$_cacheEvents = false |
Definition at line 93 of file javascript.php.
| JavascriptHelper::$_cacheToFile = false |
Definition at line 102 of file javascript.php.
| JavascriptHelper::$_rules = array() |
Definition at line 121 of file javascript.php.
| JavascriptHelper::$enabled = true |
Definition at line 48 of file javascript.php.
| JavascriptHelper::$safe = false |
Definition at line 55 of file javascript.php.
| JavascriptHelper::$tags |
Initial value:
array(
'javascriptstart' => '<script type="text/javascript">',
'javascriptend' => '</script>',
'javascriptblock' => '<script type="text/javascript">%s</script>',
'javascriptlink' => '<script type="text/javascript" src="%s"></script>'
)
Reimplemented from Helper.
Definition at line 62 of file javascript.php.
| JavascriptHelper::$useNative = false |
Definition at line 40 of file javascript.php.
1.4.7