Source for file ObjectFlexy.php
Documentation is available at ObjectFlexy.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: ObjectFlexy.php,v 1.7 2005/06/17 20:00:57 avb Exp $
require_once("HTML/QuickForm/Renderer/Object.php");
* QuickForm renderer for Flexy template engine, static version.
* A static renderer for HTML_Quickform. Makes a QuickFormFlexyObject
* from the form content suitable for use with a Flexy template
* $form =& new HTML_QuickForm('form', 'POST');
* $template =& new HTML_Template_Flexy();
* $renderer =& new HTML_QuickForm_Renderer_ObjectFlexy(&$template);
* $renderer->setHtmlTemplate("html.html");
* $renderer->setLabelTemplate("label.html");
* $form->accept($renderer);
* $view->form = $renderer->toObject();
* $template->compile("mytemplate.html");
* Based on the code for HTML_QuickForm_Renderer_ArraySmarty
* @see QuickFormFlexyObject
* HTML_Template_Flexy instance
* @var integer $_elementIdx
* The current element index inside a group
* @var integer $_groupElementIdx
var $_groupElementIdx = 0;
* Name of template file for form html
* @see setRequiredTemplate()
* Name of template file for form labels
* @see setErrorTemplate()
* Class of the element objects, so you can add your own
* @var string $_elementType
var $_elementType = 'QuickformFlexyElement';
* @param $flexy object HTML_Template_Flexy instance
$this->HTML_QuickForm_Renderer_Object (true );
if($name = $header->getName ()) {
$this->_obj->header ->$name = $header->toHtml ();
$this->_obj->header [$this->_sectionCount] = $header->toHtml ();
$this->_currentSection = $this->_sectionCount++;
} // end func renderHeader
parent ::startGroup ($group, $required, $error);
$this->_groupElementIdx = 1;
* Creates an object representing an element containing
* the key for storing this
* @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)
$ret = parent ::_elementToObject ($element, $required, $error);
if($ret->type == 'group') {
$ret->html = $element->toHtml ();
if(!empty ($this->_label)) {
$this->_renderLabel ($ret);
if(!empty ($this->_html)) {
$this->_renderHtml ($ret);
// Create an element key from the name
if (false !== ($pos = strpos($ret->name , '[')) || is_object($this->_currentGroup)) {
$keys = '->{\'' . $ret->name . '\'}';
$keys = '->{\'' . str_replace(array ('[', ']'), array ('\'}->{\'', ''), $ret->name ) . '\'}';
// special handling for elements in native groups
// skip unnamed group items unless radios: no name -> no static access
// identification: have the same key string as the parent group
if ($this->_currentGroup->keys == $keys && 'radio' != $ret->type ) {
// reduce string of keys by remove leading group keys
if (0 === strpos($keys, $this->_currentGroup->keys )) {
} elseif (0 == strlen($ret->name )) {
$keys = '->{\'element_' . $this->_elementIdx . '\'}';
$keys = '->{\'' . $ret->name . '\'}';
// for radios: add extra key from value
if ('radio' == $ret->type && '[]' != substr($keys, -2 )) {
$keys .= '->{\'' . $ret->value . '\'}';
* Stores an object representation of an element in the
* QuickformFormObject instance
* @param elObj object Object representation of an element
function _storeObject ($elObj)
if(is_object($this->_currentGroup) && ('group' != $elObj->type )) {
$code = '$this->_currentGroup' . $keys . ' = $elObj;';
$code = '$this->_obj' . $keys . ' = $elObj;';
* Set the filename of the template to render html elements.
* In your template, {html} is replaced by the unmodified html.
* If the element is required, {required} will be true.
* <font color="red" size="1">{error:h}</font><br />
* @param template string Filename of template
$this->_html = $template;
* Set the filename of the template to render form labels
* In your template, {label} is replaced by the unmodified label.
* {error} will be set to the error, if any. {required} will
* be true if this is a required field
* <font color="orange" size="1">*</font>
* @param template string Filename of template
$this->_label = $template;
function _renderLabel (&$ret)
$this->_flexy->compile ($this->_label);
$ret->label = $this->_flexy->bufferedOutputObject ($ret);
function _renderHtml (&$ret)
$this->_flexy->compile ($this->_html);
$ret->html = $this->_flexy->bufferedOutputObject ($ret);
} // end class HTML_QuickForm_Renderer_ObjectFlexy
* Adds nothing to QuickformForm, left for backwards compatibility
* Adds nothing to QuickformElement, left for backwards compatibility
Documentation generated on Mon, 11 Mar 2019 14:16:34 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|