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

Class: HTML_QuickForm_hierselect

Source Location: /main/inc/lib/pear/HTML/QuickForm/hierselect.php

Class Overview

HTML_Common
   |
   --HTML_QuickForm_element
      |
      --HTML_QuickForm_group
         |
         --HTML_QuickForm_hierselect

Class to dynamically create two or more HTML Select elements The first select changes the content of the second select and so on.


Author(s):

Version:

  • 1.0

Variables

Methods


Inherited Variables

Inherited Methods

Class: HTML_QuickForm_group

HTML_QuickForm_group::HTML_QuickForm_group()
Class constructor
HTML_QuickForm_group::accept()
Accepts a renderer
HTML_QuickForm_group::exportValue()
As usual, to get the group's value we access its elements and call
HTML_QuickForm_group::freeze()
HTML_QuickForm_group::getElementName()
Returns the element name inside the group such as found in the html form
HTML_QuickForm_group::getElements()
Gets the grouped elements
HTML_QuickForm_group::getFrozenHtml()
Returns the value of field without HTML tags
HTML_QuickForm_group::getGroupType()
Gets the group type based on its elements Will return 'mixed' if elements contained in the group are of different types.
HTML_QuickForm_group::getName()
Returns the group name
HTML_QuickForm_group::getValue()
Returns the value of the group
HTML_QuickForm_group::onQuickFormEvent()
Called by HTML_QuickForm whenever form event is made on this element
HTML_QuickForm_group::setElements()
Sets the grouped elements
HTML_QuickForm_group::setName()
Sets the group name
HTML_QuickForm_group::setPersistantFreeze()
HTML_QuickForm_group::setValue()
Sets values for group's elements
HTML_QuickForm_group::toHtml()
Returns Html for the group
HTML_QuickForm_group::unfreeze()
HTML_QuickForm_group::_createElements()
Creates the group's elements.
HTML_QuickForm_group::_createElementsIfNotExist()
A wrapper around _createElements()

Class: HTML_QuickForm_element

HTML_QuickForm_element::HTML_QuickForm_element()
Class constructor
HTML_QuickForm_element::accept()
Accepts a renderer
HTML_QuickForm_element::apiVersion()
Returns the current API version
HTML_QuickForm_element::exportValue()
Returns a 'safe' element's value
HTML_QuickForm_element::freeze()
Freeze the element so that only its value is returned
HTML_QuickForm_element::getFrozenHtml()
Returns the value of field without HTML tags
HTML_QuickForm_element::getLabel()
Returns display text for the element
HTML_QuickForm_element::getName()
Returns the element name
HTML_QuickForm_element::getType()
Returns element type
HTML_QuickForm_element::getValue()
Returns the value of the form element
HTML_QuickForm_element::isFrozen()
Returns whether or not the element is frozen
HTML_QuickForm_element::onQuickFormEvent()
Called by HTML_QuickForm whenever form event is made on this element
HTML_QuickForm_element::setLabel()
Sets display text for the element
HTML_QuickForm_element::setName()
Sets the input field name
HTML_QuickForm_element::setPersistantFreeze()
Sets wether an element value should be kept in an hidden field when the element is frozen or not
HTML_QuickForm_element::setValue()
Sets the value of the form element
HTML_QuickForm_element::unfreeze()
Unfreezes the element so that it becomes editable
HTML_QuickForm_element::_findValue()
Tries to find the element value from the values array
HTML_QuickForm_element::_generateId()
Automatically generates and assigns an 'id' attribute for the element.
HTML_QuickForm_element::_getPersistantData()
Used by getFrozenHtml() to pass the element's value if _persistantFreeze is on
HTML_QuickForm_element::_prepareValue()
Used by exportValue() to prepare the value for returning

Class: HTML_Common

HTML_Common::HTML_Common()
Class constructor
HTML_Common::apiVersion()
Returns the current API version
HTML_Common::display()
Displays the HTML to the screen
HTML_Common::getAttribute()
Returns the value of the given attribute
HTML_Common::getAttributes()
Returns the assoc array (default) or string of attributes
HTML_Common::getComment()
Returns the HTML comment
HTML_Common::getTabOffset()
Returns the tabOffset
HTML_Common::removeAttribute()
Removes an attribute
HTML_Common::setAttributes()
Sets the HTML attributes
HTML_Common::setComment()
Sets the HTML comment to be displayed at the beginning of the HTML string
HTML_Common::setLineEnd()
Sets the line end style to Windows, Mac, Unix or a custom string.
HTML_Common::setTab()
Sets the string used to indent HTML
HTML_Common::setTabOffset()
Sets the tab offset
HTML_Common::toHtml()
Abstract method. Must be extended to return the objects HTML
HTML_Common::updateAttributes()
Updates the passed attributes without changing the other existing attributes
HTML_Common::_getAttrKey()
Returns the array key for the given non-name-value pair attribute
HTML_Common::_getAttrString()
Returns an HTML formatted attribute string
HTML_Common::_getLineEnd()
Returns the lineEnd
HTML_Common::_getTab()
Returns a string containing the unit for indenting HTML
HTML_Common::_getTabs()
Returns a string containing the offset for the whole HTML code
HTML_Common::_parseAttributes()
Returns a valid atrributes array from either a string or array
HTML_Common::_removeAttr()
Removes the given attribute from the given array
HTML_Common::_updateAttrArray()
Updates the attributes in $attr1 with the values in $attr2 without changing the other existing attributes

