summaryrefslogtreecommitdiffstats
path: root/system/core/Config.php
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-08-13 18:28:45 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-08-13 18:28:45 +0200
commit3cf2715501be298ef00166d57a4df39829aa2c09 (patch)
tree9a67222945f8484c3130ec56ab6cc8ef2575ec11 /system/core/Config.php
parent6f1b3841b6f660dfbaa5e00df456d793e67fe60f (diff)
parentc4f024641ab69ed9cce62a2864e47e060b81048b (diff)
Merge branch 'develop' of ellislab.beanstalkapp.com:/codeigniter into develop
Diffstat (limited to 'system/core/Config.php')
-rw-r--r--system/core/Config.php58
1 files changed, 46 insertions, 12 deletions
diff --git a/system/core/Config.php b/system/core/Config.php
index 1096a9ea6..0e6f10e07 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
*