From 938d383efd9ad77d53337659afb2a3f891a2cbc1 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Mon, 2 May 2011 09:34:45 +0000 Subject: [PATCH] #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] --- application/utils.inc.php | 13 ++++++++----- webservices/export.php | 16 ++++------------ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index 2d69bb697..a06520e53 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -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; } diff --git a/webservices/export.php b/webservices/export.php index 4d81723c9..dc3168e4d 100644 --- a/webservices/export.php +++ b/webservices/export.php @@ -59,21 +59,13 @@ if (!empty($sExpression)) { case 'html': $oP = new NiceWebPage("iTop - Export"); + // The HTML output is made for pages located in the /pages/ folder // since this page is in a different folder, let's adjust the HTML 'base' attribute // to make the relative hyperlinks in the page work - $sServerName = $_SERVER['SERVER_NAME']; - $sProtocol = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off')) ? 'https' : 'http'; - if ($sProtocol == 'http') - { - $sPort = ($_SERVER['SERVER_PORT'] == 80) ? '' : ':'.$_SERVER['SERVER_PORT']; - } - else - { - $sPort = ($_SERVER['SERVER_PORT'] == 443) ? '' : ':'.$_SERVER['SERVER_PORT']; - } - $sUrl = "$sProtocol://{$sServerName}{$sPort}/pages/"; - $oP->set_base($sUrl); + $sUrl = utils::GetAbsoluteUrlAppRoot('/webservices/'); + $oP->set_base($sUrl.'/pages/'); + $oResultBlock = new DisplayBlock($oFilter, 'list', false, array('menu' => false, 'display_limit' => false, 'zlist' => 'details')); $oResultBlock->Display($oP, 'expresult'); break;