- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

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: IBroadcastEventReceiver IButtonControl INamingContainer IPageStatePersister IPostBackDataHandler IPostBackEventHandler ISurroundable ITemplate ITheme IValidatable IValidator TBroadcastEventParameter TCachePageStatePersister TClientScriptManager TClientSideOptions TCommandEventParameter TCompositeControl TCompositeLiteral TControl TControlAdapter TControlCollection TEmptyControlCollection TForm THead THtmlWriter TPage TPageStateFormatter TPageStatePersister TSessionPageStatePersister TTemplate TTemplateControl TTemplateManager TTextProcessor TTheme TThemeManager |
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 | getPradoScriptAssetUrl ()
boolean | getRequiresHead ()
boolean | hasBeginScripts ()
boolean | hasEndScripts ()
boolean | isBeginScriptRegistered ( string $key)
boolean | isEndScriptRegistered ( string $key)
boolean | isHeadScriptFileRegistered ( string $key)
boolean | isHeadScriptRegistered ( string $key)
boolean | isHiddenFieldRegistered ( string $key)
boolean | isScriptFileRegistered ( string $key)
boolean | isStyleSheetFileRegistered ( string $key)
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 | renderBeginScripts ( THtmlWriter $writer)
void | renderEndScripts ( THtmlWriter $writer)
void | renderHeadScriptFiles ( THtmlWriter $writer)
void | renderHeadScripts ( THtmlWriter $writer)
void | renderHiddenFields ( THtmlWriter $writer)
protected void | renderPradoScripts ( THtmlWriter $writer) Renders the HTML tags for PRADO js files
void | renderScriptFiles ( THtmlWriter $writer)
void | renderStyleSheetFiles ( THtmlWriter $writer)
void | renderStyleSheets ( THtmlWriter $writer)
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 | $callbackHandler | callback response handler
array | $options | additional callback options
Output
string | javascript statement that creates a new callback request.
Exception
## getDefaultButtonOptions
protected array getDefaultButtonOptions | (string $panelID , string $buttonID )
Input
string | $panelID | the unique ID of the container control
string | $buttonID | the unique ID of the button control
Output
array | default button options.
Exception
## getPackagePathUrl
protected array getPackagePathUrl | (string $base )
Input
string | $base | javascript 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 | $key | a 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 | $key | a 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 | $key | a 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 | $key | a 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 | $key | a unique key
Output
boolean | whether there is a hidden field registered with the specified key
Exception
## isScriptFileRegistered
public boolean isScriptFileRegistered | (string $key )
Input
string | $key | a unique key
Output
boolean | whether there is a javascript file registered with the specified key
Exception
## isStyleSheetFileRegistered
public boolean isStyleSheetFileRegistered | (string $key )
Input
string | $key | a unique key
Output
boolean | whether there is a CSS file registered with the specified key
Exception
## isStyleSheetRegistered
public boolean isStyleSheetRegistered | (string $key )
Input
string | $key | a 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 | $key | a unique key identifying the script block
string | $script | javascript block
Output
Exception
## registerCallbackControl
public void registerCallbackControl | (string $class , array $options )
Registers callback javascript for a control.
Input
string | $class | javascript class responsible for the control being registered for callback
array | $options | callback 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 | $panel | panel (or its unique ID) to register the default button action
TControl|string | $button | button (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 | $key | a unique key identifying the script block
string | $script | javascript block
Output
Exception
## registerFocusControl
public void registerFocusControl | (string $target )
Registers the control to receive default focus.
Input
string | $target | the 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 | $key | a unique key identifying the script block
string | $script | javascript block
Output
Exception
## registerHeadScriptFile
public void registerHeadScriptFile | (string $key , string $url )
Registers a javascript file in the page head
Input
string | $key | a unique key identifying the file
string | $url | URL 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 | $name | a unique key identifying the hidden field
string|array | $value | hidden 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 | $base | javascript library base path
array | $packages | list of packages or javascript files (without .js extension) to be loaded.
boolean | $debug | true to enable keep comments in javascript files loaded, null to use application configuration.
boolean | $gzip | true 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 | $class | javascript class responsible for the control being registered for postback
array | $options | postback 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 | $name | script library name.
Output
Exception
## registerScriptFile
public void registerScriptFile | (string $key , string $url )
Registers a javascript file to be rendered within the form
Input
string | $key | a unique key identifying the file
string | $url | URL 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 | $key | a unique key identifying the CSS block
string | $css | CSS 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:

     <?php
     class BasePage extends TPage {
       public function onPreRenderComplete($param) {
         parent::onPreRenderComplete($param);
         $url = 'path/to/your/stylesheet.css';
         $this->Page->ClientScript->registerStyleSheetFile($url, $url);
       }
     }
     ?>
Input
string | $key | a unique key identifying the file
string | $url | URL to the CSS file
string | $media | media 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 | $writer | writer for the rendering purpose
Output
Exception
## renderEndScripts
public void renderEndScripts | (THtmlWriter $writer )
Input
THtmlWriter | $writer | writer for the rendering purpose
Output
Exception
## renderHeadScriptFiles
public void renderHeadScriptFiles | (THtmlWriter $writer )
Input
THtmlWriter | $writer | writer for the rendering purpose
Output
Exception
## renderHeadScripts
public void renderHeadScripts | (THtmlWriter $writer )
Input
THtmlWriter | $writer | writer for the rendering purpose
Output
Exception
## renderHiddenFields
public void renderHiddenFields | (THtmlWriter $writer )
Input
THtmlWriter | $writer | writer for the rendering purpose
Output
Exception
## renderPradoScripts
protected void renderPradoScripts | (THtmlWriter $writer )
Renders the HTML tags for PRADO js files
Input
THtmlWriter | $writer | writer
Output
Exception
## renderScriptFiles
public void renderScriptFiles | (THtmlWriter $writer )
Input
THtmlWriter | $writer | writer for the rendering purpose
Output
Exception
## renderStyleSheetFiles
public void renderStyleSheetFiles | (THtmlWriter $writer )
Input
THtmlWriter | $writer | writer for the rendering purpose
Output
Exception
## renderStyleSheets
public void renderStyleSheets | (THtmlWriter $writer )
Input
THtmlWriter | $writer | writer 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
throws | TConfigurationException 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'