summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-09-22 20:45:42 +0200
committeradmin <devnull@localhost>2006-09-22 20:45:42 +0200
commit592cdcbc58963f0cf811aea59db9907943460770 (patch)
treeb04e784e804d409c237697901cb1f46e4c6ae948
parent6de4e5f149b9d467a3238250dfe4f45bb9512e87 (diff)
-rw-r--r--index.php1
-rw-r--r--system/helpers/inflector_helper.php4
-rw-r--r--system/libraries/Router.php138
-rw-r--r--user_guide/general/changelog.html1
-rw-r--r--user_guide/helpers/inflector_helper.html2
5 files changed, 109 insertions, 37 deletions
diff --git a/index.php b/index.php
index 7c910e1e1..16084c398 100644
--- a/index.php
+++ b/index.php
@@ -76,6 +76,7 @@ define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('BASEPATH', $system_folder.'/');
define('APPPATH', BASEPATH.'application/'.$application_folder);
+define('FCPATH', __FILE__);
require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;
?> \ No newline at end of file
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 3bded708e..3d8d3e0ca 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -31,7 +31,7 @@
/**
* Singular
*
- * Takes a plural word and makes it singular
+ * Takes a singular word and makes it plural
*
* @access public
* @param string
@@ -64,7 +64,7 @@ function singular($str)
/**
* Plural
*
- * Takes a singular word and makes it plural
+ * Takes a plural word and makes it singular
*
* @access public
* @param string
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 868fd909e..5bbf9e6ca 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -77,45 +77,18 @@ class CI_Router {
return;
}
-
- // Load the routes.php file
+
+ // Load the routes.php file and set the default controller
@include_once(APPPATH.'config/routes'.EXT);
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
unset($route);
- // Set the default controller
- $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
-
- // Fetch the URI string Depending on the server,
- // the URI will be available in one of two globals
- if ($this->config->item('uri_protocol') == 'auto')
- {
- $path_info = getenv('PATH_INFO');
- if ($path_info != '' AND $path_info != "/".SELF)
- {
- $this->uri_string = $path_info;
- }
- else
- {
- $path_info = getenv('ORIG_PATH_INFO');
- if ($path_info != '' AND $path_info != "/".SELF)
- {
- $this->uri_string = $path_info;
- }
- else
- {
- $this->uri_string = getenv('QUERY_STRING');
- }
- }
- }
- else
- {
- $this->uri_string = getenv(strtoupper($this->config->item('uri_protocol')));
- }
-
+ $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
- // Is there a URI string? If not, the default controller specified
- // by the admin in the "routes" file will be shown.
+ // Get the URI string
+ $this->uri_string = $this->_get_uri_string();
+
+ // 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)
@@ -301,6 +274,103 @@ class CI_Router {
// --------------------------------------------------------------------
/**
+ * Get the URI String
+ *
+ * @access private
+ * @return string
+ */
+ function _get_uri_string()
+ {
+ if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
+ {
+ $path_info = getenv('PATH_INFO');
+ if ($path_info != '' AND $path_info != "/".SELF)
+ {
+ return $path_info;
+ }
+ else
+ {
+ $req_uri = $this->_parse_request_uri();
+
+ if ($req_uri != "")
+ {
+ return $req_uri;
+ }
+ else
+ {
+ $path_info = getenv('ORIG_PATH_INFO');
+ if ($path_info != '' AND $path_info != "/".SELF)
+ {
+ return $path_info;
+ }
+ else
+ {
+ return getenv('QUERY_STRING');
+ }
+ }
+ }
+ }
+ else
+ {
+ $uri = strtoupper($this->config->item('uri_protocol'));
+
+ if ($uri == 'REQUEST_URI')
+ {
+ return $this->_parse_request_uri();
+ }
+
+ return getenv($uri);
+ }
+ }
+ // END _get_uri_string()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Parse the REQUEST_URI
+ *
+ * Due to the way REQUEST_URI works it usually contains path info
+ * that makes it unusable as URI data. We'll trim off the unnecessary
+ * data, hopefully arriving at a valid URI that we can use.
+ *
+ * @access private
+ * @return string
+ */
+ function _parse_request_uri()
+ {
+ $request_uri = getenv('REQUEST_URI');
+ $fc_path = FCPATH;
+
+ if (strpos($request_uri, '?') !== FALSE)
+ {
+ $fc_path .= '?';
+ }
+
+ $parsed_uri = explode("/", preg_replace("|/(.*)|", "\\1", str_replace("\\", "/", $request_uri)));
+
+ $i = 0;
+ foreach(explode("/", $fc_path) as $segment)
+ {
+ if ($segment == $parsed_uri[$i])
+ {
+ $i++;
+ }
+ }
+
+ $parsed_uri = implode("/", array_slice($parsed_uri, $i));
+
+ if ($parsed_uri != '')
+ {
+ $parsed_uri = '/'.$parsed_uri;
+ }
+
+ return $parsed_uri;
+ }
+ // END _parse_request_uri()
+
+ // --------------------------------------------------------------------
+
+ /**
* Filter segments for malicious characters
*
* @access private
diff --git a/user_guide/general/changelog.html b/user_guide/general/changelog.html
index c769914fc..7aa778962 100644
--- a/user_guide/general/changelog.html
+++ b/user_guide/general/changelog.html
@@ -78,6 +78,7 @@ Change Log
<li>Added <dfn>delete_cookie()</dfn> and <dfn>get_cookie()</dfn> to <a href="../helpers/cookie_helper.html">Cookie helper</a>, even though the input class has a cookie fetching function.</li>
<li>Added Oracle database driver (still undergoing testing so it might have some bugs).</li>
<li>Added the ability to combine pseudo-variables and php variables in the template parser class.</li>
+<li>Added output compression option to the config file.</li>
<li>Removed the is_numeric test from the db->escape() function.</li>
<li>Fixed a MySQLi bug that was causing error messages not to contain proper error data.</li>
<li>Fixed a bug in the email class which was causing it to ignore explicitly set alternative headers.</li>
diff --git a/user_guide/helpers/inflector_helper.html b/user_guide/helpers/inflector_helper.html
index 379f56a9b..fc7e406f8 100644
--- a/user_guide/helpers/inflector_helper.html
+++ b/user_guide/helpers/inflector_helper.html
@@ -120,7 +120,7 @@ echo underscore($word); // Returns "my_dog_spot"
<code>
$word = "my_dog_spot";<br />
-echo humanize($word); // Returns "my dog spot"
+echo humanize($word); // Returns "My Dog Spot"
</code>