![]() |
Xataface 2.0
Xataface Application Framework
|
00001 <?php 00013 require_once 'Dataface/SkinTool.php'; 00014 //require_once 'Dataface/Table.php'; 00015 //require_once 'Dataface/TableTool.php'; 00016 //require_once 'Dataface/Record.php'; 00017 require_once 'HTML/QuickForm/Renderer/Default.php'; 00018 00019 define('DATAFACE_RENDERER_FIELD_NOT_FOUND',2005); 00020 00021 class HTML_QuickForm_Renderer_Dataface extends HTML_QuickForm_Renderer_Default { 00022 var $_skinTool; 00023 var $elementTemplate = "Dataface_QuickForm_element.html"; 00024 var $groupElementTemplate = "Dataface_Quickform_groupelement.html"; 00025 00029 var $_fieldMap = array(); 00030 00031 00032 function HTML_QuickForm_Renderer_Dataface(&$form){ 00033 $this->_skinTool =& Dataface_SkinTool::getInstance(); 00034 parent::HTML_QuickForm_Renderer_Default(); 00035 $this->setRequiredNoteTemplate(''); 00036 } 00037 00038 function addField($elementname, $fieldname){ 00039 $this->_fieldMap[$elementname] = $fieldname; 00040 } 00041 00042 function renderElement(&$element, $required, $error) 00043 { 00044 $context = array( "field"=>$element->getFieldDef(), "element"=>$element->toHtml(), "required"=>$required, "error"=>$error, "frozen"=>$element->isFrozen()); 00045 $context['properties'] =& $element->getProperties(); 00046 00047 00048 00049 00050 00051 00052 if ( !$this->_inGroup ){ 00053 ob_start(); 00054 $this->_skinTool->display($context, $this->elementTemplate); 00055 $html = ob_get_contents(); 00056 ob_end_clean(); 00057 $this->_html .= $html; 00058 } else { 00059 00060 ob_start(); 00061 $this->_skinTool->display($context, $this->groupElementTemplate); 00062 $html = ob_get_contents(); 00063 ob_end_clean(); 00064 $this->_groupElements[] =& $html; 00065 } 00066 } // end func renderElement 00067 00068 function startGroup(&$group, $required, $error) 00069 { 00070 $name = $group->getName(); 00071 if ( isset( $this->_groupWraps[$name] ) ) 00072 $this->_groupTemplate = $this->_groupWraps[$name] ; // $this->_prepareTemplate($name, $group->getLabel(), $required, $error); 00073 else 00074 $this->_groupTemplate = ''; 00075 $this->_groupElementTemplate = empty($this->_groupTemplates[$name])? '': $this->_groupTemplates[$name]; 00076 $this->_groupWrap = empty($this->_groupWraps[$name])? '': $this->_groupWraps[$name]; 00077 $this->_groupElements = array(); 00078 $this->_inGroup = true; 00079 00080 } // end func startGroup 00081 00082 function finishGroup(&$group) 00083 { 00084 $separator = $group->_separator; 00085 if (is_array($separator)) { 00086 $count = count($separator); 00087 $html = ''; 00088 for ($i = 0; $i < count($this->_groupElements); $i++) { 00089 $html .= (0 == $i? '': $separator[($i - 1) % $count]) . $this->_groupElements[$i]; 00090 } 00091 } else { 00092 if (is_null($separator)) { 00093 //$separator = ' '; 00094 $separator=''; 00095 } 00096 00097 $html = implode((string)$separator, $this->_groupElements); 00098 } 00099 if (!empty($this->_groupWrap)) { 00100 $html = str_replace('{content}', $html, $this->_groupWrap); 00101 } 00102 //echo "<h1>html</h1>".$html; 00103 $this->_html .= $html; //str_replace('{element}', $html, $this->_groupTemplate); 00104 $this->_inGroup = false; 00105 } // end func finishGroup 00106 00107 } 00108 00109