Class Details

[line 38]
Class to dynamically create two or more HTML Select elements The first select changes the content of the second select and so on.

This element is considered as a group. Selects will be named groupName[0], groupName[1], groupName[2]...




Tags:

author:  Herim Vasquez <vasquezh@iro.umontreal.ca>
author:  Bertrand Mansion <bmansion@mamasam.com>
version:  1.0
since:  PHP4.04pl1
access:  public


[ Top ]


Class Variables

$_js =  ''

[line 100]

The javascript used to set and change the options



Tags:

access:  private

Type:   string


[ Top ]

$_nbElements =  0

[line 92]

Number of select elements on this group



Tags:

access:  private

Type:   int


[ Top ]

$_options = array()

[line 84]

Options for all the select elements

Format is a bit more complex as we need to know which options are related to the ones in the previous select:

Ex: // first select $select1[0] = 'Pop'; $select1[1] = 'Classical'; $select1[2] = 'Funeral doom';

// second select $select2[0][0] = 'Red Hot Chil Peppers'; $select2[0][1] = 'The Pixies'; $select2[1][0] = 'Wagner'; $select2[1][1] = 'Strauss'; $select2[2][0] = 'Pantheist'; $select2[2][1] = 'Skepticism';

// If only need two selects // - and using the depracated functions $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:'); $sel->setMainOptions($select1); $sel->setSecOptions($select2);

// - and using the new setOptions function $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:'); $sel->setOptions(array($select1, $select2));

// If you have a third select with prices for the cds $select3[0][0][0] = '15.00$'; $select3[0][0][1] = '17.00$'; etc

// You can now use $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:'); $sel->setOptions(array($select1, $select2, $select3));




Tags:

access:  private

Type:   array


[ Top ]



Class Methods


constructor HTML_QuickForm_hierselect [line 117]

void HTML_QuickForm_hierselect( [string $elementName = null], [string $elementLabel = null], [mixed $attributes = null], [mixed $separator = null])

Class constructor



Tags:

access:  public


Parameters:

string   $elementName   (optional)Input field name attribute
string   $elementLabel   (optional)Input field label in form
mixed   $attributes   (optional)Either a typical HTML attribute string or an associative array. Date format is passed along the attributes.
mixed   $separator   (optional)Use a string for one separator, use an array to alternate the separators.

[ Top ]

method accept [line 463]

void accept( &$renderer, [ $required = false], [ $error = null])



Overrides HTML_QuickForm_group::accept() (Accepts a renderer)

Parameters:

   &$renderer  
   $required  
   $error  

[ Top ]

method onQuickFormEvent [line 471]

void onQuickFormEvent( $event, $arg, &$caller)



Overrides HTML_QuickForm_group::onQuickFormEvent() (Called by HTML_QuickForm whenever form event is made on this element)

Parameters:

   $event  
   $arg  
   &$caller  

[ Top ]

method setMainOptions [line 172]

void setMainOptions( array $array)

Sets the options for the first select element. Deprecated. setOptions() should be used.



Tags:

deprecated:  Deprecated since release 3.2.2
access:  public


Parameters:

array   $array   Options for the first select element

[ Top ]

method setOptions [line 140]

void setOptions( array $options)

Initialize the array structure containing the options for each select element.

Call the functions that actually do the magic.




Tags:

access:  public


Parameters:

array   $options   Array of options defining each element

[ Top ]

method setSecOptions [line 195]

void setSecOptions( array $array)

Sets the options for the second select element. Deprecated. setOptions() should be used.

The main _options array is initialized and the _setOptions function is called.




Tags:

deprecated:  Deprecated since release 3.2.2
access:  public


Parameters:

array   $array   Options for the second select element

[ Top ]

method setValue [line 252]

void setValue( array $value)

Sets values for group's elements



Tags:

access:  public


Overrides HTML_QuickForm_group::setValue() (Sets values for group's elements)

Parameters:

array   $value   An array of 2 or more values, for the first, the second, the third etc. select

[ Top ]

method toHtml [line 281]

void toHtml( )



Overrides HTML_QuickForm_group::toHtml() (Returns Html for the group)

[ Top ]

method _convertArrayToJavascript [line 507]

string _convertArrayToJavascript( array $array, [bool $assoc = true])

Converts PHP array to its Javascript analog



Tags:

return:  Javascript representation of the value
access:  private


Parameters:

array   $array   PHP array to convert
bool   $assoc   Generate Javascript object literal (default, works like PHP's associative array) or array literal

[ Top ]

method _convertScalarToJavascript [line 537]

string _convertScalarToJavascript( mixed $val)

Converts PHP's scalar value to its Javascript analog



Tags:

return:  Javascript representation of the value
access:  private


Parameters:

mixed   $val   PHP value to convert

[ Top ]

method _createElements [line 271]

void _createElements( )

Creates all the elements for the group



Tags:

access:  private


Overrides HTML_QuickForm_group::_createElements() (Creates the group's elements.)

[ Top ]

method _escapeString [line 563]

string _escapeString( string $str)

Quotes the string so that it can be used in Javascript string constants



Tags:

access:  private


Parameters:

string   $str  

[ Top ]

method _setOptions [line 224]

void _setOptions( )

Sets the options for each select element



Tags:

access:  private


[ Top ]


Documentation generated on Thu, 12 Jun 2008 13:38:57 -0500 by phpDocumentor 1.4.1