Class TClientScriptManager

Description

TClientScriptManager class.

TClientScriptManager manages javascript and CSS stylesheets for a page.

  • author: Gabor Berczi <gabor.berczi@devworx.hu> (lazyload additions & progressive rendering)
  • author: Qiang Xue <qiang.xue@gmail.com>
  • version: $Id: TClientScriptManager.php 3167 2012-06-25 09:25:11Z ctrlaltca $
  • since: 3.0

Located in /Web/UI/TClientScriptManager.php (line 25)

TComponent
   |
   --TApplicationComponent
      |
      --TClientScriptManager
Class Constant Summary
 PACKAGES_FILE = 'Web/Javascripts/packages.php'
 SCRIPT_PATH = 'Web/Javascripts/source'
Method Summary
static void getPradoPackages ()
static void getPradoScripts ()
TClientScriptManager __construct (TPage $owner)
void flushScriptFiles (THtmlWriter $writer, [TControl $control = null])
string getCallbackReference ( $callbackHandler, [array $options = null])
array getDefaultButtonOptions (string $panelID, string $buttonID)
void getHiddenFields ()
array getPackagePathUrl (string $base)
boolean getRequiresHead ()
array getScriptUrls ()
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 markScriptFileAsRendered ( $url)
void registerBeginScript (string $key, string $script)
void registerCallbackControl (string $class, array $options)
void registerDefaultButton (TControl|string $panel, TControl|string $button)
void registerEndScript (string $key, string $script)
void registerFocusControl (string $target)
void registerHeadScript (string $key, string $script)
void registerHeadScriptFile (string $key, string $url)
void registerHiddenField (string $name, string|array $value)
void registerPostBackControl (string $class, array $options)
void registerPradoScript (string $name)
void registerScriptFile (string $key, string $url)
void registerStyleSheet (string $key, string $css, [ $media = ''])
void registerStyleSheetFile (string $key, string $url, [string $media = ''])
void renderEndScripts (THtmlWriter $writer)
void renderHeadScripts (THtmlWriter $writer)
void renderHiddenFieldsBegin ( $writer)
void renderHiddenFieldsEnd ( $writer)
void renderHiddenFieldsInt (THtmlWriter $writer,  $initial)
void renderScriptFiles ( $writer,  $scripts)
void renderScriptFilesBegin ( $writer)
void renderScriptFilesEnd ( $writer)
void renderStyleSheets (THtmlWriter $writer)
Methods
static method getPradoPackages (line 111)
  • access: public
static void getPradoPackages ()
static method getPradoScripts (line 116)
  • access: public
static void getPradoScripts ()
Constructor __construct (line 96)

Constructor.

  • access: public
TClientScriptManager __construct (TPage $owner)
  • TPage $owner: page that owns this client script manager
checkIfNotInRender (line 745)

Checks whether page rendering has not begun yet

  • access: protected
void checkIfNotInRender ()
flushScriptFiles (line 705)

Flushes all pending script registrations

  • access: public
void flushScriptFiles (THtmlWriter $writer, [TControl $control = null])
  • THtmlWriter $writer: writer for the rendering purpose
  • TControl $control: the control forcing the flush (used only in error messages)
getCallbackReference (line 244)

Returns javascript statement that create a new callback request object.

  • return: javascript statement that creates a new callback request.
  • access: public
string getCallbackReference ( $callbackHandler, [array $options = null])
  • ICallbackEventHandler $callbackHandler: callback response handler
  • array $options: additional callback options
getDefaultButtonOptions (line 330)
  • return: default button options.
  • access: protected
array getDefaultButtonOptions (string $panelID, string $buttonID)
  • string $panelID: the unique ID of the container control
  • string $buttonID: the unique ID of the button control
getHiddenFields (line 737)
  • access: public
void getHiddenFields ()
getPackagePathUrl (line 222)
  • return: tuple($path,$url).
  • access: protected
array getPackagePathUrl (string $base)
  • string $base: javascript package path.
getPradoScriptAssetUrl (line 198)
  • return: Prado javascript library base asset url.
  • access: public
