admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 1 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
| 2 | /** |
| 3 | * Code Igniter |
| 4 | * |
| 5 | * An open source application development framework for PHP 4.3.2 or newer |
| 6 | * |
| 7 | * @package CodeIgniter |
| 8 | * @author Rick Ellis |
| 9 | * @copyright Copyright (c) 2006, pMachine, Inc. |
| 10 | * @license http://www.codeignitor.com/user_guide/license.html |
| 11 | * @link http://www.codeigniter.com |
| 12 | * @since Version 1.0 |
| 13 | * @filesource |
| 14 | */ |
| 15 | |
| 16 | // ------------------------------------------------------------------------ |
| 17 | |
| 18 | /** |
| 19 | * Router Class |
| 20 | * |
| 21 | * Parses URIs and determines routing |
| 22 | * |
| 23 | * @package CodeIgniter |
| 24 | * @subpackage Libraries |
| 25 | * @author Rick Ellis |
| 26 | * @category Libraries |
| 27 | * @link http://www.codeigniter.com/user_guide/general/routing.html |
| 28 | */ |
| 29 | class CI_Router { |
| 30 | |
| 31 | var $config; |
| 32 | var $uri_string = ''; |
| 33 | var $segments = array(); |
admin | 99bccd6 | 2006-09-21 17:05:40 +0000 | [diff] [blame] | 34 | var $rsegments = array(); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 35 | var $routes = array(); |
| 36 | var $class = ''; |
| 37 | var $method = 'index'; |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 38 | var $directory = ''; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 39 | var $uri_protocol = 'auto'; |
| 40 | var $default_controller; |
| 41 | var $scaffolding_request = FALSE; // Must be set to FALSE |
| 42 | |
| 43 | /** |
| 44 | * Constructor |
| 45 | * |
| 46 | * Runs the route mapping function. |
| 47 | */ |
| 48 | function CI_Router() |
| 49 | { |
| 50 | $this->config =& _load_class('CI_Config'); |
| 51 | $this->_set_route_mapping(); |
| 52 | log_message('debug', "Router Class Initialized"); |
| 53 | } |
| 54 | |
| 55 | // -------------------------------------------------------------------- |
| 56 | |
| 57 | /** |
| 58 | * Set the route mapping |
| 59 | * |
| 60 | * This function determies what should be served based on the URI request, |
| 61 | * as well as any "routes" that have been set in the routing config file. |
| 62 | * |
| 63 | * @access private |
| 64 | * @return void |
| 65 | */ |
| 66 | function _set_route_mapping() |
| 67 | { |
| 68 | // Are query strings enabled? If so we're done... |
| 69 | if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')])) |
| 70 | { |
| 71 | $this->set_class($_GET[$this->config->item('controller_trigger')]); |
| 72 | |
| 73 | if (isset($_GET[$this->config->item('function_trigger')])) |
| 74 | { |
| 75 | $this->set_method($_GET[$this->config->item('function_trigger')]); |
| 76 | } |
| 77 | |
| 78 | return; |
| 79 | } |
admin | 592cdcb | 2006-09-22 18:45:42 +0000 | [diff] [blame] | 80 | |
| 81 | // Load the routes.php file and set the default controller |
admin | 99bccd6 | 2006-09-21 17:05:40 +0000 | [diff] [blame] | 82 | @include_once(APPPATH.'config/routes'.EXT); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 83 | $this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route; |
| 84 | unset($route); |
| 85 | |
admin | 592cdcb | 2006-09-22 18:45:42 +0000 | [diff] [blame] | 86 | $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 87 | |
admin | 592cdcb | 2006-09-22 18:45:42 +0000 | [diff] [blame] | 88 | // Is there a URI string? If not, the default controller specified in the "routes" file will be shown. |
admin | dbd8aec | 2006-09-22 19:20:09 +0000 | [diff] [blame] | 89 | if (($this->uri_string = $this->_get_uri_string()) == '') |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 90 | { |
| 91 | if ($this->default_controller === FALSE) |
| 92 | { |
| 93 | show_error("Unable to determine what should be displayed. A default route has not been specified in the routing file."); |
| 94 | } |
| 95 | |
| 96 | $this->set_class($this->default_controller); |
| 97 | $this->set_method('index'); |
| 98 | |
| 99 | log_message('debug', "No URI present. Default controller set."); |
| 100 | return; |
| 101 | } |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 102 | unset($this->routes['default_controller']); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 103 | |
| 104 | // Do we need to remove the suffix specified in the config file? |
| 105 | if ($this->config->item('url_suffix') != "") |
| 106 | { |
| 107 | $this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string); |
| 108 | } |
| 109 | |
| 110 | // Explode the URI Segments. The individual segments will |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 111 | // be stored in the $this->segments array. |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 112 | foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val) |
| 113 | { |
| 114 | // Filter segments for security |
| 115 | $val = trim($this->_filter_uri($val)); |
| 116 | |
| 117 | if ($val != '') |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 118 | $this->segments[] = $val; |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 119 | } |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 120 | |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 121 | // Parse any custom routing that may exist |
| 122 | $this->_parse_routes(); |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 123 | |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 124 | // Re-index the segment array so that it starts with 1 rather than 0 |
admin | 99bccd6 | 2006-09-21 17:05:40 +0000 | [diff] [blame] | 125 | $this->_reindex_segments(); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 126 | } |
| 127 | // END _set_route_mapping() |
| 128 | |
| 129 | // -------------------------------------------------------------------- |
| 130 | |
| 131 | /** |
| 132 | * Compile Segments |
| 133 | * |
| 134 | * This function takes an array of URI segments as |
| 135 | * input, and puts it into the $this->segments array. |
| 136 | * It also sets the current class/method |
| 137 | * |
| 138 | * @access private |
| 139 | * @param array |
| 140 | * @param bool |
| 141 | * @return void |
| 142 | */ |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 143 | function _compile_segments($segments = array()) |
| 144 | { |
| 145 | $segments = $this->_validate_segments($segments); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 146 | |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 147 | if (count($segments) == 0) |
| 148 | { |
| 149 | return; |
| 150 | } |
| 151 | |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 152 | $this->set_class($segments[0]); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 153 | |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 154 | if (isset($segments[1])) |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 155 | { |
| 156 | // A scaffolding request. No funny business with the URL |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 157 | if ($this->routes['scaffolding_trigger'] == $segments[1] AND $segments[1] != '_ci_scaffolding') |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 158 | { |
| 159 | $this->scaffolding_request = TRUE; |
| 160 | unset($this->routes['scaffolding_trigger']); |
| 161 | } |
| 162 | else |
| 163 | { |
| 164 | // A standard method request |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 165 | $this->set_method($segments[1]); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 166 | } |
| 167 | } |
admin | 99bccd6 | 2006-09-21 17:05:40 +0000 | [diff] [blame] | 168 | |
| 169 | // Update our "routed" segment array to contain the segments. |
| 170 | // Note: If there is no custom routing, this array will be |
| 171 | // identical to $this->segments |
| 172 | $this->rsegments = $segments; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 173 | } |
| 174 | // END _compile_segments() |
| 175 | |
| 176 | // -------------------------------------------------------------------- |
| 177 | |
| 178 | /** |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 179 | * Validates the supplied segments. Attempts to determine the path to |
| 180 | * the controller. |
| 181 | * |
| 182 | * @access private |
| 183 | * @param array |
| 184 | * @return array |
| 185 | */ |
| 186 | function _validate_segments($segments) |
| 187 | { |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 188 | // Does the requested controller exist in the root folder? |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 189 | if (file_exists(APPPATH.'controllers/'.$segments[0].EXT)) |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 190 | { |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 191 | return $segments; |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 192 | } |
admin | 1cf89aa | 2006-09-03 18:24:39 +0000 | [diff] [blame] | 193 | |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 194 | // Is the controller in a sub-folder? |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 195 | if (is_dir(APPPATH.'controllers/'.$segments[0])) |
admin | 1cf89aa | 2006-09-03 18:24:39 +0000 | [diff] [blame] | 196 | { |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 197 | // Set the directory and remove it from the segment array |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 198 | $this->set_directory($segments[0]); |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 199 | $segments = array_slice($segments, 1); |
| 200 | |
admin | 1cf89aa | 2006-09-03 18:24:39 +0000 | [diff] [blame] | 201 | if (count($segments) > 0) |
| 202 | { |
| 203 | // Does the requested controller exist in the sub-folder? |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 204 | if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT)) |
admin | 1cf89aa | 2006-09-03 18:24:39 +0000 | [diff] [blame] | 205 | { |
| 206 | show_404(); |
| 207 | } |
| 208 | } |
| 209 | else |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 210 | { |
| 211 | $this->set_class($this->default_controller); |
| 212 | $this->set_method('index'); |
admin | 2781849 | 2006-09-05 03:31:28 +0000 | [diff] [blame] | 213 | |
| 214 | // Does the default controller exist in the sub-folder? |
| 215 | if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT)) |
| 216 | { |
| 217 | $this->directory = ''; |
| 218 | return array(); |
| 219 | } |
| 220 | |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | return $segments; |
| 224 | } |
| 225 | |
| 226 | // Can't find the requested controller... |
| 227 | show_404(); |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 228 | } |
| 229 | // END _validate_segments() |
admin | 99bccd6 | 2006-09-21 17:05:40 +0000 | [diff] [blame] | 230 | |
| 231 | // -------------------------------------------------------------------- |
| 232 | /** |
| 233 | * Re-index Segments |
| 234 | * |
| 235 | * This function re-indexes the $this->segment array so that it |
| 236 | * starts at 1 rather then 0. Doing so makes it simpler to |
| 237 | * use functions like $this->uri->segment(n) since there is |
| 238 | * a 1:1 relationship between the segment array and the actual segments. |
| 239 | * |
| 240 | * @access private |
| 241 | * @return void |
| 242 | */ |
| 243 | function _reindex_segments() |
| 244 | { |
| 245 | // Is the routed segment array different then the main segment array? |
| 246 | $diff = (count(array_diff($this->rsegments, $this->segments)) == 0) ? FALSE : TRUE; |
| 247 | |
| 248 | $i = 1; |
| 249 | foreach ($this->segments as $val) |
| 250 | { |
| 251 | $this->segments[$i++] = $val; |
| 252 | } |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 253 | unset($this->segments[0]); |
admin | 99bccd6 | 2006-09-21 17:05:40 +0000 | [diff] [blame] | 254 | |
| 255 | if ($diff == FALSE) |
| 256 | { |
| 257 | $this->rsegments = $this->segments; |
| 258 | } |
| 259 | else |
| 260 | { |
| 261 | $i = 1; |
| 262 | foreach ($this->rsegments as $val) |
| 263 | { |
| 264 | $this->rsegments[$i++] = $val; |
| 265 | } |
admin | 83b05a8 | 2006-09-25 21:06:46 +0000 | [diff] [blame] | 266 | unset($this->rsegments[0]); |
admin | 99bccd6 | 2006-09-21 17:05:40 +0000 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | // END _reindex_segments() |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 270 | |
| 271 | // -------------------------------------------------------------------- |
| 272 | |
| 273 | /** |
admin | 592cdcb | 2006-09-22 18:45:42 +0000 | [diff] [blame] | 274 | * Get the URI String |
| 275 | * |
| 276 | * @access private |
| 277 | * @return string |
| 278 | */ |
| 279 | function _get_uri_string() |
| 280 | { |
| 281 | if (strtoupper($this->config->item('uri_protocol')) == 'AUTO') |
| 282 | { |
| 283 | $path_info = getenv('PATH_INFO'); |
| 284 | if ($path_info != '' AND $path_info != "/".SELF) |
| 285 | { |
| 286 | return $path_info; |
| 287 | } |
| 288 | else |
| 289 | { |
| 290 | $req_uri = $this->_parse_request_uri(); |
| 291 | |
| 292 | if ($req_uri != "") |
| 293 | { |
| 294 | return $req_uri; |
| 295 | } |
| 296 | else |
| 297 | { |
| 298 | $path_info = getenv('ORIG_PATH_INFO'); |
| 299 | if ($path_info != '' AND $path_info != "/".SELF) |
| 300 | { |
| 301 | return $path_info; |
| 302 | } |
| 303 | else |
| 304 | { |
| 305 | return getenv('QUERY_STRING'); |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | else |
| 311 | { |
| 312 | $uri = strtoupper($this->config->item('uri_protocol')); |
| 313 | |
| 314 | if ($uri == 'REQUEST_URI') |
| 315 | { |
| 316 | return $this->_parse_request_uri(); |
| 317 | } |
| 318 | |
| 319 | return getenv($uri); |
| 320 | } |
| 321 | } |
| 322 | // END _get_uri_string() |
| 323 | |
| 324 | // -------------------------------------------------------------------- |
| 325 | |
| 326 | /** |
| 327 | * Parse the REQUEST_URI |
| 328 | * |
| 329 | * Due to the way REQUEST_URI works it usually contains path info |
| 330 | * that makes it unusable as URI data. We'll trim off the unnecessary |
| 331 | * data, hopefully arriving at a valid URI that we can use. |
| 332 | * |
| 333 | * @access private |
| 334 | * @return string |
| 335 | */ |
| 336 | function _parse_request_uri() |
| 337 | { |
admin | dbd8aec | 2006-09-22 19:20:09 +0000 | [diff] [blame] | 338 | if (($request_uri = getenv('REQUEST_URI')) == '') |
| 339 | { |
| 340 | return ''; |
| 341 | } |
| 342 | |
admin | 592cdcb | 2006-09-22 18:45:42 +0000 | [diff] [blame] | 343 | $fc_path = FCPATH; |
| 344 | |
| 345 | if (strpos($request_uri, '?') !== FALSE) |
| 346 | { |
| 347 | $fc_path .= '?'; |
| 348 | } |
| 349 | |
| 350 | $parsed_uri = explode("/", preg_replace("|/(.*)|", "\\1", str_replace("\\", "/", $request_uri))); |
| 351 | |
| 352 | $i = 0; |
| 353 | foreach(explode("/", $fc_path) as $segment) |
| 354 | { |
| 355 | if ($segment == $parsed_uri[$i]) |
| 356 | { |
| 357 | $i++; |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | $parsed_uri = implode("/", array_slice($parsed_uri, $i)); |
| 362 | |
| 363 | if ($parsed_uri != '') |
| 364 | { |
| 365 | $parsed_uri = '/'.$parsed_uri; |
| 366 | } |
| 367 | |
| 368 | return $parsed_uri; |
| 369 | } |
| 370 | // END _parse_request_uri() |
| 371 | |
| 372 | // -------------------------------------------------------------------- |
| 373 | |
| 374 | /** |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 375 | * Filter segments for malicious characters |
| 376 | * |
| 377 | * @access private |
| 378 | * @param string |
| 379 | * @return string |
| 380 | */ |
| 381 | function _filter_uri($str) |
| 382 | { |
admin | 1082bdd | 2006-08-27 19:32:02 +0000 | [diff] [blame] | 383 | if ($this->config->item('permitted_uri_chars') != '') |
| 384 | { |
| 385 | if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str)) |
| 386 | { |
| 387 | exit('The URI you submitted has disallowed characters: '.$str); |
| 388 | } |
| 389 | } |
| 390 | return $str; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 391 | } |
| 392 | // END _filter_uri() |
| 393 | |
| 394 | // -------------------------------------------------------------------- |
| 395 | |
| 396 | /** |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 397 | * Parse Routes |
| 398 | * |
| 399 | * This function matches any routes that may exist in |
| 400 | * the config/routes.php file against the URI to |
| 401 | * determine if the class/method need to be remapped. |
| 402 | * |
| 403 | * @access private |
| 404 | * @return void |
| 405 | */ |
| 406 | function _parse_routes() |
| 407 | { |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 408 | // Do we even have any custom routing to deal with? |
| 409 | if (count($this->routes) == 0) |
| 410 | { |
| 411 | $this->_compile_segments($this->segments); |
| 412 | return; |
| 413 | } |
| 414 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 415 | // Turn the segment array into a URI string |
| 416 | $uri = implode('/', $this->segments); |
| 417 | $num = count($this->segments); |
| 418 | |
| 419 | // Is there a literal match? If so we're done |
| 420 | if (isset($this->routes[$uri])) |
| 421 | { |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 422 | $this->_compile_segments(explode('/', $this->routes[$uri])); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 423 | return; |
| 424 | } |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 425 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 426 | // Loop through the route array looking for wildcards |
admin | d4e9507 | 2006-08-26 01:15:06 +0000 | [diff] [blame] | 427 | foreach (array_slice($this->routes, 1) as $key => $val) |
admin | b071bb5 | 2006-08-26 19:28:37 +0000 | [diff] [blame] | 428 | { |
admin | d4e9507 | 2006-08-26 01:15:06 +0000 | [diff] [blame] | 429 | // Convert wildcards to RegEx |
| 430 | $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key)); |
| 431 | |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 432 | // Does the RegEx match? |
admin | 71430b4 | 2006-09-15 20:29:25 +0000 | [diff] [blame] | 433 | if (preg_match('#^'.$key.'$#', $uri)) |
admin | d4e9507 | 2006-08-26 01:15:06 +0000 | [diff] [blame] | 434 | { |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 435 | // Do we have a back-reference? |
admin | d4e9507 | 2006-08-26 01:15:06 +0000 | [diff] [blame] | 436 | if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) |
| 437 | { |
admin | 71430b4 | 2006-09-15 20:29:25 +0000 | [diff] [blame] | 438 | $val = preg_replace('#^'.$key.'$#', $val, $uri); |
admin | d4e9507 | 2006-08-26 01:15:06 +0000 | [diff] [blame] | 439 | } |
| 440 | |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 441 | $this->_compile_segments(explode('/', $val)); |
| 442 | return; |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 443 | } |
admin | e07fbb3 | 2006-08-26 17:11:01 +0000 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | // If we got this far it means we didn't encounter a |
| 447 | // matching route so we'll set the site default route |
| 448 | $this->_compile_segments($this->segments); |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 449 | } |
| 450 | // END set_method() |
admin | 45c872b | 2006-08-26 04:51:38 +0000 | [diff] [blame] | 451 | |
| 452 | // -------------------------------------------------------------------- |
| 453 | |
| 454 | /** |
| 455 | * Set the class name |
| 456 | * |
| 457 | * @access public |
| 458 | * @param string |
| 459 | * @return void |
| 460 | */ |
| 461 | function set_class($class) |
| 462 | { |
| 463 | $this->class = $class; |
| 464 | } |
| 465 | // END set_class() |
| 466 | |
| 467 | // -------------------------------------------------------------------- |
| 468 | |
| 469 | /** |
| 470 | * Fetch the current class |
| 471 | * |
| 472 | * @access public |
| 473 | * @return string |
| 474 | */ |
| 475 | function fetch_class() |
| 476 | { |
| 477 | return $this->class; |
| 478 | } |
| 479 | // END fetch_class() |
| 480 | |
| 481 | // -------------------------------------------------------------------- |
| 482 | |
| 483 | /** |
| 484 | * Set the method name |
| 485 | * |
| 486 | * @access public |
| 487 | * @param string |
| 488 | * @return void |
| 489 | */ |
| 490 | function set_method($method) |
| 491 | { |
| 492 | $this->method = $method; |
| 493 | } |
| 494 | // END set_method() |
| 495 | |
| 496 | // -------------------------------------------------------------------- |
| 497 | |
| 498 | /** |
| 499 | * Fetch the current method |
| 500 | * |
| 501 | * @access public |
| 502 | * @return string |
| 503 | */ |
| 504 | function fetch_method() |
| 505 | { |
| 506 | return $this->method; |
| 507 | } |
| 508 | // END fetch_method() |
| 509 | |
| 510 | // -------------------------------------------------------------------- |
| 511 | |
| 512 | /** |
| 513 | * Set the directory name |
| 514 | * |
| 515 | * @access public |
| 516 | * @param string |
| 517 | * @return void |
| 518 | */ |
| 519 | function set_directory($dir) |
| 520 | { |
| 521 | $this->directory = $dir.'/'; |
| 522 | } |
| 523 | // END set_directory() |
| 524 | |
| 525 | // -------------------------------------------------------------------- |
| 526 | |
| 527 | /** |
| 528 | * Fetch the sub-directory (if any) that contains the requested controller class |
| 529 | * |
| 530 | * @access public |
| 531 | * @return string |
| 532 | */ |
| 533 | function fetch_directory() |
| 534 | { |
| 535 | return $this->directory; |
| 536 | } |
| 537 | // END fetch_directory() |
| 538 | |
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 539 | } |
| 540 | // END Router Class |
| 541 | ?> |