Changeset 4597 for trunk/core/router.core.php
- Timestamp:
- 08/22/10 19:35:26 (21 months ago)
- File:
-
- 1 edited
-
trunk/core/router.core.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.