string getPradoScriptAssetUrl ()
getRenderedScriptFiles (line 657)
  • access: protected
void getRenderedScriptFiles ()
getRequiresHead (line 105)
  • return: whether THead is required in order to render CSS and js within head
  • since: 3.1.1
  • access: public
boolean getRequiresHead ()
getScriptUrls (line 209)

Returns the URLs of all script files referenced on the page

  • return: Combined list of all script urls used in the page
  • access: public
array getScriptUrls ()
getStyleSheetUrls (line 406)

Returns the URLs of all stylesheet files referenced on the page

  • return: Combined list of all stylesheet urls used in the page
  • access: public
array getStyleSheetUrls ()
hasBeginScripts (line 576)
  • return: true if any begin scripts are registered.
  • access: public
boolean hasBeginScripts ()
hasEndScripts (line 568)
  • return: true if any end scripts are registered.
  • access: public
boolean hasEndScripts ()
isBeginScriptRegistered (line 551)
  • return: whether there is a beginning javascript block registered with the specified key
  • access: public
boolean isBeginScriptRegistered (string $key)
  • string $key: a unique key
isEndScriptRegistered (line 560)
  • return: whether there is an ending javascript block registered with the specified key
  • access: public
boolean isEndScriptRegistered (string $key)
  • string $key: a unique key
isHeadScriptFileRegistered (line 524)
  • return: whether there is a head javascript file registered with the specified key
  • access: public
boolean isHeadScriptFileRegistered (string $key)
  • string $key: a unique key
isHeadScriptRegistered (line 533)
  • return: whether there is a head javascript block registered with the specified key
  • access: public
boolean isHeadScriptRegistered (string $key)
  • string $key: a unique key
isHiddenFieldRegistered (line 585)
  • return: whether there is a hidden field registered with the specified key
  • access: public
boolean isHiddenFieldRegistered (string $key)
  • string $key: a unique key
isScriptFileRegistered (line 542)
  • return: whether there is a javascript file registered with the specified key
  • access: public
boolean isScriptFileRegistered (string $key)
  • string $key: a unique key
isStyleSheetFileRegistered (line 506)
  • return: whether there is a CSS file registered with the specified key
  • access: public
boolean isStyleSheetFileRegistered (string $key)
  • string $key: a unique key
isStyleSheetRegistered (line 515)
  • return: whether there is a CSS block registered with the specified key
  • access: public
boolean isStyleSheetRegistered (string $key)
  • string $key: a unique key
markScriptFileAsRendered (line 641)
  • access: public
void markScriptFileAsRendered ( $url)
  • $url
registerBeginScript (line 466)

Registers a javascript script block at the beginning of the form

  • access: public
void registerBeginScript (string $key, string $script)
  • string $key: a unique key identifying the script block
  • string $script: javascript block
registerCallbackControl (line 261)

Registers callback javascript for a control.

  • access: public
void registerCallbackControl (string $class, array $options)
  • string $class: javascript class responsible for the control being registered for callback
  • array $options: callback options
registerDefaultButton (line 303)

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

  • access: public
void registerDefaultButton (TControl|string $panel, TControl|string $button)
  • 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
registerEndScript (line 480)

Registers a javascript script block at the end of the form

  • access: public
void registerEndScript (string $key, string $script)
  • string $key: a unique key identifying the script block
  • string $script: javascript block
registerFocusControl (line 343)

Registers the control to receive default focus.

  • access: public
void registerFocusControl (string $target)
  • string $target: the client ID of the control to receive default focus
registerHeadScript (line 439)

Registers a javascript block in the page head.

  • access: public
void registerHeadScript (string $key, string $script)
  • string $key: a unique key identifying the script block
  • string $script: javascript block
registerHeadScriptFile (line 425)

Registers a javascript file in the page head

  • access: public
void registerHeadScriptFile (string $key, string $url)
  • string $key: a unique key identifying the file
  • string $url: URL to the javascript file
registerHiddenField (line 494)

Registers a hidden field to be rendered in the form.

  • access: public
