Browse Source

Fixed absolute/relative path issues in the JS and href places

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1763 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 years ago
parent
commit
648af437b5

+ 11 - 6
application/itopwebpage.class.inc.php

@@ -50,7 +50,7 @@ class iTopWebPage extends NiceWebPage
 		$this->m_aTabs = array();
 		$this->m_sMenu = "";
 		$this->m_sMessage = '';
-		$sAbsURLAppRoot = addslashes(utils::GetAbsoluteUrlAppRoot()); // Pass it to Javascript scripts
+		$this->SetRootUrl(utils::GetAbsoluteUrlAppRoot());
 		$oAppContext = new ApplicationContext();
 		$sExtraParams = $oAppContext->GetForLink();
 		$sAppContext = addslashes($sExtraParams);
@@ -402,11 +402,6 @@ EOF
 			}
 		}
 		
-		function GetAbsoluteUrlAppRoot()
-		{
-			return '$sAbsURLAppRoot';
-		}
-		
 		function AddAppContext(sURL)
 		{
 			var sContext = '$sAppContext';
@@ -546,6 +541,16 @@ EOF
 	 */
     public function output()
     {
+    	$sAbsURLAppRoot = addslashes($this->m_sRootUrl);
+		$this->add_script(
+<<<EOF
+function GetAbsoluteUrlAppRoot()
+{
+	return '$sAbsURLAppRoot';
+}
+EOF
+		);
+		$this->set_base($this->m_sRootUrl.'pages/');
 		$sForm = $this->GetSiloSelectionForm();
 		$this->DisplayMenu(); // Compute the menu
 

+ 0 - 1
application/loginwebpage.class.inc.php

@@ -89,7 +89,6 @@ h1 {
 }
 EOF
 );
-		$this->set_base(utils::GetAbsoluteUrlAppRoot().'pages/');
 	}
 	
 	public static function SetLoginFailedMessage($sMessage)

+ 19 - 9
application/nicewebpage.class.inc.php

@@ -30,30 +30,30 @@ require_once(APPROOT."/application/webpage.class.inc.php");
 class NiceWebPage extends WebPage
 {
 	var $m_aReadyScripts;
+	var $m_sRootUrl;
 	
     public function __construct($s_title)
     {
         parent::__construct($s_title);
 		$this->m_aReadyScripts = array();
 		$this->add_linked_script("../js/jquery-1.4.2.min.js");
-		//$this->add_linked_script("../js/jquery.history_remote.pack.js");
 		$this->add_linked_stylesheet('../css/ui-lightness/jquery-ui-1.8.2.custom.css');
 		$this->add_linked_script('../js/jquery-ui-1.8.2.custom.min.js');
-		//$this->add_linked_script("../js/ui.resizable.js");
-//		$this->add_linked_script("../js/ui.tabs.js");
 		$this->add_linked_script("../js/hovertip.js");
-//		$this->add_linked_script("../js/jqModal.js");
 		$this->add_linked_stylesheet("../css/light-grey.css");
-//		$this->add_linked_stylesheet("../js/themes/light/light.tabs.css");
-		//$this->add_linked_stylesheet("../css/jquery.tabs-ie.css", "lte IE 7");
-//		$this->add_linked_stylesheet("../css/jqModal.css");
-		$this->add_ready_script('    window.setTimeout(hovertipInit, 1);');
+
+		$this->m_sRootUrl = '../'; 		
     }
 	
+    public function SetRootUrl($sRootUrl)
+    {
+    	$this->m_sRootUrl = $sRootUrl;
+    }
+    
 	public function small_p($sText)
 	{
 		$this->add("<p style=\"font-size:smaller\">$sText</p>\n");
-	}	
+	}
 
 	// By Rom, used by CSVImport and Advanced search
 	public function MakeClassesSelect($sName, $sDefaultValue, $iWidthPx, $iActionCode = null)
