Changeset 174 for trunk/trax/vendor/trax/router.php
- Timestamp:
- 03/13/06 21:10:15 (4 years ago)
- Files:
-
- trunk/trax/vendor/trax/router.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/trax/vendor/trax/router.php
r162 r174 106 106 * empty string, it matches a path that is an empty string. 107 107 * Otherwise, try to match $url to the path part of the table 108 * entry according to {@link http://www.php.net/manual/en/ref.pcre.php Perl regular expression} 109 * rules. Return the first matching route to the caller, and 110 * also save a copy in {@link $selected_route}. 108 * entry according to 109 * {@link http://www.php.net/manual/en/ref.pcre.php Perl regular expression} 110 * rules. If a matching route is found, return it any to the caller, and 111 * also save a copy in {@link $selected_route}; if no matching 112 * route is found return null. 111 113 * @param string $url 112 114 * @uses build_route_regexp() … … 115 117 * @uses $routes_count 116 118 * @uses $selected_route 117 * @return string[] Selected route.Path is in return['path'],119 * @return mixed Matching route or null. Path is in return['path'], 118 120 * params in return['params'], 119 121 */ 120 122 function find_route($url) { 123 //error_log('url='.$url); 121 124 // ensure at least one route (the default route) exists 122 125 if($this->routes_count == 0) { … … 130 133 unset($reg_exp); 131 134 $route_regexp = $this->build_route_regexp($route['path']); 135 //error_log("route regexp=/$route_regexp/"); 132 136 if($url == "" && $route_regexp == "") { 137 //error_log('selected'); 133 138 $this->selected_route = $route; 134 139 break; 135 140 } elseif(preg_match("/$route_regexp/",$url) && $route_regexp != "") { 141 //error_log('selected'); 136 142 $this->selected_route = $route; 137 143 break; 138 144 } elseif($route['path'] == $this->default_route_path) { 145 //error_log('defaulted'); 139 146 $this->selected_route = $route; 140 147 break; 141 148 } 142 149 } 143 150 //error_log('selected route='.var_export($this->selected_route,true)); 144 151 return $this->selected_route; 145 152 } // function find_route($url) … … 148 155 * Build a regular expression that matches a route 149 156 * 150 * <b>FIXME:</b> Should this method be private? 157 * @todo <b>FIXME:</b> Should this method be private? 158 * @todo <b>FIXME:</b> Shouldn't the regexp match be the same as 159 * for a PHP variable name? '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' 151 160 * @param string $route_path A route path. 152 161 * @return string Regular expression that matches the route in … … 161 170 $route_path = explode("/",$route_path); 162 171 } 163 // echo "route path:\n"; 164 // var_dump($route_path); 172 //error_log("route path:\n".var_export($route_path,true)); 165 173 if(count($route_path) > 0) { 166 174 foreach($route_path as $path_element) { … … 175 183 } 176 184 } 177 178 185 return $route_regexp; 179 186 }

