Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml


Classes:
Keyword

Class TClientScriptManager

TComponent
   |
   --TApplicationComponent
      |
      --TClientScriptManager

TClientScriptManager class.

TClientScriptManager manages javascript and CSS stylesheets for a page.

Since: 3.0
Author: Qiang Xue <qiang.xue@gmail.com>

Constructor Summary
public
__construct Array
Constructor.

Method Summary
string
getCallbackReference ( ICallbackEventHandler $callbackHandler, array $options)
Returns javascript statement that create a new callback request object.
protected  array
getDefaultButtonOptions ( string $panelID, string $buttonID)
protected  array
getPackagePathUrl ( string $base)
string
boolean
boolean
boolean
boolean
isBeginScriptRegistered ( string $key)
boolean
isEndScriptRegistered ( string $key)
boolean
boolean
isHeadScriptRegistered ( string $key)
boolean
isHiddenFieldRegistered ( string $key)
boolean
isScriptFileRegistered ( string $key)
boolean
boolean
isStyleSheetRegistered ( string $key)
void
registerBeginScript ( string $key, string $script)
Registers a javascript script block at the beginning of the form
void
registerCallbackControl ( string $class, array $options)
Registers callback javascript for a control.
void
registerDefaultButton ( TControl|string $panel, TControl|string $button)
Register a default button to panel. When the $panel is in focus and the 'enter' key is pressed, the $button will be clicked.
void
registerEndScript ( string $key, string $script)
Registers a javascript script block at the end of the form
void
registerFocusControl ( string $target)
Registers the control to receive default focus.
void
registerHeadScript ( string $key, string $script)
Registers a javascript block in the page head.
void
registerHeadScriptFile ( string $key, string $url)
Registers a javascript file in the page head
void
registerHiddenField ( string $name, string|array $value)
Registers a hidden field to be rendered in the form.
string
registerJavascriptPackages ( string $base, array $packages, boolean $debug, boolean $gzip)
Publishes a javascript library path and register packages to be loaded.
void
registerPostBackControl ( string $class, array $options)
Registers postback javascript for a control. A null class parameter will prevent the javascript code registration.
void
registerPradoScript ( string $name)
Registers Prado javascript by library name. See "Web/Javascripts/source/packages.php" for library names.
void
registerScriptFile ( string $key, string $url)
Registers a javascript file to be rendered within the form
void
registerStyleSheet ( string $key, string $css, mixed $media)
Registers a CSS block to be rendered in the page head
void
registerStyleSheetFile ( string $key, string $url, string $media)
Registers a CSS file to be rendered in the page head
void
void
void
void
void
protected  void
Renders the HTML tags for PRADO js files
void
void
void
protected  void
verifyJavascriptPackages ( mixed $base, mixed $path, mixed $scripts)
Methods Inherited From TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()
Methods Inherited From TComponent
TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()

Constant Summary
string SCRIPT_LOADER the PHP script for loading Prado javascript files
string SCRIPT_PATH directory containing Prado javascript files

Constructor Details

__construct

public __construct Array

Constructor.


Method Details

getCallbackReference

public string getCallbackReference (ICallbackEventHandler $callbackHandler , array $options )

Returns javascript statement that create a new callback request object.

Input
ICallbackEventHandler$callbackHandlercallback response handler
array$optionsadditional callback options
Output
string javascript statement that creates a new callback request.
Exception

getDefaultButtonOptions

protected array getDefaultButtonOptions (string $panelID , string $buttonID )

Input
string$panelIDthe unique ID of the container control
string$buttonIDthe unique ID of the button control
Output
array default button options.
Exception

getPackagePathUrl

protected array getPackagePathUrl (string $base )

Input
string$basejavascript package path.
Output
array tuple($path,$url).
Exception

getPradoScriptAssetUrl

public string getPradoScriptAssetUrl ()

Output
string Prado javascript library base asset url.
Exception

getRequiresHead

public boolean getRequiresHead ()