@@ -100,6 +100,16 @@ class NiceWebPage extends WebPage
 	 */
     public function output()
     {
+    	$sAbsURLAppRoot = addslashes($this->m_sRootUrl);
+		$this->add_script(
+<<<EOF
+function GetAbsoluteUrlAppRoot()
+{
+	return '$sAbsURLAppRoot';
+}
+EOF
+		);
+		$this->set_base($this->m_sRootUrl.'pages/');
         if (count($this->m_aReadyScripts)>0)
         {
 			$this->add_script("\$(document).ready(function() {\n".implode("\n", $this->m_aReadyScripts)."\n});");

+ 1 - 1
core/bulkchange.class.inc.php

@@ -917,7 +917,7 @@ class BulkChange
 		$aDetails = array();
 		while ($oChange = $oBulkChanges->Fetch())
 		{
-			$sDate = '<a href="?step=10&changeid='.$oChange->GetKey().'&'.$oAppContext->GetForLink().'">'.$oChange->Get('date').'</a>';
+			$sDate = '<a href="csvimport.php?step=10&changeid='.$oChange->GetKey().'&'.$oAppContext->GetForLink().'">'.$oChange->Get('date').'</a>';
 			$sUser = $oChange->GetUserName();
 			if (preg_match('/^(.*)\\(CSV\\)$/i', $oChange->Get('userinfo'), $aMatches))
 			{

+ 2 - 2
pages/audit.php

@@ -203,7 +203,7 @@ try
 					if ($iCount == 0)
 					{
 						// nothing to check, really !
-						$aRow['nb_errors'] = "<a href=\"?operation=errors&category=".$oAuditCategory->GetKey()."&rule=".$oAuditRule->GetKey()."\">0</a>"; 
+						$aRow['nb_errors'] = "<a href=\"audit.php?operation=errors&category=".$oAuditCategory->GetKey()."&rule=".$oAuditRule->GetKey()."\">0</a>"; 
 						$aRow['percent_ok'] = '100.00';
 						$aRow['class'] = GetReportColor($iCount, 0);
 					}
@@ -218,7 +218,7 @@ try
 							{
 								$aObjectsWithErrors[$oObj->GetKey()] = true;
 							}
-							$aRow['nb_errors'] = ($iErrorsCount == 0) ? '0' : "<a href=\"?operation=errors&category=".$oAuditCategory->GetKey()."&rule=".$oAuditRule->GetKey()."&".$oAppContext->GetForLink()."\">$iErrorsCount</a>"; 
+							$aRow['nb_errors'] = ($iErrorsCount == 0) ? '0' : "<a href=\"audit.php?operation=errors&category=".$oAuditCategory->GetKey()."&rule=".$oAuditRule->GetKey()."&".$oAppContext->GetForLink()."\">$iErrorsCount</a>"; 
 							$aRow['percent_ok'] = sprintf('%.2f', 100.0 * (($iCount - $iErrorsCount) / $iCount));
 							$aRow['class'] = GetReportColor($iCount, $iErrorsCount);							
 						}

+ 3 - 3
pages/schema.php

@@ -38,7 +38,7 @@ LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be
  */
 function MakeClassHLink($sClass, $sContext)
 {
-	return "<a href=\"?operation=details_class&class=$sClass{$sContext}\" title=\"".MetaModel::GetClassDescription($sClass)."\">".MetaModel::GetName($sClass)."</a>";
+	return "<a href=\"schema.php?operation=details_class&class=$sClass{$sContext}\" title=\"".MetaModel::GetClassDescription($sClass)."\">".MetaModel::GetName($sClass)."</a>";
 }
 
 /**
@@ -47,7 +47,7 @@ function MakeClassHLink($sClass, $sContext)
 function MakeRelationHLink($sRelCode, $sContext)
 {
 	$sDesc = MetaModel::GetRelationDescription($sRelCode);
-	return "<a href=\"?operation=details_relation&relcode=$sRelCode{$sContext}\" title=\"$sDesc\">".$sRelCode."</a>";
+	return "<a href=\"schema.php?operation=details_relation&relcode=$sRelCode{$sContext}\" title=\"$sDesc\">".$sRelCode."</a>";
 }
 
 /**
@@ -363,7 +363,7 @@ function DisplayClassDetails($oPage, $sClass, $sContext)
 	{
 		$sParents = '';
 	}
-	$oPage->p("[<a href=\"?operation=list{$sContext}\">".Dict::S('UI:Schema:AllClasses')."</a>] $sParents");
+	$oPage->p("[<a href=\"schema.php?operation=list{$sContext}\">".Dict::S('UI:Schema:AllClasses')."</a>] $sParents");
 
 	if (MetaModel::HasChildrenClasses($sClass))
 	{

+ 3 - 2
setup/index.php

@@ -660,7 +660,7 @@ function LicenceAcknowledgement($oP, $aParamValues, $iCurrentStep)
 	
 	$oP->set_title('License agreement');
 	$oP->add('<h2>iTop is released by <a href="http://www.combodo.com" target="_blank">Combodo SARL</a> under the terms of the GPL V3 license. In order to use iTop you must accept the terms of this license.</h2>');
-	$oP->add("<iframe style=\"width: 100%; height: 350px; overflow-y:auto; font-size:0.8em;\" src=\"./licence.html\">Next: Database server selection</iframe>\n");
+	$oP->add("<iframe style=\"width: 100%; height: 350px; overflow-y:auto; font-size:0.8em;\" src=\"../setup/licence.html\">Next: Database server selection</iframe>\n");
 	$oP->add("<form id=\"theForm\" method=\"post\">\n");
 	AddParamsToForm($oP, $aParamValues, array('licence_ok'));
 
@@ -1151,6 +1151,7 @@ function DisplaySummary(SetupPage $oP, $aParamValues, $iCurrentStep, Config $oCo
 			}
 		}
 		$oP->set_title('Installation Summary');
+		$oP->SetRootUrl($aParamValues['application_path']);
 		$oP->add("<h3>iTop version ".$aAvailableModules[ROOT_MODULE]['version_code']." will be installed.</h3>");
 
 		$oP->add('<div id="summary_content" style="height:350px;overflow-y:auto;border:1px solid #999;padding-left:1em;">');
@@ -1325,7 +1326,7 @@ function DisplaySummary(SetupPage $oP, $aParamValues, $iCurrentStep, Config $oCo
 	$oP->add("</form>\n");
 	
 	$oP->add("<div id=\"log\" style=\"color:#F00;\"></div>\n");
-	$oP->add_linked_script('./jquery.progression.js');
+	$oP->add_linked_script('../setup/jquery.progression.js');
 	PopulateDataFilesList($oP, $aParamValues, $oConfig);
 	$oP->add_ready_script(
 <<<EOF

+ 8 - 8
setup/setup.js

@@ -163,7 +163,7 @@ function DoCompileDataModel()
 {
 	$('#log').html('');
 	$('#setup').block({message: '<p><span id="setup_msg">Preparing data model...</span><br/><div id=\"progress\">0%</div></p>'});
-	$('#progress').progression( {Current:5, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000'} );
+	$('#progress').progression( {Current:5, Maximum: 100, aBackgroundImg: GetAbsoluteUrlAppRoot()+'setup/orange-progress.gif', aTextColor: '#000000'} );
 
 	var sSelectedModules = GetSelectedModules();
 	var sMode = $(':input[name=mode]').val();
@@ -171,7 +171,7 @@ function DoCompileDataModel()
 	var sTargetDir = $(':input[name=target_dir]').val();
 	
 	// Call the asynchronous page that performs the compilation of the data model and the creation of the configuration file
-	AsyncCompileDataModel(sSelectedModules, sMode, sSourceDir, sTargetDir, function(response, status, xhr) {
+	AsyncCompileDataModel(sSelectedModules, sMode, sSourceDir, sTargetDir, '', function(response, status, xhr) {
 		$('#log').html(response);
 		DoUpdateDBSchema();
 	});
@@ -181,7 +181,7 @@ function DoUpdateDBSchema()
 {
 	$('#log').html('');
 	$('#setup').block({message: '<p><span id="setup_msg">Updating DB schema...</span><br/><div id=\"progress\">5%</div></p>'});
-	$('#progress').progression( {Current:10, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000'} );
+	$('#progress').progression( {Current:10, Maximum: 100, aBackgroundImg: GetAbsoluteUrlAppRoot()+'setup/orange-progress.gif', aTextColor: '#000000'} );
 
 	var sSelectedModules = GetSelectedModules();
 	var sMode = $(':input[name=mode]').val();
@@ -204,7 +204,7 @@ function DoUpdateProfiles()
 {
 	$('#log').html('');
 	$('#setup_msg').text('Updating Profiles...');
-	$('#progress').progression( {Current:40,  Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000'} );
+	$('#progress').progression( {Current:40,  Maximum: 100, aBackgroundImg: GetAbsoluteUrlAppRoot()+'setup/orange-progress.gif', aTextColor: '#000000'} );
 
 	var sSelectedModules = GetSelectedModules();
 	var sMode = $(':input[name=mode]').val();
@@ -249,7 +249,7 @@ function DoLoadDataAsynchronous(response, status, xhr)
 		{
 			$('#log').html('');
 			$('#setup_msg').text('Loading data...');
-			$('#progress').progression( {Current: 60, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000'} );
+			$('#progress').progression( {Current: 60, Maximum: 100, aBackgroundImg: GetAbsoluteUrlAppRoot()+'setup/orange-progress.gif', aTextColor: '#000000'} );
 //			$('#log').ajaxError(
 //					function(e, xhr, settings, exception)
 //					{
@@ -297,9 +297,9 @@ function LoadNextDataFile(response, status, xhr)
 			iPercent = 60+Math.round((40.0 * (1+iCounter)) / aFilesToLoad.length);
 			sFileName = aFilesToLoad[iCounter];
 			//alert('Loading file '+sFileName+' ('+iPercent+' %) - '+sSessionStatus);
-			$("#progress").progression({ Current: iPercent, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000' });
+			$("#progress").progression({ Current: iPercent, Maximum: 100, aBackgroundImg: GetAbsoluteUrlAppRoot()+'setup/orange-progress.gif', aTextColor: '#000000' });
 			iCounter++;
-			$('#log').load( 'ajax.dataloader.php',
+			$('#log').load( GetAbsoluteUrlAppRoot()+'setup/ajax.dataloader.php',
 				{
 					'selected_modules': GetSelectedModules(),
 					'db_server': $(':input[name=db_server]').val(),
@@ -319,7 +319,7 @@ function LoadNextDataFile(response, status, xhr)
 		else
 		{
 			// We're done
-			$("#progress").progression({ Current: 100, Maximum: 100, aBackgroundImg: 'orange-progress.gif', aTextColor: '#000000' });
+			$("#progress").progression({ Current: 100, Maximum: 100, aBackgroundImg: GetAbsoluteUrlAppRoot()+'setup/orange-progress.gif', aTextColor: '#000000' });
 			//$('#setup').unblock();
 			$('#GoToNextStep').submit(); // Use the hidden form to navigate to the next step
 		}

+ 6 - 5
setup/setup_environment.js

@@ -7,17 +7,18 @@
  * @param string sTargetDir The target directory (is created if needed) for compiled modules
  * @return void
  */ 
-function AsyncCompileDataModel(sSelectedModules, sMode, sSourceDir, sTargetDir, OnCompleteFn)
+function AsyncCompileDataModel(sSelectedModules, sMode, sSourceDir, sTargetDir, sWorkspaceDir, OnCompleteFn)
 {
 	try
 	{
-		$.post( 'ajax.dataloader.php',
+		$.post( GetAbsoluteUrlAppRoot()+'setup/ajax.dataloader.php',
 						{ 
 							'operation': 'compile_data_model',
 							'selected_modules': sSelectedModules,
 							'mode': sMode,
 							'source_dir': sSourceDir,
-							'target_dir': sTargetDir
+							'target_dir': sTargetDir,
+							'workspace_dir': sWorkspaceDir
 						},
 						OnCompleteFn, 'html');
 	}
@@ -45,7 +46,7 @@ function AsyncUpdateDBSchema(sSelectedModules, sMode, sModulesDir, sDBServer, sD
 {
 	try
 	{
-		$.post( 'ajax.dataloader.php',
+		$.post( GetAbsoluteUrlAppRoot()+'setup/ajax.dataloader.php',
 						{ 
 							'operation': 'update_db_schema',
 							'selected_modules': sSelectedModules,
@@ -86,7 +87,7 @@ function AsyncUpdateProfiles(sSelectedModules, sMode, sModulesDir, sDBServer, sD
 {
 	try
 	{
-		$.post( 'ajax.dataloader.php',
+		$.post( GetAbsoluteUrlAppRoot()+'setup/ajax.dataloader.php',
 						{ 
 							'operation': 'after_db_create',
 							'selected_modules': sSelectedModules,

+ 3 - 3
setup/setuppage.class.inc.php

@@ -40,8 +40,8 @@ class SetupPage extends NiceWebPage
     {
         parent::__construct($sTitle);
    		$this->add_linked_script("../js/jquery.blockUI.js");
-   		$this->add_linked_script("./setup.js");
-   		$this->add_linked_script("./setup_environment.js");
+   		$this->add_linked_script("../setup/setup.js");
+   		$this->add_linked_script("../setup/setup_environment.js");
         $this->add_style("
 body {
 	background-color: #eee;
@@ -425,7 +425,7 @@ function InitDataModel($oConfig, $bModelOnly = true, $bUseCache = false)
 		SetupPage::log_info("MetaModel::Startup (ModelOnly = $bModelOnly)");
 	}
 
-	if ($bUseCache)
+	if (!$bUseCache)
 	{
 		// Reset the cache for the first use !
 		MetaModel::ResetCache($oConfig);

+ 1 - 1
webservices/soapserver.php

@@ -34,7 +34,7 @@ require_once(APPROOT.'/application/startup.inc.php');
 $sWsdlUri = 'http'.((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off')) ? 's' : '').'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].dirname($_SERVER['SCRIPT_NAME']).'/../webservices/itop.wsdl.php';
 if (isset($_REQUEST['service_category']) && (!empty($_REQUEST['service_category'])))
 {
-	$sWsdlUri .= "?service_category=".$_REQUEST['service_category'];
+	$sWsdlUri .= "soapserver.php?service_category=".$_REQUEST['service_category'];
 }