diff options
author | philsturgeon <devnull@localhost> | 2011-06-15 17:03:29 +0200 |
---|---|---|
committer | philsturgeon <devnull@localhost> | 2011-06-15 17:03:29 +0200 |
commit | b2e728f9ec393b181d287717a5e2adbc781aad82 (patch) | |
tree | c939618480a8296d15e4d6c9dd6f9a9ddca4acd7 /system/core | |
parent | 96bf25d7c6bb73e957a522db11cd8b42a5aa6cd3 (diff) | |
parent | 76696d76e137e98f0597547b71b40a991d8b025b (diff) |
Merged base_url changes.
Diffstat (limited to 'system/core')
-rw-r--r-- | system/core/Config.php | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/system/core/Config.php b/system/core/Config.php index fa71f4d3d..d871f5432 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -203,10 +203,7 @@ class CI_Config { // -------------------------------------------------------------------- /** - * Fetch a config file item - adds slash after item - * - * The second parameter allows a slash to be added to the end of - * the item, in the case of a path. + * Fetch a config file item - adds slash after item (if item is not empty) * * @access public * @param string the config item name @@ -219,6 +216,10 @@ class CI_Config { { return FALSE; } + if( trim($this->config[$item]) == '') + { + return ''; + } return rtrim($this->config[$item], '/').'/'; } @@ -227,6 +228,7 @@ class CI_Config { /** * Site URL + * Returns base_url . index_page [. uri_string] * * @access public * @param string the URI string @@ -241,14 +243,48 @@ class CI_Config { if ($this->item('enable_query_strings') == FALSE) { + $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix'); + return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; + } + else + { + return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri); + } + } + + // ------------------------------------------------------------- + + /** + * Base URL + * Returns base_url [. uri_string] + * + * @access public + * @param string $uri + * @return string + */ + function base_url($uri = '') + { + return $this->slash_item('base_url').ltrim($this->_uri_string($uri),'/'); + } + + // ------------------------------------------------------------- + + /** + * Build URI string for use in Config::site_url() and Config::base_url() + * + * @access protected + * @param $uri + * @return string + */ + protected function _uri_string($uri) + { + if ($this->item('enable_query_strings') == FALSE) + { if (is_array($uri)) { $uri = implode('/', $uri); } - - $index = $this->item('index_page') == '' ? '' : $this->slash_item('index_page'); - $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix'); - return $this->slash_item('base_url').$index.trim($uri, '/').$suffix; + $uri = trim($uri, '/'); } else { @@ -262,16 +298,14 @@ class CI_Config { $str .= $prefix.$key.'='.$val; $i++; } - $uri = $str; } - - return $this->slash_item('base_url').$this->item('index_page').'?'.$uri; } + return $uri; } // -------------------------------------------------------------------- - + /** * System URL * |