Source for file Object.php
Documentation is available at Object.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Ron McClain <ron@humaniq.com> |
// +----------------------------------------------------------------------+
// $Id: Object.php,v 1.2 2003/11/03 12:53:01 avb Exp $
require_once('HTML/QuickForm/Renderer.php');
* A concrete renderer for HTML_QuickForm, makes an object from form contents
* Based on HTML_Quickform_Renderer_Array code
* The object being generated
* Number of sections in the form (i.e. number of headers in it)
* @var integer $_sectionCount
* @var integer $_currentSection
* Object representing current group
* @var object $_currentGroup
var $_currentGroup = null;
* Class of Element Objects
* @var object $_elementType
var $_elementType = 'QuickFormElement';
* Additional style information for different elements
* @var array $_elementStyles
var $_elementStyles = array ();
* true: collect all hidden elements into string; false: process them as usual form elements
* @var bool $_collectHidden
var $_collectHidden = false;
* @param collecthidden bool true: collect all hidden elements
$this->HTML_QuickForm_Renderer ();
$this->_collectHidden = $collecthidden;
* Return the rendered Object
* Set the class of the form elements. Defaults to StdClass.
* @param type string Name of element class
$this->_elementType = $type;
$this->_obj->frozen = $form->isFrozen ();
$this->_obj->javascript = $form->getValidationScript ();
$this->_obj->attributes = $form->getAttributes (true );
$this->_obj->requirednote = $form->getRequiredNote ();
$this->_obj->errors = new StdClass;
if($this->_collectHidden) {
$this->_obj->hidden = '';
$this->_currentSection = null;
$this->_sectionCount = 0;
$hobj->header = $header->toHtml ();
$this->_obj->sections [$this->_sectionCount] = $hobj;
$this->_currentSection = $this->_sectionCount++;
$elObj = $this->_elementToObject ($element, $required, $error);
$this->_obj->errors ->$name = $error;
$this->_storeObject ($elObj);
} // end func renderElement
if($this->_collectHidden) {
$this->_obj->hidden .= $element->toHtml () . "\n";
} //end func renderHidden
$this->_currentGroup = $this->_elementToObject ($group, $required, $error);
$name = $this->_currentGroup->name;
$this->_view->errors ->$name = $error;
$this->_storeObject ($this->_currentGroup);
$this->_currentGroup = null;
} // end func finishGroup
* Creates an object representing an element
* @param element object An HTML_QuickForm_element object
* @param required bool Whether an element is required
* @param error string Error associated with the element
function _elementToObject (&$element, $required, $error)
if($this->_elementType) {
$ret = new $this->_elementType;
$ret->name = $element->getName ();
$ret->value = $element->getValue ();
$ret->type = $element->getType ();
$ret->frozen = $element->isFrozen ();
$labels = $element->getLabel ();
foreach ($labels as $key => $label) {
$key = is_int($key)? $key + 2: $key;
$ret->{'label_' . $key} = $label;
$ret->required = $required;
if(isset ($this->_elementStyles [$ret->name ])) {
$ret->style = $this->_elementStyles [$ret->name ];
$ret->styleTemplate = "styles/". $ret->style . ".html";
if($ret->type == 'group') {
$ret->separator = $element->_separator;
$ret->elements = array ();
$ret->html = $element->toHtml ();
* Stores an object representation of an element in the form array
* @param elObj object Object representation of an element
function _storeObject ($elObj)
if(is_object($this->_currentGroup ) && $elObj->type != 'group') {
$this->_currentGroup ->elements [] = $elObj;
} elseif (isset ($this->_currentSection )) {
$this->_obj ->sections [$this->_currentSection ]->elements [] = $elObj;
$this->_obj ->elements [] = $elObj;
$this->_elementStyles = array_merge($this->_elementStyles , $elementName);
$this->_elementStyles [$elementName] = $styleName;
} // end class HTML_QuickForm_Renderer_Object
* @abstract Long Description
* This class represents the object passed to outputObject()
* {form.outputJavaScript():h}
* {form.outputHeader():h}
* <td>{form.name.label:h}</td><td>{form.name.html:h}</td>
* Whether the form has been frozen
* Javascript for client-side validation
* @var string $javascript
* Attributes for form tag
* @var string $attributes
* Note about required elements
* @var string $requirednote
* Collected html of all hidden variables
* Set if there were validation errors.
* StdClass object with element names for keys and their
* error messages as values
* Array of QuickformElementObject elements. If there are headers in the form
* this will be empty and the elements will be in the
* Array of sections contained in the document
* Output <form> header
* {form.outputHeader():h}
* @return string <form attributes>
* {form.outputJavaScript():h}
* @return string Javascript
} // end class QuickformForm
* Convenience class describing a form element.
* The properties defined here will be available from
* your flexy templates by referencing
* {form.zip.label:h}, {form.zip.html:h}, etc.
* Whether the element is frozen
* Whether element is required
* Error associated with the element
* Some information about element style
* If element is a group, the group separator
* If element is a group, an array of subelements
if($this->type == $type) {
if($this->type == "submit" || $this->type == "reset") {
$filename = "styles/". $this->style. ".html";
HTML_Template_Flexy ::staticQuickTemplate ($filename, $this);
} // end class QuickformElement
Documentation generated on Mon, 11 Mar 2019 13:52:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|