Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CGoogleApi
  • CHtml
  • CJavaScript
  • CJavaScriptExpression
  • CJSON
  • X2Html
  • Overview
  • Package
  • Class
  • Tree

Class CJavaScript

CJavaScript is a helper class containing JavaScript-related handling functions.

Package: system\web\helpers
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/web/helpers/CJavaScript.php
Methods summary
public static string
# quote( string $js, boolean $forUrl = false )

Quotes a javascript string. After processing, the string can be safely enclosed within a pair of quotation marks and serve as a javascript string.

Quotes a javascript string. After processing, the string can be safely enclosed within a pair of quotation marks and serve as a javascript string.

Parameters

$js
string
$js string to be quoted
$forUrl
boolean
$forUrl whether this string is used as a URL

Returns

string
the quoted string
public static string
# encode( mixed $value, boolean $safe = false )

Encodes a PHP variable into javascript representation.

Encodes a PHP variable into javascript representation.

Example:

$options=array('key1'=>true,'key2'=>123,'key3'=>'value');
echo CJavaScript::encode($options);
// The following javascript code would be generated:
// {'key1':true,'key2':123,'key3':'value'}

For highly complex data structures use CJavaScript::jsonEncode() and CJavaScript::jsonDecode() to serialize and unserialize.

If you are encoding user input, make sure $safe is set to true.

Parameters

$value
mixed
$value PHP variable to be encoded
$safe
boolean
$safe If true, 'js:' will not be allowed. In case of wrapping code with CJavaScriptExpression JavaScript expression will stay as is no matter what value this parameter is set to. Default is false. This parameter is available since 1.1.11.

Returns

string
the encoded string
public static string
# jsonEncode( mixed $data )

Returns the JSON representation of the PHP data.

Returns the JSON representation of the PHP data.

Parameters

$data
mixed
$data the data to be encoded

Returns

string
the JSON representation of the PHP data.
public static mixed
# jsonDecode( string $data, boolean $useArray = true )

Decodes a JSON string.

Decodes a JSON string.

Parameters

$data
string
$data the data to be decoded
$useArray
boolean
$useArray whether to use associative array to represent object data

Returns

mixed
the decoded PHP data
API documentation generated by ApiGen 2.8.0