Output
boolean whether THead is required in order to render CSS and js within head
Exception

hasBeginScripts

public boolean hasBeginScripts ()

Output
boolean true if any begin scripts are registered.
Exception

hasEndScripts

public boolean hasEndScripts ()

Output
boolean true if any end scripts are registered.
Exception

isBeginScriptRegistered

public boolean isBeginScriptRegistered (string $key )

Input
string$keya unique key
Output
boolean whether there is a beginning javascript block registered with the specified key
Exception

isEndScriptRegistered

public boolean isEndScriptRegistered (string $key )

Input
string$keya unique key
Output
boolean whether there is an ending javascript block registered with the specified key
Exception

isHeadScriptFileRegistered

public boolean isHeadScriptFileRegistered (string $key )

Input
string$keya unique key
Output
boolean whether there is a head javascript file registered with the specified key
Exception

isHeadScriptRegistered

public boolean isHeadScriptRegistered (string $key )

Input
string$keya unique key
Output
boolean whether there is a head javascript block registered with the specified key
Exception

isHiddenFieldRegistered

public boolean isHiddenFieldRegistered (string $key )

Input
string$keya unique key
Output
boolean whether there is a hidden field registered with the specified key
Exception

isScriptFileRegistered

public boolean isScriptFileRegistered (string $key )

Input
string$keya unique key
Output
boolean whether there is a javascript file registered with the specified key
Exception

isStyleSheetFileRegistered

public boolean isStyleSheetFileRegistered (string $key )

Input
string$keya unique key
Output
boolean whether there is a CSS file registered with the specified key
Exception

isStyleSheetRegistered

public boolean isStyleSheetRegistered (string $key )

Input
string$keya unique key
Output
boolean whether there is a CSS block registered with the specified key
Exception

registerBeginScript

public void registerBeginScript (string $key , string $script )

Registers a javascript script block at the beginning of the form

Input
string$keya unique key identifying the script block
string$scriptjavascript block
Output
Exception

registerCallbackControl

public void registerCallbackControl (string $class , array $options )

Registers callback javascript for a control.

Input
string$classjavascript class responsible for the control being registered for callback
array$optionscallback options
Output
Exception

registerDefaultButton

public void registerDefaultButton (TControl|string $panel , TControl|string $button )

Register a default button to panel. When the $panel is in focus and the 'enter' key is pressed, the $button will be clicked.

Input
TControl|string$panelpanel (or its unique ID) to register the default button action
TControl|string$buttonbutton (or its unique ID) to trigger a postback
Output
Exception

registerEndScript

public void registerEndScript (string $key , string $script )

Registers a javascript script block at the end of the form

Input
string$keya unique key identifying the script block
string$scriptjavascript block
Output
Exception

registerFocusControl

public void registerFocusControl (string $target )

Registers the control to receive default focus.

Input
string$targetthe client ID of the control to receive default focus
Output
Exception

registerHeadScript

public void registerHeadScript (string $key , string $script )

Registers a javascript block in the page head.

Input
string$keya unique key identifying the script block
string$scriptjavascript block
Output
Exception

registerHeadScriptFile

public void registerHeadScriptFile (string $key , string $url )

Registers a javascript file in the page head

Input
string$keya unique key identifying the file
string$urlURL to the javascript file
Output
Exception

registerHiddenField

public void registerHiddenField (string $name , string|array $value )

Registers a hidden field to be rendered in the form.

Input
string$namea unique key identifying the hidden field
string|array$valuehidden field value, if the value is an array, every element in the array will be rendered as a hidden field value.
Output
Exception

registerJavascriptPackages

public string registerJavascriptPackages (string $base , array $packages , boolean $debug , boolean $gzip )

Publishes a javascript library path and register packages to be loaded.

See TClientScriptLoader for component that enables users to register custom javascript libraries.

