[Fusionforge-commits] r15923 - trunk/src/common/include

Olivier Berger olberger at fusionforge.org
Tue Jul 3 17:01:01 CEST 2012


Author: olberger
Date: 2012-07-03 17:01:00 +0200 (Tue, 03 Jul 2012)
New Revision: 15923

Modified:
   trunk/src/common/include/utils.php
Log:
add optional forced http|https prefix to util_make_url() and its subcalls

Modified: trunk/src/common/include/utils.php
===================================================================
--- trunk/src/common/include/utils.php	2012-07-03 14:50:03 UTC (rev 15922)
+++ trunk/src/common/include/utils.php	2012-07-03 15:01:00 UTC (rev 15923)
@@ -1081,23 +1081,30 @@
 /**
  * Return URL prefix (http:// or https://)
  *
+ * @param       string  $prefix (optional) : 'http' or 'https' to force it
  * @return	string	URL prefix
  */
-function util_url_prefix() {
-	if (forge_get_config('use_ssl')) {
-		return "https://";
-	} else {
-		return "http://";
+function util_url_prefix($prefix = '') {
+	if ($prefix == 'http' || $prefix == 'https' ) {
+		return $prefix . '://';
 	}
+	else {
+		if (forge_get_config('use_ssl')) {
+			return "https://";
+		} else {
+			return "http://";
+		}
+	}
 }
 
 /**
  * Construct the base URL http[s]://forge_name[:port]
  *
+ * @param       string  $prefix (optional) : 'http' or 'https' to force it
  * @return	string base URL
  */
-function util_make_base_url() {
-	$url = util_url_prefix();
+function util_make_base_url($prefix = '') {
+	$url = util_url_prefix($prefix);
 	$url .= forge_get_config('web_host') ;
 	if (forge_get_config('https_port') && (forge_get_config('https_port') != 443)) {
 		$url .= ":".forge_get_config('https_port') ;
@@ -1108,11 +1115,12 @@
 /**
  * Construct full URL from a relative path
  *
- * @param	string	$path
+ * @param	string	$path (optional)
+ * @param       string  $prefix (optional) : 'http' or 'https' to force it
  * @return	string	URL
  */
-function util_make_url($path = '') {
-	$url = util_make_base_url().util_make_uri($path) ;
+function util_make_url($path = '', $prefix = '') {
+	$url = util_make_base_url($prefix).util_make_uri($path) ;
 	return $url;
 }
 




More information about the Fusionforge-commits mailing list