![]() |
Xataface 2.0
Xataface Application Framework
|
00001 <?php 00002 /* vim: set expandtab tabstop=4 shiftwidth=4: */ 00003 // +----------------------------------------------------------------------+ 00004 // | PHP version 4.0 | 00005 // +----------------------------------------------------------------------+ 00006 // | Copyright (c) 1997-2003 The PHP Group | 00007 // +----------------------------------------------------------------------+ 00008 // | This source file is subject to version 2.0 of the PHP license, | 00009 // | that is bundled with this package in the file LICENSE, and is | 00010 // | available at through the world-wide-web at | 00011 // | http://www.php.net/license/2_02.txt. | 00012 // | If you did not receive a copy of the PHP license and are unable to | 00013 // | obtain it through the world-wide-web, please send a note to | 00014 // | license@php.net so we can mail you a copy immediately. | 00015 // +----------------------------------------------------------------------+ 00016 // | Authors: Alexey Borzov <borz_off@cs.msu.su> | 00017 // | Adam Daniel <adaniel1@eesus.jnj.com> | 00018 // | Bertrand Mansion <bmansion@mamasam.com> | 00019 // | Thomas Schulz <ths@4bconsult.de> | 00020 // +----------------------------------------------------------------------+ 00021 // 00022 // $Id: Array.php,v 1.1.1.1 2005/11/29 19:21:56 sjhannah Exp $ 00023 00024 require_once 'HTML/QuickForm/Renderer/Array.php'; 00025 00098 class HTML_QuickForm_Renderer_ArrayDataface extends HTML_QuickForm_Renderer_Array 00099 { 00100 00108 function HTML_QuickForm_Renderer_ArrayDataface($collectHidden = false, $staticLabels = false, $assoc = true) 00109 { 00110 $this->HTML_QuickForm_Renderer_Array($collectHidden, $staticLabels, $assoc); 00111 00112 } // end constructor 00113 00114 00115 function startForm(&$form){ 00116 00117 parent::startForm($form); 00118 foreach ( $form->_errors as $key=>$val){ 00119 if ( is_int($key) ){ 00120 $this->_ary['errors'][] = $val; 00121 } 00122 } 00123 } 00124 00134 function _elementToArray(&$element, $required, $error) 00135 { 00136 00137 $ret = array( 00138 'name' => $element->getName(), 00139 'value' => $element->getValue(), 00140 'type' => $element->getType(), 00141 'frozen' => $element->isFrozen(), 00142 'required' => $required, 00143 'error' => $error, 00144 'field' => $element->getFieldDef(), 00145 'properties'=> $element->getProperties() 00146 ); 00147 //if ( !$ret['name']) {var_dump($element);} 00148 // render label(s) 00149 $labels = $element->getLabel(); 00150 if (is_array($labels) && $this->_staticLabels) { 00151 foreach($labels as $key => $label) { 00152 $key = is_int($key)? $key + 1: $key; 00153 if (1 === $key) { 00154 $ret['label'] = $label; 00155 } else { 00156 $ret['label_' . $key] = $label; 00157 } 00158 } 00159 } else { 00160 $ret['label'] = $labels; 00161 } 00162 00163 // set the style for the element 00164 00165 if (isset($this->_elementStyles[$ret['name']])) { 00166 $ret['style'] = $this->_elementStyles[$ret['name']]; 00167 } 00168 if ('group' == $ret['type']) { 00169 $ret['separator'] = $element->_separator; 00170 $ret['elements'] = array(); 00171 } else { 00172 $ret['html'] = $element->toHtml(); 00173 } 00174 00175 if (!empty($error)) { 00176 $this->_ary['errors'][$ret['name']] = $error; 00177 } 00178 return $ret; 00179 } 00180 00181 00182 function renderHeader(&$header) 00183 { 00184 $this->_ary['sections'][$this->_sectionCount] = array( 00185 'header' => $header->toHtml(), 00186 'name' => $header->getName(), 00187 'field' => $header->getFieldDef() 00188 ); 00189 $this->_currentSection = $this->_sectionCount++; 00190 } // end func renderHeader 00191 00192 00193 00194 00195 }