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

Class: HTML_QuickForm2_JavascriptBuilder

Source Location: /HTML_QuickForm2-2.1.0/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 38]
Javascript aggregator and builder class


[ Top ]


Class Variables

$defaultAbsPath =

[line 79]

Default filesystem path to JS library files
  • Access: protected

Type:   string


[ Top ]

$defaultWebPath =

[line 73]

Default web path to JS library files
  • Access: protected

Type:   string


[ Top ]

$forceValidator = array()

[line 59]

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 85]

Current form ID
  • Access: protected

Type:   string


[ Top ]

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

[line 65]

Javascript libraries
  • Access: protected

Type:   array


[ Top ]

$rules = array()

[line 44]

Client-side rules
  • Access: protected

Type:   array


[ Top ]

$scripts = array()

[line 50]

Elements' setup code
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 97]

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 208]

void addElementJavascript( string $script)

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

Parameters:

string   $script   — 

[ Top ]

addLibrary   [line 126]

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 197]

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 313]

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 370]

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 217]

void forceValidator( )

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

[ Top ]

getFormJavascript   [line 231]

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 143]

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 247]

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 267]

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 181]

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 290]

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 Wed, 10 Apr 2019 08:56:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.