HTML_QuickForm2
[ class tree: HTML_QuickForm2 ] [ index: HTML_QuickForm2 ] [ all elements ]

Class: HTML_QuickForm2_JavascriptBuilder

Source Location: /HTML_QuickForm2-2.0.2/HTML/QuickForm2/JavascriptBuilder.php

Class Overview


Javascript aggregator and builder class


Author(s):

Version:

  • Release: @package_version@

Variables

Methods


Child classes:

HTML_QuickForm2_Container_Repeat_JavascriptBuilder
Javascript builder used when rendering a repeat prototype

Inherited Variables

Inherited Methods


Class Details

[line 61]
Javascript aggregator and builder class


[ Top ]


Class Variables

$defaultAbsPath =

[line 102]

Default filesystem path to JS library files
  • Access: protected

Type:   string


[ Top ]

$defaultWebPath =

[line 96]

Default web path to JS library files
  • Access: protected

Type:   string


[ Top ]

$forceValidator = array()

[line 82]

Whether to generate a validator object for the form if no rules are present

Needed when the form contains an empty repeat element

  • Access: protected

Type:   array


[ Top ]

$formId =  null

[line 108]

Current form ID
  • Access: protected

Type:   string


[ Top ]

$libraries = array(
        'base' => array('file' => 'quickform.js'))

[line 88]

Javascript libraries
  • Access: protected

Type:   array


[ Top ]

$rules = array()

[line 67]

Client-side rules
  • Access: protected

Type:   array


[ Top ]

$scripts = array()

[line 73]

Elements' setup code
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 120]

HTML_QuickForm2_JavascriptBuilder __construct( [string $defaultWebPath = 'js/'], [string $defaultAbsPath = null])

Constructor, sets default web path to JS library files and default filesystem path
  • Access: public

Parameters:

string   $defaultWebPath     default web path to JS library files (to use in <script src="...">)
string   $defaultAbsPath     default filesystem path to JS library files (to inline these files into the page), this is set to a package subdirectory of PEAR data_dir if not given

[ Top ]

addElementJavascript   [line 231]

void addElementJavascript( string $script)

Adds element's setup code to form's Javascript
  • Access: public

Parameters:

string   $script     

[ Top ]

addLibrary   [line 149]

void addLibrary( string $name, string $fileName, [string $webPath = null], [string $absPath = null])

Adds a Javascript library file to the list
  • Access: public

Parameters:

string   $name     name to reference the library by
string   $fileName     file name, without path
string   $webPath     path relative to web root to reference in <script src="">, $defaultWebPath will be used if not given
string   $absPath     filesystem path where the file resides, used when inlining libraries, $defaultAbsPath will be used if not given

[ Top ]

addRule   [line 220]

void addRule( HTML_QuickForm2_Rule $rule, [bool $triggers = false])

Adds the Rule javascript to the list of current form Rules
  • Access: public

Parameters:

HTML_QuickForm2_Rule   $rule     Rule instance
bool   $triggers     Whether rule code should contain "triggers" for live validation

[ Top ]

encode   [line 331]

string encode( mixed $value)

Encodes a value for use as Javascript literal

NB: unlike json_encode() we do not enforce UTF-8 charset here

  • Return: value as Javascript literal
  • Access: public

Parameters:

mixed   $value     

[ Top ]

encodeNameValue   [line 388]

string encodeNameValue( mixed $name, mixed $value)

Callback for array_map used to generate name-value pairs
  • Access: protected

Parameters:

mixed   $name     
mixed   $value     

[ Top ]

forceValidator   [line 240]

void forceValidator( )

Enables generating a validator for the current form even if no rules are present
  • Access: public

[ Top ]

getFormJavascript   [line 254]

string getFormJavascript( [string $formId = null], [boolean $addScriptTags = true])

Returns per-form javascript (client-side validation and elements' setup)
  • Access: public

Parameters:

string   $formId     form ID, if empty returns code for all forms
boolean   $addScriptTags     whether to enclose code in <script> tags

[ Top ]

getLibraries   [line 166]

string|array getLibraries( [bool $inline = false], [bool $addScriptTags = true])

Returns Javascript libraries
  • Access: public

Parameters:

bool   $inline     whether to return a list of library file names or contents of files
bool   $addScriptTags     whether to enclose the results in <script> tags

[ Top ]

getSetupCode   [line 270]

string getSetupCode( [string $formId = null], [bool $addScriptTags = false])

Returns setup code for form elements
  • Access: public

Parameters:

string   $formId     form ID, if empty returns code for all forms
bool   $addScriptTags     whether to enclose code in <script> tags

[ Top ]

getValidator   [line 290]

string getValidator( [string $formId = null], [bool $addScriptTags = false])

Returns client-side validation code
  • Access: public

Parameters:

string   $formId     form ID, if empty returns code for all forms
bool   $addScriptTags     whether to enclose code in <script> tags

[ Top ]

setFormId   [line 204]

void setFormId( string $formId)

Sets ID of the form currently being processed

All subsequent calls to addRule() and addElementJavascript() will store the scripts for that form

  • Access: public

Parameters:

string   $formId     

[ Top ]

wrapScript   [line 313]

string wrapScript( string $js)

Wraps the given Javascript code in <script> tags
  • Return: code wrapped in <script></script> tags, empty string if $js is empty
  • Access: protected

Parameters:

string   $js     Javascript code

[ Top ]


Documentation generated on Sat, 28 Jun 2014 09:30:22 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.