Changeset 5990
- Timestamp:
- 02/02/12 06:56:12 (4 months ago)
- File:
-
- 1 edited
-
trunk/core/router.core.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/router.core.php
r5942 r5990 49 49 * With Routing you are able to map a logical name to a specific physical name. 50 50 * Examples: map a logical URL (a mod_rewritten one) to a Controller/Method/Parameter 51 * or map a FileRequest via logical URL (a mod_rewritten one) to a DownloadController/Method/Parameters 51 * or map a FileRequest via logical URL (a mod_rewritten one) to a DownloadController/Method/Parameters. 52 * Routes are a valuable concept because they separate your URLs from your data. 52 53 * 53 54 * There are two different URL Formatings allowed: … … 95 96 96 97 /** 98 * Get and prepare the SERVER_URL/URI 99 * 100 * Several fixes are applied to the $request_url (which is Clansuite_HttpRequest::getRequestURI()) 101 * It's already (1) lowercased and (2) urldecoded when incomming. 102 * This function (3) strips slashes from beginning and end and (4) prepends a slash. 103 * Then (5) strips PHP_SELF from the uri string. 104 * A multislash removal is not needed, because of the later usage of preg_split. 105 * 106 * @param string $request_url Clansuite_HttpRequest::getRequestURI 107 * 108 * @return string Request URL 109 */ 110 private function prepareRequestURI($request_uri) 111 { 112 #Clansuite_Debug::firebug('The unprepared Server Request URI is "' . $request_uri . '"'); 113 114 # add slash in front + remove slash at the end 115 $this->uri = '/' . trim($request_uri, '/'); 116 117 # subtract PHP_SELF from uri 118 $url_directory_prefix_length = strlen(dirname($_SERVER['PHP_SELF'])); 119 $this->uri = substr($this->uri, $url_directory_prefix_length); 120 121 #Clansuite_Debug::firebug('The prepared Server Request URI is "' . $this->uri . '"'); 122 123 return $this->uri; 124 } 125 126 /** 97 127 * Add route 98 128 * … … 105 135 * 1) Preprocess the route 106 136 */ 137 107 138 # split the pattern describing the URL target into uri segments 108 139 $url_pattern = ltrim($url_pattern, '/'); 140 141 # then transform placeholders like (:num) or (:id) 142 $url_pattern = self::placeholdersToRegexp($url_pattern); 143 109 144 $segments = explode('/', $url_pattern); 110 145 111 # the incomming route might have placeholders lile (:num) or (:id)112 $url_pattern = self::placeholdersToRegexp($url_pattern);113 114 146 $regexp = $this->processSegmentsRegExp($segments, $route_options); 115 $options = array('regexp' => $regexp, 116 'number_of_segments' => count($segments)); 147 148 $options = array( 149 'regexp' => $regexp, 150 'number_of_segments' => count($segments) 151 ); 117 152 118 153 … … 498 533 } 499 534 500 /**501 * Get and prepare the SERVER_URL/URI502 *503 * Several fixes are applied the $request_url (which is Clansuite_HttpRequest::getRequestURI())504 * It's already (1) lowercased and (2) urldecoded when incomming.505 * This function (3) strips slashes from beginning and end and (4) prepends a slash.506 * A multislash removal is not needed, because of the later usage of preg_split.507 *508 * @param string $request_url Clansuite_HttpRequest::getRequestURI509 *510 * @return string Request URL511 */512 private function prepareRequestURI($request_uri)513 {514 #Clansuite_Debug::firebug('The unprepared Server Request URI is "' . $request_uri . '"');515 516 # add slash in front + remove slash at the end517 $this->uri = '/' . trim($request_uri, '/');518 519 # path subtraction (get length of dirname of php_self and subtract from uri)520 $url_directory_prefix_length = strlen(dirname($_SERVER['PHP_SELF']));521 $this->uri = substr($this->uri, $url_directory_prefix_length);522 523 #Clansuite_Debug::firebug('The prepared Server Request URI is "' . $this->uri . '"');524 525 return $this->uri;526 }527 535 528 536 /**
Note: See TracChangeset
for help on using the changeset viewer.
