#379 GetAbsoluteUrlRoot becomes GetAbsoluteUrlAppRoot which will simplify the development of plugins, fixed a cosmetic issue in export.php (format: html + iTop not installed in the url root path)

SVN:trunk[1259]
This commit is contained in:
Romain Quetiez
2011-05-02 09:34:45 +00:00
parent cc35e41028
commit 938d383efd
2 changed files with 12 additions and 17 deletions

View File

@@ -345,14 +345,17 @@ class utils
* @param $bForceHTTPS bool True to force HTTPS, false otherwise
* @return string The absolute URL to the server's root, without the first slash
*/
static public function GetAbsoluteUrlRoot($bForceHTTPS = false)
static public function GetAbsoluteUrlAppRoot($sCurrentRelativePath = '', $bForceHTTPS = false)
{
$sAbsoluteUrl = self::GetAbsoluteUrl(false, $bForceHTTPS); // False => Don't get the query string
$sServerPos = 3 + strpos($sAbsoluteUrl, '://');
$iFirstSlashPos = strpos($sAbsoluteUrl, '/', $sServerPos);
if ($iFirstSlashPos !== false)
$sAppRootPos = strpos($sAbsoluteUrl, $sCurrentRelativePath);
if ($sAppRootPos !== false)
{
$sAbsoluteUrl = substr($sAbsoluteUrl, 0, $iFirstSlashPos); // remove the current page, keep just the path, without the first /
$sAbsoluteUrl = substr($sAbsoluteUrl, 0, $sAppRootPos); // remove the current page and path
}
else
{
throw new Exception("Failed to determine application root path $sAbsoluteUrl ($sCurrentRelativePath)");
}
return $sAbsoluteUrl;
}