Input
string$basejavascript library base path
array$packageslist of packages or javascript files (without .js extension) to be loaded.
boolean$debugtrue to enable keep comments in javascript files loaded, null to use application configuration.
boolean$gziptrue to gzip the javascript code if browsers and php supports it.
Output
string javascript src url
Exception

registerPostBackControl

public void registerPostBackControl (string $class , array $options )

Registers postback javascript for a control. A null class parameter will prevent the javascript code registration.

Input
string$classjavascript class responsible for the control being registered for postback
array$optionspostback options
Output
Exception

registerPradoScript

public void registerPradoScript (string $name )

Registers Prado javascript by library name. See "Web/Javascripts/source/packages.php" for library names.

Input
string$namescript library name.
Output
Exception

registerScriptFile

public void registerScriptFile (string $key , string $url )

Registers a javascript file to be rendered within the form

Input
string$keya unique key identifying the file
string$urlURL to the javascript file to be rendered
Output
Exception

registerStyleSheet

public void registerStyleSheet (string $key , string $css , mixed $media )

Registers a CSS block to be rendered in the page head

Input
string$keya unique key identifying the CSS block
string$cssCSS block
mixed$media
Output
Exception

registerStyleSheetFile

public void registerStyleSheetFile (string $key , string $url , string $media )

Registers a CSS file to be rendered in the page head

The CSS files in themes are registered in OnPreRenderComplete if you want to override CSS styles in themes you need to register it after this event is completed.

Example:

  1. <?php
  2. class BasePage extends TPage {
  3. public function onPreRenderComplete($param) {
  4. parent::onPreRenderComplete($param);
  5. $url = 'path/to/your/stylesheet.css';
  6. $this->Page->ClientScript->registerStyleSheetFile($url, $url);
  7. }
  8. }
  9. ?>

Input
string$keya unique key identifying the file
string$urlURL to the CSS file
string$mediamedia type of the CSS (such as 'print', 'screen', etc.). Defaults to empty, meaning the CSS applies to all media types.
Output
Exception

renderBeginScripts

public void renderBeginScripts (THtmlWriter $writer )

Input
THtmlWriter$writerwriter for the rendering purpose
Output
Exception

renderEndScripts

public void renderEndScripts (THtmlWriter $writer )

Input
THtmlWriter$writerwriter for the rendering purpose
Output
Exception

renderHeadScriptFiles

public void renderHeadScriptFiles (THtmlWriter $writer )

Input
THtmlWriter$writerwriter for the rendering purpose
Output
Exception

renderHeadScripts

public void renderHeadScripts (THtmlWriter $writer )

Input
THtmlWriter$writerwriter for the rendering purpose
Output
Exception

renderHiddenFields

public void renderHiddenFields (THtmlWriter $writer )

Input
THtmlWriter$writerwriter for the rendering purpose
Output
Exception

renderPradoScripts

protected void renderPradoScripts (THtmlWriter $writer )

Renders the HTML tags for PRADO js files

Input
THtmlWriter$writerwriter
Output
Exception

renderScriptFiles

public void renderScriptFiles (THtmlWriter $writer )

Input
THtmlWriter$writerwriter for the rendering purpose
Output
Exception

renderStyleSheetFiles

public void renderStyleSheetFiles (THtmlWriter $writer )

Input
THtmlWriter$writerwriter for the rendering purpose
Output
Exception

renderStyleSheets

public void renderStyleSheets (THtmlWriter $writer )

Input
THtmlWriter$writerwriter for the rendering purpose
Output
Exception

verifyJavascriptPackages

protected void verifyJavascriptPackages (mixed $base , mixed $path , mixed $scripts )

Input
mixed$base
mixed$path
mixed$scripts
Output
Exception
throwsTConfigurationException when javascript packages mismatch.


Constant Details

SCRIPT_LOADER

the PHP script for loading Prado javascript files

Type:

string

Value:

'Web/Javascripts/clientscripts.php'

SCRIPT_PATH

directory containing Prado javascript files

Type:

string

Value:

'Web/Javascripts/source'