Changeset 5991
- Timestamp:
- 02/02/12 07:01:06 (4 months ago)
- Location:
- trunk/core
- Files:
-
- 2 edited
-
modulecontroller.core.php (modified) (12 diffs)
-
renderer/templatemapper.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/modulecontroller.core.php
r5979 r5991 93 93 94 94 /** 95 * Returns the Doctrine Entity Manager 96 * 95 97 * @return \Doctrine\ORM\EntityManager 96 98 */ … … 158 160 159 161 /** 160 * Init alizes the model (active records/entities/repositories) of the module162 * Initializes the model (active records/entities/repositories) of the module 161 163 * 162 164 * @param $modulename Modulname … … 181 183 if(is_dir($module_models_path) === true) 182 184 { 183 if(isset($entity) === true) # method parameter185 if(isset($entity) === true) 184 186 { 187 # use second parameter of method 185 188 $entity = $module_models_path . 'entities' . DS . ucfirst($entity) . '.php'; 186 189 } 187 else # build entity filename by modulename190 else 188 191 { 192 # build entity filename by modulename 189 193 $entity = $module_models_path . 'entities' . DS . ucfirst($modulename) . '.php'; 190 194 } … … 196 200 197 201 $repos = $module_models_path . 'repositories' . DS . ucfirst($modulename) . 'Repository.php'; 202 198 203 if(is_file($repos) === true and class_exists('Entities\\' . ucfirst($modulename), false) === false) 199 204 { … … 240 245 * 241 246 * @param string $keyname The keyname to find in the array. 242 * @param mixed $default_one A default value, which is returned, if the keyname was not found. 243 * @param mixed $default_two A default value, which is returned, if the keyname was not found and default_one is null. 247 * @param mixed $default_one A default value returned, when keyname was not found. 248 * @param mixed $default_two A default value returned, when keyname was not found and default_one is null. 249 * @return mixed 244 250 */ 245 251 public static function getConfigValue($keyname, $default_one = null, $default_two = null) … … 377 383 378 384 /** 379 * Ensures the template extension is correct.380 *381 * @param string $template The template filename.382 */383 public static function checkTemplateExtension($template)384 {385 # get extension of template386 $template_extension = mb_strtolower(pathinfo($template, PATHINFO_EXTENSION));387 388 # whitelist definition for listing all allowed template filetypes389 $allowed_extensions = array('html','php','tpl');390 391 # check if extension is one of the allowed ones392 if (false === in_array($template_extension, $allowed_extensions))393 {394 $message = 'Template Extension invalid <strong>'.$template_extension.'</strong> on <strong>'.$template.'</strong>';395 trigger_error($message, E_USER_NOTICE);396 }397 }398 399 /**400 * Returns the Template Name401 *402 * @return Returns the templateName as String403 */404 public function getTemplateName()405 {406 # if the templateName was not set manually, we construct it from module/action infos407 if(empty($this->template) === true)408 {409 # construct template name410 $template = Clansuite_TargetRoute::getActionName() . '.tpl';411 $this->setTemplate($template);412 }413 return $this->template;414 }415 416 /**417 385 * Sets the Render Mode 418 386 * … … 426 394 /** 427 395 * Get the Render Mode 396 * 397 * @return string LAYOUT|NOLAYOUT 428 398 */ 429 399 public function getRenderMode() … … 433 403 $this->getView()->renderMode = 'LAYOUT'; 434 404 } 405 435 406 return $this->getView()->renderMode; 436 407 } … … 475 446 476 447 # Debug display of Layout Template and Content Template 477 if(DEBUG == true) 478 { 479 #Clansuite_Debug::firebug('Layout/Wrapper Template: ' . $this->view->getLayoutTemplate() . '<br />'); 480 #Clansuite_Debug::firebug('Template Name: ' . $templatename . '<br />'); 481 } 448 #Clansuite_Debug::firebug('Layout/Wrapper Template: ' . $this->view->getLayoutTemplate() . '<br />'); 449 #Clansuite_Debug::firebug('Template Name: ' . $templatename . '<br />'); 482 450 483 451 # render the content / template … … 542 510 public function redirectToReferer() 543 511 { 544 $referer = '';545 512 $referer = self::getHttpRequest()->getReferer(); 546 513 … … 554 521 $route = Clansuite_HttpRequest::getRoute(); 555 522 556 # we use internal rewrite style here: /module/action 557 # redirect() builds the url 558 $redirect_to = '/'; 559 $redirect_to .= $route->getModuleName(); 560 523 # we use internal rewrite style here: /module/action 524 $redirect_to = '/' . $route->getModuleName(); 561 525 $submodule = $route->getSubModuleName(); 526 562 527 if(empty($submodule) === false) 563 528 { … … 565 530 } 566 531 532 # redirect() builds the url 567 533 $this->redirect($redirect_to); 568 534 } -
trunk/core/renderer/templatemapper.php
r5941 r5991 40 40 * Clansuite_View_Mapper 41 41 * 42 * By definition a mapper sets up a communication between two independent objects. 42 43 * Clansuite_View_Mapper is a "class action" to "template" mapper. 43 44 * This has nothing to do with rendering, but with template selection for the view. 44 * If no template was set manually, this class will help determining the template, 45 * If no template was set manually in the action of a module (class), 46 * this class will help determining the template, 45 47 * by mapping the requested class and action to a template. 46 48 */ 47 49 class Clansuite_View_Mapper 48 50 { 51 /** 52 * Ensures the template extension is correct. 53 * 54 * @param string $template The template filename. 55 */ 56 public static function checkTemplateExtension($template) 57 { 58 # get extension of template 59 $template_extension = mb_strtolower(pathinfo($template, PATHINFO_EXTENSION)); 49 60 61 # whitelist definition for listing all allowed template filetypes 62 $allowed_extensions = array('html','php','tpl'); 63 64 # check if extension is one of the allowed ones 65 if (false === in_array($template_extension, $allowed_extensions)) 66 { 67 $message = 'Template Extension invalid <strong>'.$template_extension.'</strong> on <strong>'.$template.'</strong>'; 68 trigger_error($message, E_USER_NOTICE); 69 } 70 } 71 72 /** 73 * Returns the Template Name 74 * 75 * @return Returns the templateName as String 76 */ 77 public function getTemplateName() 78 { 79 # if the templateName was not set manually, we construct it from module/action infos 80 if(empty($this->template) === true) 81 { 82 # construct template name 83 $template = Clansuite_TargetRoute::getActionName() . '.tpl'; 84 85 $this->setTemplate($template); 86 } 87 88 return $this->template; 89 } 50 90 } 91 ?>
Note: See TracChangeset
for help on using the changeset viewer.
