summaryrefslogtreecommitdiffstats
path: root/system/core/Router.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/core/Router.php')
-rwxr-xr-xsystem/core/Router.php54
1 files changed, 30 insertions, 24 deletions
diff --git a/system/core/Router.php b/system/core/Router.php
index b251abb4b..fe9909b06 100755
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Router Class
*
@@ -46,36 +44,42 @@ class CI_Router {
* @var object
*/
public $config;
+
/**
* List of routes
*
* @var array
*/
- public $routes = array();
+ public $routes = array();
+
/**
* List of error routes
*
* @var array
*/
- public $error_routes = array();
+ public $error_routes = array();
+
/**
* Current class name
*
* @var string
*/
- public $class = '';
+ public $class = '';
+
/**
* Current method name
*
* @var string
*/
- public $method = 'index';
+ public $method = 'index';
+
/**
* Sub-directory that contains the requested controller class
*
* @var string
*/
- public $directory = '';
+ public $directory = '';
+
/**
* Default controller (and method if specific)
*
@@ -111,7 +115,7 @@ class CI_Router {
// since URI segments are more search-engine friendly, but they can optionally be used.
// If this feature is enabled, we will gather the directory/class/method a little differently
$segments = array();
- if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
+ if ($this->config->item('enable_query_strings') === TRUE && isset($_GET[$this->config->item('controller_trigger')]))
{
if (isset($_GET[$this->config->item('directory_trigger')]))
{
@@ -133,7 +137,7 @@ class CI_Router {
}
// Load the routes.php file.
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
+ if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
}
@@ -147,7 +151,7 @@ class CI_Router {
// 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']);
+ $this->default_controller = empty($this->routes['default_controller']) ? FALSE : strtolower($this->routes['default_controller']);
// Were there any query string segments? If so, we'll validate them and bail out since we're done.
if (count($segments) > 0)
@@ -213,7 +217,6 @@ class CI_Router {
* input, and sets the current class/method
*
* @param array
- * @param bool
* @return void
*/
protected function _set_request($segments = array())
@@ -239,17 +242,20 @@ class CI_Router {
$segments[1] = 'index';
}
+ // This is being routed to a file in a sub directory
+ $this->directory and array_unshift($segments, trim($this->directory, '/'));
+
// Update our "routed" segment array to contain the segments.
// Note: If there is no custom routing, this array will be
- // identical to $this->uri->segments
+ // identical to $this->uri->segments
$this->uri->rsegments = $segments;
}
// --------------------------------------------------------------------
/**
- * Validates the supplied segments. Attempts to determine the path to
- * the controller.
+ * Validates the supplied segments.
+ * Attempts to determine the path to the controller.
*
* @param array
* @return array
@@ -340,7 +346,7 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Parse Routes
+ * Parse Routes
*
* This function matches any routes that may exist in
* the config/routes.php file against the URI to
@@ -369,7 +375,7 @@ class CI_Router {
if (preg_match('#^'.$key.'$#', $uri))
{
// Do we have a back-reference?
- if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
+ if (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE)
{
$val = preg_replace('#^'.$key.'$#', $val, $uri);
}
@@ -411,7 +417,7 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Set the method name
+ * Set the method name
*
* @param string
* @return void
@@ -424,7 +430,7 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Fetch the current method
+ * Fetch the current method
*
* @return string
*/
@@ -441,7 +447,7 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Set the directory name
+ * Set the directory name
*
* @param string
* @return void
@@ -454,7 +460,7 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Fetch the sub-directory (if any) that contains the requested controller class
+ * Fetch the sub-directory (if any) that contains the requested controller class
*
* @return string
*/
@@ -466,10 +472,10 @@ class CI_Router {
// --------------------------------------------------------------------
/**
- * Set the controller overrides
+ * Set the controller overrides
*
* @param array
- * @return null
+ * @return void
*/
public function _set_overrides($routing)
{
@@ -483,7 +489,7 @@ class CI_Router {
$this->set_directory($routing['directory']);
}
- if (isset($routing['controller']) AND $routing['controller'] != '')
+ if (isset($routing['controller']) && $routing['controller'] != '')
{
$this->set_class($routing['controller']);
}
@@ -498,4 +504,4 @@ class CI_Router {
}
/* End of file Router.php */
-/* Location: ./system/core/Router.php */
+/* Location: ./system/core/Router.php */ \ No newline at end of file