/** * Sets the routes. * * @return void */ public function _set_routing() { if ($this->config->item('enable_query_strings') && isset($_GET[$this->config->item('controller_trigger')])) { // controller $this->class = trim($this->uri->_filter_uri($_GET[$this->config->item('controller_trigger')])); // module if (isset($_GET[$this->config->item('module_trigger')])) { $this->module = trim($this->uri->_filter_uri($_GET[$this->config->item('module_trigger')])); // check if it is installed include APPPATH . 'config/modules.php'; if (in_array($this->module, array_keys($modules)) && !in_array($this->module, $disable_controller)) { // get path $this->module_path = $modules[$this->module]; } else { // no module with that name exists $this->module = false; } } // method if (isset($_GET[$this->config->item('function_trigger')])) { $this->method = trim($this->uri->_filter_uri($_GET[$this->config->item('function_trigger')])); } // language if (isset($_GET[$this->config->item('language_trigger')]) && ($key = $this->valid_lang_key($_GET[$this->config->item('language_trigger')]))) { $this->lang_key = $key; $this->apply_language(); } else { // Browser detection : need to be rewritten // This function does not return the good language in case of root ("/") URL // It just returns the first found browser lang code, which can be incorrect. // $this->detect_language(); // No browser detection : Ionize defined default lang code. $this->set_default_language(); } } else { // Fetch the complete URI string $this->uri->_fetch_uri_string(); // use the default controller if (empty($this->uri->uri_string)) { $this->load_default_uri(); } $this->uri->_remove_url_suffix(); // clean the uri and explode it $this->explode_segments($this->uri->uri_string); // LANGUAGE: // check if we have a valid language key there if ($key = $this->validate_lang_key($raw_key = current($this->uri->segments))) { $this->lang_key = $key; $this->apply_language(); // remove the language key array_shift($this->uri->segments); if (empty($this->uri->segments)) { // load the default uri again $this->load_default_uri(); $this->uri->_remove_url_suffix(); // clean the uri and explode it $this->explode_segments($this->uri->uri_string); } else { // remove the language key from the uri_string $this->uri->uri_string = '/' . preg_replace('/\\/?' . preg_quote($raw_key) . '\\//', '', $this->uri->uri_string); } } else { // No browser detection : Ionize defined default lang code. $this->set_default_language(); // Browser detection : need to be rewritten // This function does not return the good language in case of root ("/") URL // It just returns the first found browser lang code, which can be incorrect. // $this->detect_language(); } // END LANGUAGE // get the generated module file and see if we can match to a module include APPPATH . 'config/modules.php'; // get the first segment, to match to the modules $rmodule = current($this->uri->segments); // do we have a module with that name? if (in_array($rmodule, array_keys($modules)) && !in_array($rmodule, $disable_controller)) { // yes, remove it and store it as a module, also remove the module name from the uri $this->module_path = $modules[array_shift($this->uri->segments)]; $this->module = $rmodule; } elseif (in_array($rmodule, array_keys($aliases))) { // yes, get module and controller, remove alias from the uri list($this->module_path, $c) = each($aliases[array_shift($this->uri->segments)]); $this->module = array_search($this->module_path, $modules); // add the controller back to it, so the match_to_routes() and find controller works as they should $this->uri->segments = array_merge(array($c), $this->uri->segments); } if ($this->module_path) { // we have module, add the module to the cascade Finder::$paths = array_merge(array(MODPATH . $this->module_path . '/'), Finder::$paths); } $this->uri->segments = $this->match_to_routes($this->uri->segments); $this->find_controller($this->uri->segments); // add the module first so it is correct if ($this->module_path) { $this->uri->segments = array_merge(array($this->module), $this->uri->segments); } // make them start with 1 $this->uri->_reindex_segments(); } }
/** * Sets the routes. * * @return void */ public function _set_routing() { if ($this->config->item('enable_query_strings') && isset($_GET[$this->config->item('controller_trigger')])) { // controller $this->class = trim($this->uri->_filter_uri($_GET[$this->config->item('controller_trigger')])); // module if (isset($_GET[$this->config->item('module_trigger')])) { $this->module = trim($this->uri->_filter_uri($_GET[$this->config->item('module_trigger')])); // check if it is installed include APPPATH . 'config/modules.php'; if (in_array($this->module, array_keys($modules)) && !in_array($this->module, $disable_controller)) { // get path $this->module_path = $modules[$this->module]; } else { // no module with that name exists $this->module = FALSE; } } // method if (isset($_GET[$this->config->item('function_trigger')])) { $this->method = trim($this->uri->_filter_uri($_GET[$this->config->item('function_trigger')])); } // language if (isset($_GET[$this->config->item('language_trigger')]) && ($key = $this->valid_lang_key($_GET[$this->config->item('language_trigger')]))) { $this->lang_key = $key; $this->apply_language(); } else { // Lang detection : Cookie, Browser $this->detect_language(); } } else { // Fetch the complete URI string $this->uri->_fetch_uri_string(); // use the default controller if (empty($this->uri->uri_string)) { $this->uri->uri_string = ''; } $this->uri->_remove_url_suffix(); // clean the uri and explode it $this->explode_segments($this->uri->uri_string); $this->raw_key = current($this->uri->segments); // Language key : check if we have a valid language key there if ($key = $this->validate_lang_key($this->raw_key)) { if (count($this->uri->segments) == 1 && $key == $this->config->item('default_lang_code')) { $this->redirect_home_to_base_url(); } $this->lang_key = $key; $this->apply_language(); // remove the language key array_shift($this->uri->segments); if (empty($this->uri->segments)) { $this->uri->uri_string = ''; } else { // remove the language key from the uri_string $this->uri->uri_string = strstr($this->uri->uri_string, '/'); } } else { // Lang detection : Cookie, Browser $this->detect_language(); // Home Page : Redirect to detected lang ? if ($this->raw_key == '') { $this->redirect_home_to_lang_url(); } } // END Language key // get the generated module file and see if we can match to a module include APPPATH . 'config/modules.php'; // get the first segment, to match to the modules $rmodule = current($this->uri->segments); // do we have a module with that name? if (in_array($rmodule, array_keys($modules)) && !in_array($rmodule, $disable_controller)) { // yes, remove it and store it as a module, also remove the module name from the uri $this->module_path = $modules[array_shift($this->uri->segments)]; $this->module = $rmodule; } elseif (in_array($rmodule, array_keys($aliases))) { // yes, get module and controller, remove alias from the uri list($this->module_path, $c) = each($aliases[array_shift($this->uri->segments)]); $this->module = array_search($this->module_path, $modules); // add the controller back to it, so the match_to_routes() and find controller works as they should $this->uri->segments = array_merge(array($c), $this->uri->segments); } if ($this->module_path) { // we have module, add the module to the cascade Finder::$paths = array_merge(array(MODPATH . $this->module_path . '/'), Finder::$paths); } $this->uri->segments = $this->match_to_routes($this->uri->segments); $this->find_controller($this->uri->segments); // add the module first so it is correct if ($this->module_path) { $this->uri->segments = array_merge(array($this->module), $this->uri->segments); } // make them start with 1 $this->uri->_reindex_segments(); } }