| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/view/src/wact/lmbWactTemplate.class.php'); 10 lmb_require('limb/view/src/lmbView.class.php'); 11 12 /** 13 * class lmbWactView. 14 * 15 * @package view 16 * @version $Id$ 17 */ 18 class lmbWactView extends lmbView 19 { 20 protected $wact_template; 21 protected $forms_datasources = array(); 22 protected $forms_errors = array(); 23 protected $cache_dir; 24 25 function setCacheDir($dir) 26 { 27 $this->cache_dir = $dir; 28 } 29 30 function render() 31 { 32 if($tpl = $this->_getWactTemplate()) 33 { 34 $this->_fillWactTemplate($tpl); 35 return $tpl->capture(); 36 } 37 } 38 39 function reset() 40 { 41 parent :: reset(); 42 $this->forms_datasources = array(); 43 $this->forms_errors = array(); 44 $this->wact_template = null; 45 } 46 47 function getWactTemplate() 48 { 49 return $this->_getWactTemplate(); 50 } 51 52 function setFormDatasource($form_name, $datasource) 53 { 54 $this->forms_datasources[$form_name] = $datasource; 55 } 56 57 function getFormDatasource($form_name) 58 { 59 if(isset($this->forms_datasources[$form_name])) 60 return $this->forms_datasources[$form_name]; 61 else 62 return null; 63 } 64 65 function setFormErrors($form_name, $error_list) 66 { 67 $this->forms_errors[$form_name] = $error_list; 68 } 69 70 function getForms() 71 { 72 return $this->forms_datasources; 73 } 74 75 function findChild($id) 76 { 77 if($tpl = $this->_getWactTemplate()) 78 return $tpl->findChild($id); 79 } 80 81 protected function _getWactTemplate() 82 { 83 if($this->wact_template) 84 return $this->wact_template; 85 86 if(!$path = $this->getTemplate()) 87 return null; 88 89 $this->wact_template = new lmbWactTemplate($path, $this->cache_dir); 90 return $this->wact_template; 91 } 92 93 protected function _fillWactTemplate($template) 94 { 95 foreach($this->getVariables() as $variable_name => $value) 96 $template->set($variable_name, $value); 97 98 foreach($this->forms_datasources as $form_id => $datasource) 99 { 100 $form_component = $template->getChild($form_id); 101 $form_component->registerDataSource($datasource); 102 } 103 104 foreach($this->forms_errors as $form_id => $error_list) 105 { 106 $form_component = $template->getChild($form_id); 107 if(!$error_list->isValid()) 108 { 109 lmb_require('limb/wact/src/components/form/error.inc.php'); 110 $error_list->setFieldNameDictionary(new WactFormFieldNameDictionary($form_component)); 111 $form_component->setErrors($error_list->getReadable()); 112 } 113 } 114 } 115 } 116 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Aug 29 04:49:26 2008 | Cross-referenced by PHPXref 0.7 |