void registerHiddenField (string $name, string|array $value)
  • 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.
registerPostBackControl (line 278)

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

  • access: public
void registerPostBackControl (string $class, array $options)
  • string $class: javascript class responsible for the control being registered for postback
  • array $options: postback options
registerPradoScript (line 126)

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

  • access: public
void registerPradoScript (string $name)
  • string $name: script library name.
registerPradoScriptInternal (line 136)

Registers a Prado javascript library to be loaded.

  • access: protected
void registerPradoScriptInternal ( $name)
  • $name
registerScriptFile (line 453)

Registers a javascript file to be rendered within the form

  • access: public
void registerScriptFile (string $key, string $url)
  • string $key: a unique key identifying the file
  • string $url: URL to the javascript file to be rendered
registerStyleSheet (line 394)

Registers a CSS block to be rendered in the page head

  • access: public
void registerStyleSheet (string $key, string $css, [ $media = ''])
  • string $key: a unique key identifying the CSS block
  • string $css: CSS block
  • $media
registerStyleSheetFile (line 378)

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.  ?>

  • access: public
void registerStyleSheetFile (string $key, string $url, [string $media = ''])
  • 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.
renderAllPendingScriptFiles (line 665)
  • access: public
void renderAllPendingScriptFiles (THtmlWriter $writer)
  • THtmlWriter $writer: writer for the rendering purpose
renderBeginScripts (line 677)
  • access: public
void renderBeginScripts (THtmlWriter $writer)
  • THtmlWriter $writer: writer for the rendering purpose
renderEndScripts (line 685)
  • access: public
void renderEndScripts (THtmlWriter $writer)
  • THtmlWriter $writer: writer for the rendering purpose
renderHeadScriptFiles (line 618)
  • access: public
void renderHeadScriptFiles (THtmlWriter $writer)
  • THtmlWriter $writer: writer for the rendering purpose
renderHeadScripts (line 626)
  • access: public
void renderHeadScripts (THtmlWriter $writer)
  • THtmlWriter $writer: writer for the rendering purpose
renderHiddenFieldsBegin (line 690)
  • access: public
void renderHiddenFieldsBegin ( $writer)
  • $writer
renderHiddenFieldsEnd (line 695)
  • access: public
void renderHiddenFieldsEnd ( $writer)
  • $writer
renderHiddenFieldsInt (line 714)
  • access: protected
void renderHiddenFieldsInt (THtmlWriter $writer,  $initial)
  • THtmlWriter $writer: writer for the rendering purpose
  • $initial
renderScriptFiles (line 648)
  • access: protected
void renderScriptFiles ( $writer,  $scripts)
  • $writer
  • Array $scripts
renderScriptFilesBegin (line 631)
  • access: public
void renderScriptFilesBegin ( $writer)
  • $writer
renderScriptFilesEnd (line 636)
  • access: public
void renderScriptFilesEnd ( $writer)
  • $writer
renderStyleSheetFiles (line 593)
  • access: public
void renderStyleSheetFiles (THtmlWriter $writer)
  • THtmlWriter $writer: writer for the rendering purpose
renderStyleSheets (line 609)
  • access: public
void renderStyleSheets (THtmlWriter $writer)
  • THtmlWriter $writer: writer for the rendering purpose

Inherited Methods

Inherited From TApplicationComponent

TApplicationComponent::getApplication()
TApplicationComponent::getRequest()
TApplicationComponent::getResponse()
TApplicationComponent::getService()
TApplicationComponent::getSession()
TApplicationComponent::getUser()
TApplicationComponent::publishAsset()
TApplicationComponent::publishFilePath()

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::__call()
TComponent::__get()
TComponent::__set()
TComponent::__sleep()
TComponent::__wakeup()
Class Constants
PACKAGES_FILE = 'Web/Javascripts/packages.php' (line 34)

file containing javascript packages and their cross dependencies

SCRIPT_PATH = 'Web/Javascripts/source' (line 30)

directory containing Prado javascript files

Documentation generated on Mon, 25 Jun 2012 14:37:34 +0200 by phpDocumentor 1.4.3