summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2013-07-18 02:19:59 +0200
committerAndrey Andreev <narf@devilix.net>2013-07-18 02:19:59 +0200
commit2023c3d05b042cf1322286d69557c2b8bf3bd8d5 (patch)
tree2dab60654b21424ea14d9df174425501571b0a5a /system/helpers
parentd5ab75e7d6636ce324416c4b3856bc552c9028d1 (diff)
Add an optional parameter to URL helpers base_url() and site_url() (supersedes #2535)
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/url_helper.php28
1 files changed, 21 insertions, 7 deletions
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index d0fab3fe0..36219630d 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -46,13 +46,20 @@ if ( ! function_exists('site_url'))
* Create a local URL based on your basepath. Segments can be passed via the
* first parameter either as a string or an array.
*
- * @param string
+ * @param string $uri
+ * @param string $protocol
* @return string
*/
function site_url($uri = '')
{
- $CI =& get_instance();
- return $CI->config->site_url($uri);
+ $site_url = get_instance()->config->site_url($uri);
+
+ if (isset($protocol))
+ {
+ $site_url = $protocol.substr($site_url, strpos($site_url, '://'));
+ }
+
+ return $site_url;
}
}
@@ -67,13 +74,20 @@ if ( ! function_exists('base_url'))
* Segments can be passed in as a string or an array, same as site_url
* or a URL to a file can be passed in, e.g. to an image file.
*
- * @param string
+ * @param string $uri
+ * @param string $protocol
* @return string
*/
- function base_url($uri = '')
+ function base_url($uri = '', $protocol = NULL)
{
- $CI =& get_instance();
- return $CI->config->base_url($uri);
+ $base_url = get_instance()->config->base_url($uri);
+
+ if (isset($protocol))
+ {
+ $base_url = $protocol.substr($base_url, strpos($base_url, '://'));
+ }
+
+ return $base_url;
}
}