From d09c51afac9df77a52380dc2ac6581a104faa2ff Mon Sep 17 00:00:00 2001 From: "anaxamaxan@blackdog.local" Date: Wed, 2 Feb 2011 23:00:16 -0800 Subject: Made config->base_url() accept parameters. config->base_url($uri). Updated base_url() in url_helper accordingly. --- system/core/Config.php | 58 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 12 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index da22222dc..554b7360a 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -194,10 +194,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 @@ -210,6 +207,10 @@ class CI_Config { { return FALSE; } + if( trim($this->config[$item]) == '') + { + return ''; + } return rtrim($this->config[$item], '/').'/'; } @@ -218,6 +219,7 @@ class CI_Config { /** * Site URL + * Returns base_url . index_page [. uri_string] * * @access public * @param string the URI string @@ -230,16 +232,50 @@ class CI_Config { return $this->slash_item('base_url').$this->item('index_page'); } + 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 { @@ -253,16 +289,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 * -- cgit v1.2.3-24-g4f1b From 3a746655e92ec59ee7e731c3535673a9aedc5d3e Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Tue, 19 Apr 2011 10:59:47 -0500 Subject: Removing internal references to the EXT constant. Additionally, marked the constant as deprecated. Use ".php" instead. Also adding upgrade notes from 2.0.2 to 2.0.3. --- system/core/Config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 863c5ef4b..4493ff266 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -80,7 +80,7 @@ class CI_Config { */ function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { - $file = ($file == '') ? 'config' : str_replace(EXT, '', $file); + $file = ($file == '') ? 'config' : str_replace('.php', '', $file); $found = FALSE; $loaded = FALSE; @@ -92,7 +92,7 @@ class CI_Config { foreach ($check_locations as $location) { - $file_path = $path.'config/'.$location.EXT; + $file_path = $path.'config/'.$location.'.php'; if (in_array($file_path, $this->is_loaded, TRUE)) { @@ -152,7 +152,7 @@ class CI_Config { { return FALSE; } - show_error('The configuration file '.$file.EXT.' does not exist.'); + show_error('The configuration file '.$file.'.php'.' does not exist.'); } return TRUE; -- cgit v1.2.3-24-g4f1b From d127e611c64fd1cf6a750b20c4e35b1158e06e27 Mon Sep 17 00:00:00 2001 From: katzgrau Date: Fri, 22 Apr 2011 10:59:25 -0400 Subject: Fixed re-searching for config file even though one had been loaded ($found was set to true, never reset). Also fixes getsparks issue. --- system/core/Config.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 4493ff266..1096a9ea6 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -144,6 +144,7 @@ class CI_Config { $loaded = TRUE; log_message('debug', 'Config file loaded: '.$file_path); + break; } if ($loaded === FALSE) @@ -326,4 +327,4 @@ class CI_Config { // END CI_Config class /* End of file Config.php */ -/* Location: ./system/core/Config.php */ \ No newline at end of file +/* Location: ./system/core/Config.php */ -- cgit v1.2.3-24-g4f1b From 114ab0988e20ac6be39ad363ff897a1a3b85e565 Mon Sep 17 00:00:00 2001 From: Razican Date: Mon, 25 Apr 2011 17:26:45 +0200 Subject: Fixed double-space typo. --- system/core/Config.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 1096a9ea6..fa71f4d3d 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -1,4 +1,4 @@ - Date: Tue, 26 Apr 2011 09:59:29 -0400 Subject: Automatic base_url generation was missing a ending slash. --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index fa71f4d3d..55c623b3c 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -55,7 +55,7 @@ class CI_Config { { $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; $base_url .= '://'. $_SERVER['HTTP_HOST']; - $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); + $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']).'/'; } else -- cgit v1.2.3-24-g4f1b From 32dbac2695490fb751fc8da645bba945bc8da718 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Tue, 26 Apr 2011 22:51:32 -0400 Subject: Reverting last change. Don't know what I was thinking. :( --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 55c623b3c..fa71f4d3d 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -55,7 +55,7 @@ class CI_Config { { $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; $base_url .= '://'. $_SERVER['HTTP_HOST']; - $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']).'/'; + $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); } else -- cgit v1.2.3-24-g4f1b From 4b9c62980599228f070b401c7673dce8085b0c61 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 1 Jul 2011 17:40:48 -0500 Subject: backed out 648b42a75739, which was a NON-trivial whitespace commit. It broke the Typography class's string replacements, for instance --- system/core/Config.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index fa71f4d3d..1096a9ea6 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -1,4 +1,4 @@ -