CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 1.3 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.3
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Classes

  • AclBase
  • AclBehavior
  • AclComponent
  • AclNode
  • AclShell
  • Aco
  • AcoAction
  • AjaxHelper
  • ApcEngine
  • ApiShell
  • App
  • AppController
  • AppHelper
  • AppModel
  • Aro
  • AuthComponent
  • BakeShell
  • BakeTask
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeRoute
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbConfigTask
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • FileLog
  • FixtureTask
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JqueryEngineHelper
  • JsBaseEngineHelper
  • JsHelper
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • MootoolsEngineHelper
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginShortRoute
  • PluginTask
  • ProjectTask
  • PrototypeEngineHelper
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • Set
  • Shell
  • String
  • TemplateTask
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count

Class JsBaseEngineHelper

JsEngineBaseClass

Abstract Base Class for All JsEngines to extend. Provides generic methods.

Object
Extended by Overloadable
Extended by Helper
Extended by AppHelper
Extended by JsBaseEngineHelper
Direct Subclasses
  • JqueryEngineHelper
  • MootoolsEngineHelper
  • PrototypeEngineHelper
Package: cake\cake\libs\view\helpers
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc.
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: view/helpers/js.php

Properties summary

  • $_callbackArguments public
    array
    Contains a list of callback names -> default arguments.
  • $_optionMap public
    array

    Collection of option maps. Option maps allow other helpers to use generic names for engine callbacks and options. Allowing uniform code access for all engine types. Their use is optional for end user use though.

  • $bufferedMethods public
    array

    An array of lowercase method names in the Engine that are buffered unless otherwise disabled. This allows specific 'end point' methods to be automatically buffered by the JsHelper.

  • $selection public
    string
    The js snippet for the current selection.
  • $useNative public
    boolean
    Determines whether native JSON extension is used for encoding. Set by object constructor.

Inherited Properties

  • __cleaned, __tainted, action, argSeparator, base, data, helpers, here, namedArgs, params, plugin, tags, theme, validationErrors, webroot

Method Summary

  • __construct() public
    Constructor.
  • _mapOptions() public

    Maps Abstract options to engine specific option names. If attributes are missing from the map, they are not changed.

  • _parseOptions() public

    Parse an options assoc array into an Javascript object literal. Similar to object() but treats any non-integer value as a string, does not include { }

  • _prepareCallbacks() public

    Prepare callbacks and wrap them with function ([args]) { } as defined in _callbackArgs array.

  • _processOptions() public

    Conveinence wrapper method for all common option processing steps. Runs _mapOptions, _prepareCallbacks, and _parseOptions in order.

  • _toQuerystring() public
    Convert an array of data into a query string
  • _utf8ToHex() public
    Encode a string into JSON. Converts and escapes necessary characters.
  • alert() public
    Create an alert() message in Javascript
  • confirm() public
    Create a confirm() message
  • confirmReturn() public

    Generate a confirm snippet that returns false from the current function scope.

  • domReady() public
    Create a domReady event. This is a special event in many libraries
  • drag() public

    Create a draggable element. Works on the currently selected element. Additional options may be supported by the library implementation.

  • drop() public

    Create a droppable element. Allows for draggable elements to be dropped on it. Additional options may be supported by the library implementation.

  • each() public
    Create an iteration over the current selection result.
  • effect() public
    Trigger an Effect.
  • escape() public
    Escape a string to be JSON friendly.
  • event() public
    Add an event to the script cache. Operates on the currently selected elements.
  • get() public
    Create javascript selector for a CSS rule
  • object() public

    Generates a JavaScript object in JavaScript Object Notation (JSON) from an array. Will use native JSON encode method if available, and $useNative == true

  • prompt() public
    Create a prompt() Javascript function
  • redirect() public

    Redirects to a URL. Creates a window.location modification snippet that can be used to trigger 'redirects' from Javascript.

  • request() public
    Make an XHR request
  • serializeForm() public

    Serialize the form attached to $selector. Pass true for $isForm if the current selection is a form element. Converts the form or the form element attached to the current selection into a string/json object (depending on the library implementation) for use with XHR operations.

  • slider() public

    Create a slider UI widget. Comprised of a track and knob. Additional options may be supported by the library implementation.

  • sortable() public

    Create a sortable element. Additional options may be supported by the library implementation.

  • value() public
    Converts a PHP-native variable of any type to a JSON-equivalent representation

Method Detail

__construct() public ¶

__construct( )

Constructor.

Overrides
Object::__construct()

_mapOptions() public ¶

_mapOptions( string $method , array $options )

Maps Abstract options to engine specific option names. If attributes are missing from the map, they are not changed.

Parameters
string $method
Name of method whose options are being worked with.
array $options
Array of options to map.
Returns
array
Array of mapped options.

_parseOptions() public ¶

_parseOptions( array $options , array $safeKeys = array() )

Parse an options assoc array into an Javascript object literal. Similar to object() but treats any non-integer value as a string, does not include { }

Parameters
array $options
Options to be converted
array $safeKeys optional array()
Keys that should not be escaped.
Returns
string
Parsed JSON options without enclosing { }.

_prepareCallbacks() public ¶

_prepareCallbacks( string $method , array $options , string $callbacks = array() )

Prepare callbacks and wrap them with function ([args]) { } as defined in _callbackArgs array.

Parameters
string $method
Name of the method you are preparing callbacks for.
array $options
Array of options being parsed
string $callbacks optional array()
Additional Keys that contain callbacks
Returns
array
Array of options with callbacks added.

