Changeset 4597
- Timestamp:
- 08/22/10 19:35:26 (18 months ago)
- Location:
- trunk/core
- Files:
-
- 5 edited
-
dispatcher.core.php (modified) (4 diffs)
-
httpresponse.core.php (modified) (3 diffs)
-
router.core.php (modified) (14 diffs)
-
viewhelper/smarty/function.breadcrumbs.php (modified) (2 diffs)
-
viewhelper/smarty/function.browserupdate.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/dispatcher.core.php
r4578 r4597 27 27 * @copyright Jens-André Koch (2005-onwards) 28 28 * @link http://www.clansuite.com 29 * 29 * 30 30 * @version SVN: $Id$ 31 31 */ … … 61 61 $route = Clansuite_HttpRequest::getRoute(); 62 62 63 #$event = Clansuite_EventDispatcher::instantiate();63 #$event = Clansuite_EventDispatcher::instantiate(); 64 64 #$event->addEventHandler('onBeforeControllerMethodCall', new Clansuite_Event_InitializeModule()); 65 65 … … 69 69 } 70 70 71 $filename = $route->getFilename();72 71 $classname = $route->getClassname(); 73 72 $method = $route->getMethod(); 74 73 $parameters = $route->getParameters(); 75 $request_meth = Clansuite_HttpRequest::getRequestMethod();76 $renderengine = $route->getRenderEngine();74 #$request_meth = Clansuite_HttpRequest::getRequestMethod(); 75 #$renderengine = $route->getRenderEngine(); 77 76 78 77 Clansuite_Debug::firebug($route); 79 78 #unset($route); 80 79 81 /** 82 * The file we want to call has to exists 83 */ 84 if(false === is_file($filename) ) 85 { 86 throw new Clansuite_Exception('File not found "' . $filename .'".'); 87 } 88 else 89 { 90 include $filename; 91 } 80 $controllerInstance = new $classname( 81 Clansuite_CMS::getInjector()->instantiate('Clansuite_HttpRequest'), 82 Clansuite_CMS::getInjector()->instantiate('Clansuite_HttpResponse') 83 ); 92 84 93 /** 94 * Inside this file, the correct class has to exist 95 */ 96 if(true === class_exists($classname, false)) 97 { 98 # instantiate the module controller and pass request and response object to it 99 $controllerInstance = new $classname( 100 Clansuite_CMS::getInjector()->instantiate('Clansuite_HttpRequest'), 101 Clansuite_CMS::getInjector()->instantiate('Clansuite_HttpResponse') 102 ); 103 } 104 else 105 { 106 throw new Clansuite_Exception('There was no controller named "' . $classname . '".'); 107 } 108 109 /** 110 * Initialize the Module 111 */ 85 # Initialize the Module 112 86 if(true === method_exists($controllerInstance, 'initializeModule')) 113 87 { … … 115 89 } 116 90 117 # @todo fix wrong position118 91 Clansuite_Breadcrumb::initBreadcrumbs(); 119 92 120 /** 121 * Handle Method 122 * 123 * 1) check if method exists in class (meaning the module file) -> CALL 124 * 2) check if method exists in module/actions path (command factory) -> CALL 125 * 3) if not found display error -> ERROR 126 */ 93 # Finally: dispatch to the requested controller method 127 94 if(true === method_exists($controllerInstance, $method)) 128 95 { 129 96 $controllerInstance->$method($parameters); 130 97 } 131 /*132 elseif(is_file(ROOT_MOD . $modulename.'/controller/commands/'.$methodname.'.php') === true)133 {134 # command controller factory135 # create command (by including the file of the actioncontroller)136 # example: 'modulename/controller/commands/action_show.php'137 return ROOT_MOD . $modulename.'/controller/commands/'.$methodname.'.php';138 }*/139 else # error140 {141 throw new Clansuite_Exception('There was no action named "' . $method . '".', 2);142 }143 98 } 144 99 } -
trunk/core/httpresponse.core.php
r4578 r4597 27 27 * @copyright Copyleft: All rights reserved. Jens-André Koch (2005 - onwards) 28 28 * @link http://www.clansuite.com 29 * 29 * 30 30 * @version SVN: $Id$ 31 31 */ … … 101 101 102 102 /** 103 * Get-Method for HTTP 1.1 status code and its meaning. 104 * 105 * used in (@link $this->flush ) 106 * @see $this->flush() 103 * Get HTTP 1.1 status code description by status code. 104 * 107 105 * @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 108 106 */ … … 129 127 '404' => 'Not Found', 130 128 # Server Error 131 '500' => 'Internal Server Error' 129 '500' => 'Internal Server Error', 130 '503' => 'Service Temporarily Unavailable' 132 131 ); 133 132 -
trunk/core/router.core.php
r4578 r4597 237 237 238 238 /** 239 * if there are no uri segments, loading routes and matching is pointless240 * return the default route239 * If there are no uri segments, loading routes and matching is pointless. 240 * Dispatch to the default route! 241 241 */ 242 242 if(empty($this->uri) or $this->uri === '/') … … 245 245 Clansuite_TargetRoute::setAction('show'); 246 246 247 return Clansuite_TargetRoute::getInstance(); 247 if(Clansuite_TargetRoute::dispatchable() === true) 248 { 249 return Clansuite_TargetRoute::getInstance(); 250 } 248 251 } 249 252 … … 269 272 public function mapMatchURI() 270 273 { 271 Clansuite_Debug::firebug($this->uri);274 #Clansuite_Debug::firebug($this->uri); 272 275 273 276 /** … … 287 290 $uri = implode('/', $this->uri_segments); 288 291 289 Clansuite_Debug::firebug($route_values);292 #Clansuite_Debug::firebug($route_values); 290 293 291 294 /** … … 296 299 if (1 === preg_match('/^:([a-zA-Z_]+)$/', $uri, $match)) 297 300 { 298 Clansuite_Debug::firebug($match);301 #Clansuite_Debug::firebug($match); 299 302 $name = $match[1]; #setController($match[1]); 300 303 $found_route = $name; … … 304 307 elseif(1 === preg_match( $route_values['regexp'], $uri, $matches)) 305 308 { 306 Clansuite_Debug::firebug($matches);309 #Clansuite_Debug::firebug($matches); 307 310 308 311 # parameters found by regular expression have priority … … 312 315 } 313 316 317 if(isset($matches['subcontroller'])) 318 { 319 Clansuite_TargetRoute::setSubController($matches['subcontroller']); 320 } 321 314 322 if(isset($matches['action'])) 315 323 { … … 323 331 } 324 332 325 # route found 326 break; 333 if(Clansuite_TargetRoute::dispatchable() === true) 334 { 335 # route found 336 break; 337 } 338 else 339 { 340 Clansuite_TargetRoute::reset(); 341 } 327 342 } 328 343 } … … 639 654 $this->addRoute('/:controller/:action/:id'); 640 655 $this->addRoute('/:controller/:action/:id/:format'); 641 /* 656 642 657 $this->addRoute('/:controller/:subcontroller'); 643 658 $this->addRoute('/:controller/:subcontroller/:action'); 644 659 $this->addRoute('/:controller/:subcontroller/:action/:id'); 645 660 $this->addRoute('/:controller/:subcontroller/:action/:id/:format'); 646 */647 661 } 648 662 } … … 725 739 726 740 # subcontroller 727 if( 'admin' == $subcontroller)741 if(isset($subcontroller) and 'admin' == $subcontroller) 728 742 { 729 743 $filename_postfix = '.admin.php'; 730 744 } 731 else 745 elseif(isset($subcontroller) and $subcontroller != 'admin') # any subcontroller name as postfix 746 { 747 $filename_postifx = '.'.$subcontroller.'.php'; 748 } 749 else # apply standard postfix 732 750 { 733 751 $filename_postfix = '.module.php'; … … 789 807 $action = $submodule . '_' . $action; 790 808 } 791 792 #Clansuite_Debug::firebug($action);793 809 794 810 # all clansuite actions are prefixed with 'action_' … … 844 860 public static function getFilename() 845 861 { 846 if(empty(self::$parameters['filename']))847 {862 #if(empty(self::$parameters['filename'])) 863 #{ 848 864 self::setFilename(self::mapControllerToFilename(self::getModulePath(), self::getController(), self::getSubController())); 849 }865 #} 850 866 851 867 return self::$parameters['filename']; … … 954 970 return self::$parameters['method']; 955 971 } 956 else # add method prefix (action_) and subcontroller prefix (admin_) 957 { 958 #if(empty(self::$parameters['method'])) 959 #{ 960 self::setMethod(self::mapActionToActioname(self::getAction(), self::getSubController())); 961 #} 972 # add method prefix (action_) and subcontroller prefix (admin_) 973 else 974 { 975 self::setMethod(self::mapActionToActioname(self::getAction(), self::getSubController())); 976 962 977 } 963 978 … … 1019 1034 $string = (string) implode(",", self::$parameters); 1020 1035 Clansuite_Debug::firebug($string); 1036 } 1037 1038 public static function dispatchable() 1039 { 1040 $filename = self::getFilename(); 1041 $classname = self::getClassname(); 1042 $method = self::getMethod(); 1043 1044 /** 1045 * The file we want to call has to exists 1046 */ 1047 if(is_file($filename)) 1048 { 1049 include $filename; 1050 1051 /** 1052 * Inside this file, the correct class has to exist 1053 */ 1054 if(class_exists($classname, false)) 1055 { 1056 # WATCH IT! method_exists works on objects, is_callable on classes! ,) 1057 if(is_callable($classname, $method)) 1058 { 1059 Clansuite_Debug::firebug('(OK) Route is dispatchable: '. $filename .' '. $classname .'->'. $method); 1060 return true; 1061 } 1062 else 1063 { 1064 return false; 1065 } 1066 } 1067 else 1068 { 1069 return false; 1070 } 1071 } 1072 else 1073 { 1074 Clansuite_Debug::firebug('(ERROR) Route not dispatchable: '. $filename .' '. $classname .'->'. $method); 1075 return false; 1076 } 1077 } 1078 1079 public static function reset() 1080 { 1081 $reset_params = array( 1082 # File 1083 'filename' => null, 1084 'classname' => null, 1085 # Call 1086 'controller' => null, 1087 'subcontroller' => null, 1088 'action' => 'show', 1089 'method' => null, 1090 'params' => null 1091 ); 1092 1093 self::$parameters = array_merge(self::$parameters, $reset_params); 1021 1094 } 1022 1095 -
trunk/core/viewhelper/smarty/function.breadcrumbs.php
r4578 r4597 1 1 <?php 2 /** 3 * Smarty plugin 4 * @package Smarty 5 * @subpackage plugins 6 */ 7 8 /** 9 * This smarty function is part of "Clansuite - just an eSports CMS" 10 * @link http://www.clansuite.com 11 * 12 * @author Jens-André Koch <vain@clansuite.com> 13 * @copyright Jens-André Koch (2005 - onwards) 14 * @license GNU General Public License v2 or any later version 15 * @version SVN $Id$ 16 * 17 * @example 18 * {breadcrumbs} 19 * 20 * @return string 21 */ 2 22 function smarty_function_breadcrumbs($params, $smarty) 3 23 { … … 12 32 } 13 33 14 Clansuite_Debug::firebug($trail);34 #Clansuite_Debug::firebug($trail); 15 35 16 36 # is the seperator element set via the smarty function call? -
trunk/core/viewhelper/smarty/function.browserupdate.php
r4350 r4597 10 10 * @link http://www.clansuite.com 11 11 * 12 * @author Jens-André Koch <jakoch@web.de>13 * @copyright Copyright (C) 2009 Jens-André Koch14 * @license GNU General Public License v2 or any later version15 * @version SVN $Id$12 * @author Jens-André Koch <vain@clansuite.com> 13 * @copyright Jens-André Koch (2005 - onwards) 14 * @license GNU General Public License v2 or any later version 15 * @version SVN $Id$ 16 16 * 17 17 * Smarty Function to output the browser update (notice) javascript.
Note: See TracChangeset
for help on using the changeset viewer.
