Changeset 5940
- Timestamp:
- 01/15/12 19:36:06 (4 months ago)
- Location:
- trunk/core/renderer
- Files:
-
- 7 edited
-
csv.renderer.php (modified) (3 diffs)
-
php.renderer.php (modified) (2 diffs)
-
phptal.renderer.php (modified) (6 diffs)
-
renderer.base.php (modified) (2 diffs)
-
serialized.renderer.php (modified) (1 diff)
-
smarty.renderer.php (modified) (5 diffs)
-
xtemplate.renderer.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/renderer/csv.renderer.php
r4766 r5940 53 53 { 54 54 private $data = array(); 55 private $header = array(); 55 private $header = array(); 56 56 57 57 public function initializeEngine() … … 66 66 67 67 /** 68 * @param string $filepath location of where the csv file should be saved 68 * @param string $template The filepath location of where to save the csv file. 69 * @param array|object viewdata 69 70 */ 70 public function render($ filepath)71 public function render($template, $viewdata) 71 72 { 72 73 $this->mssafe_csv($ filepath, $this->data, $this->header);73 $this->data = $viewdata; 74 $this->mssafe_csv($template, $this->data, $this->header); 74 75 } 75 76 … … 102 103 private function mssafe_csv($filepath, $data, $header = array()) 103 104 { 104 if($fp = fopen($filepath, 'w')) 105 $fp = fopen($filepath, 'w'); 106 107 if($fp === true) 105 108 { 106 109 $show_header = true; -
trunk/core/renderer/php.renderer.php
r5812 r5940 107 107 if(is_object($key)) 108 108 { 109 # @todo pull object props to array 109 110 $this->data[$key] = $value->fetch(); 110 111 } … … 128 129 * @return string HTML Representation of Template with Vars 129 130 */ 130 public function render( )131 public function render($template, $viewdata) 131 132 { 132 return $this->fetch(); 133 $this->assign($viewdata); 134 135 return $this->fetch($template); 133 136 } 134 137 -
trunk/core/renderer/phptal.renderer.php
r5811 r5940 98 98 * Add data to the PHPTAL view 99 99 * 100 * @param mixed $tpl_parameter 101 * @param mixed $value 102 */ 103 public function assign($tpl_parameter, $value )100 * @param mixed $tpl_parameter The placeholder. 101 * @param mixed $value The value. 102 */ 103 public function assign($tpl_parameter, $value = null) 104 104 { 105 105 if(is_array($tpl_parameter)) … … 112 112 else 113 113 { 114 $this->renderer->$param = $val; 115 } 116 } 117 118 /* 114 if ($tpl_parameter != null) 115 { 116 $this->renderer->$tpl_parameter = $value; 117 } 118 } 119 } 120 119 121 public function setTemplate($template) 120 122 { 121 123 $this->renderer->setTemplate($template); 122 } */124 } 123 125 124 126 /** … … 168 170 } 169 171 170 /**171 * Set PHPTAL variables172 *173 * @param string $key variable name174 * @param string $value variable value175 */176 public function __set($key, $value)177 {178 $this->renderer->assign($key, $value);179 }180 181 /**182 * Get PHPTAL Variable Value183 *184 * @param string $key variable name185 * @return mixed variable value186 */187 public function __get($key)188 {189 return $this->renderer->$key;190 }191 192 /**193 * Check if PHPTAL variable is set194 *195 * @param string $key variable name196 */197 public function __isset($key)198 {199 return isset($this->renderer->$key);200 }201 202 /**203 * Unset PHPTAL variable204 *205 * @param string $key variable name206 */207 public function __unset($key)208 {209 if (isset($this->renderer->$key))210 {211 unset($this->renderer->$key);212 }213 }214 215 /**216 * Clone PHPTAL object217 *218 * @todo Check if clone is needed to work with several instances of phptal for widgets?219 */220 /*221 public function __clone()222 {223 $this->phptal = clone $this->phptal;224 }225 */226 172 227 173 /** … … 247 193 $output = $this->renderer->execute(); 248 194 195 # return or echo the content 249 196 if ($returnContent === true) 250 197 { … … 256 203 } 257 204 } 258 catch ( Clansuite_Exception $e)205 catch (Exception $e) 259 206 { 260 207 throw new Clansuite_Exception($e); … … 302 249 return $this->renderer->setCacheLifetime($lifetime); 303 250 } 251 /** 252 * Set PHPTAL variables 253 * 254 * @param string $key variable name 255 * @param string $value variable value 256 */ 257 public function __set($key, $value) 258 { 259 $this->renderer->assign($key, $value); 260 } 261 262 /** 263 * Get PHPTAL Variable Value 264 * 265 * @param string $key variable name 266 * @return mixed variable value 267 */ 268 public function __get($key) 269 { 270 return $this->renderer->$key; 271 } 272 273 /** 274 * Check if PHPTAL variable is set 275 * 276 * @param string $key variable name 277 */ 278 public function __isset($key) 279 { 280 return isset($this->renderer->$key); 281 } 282 283 /** 284 * Unset PHPTAL variable 285 * 286 * @param string $key variable name 287 */ 288 public function __unset($key) 289 { 290 if (isset($this->renderer->$key)) 291 { 292 unset($this->renderer->$key); 293 } 294 } 295 296 /** 297 * Clone PHPTAL object 298 * 299 * @todo Check if clone is needed to work with several instances of phptal for widgets? 300 */ 301 /* 302 public function __clone() 303 { 304 $this->phptal = clone $this->phptal; 305 } 306 */ 304 307 } 305 308 ?> -
trunk/core/renderer/renderer.base.php
r5810 r5940 78 78 79 79 /** 80 * @var array|object Viewdata 81 */ 82 public $viewdata = null; 83 84 /** 80 85 * Construct Renderer 81 86 * … … 110 115 * Renders the given Template with renderMode wrapped (with Layout) 111 116 * 112 * @return string 113 */ 114 abstract public function render($template); 117 * @param string Template 118 * @param array|object Data to assign to the template. 119 * @return string 120 */ 121 abstract public function render($template, $viewdata); 115 122 116 123 /** -
trunk/core/renderer/serialized.renderer.php
r4738 r5940 54 54 /** 55 55 * Render serialized PHP data 56 * 57 * @param $template Unused. 58 * @param $viewdata Data to serialize. 59 * 60 * @return string Serialized data. 56 61 */ 57 public function render($ data)62 public function render($template, $viewdata) 58 63 { 59 return serialize($this-> data);64 return serialize($this->viewdata); 60 65 } 61 66 } -
trunk/core/renderer/smarty.renderer.php
r5893 r5940 70 70 71 71 # debug display of all smarty related directories 72 # $this->renderer->testInstall();72 # $this->renderer->testInstall(); 73 73 } 74 74 75 75 /** 76 76 * Set up Smarty Template Engine 77 * 78 * @param string $template Template Name for "Frontloader" Rendering Engines (xtpl). 77 79 */ 78 80 public function initializeEngine($template = null) … … 212 214 */ 213 215 $tpl_array = array( $this->getThemeTemplatePaths(), # 1 + 2 214 $this->getModuleTemplatePaths(), # 3 + 4 215 ROOT_THEMES_CORE . 'view' . DS . 'smarty', # 5 216 $this->getModuleTemplatePaths(), # 3 + 4 217 ROOT_THEMES_CORE . 'view' . DS . 'smarty', # 5 216 218 ROOT_THEMES); # 6 217 219 … … 229 231 * 3) clansuite module smarty plugins => modules\module_name\viewhelper\smarty\ 230 232 */ 231 232 $this->renderer->setPluginsDir( 233 234 $this->renderer->setPluginsDir( 233 235 array( ROOT_LIBRARIES . 'smarty' . DS . 'plugins', 234 ROOT_CORE . 'viewhelper' . DS . 'smarty' . DS, 236 ROOT_CORE . 'viewhelper' . DS . 'smarty' . DS, 235 237 ROOT_MOD . Clansuite_TargetRoute::getModuleName() . DS . 'viewhelper' . DS. 'smarty' . DS 236 238 )); … … 313 315 public function assign($tpl_parameter, $value = null) 314 316 { 315 if(is_array($tpl_parameter) === true )317 if(is_array($tpl_parameter) === true or is_object($tpl_parameter) === true ) 316 318 { 317 319 $this->renderer->assign($tpl_parameter); … … 487 489 * 488 490 * @param string $templatename Template Filename 491 * @param array|object $data Data to assign to the view. 489 492 * @return wrapper tpl layout 490 493 */ 491 public function render($template) 492 { 494 public function render($template, $viewdata = null) 495 { 496 if(isset($viewdata)) 497 { 498 $this->assign($viewdata); 499 } 500 493 501 # 1. assign common template values and Clansuite constants as Smarty Template Variables. 494 502 $this->renderer->assignGlobal($this->getConstants()); -
trunk/core/renderer/xtemplate.renderer.php
r5080 r5940 64 64 if(class_exists('XTemplate', false) == false) 65 65 { 66 # check if Smartylibrary exists66 # check if library exists 67 67 if(is_file(ROOT_LIBRARIES . 'xtemplate/xtemplate.class.php') === true) 68 68 { … … 125 125 } 126 126 127 public function render($template )127 public function render($template, $viewdata) 128 128 { 129 $this->renderer->assign($viewdata); 129 130 $this->renderer->parse($template); 130 131 $this->renderer->out($template);
Note: See TracChangeset
for help on using the changeset viewer.