_processOptions() public ¶

_processOptions( string $method , array $options )

Conveinence wrapper method for all common option processing steps. Runs _mapOptions, _prepareCallbacks, and _parseOptions in order.

Parameters
string $method
Name of method processing options for.
array $options
Array of options to process.
Returns
string
Parsed options string.

_toQuerystring() public ¶

_toQuerystring( array $parameters )

Convert an array of data into a query string

Parameters
array $parameters
Array of parameters to convert to a query string
Returns
string
Querystring fragment

_utf8ToHex() public ¶

_utf8ToHex( string $string )

Encode a string into JSON. Converts and escapes necessary characters.

Parameters
string $string
The string that needs to be utf8->hex encoded

alert() public ¶

alert( string $message )

Create an alert() message in Javascript

Parameters
string $message
Message you want to alter.
Returns
string
completed alert()

confirm() public ¶

confirm( string $message )

Create a confirm() message

Parameters
string $message
Message you want confirmed.
Returns
string
completed confirm()

confirmReturn() public ¶

confirmReturn( string $message )

Generate a confirm snippet that returns false from the current function scope.

Parameters
string $message
Message to use in the confirm dialog.
Returns
string
completed confirm with return script

domReady() public ¶

domReady( string $functionBody )

Create a domReady event. This is a special event in many libraries

Parameters
string $functionBody
The code to run on domReady
Returns
string
completed domReady method

drag() public ¶

drag( array $options = array() )

Create a draggable element. Works on the currently selected element. Additional options may be supported by the library implementation.

Options

  • handle - selector to the handle element.
  • snapGrid - The pixel grid that movement snaps to, an array(x, y)
  • container - The element that acts as a bounding box for the draggable element.

Event Options

  • start - Event fired when the drag starts
  • drag - Event fired on every step of the drag
  • stop - Event fired when dragging stops (mouse release)
Parameters
array $options optional array()
Options array see above.
Returns
string
Completed drag script

drop() public ¶

drop( $options = array() )

Create a droppable element. Allows for draggable elements to be dropped on it. Additional options may be supported by the library implementation.

Options

  • accept - Selector for elements this droppable will accept.
  • hoverclass - Class to add to droppable when a draggable is over.

Event Options

  • drop - Event fired when an element is dropped into the drop zone.
  • hover - Event fired when a drag enters a drop zone.
  • leave - Event fired when a drag is removed from a drop zone without being dropped.
Returns
string
Completed drop script

each() public ¶

each( string $callback )

Create an iteration over the current selection result.

Parameters
string $callback
The function body you wish to apply during the iteration.
Returns
string
completed iteration

effect() public ¶

effect( string $name , array $options )

Trigger an Effect.

Supported Effects

The following effects are supported by all core JsEngines

  • show - reveal an element.
  • hide - hide an element.
  • fadeIn - Fade in an element.
  • fadeOut - Fade out an element.
  • slideIn - Slide an element in.
  • slideOut - Slide an element out.

Options

  • speed - Speed at which the animation should occur. Accepted values are 'slow', 'fast'. Not all effects use the speed option.
Parameters
string $name
The name of the effect to trigger.
array $options
Array of options for the effect.
Returns
string
completed string with effect.

escape() public ¶

escape( string $string )

Escape a string to be JSON friendly.

List of escaped elements:

  • "\r" => '\n'
  • "\n" => '\n'
  • '"' => '\"'
Parameters
string $string
$script String that needs to get escaped.
Returns
string
Escaped string.

event() public ¶

event( string $type , string $callback , array $options = array() )

Add an event to the script cache. Operates on the currently selected elements.

Options

  • wrap - Whether you want the callback wrapped in an anonymous function. (defaults to true)
  • stop - Whether you want the event to stopped. (defaults to true)
Parameters
string $type
Type of event to bind to the current dom id
string $callback
The Javascript function you wish to trigger or the function literal
array $options optional array()
Options for the event.
Returns
string
completed event handler

get() public ¶

get( string $selector )

Create javascript selector for a CSS rule

Parameters
string $selector
The selector that is targeted
Returns
object
instance of $this. Allows chained methods.

object() public ¶

object( array $data = array() , array $options = array() )

Generates a JavaScript object in JavaScript Object Notation (JSON) from an array. Will use native JSON encode method if available, and $useNative == true

Options:

  • prefix - String prepended to the returned data.
  • postfix - String appended to the returned data.
Parameters
array $data optional array()
Data to be converted.
array $options optional array()
Set of options, see above.
Returns
string
A JSON code block

prompt() public ¶

prompt( string $message , string $default = '' )

Create a prompt() Javascript function

Parameters
string $message
Message you want to prompt.
string $default optional ''
Default message
Returns
string
completed prompt()

redirect() public ¶

redirect( mixed $url = null , array $options ,… )

Redirects to a URL. Creates a window.location modification snippet that can be used to trigger 'redirects' from Javascript.

Parameters
mixed $url optional null
array $options ,…
Returns
string
completed redirect in javascript

request() public ¶

request( mixed $url , array $options = array() )

Make an XHR request

Event Options

  • complete - Callback to fire on complete.
  • success - Callback to fire on success.
  • before - Callback to fire on request initialization.
  • error - Callback to fire on request failure.

Options

  • method - The method to make the request with defaults to GET in more libraries
  • async - Whether or not you want an asynchronous request.
  • data - Additional data to send.
  • update - Dom id to update with the content of the request.
  • type - Data type for response. 'json' and 'html' are supported. Default is html for most libraries.
  • evalScripts - Whether or not