config =& load_class('Config'); $this->_set_route_mapping(); log_message('debug', "Router Class Initialized"); } public function _set_route_mapping() { echo 'a'; // Are query strings enabled in the config file? // If so, we're done since segment based URIs are not used with query strings. if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')])) { $this->set_class($_GET[$this->config->item('controller_trigger')]); if (isset($_GET[$this->config->item('function_trigger')])) { $this->set_method($_GET[$this->config->item('function_trigger')]); } return; } echo 'b'; // Load the routes.php file. @include(APPPATH.'config/routes'.EXT); $this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route; unset($route); // Set the default controller so we can display it in the event // the URI doesn't correlated to a valid controller. $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']); // Fetch the complete URI string $this->uri_string = $this->_get_uri_string(); // If the URI contains only a slash we'll kill it if ($this->uri_string == '/') { $this->uri_string = ''; } echo 'c'; // Is there a URI string? If not, the default controller specified in the "routes" file will be shown. if ($this->uri_string == '') { if ($this->default_controller === FALSE) { show_error("Unable to determine what should be displayed. A default route has not been specified in the routing file."); } $this->set_class($this->default_controller); $this->set_method('index'); log_message('debug', "No URI present. Default controller set."); return; } unset($this->routes['default_controller']); echo 'd'; // Do we need to remove the suffix specified in the config file? if ($this->config->item('url_suffix') != "") { $this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string); } // Modified by: Peter Goodman // Split the URI Segments. The individual segments will // be stored in the $this->segments array, then checked over // to see if any of them are sub-folders of the original // controllers directory. $this->segments = preg_split("~/~", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string), -1, PREG_SPLIT_NO_EMPTY); $i = -1; while(isset($this->segments[++$i])) { if(is_dir($this->segments[$i])) { $this->directory .= array_shift($this->segments) .'/'; } else { break; } } $this->segments = array_values($this->segments); // end modification echo 'e'; // Parse any custom routing that may exist $this->_parse_routes(); echo 'f'; // Re-index the segment array so that it starts with 1 rather than 0 $this->_reindex_segments(); echo 'g'; } }