diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index 6742ef562..faef5b837 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -718,6 +718,12 @@ EOF case 'open_flash_chart': static $iChartCounter = 0; + $oAppContext = new ApplicationContext(); + $sContext = $oAppContext->GetForLink(); + if (!empty($sContext)) + { + $sContext = '&'.$sContext; + } $sChartType = isset($aExtraParams['chart_type']) ? $aExtraParams['chart_type'] : 'pie'; $sTitle = isset($aExtraParams['chart_title']) ? $aExtraParams['chart_title'] : ''; $sGroupBy = isset($aExtraParams['group_by']) ? $aExtraParams['group_by'] : ''; @@ -748,6 +754,7 @@ EOF $aData = array(); $aLabels = array(); $idx = 0; + $aURLs = array(); foreach($aGroupBy as $sValue => $iValue) { $oDrillDownFilter = clone $this->m_oFilter; @@ -758,7 +765,7 @@ EOF $sURLList = ''; foreach($aURLs as $index => $sURL) { - $sURLList .= "\taURLs[$index] = '".utils::GetAbsoluteUrlAppRoot()."pages/UI.php?operation=search&format=html&filter=".addslashes($sURL)."';\n"; + $sURLList .= "\taURLs[$index] = '".utils::GetAbsoluteUrlAppRoot()."pages/UI.php?operation=search&format=html{$sContext}&filter=".addslashes($sURL)."';\n"; } $oPage->add_script( <<GetForLink(); + $sAppContext = addslashes($sExtraParams); $this->add_header("Content-type: text/html; charset=utf-8"); $this->add_header("Cache-control: no-cache"); $this->add_linked_stylesheet("../css/jquery.treeview.css"); @@ -361,18 +362,18 @@ EOF { if (id > 0) { - window.location.href = GetAbsoluteUrlAppRoot()+'pages/UI.php?operation=details&class='+sClass+'&id='+id; + window.location.href = AddAppContext(GetAbsoluteUrlAppRoot()+'pages/UI.php?operation=details&class='+sClass+'&id='+id); } else { - window.location.href = sDefaultUrl; + window.location.href = sDefaultUrl; // Already contains the context... } } function BackToList(sClass) { - window.location.href = GetAbsoluteUrlAppRoot()+'pages/UI.php?operation=search_oql&oql_class='+sClass+'&oql_clause=WHERE id=0'; + window.location.href = AddAppContext(GetAbsoluteUrlAppRoot()+'pages/UI.php?operation=search_oql&oql_class='+sClass+'&oql_clause=WHERE id=0'); } function ShowDebug() @@ -388,6 +389,19 @@ EOF return '$sAbsURLAppRoot'; } + function AddAppContext(sURL) + { + var sContext = '$sAppContext'; + if (sContext.length > 0) + { + if (sURL.indexOf('?') == -1) + { + return sURL+'?'+sContext; + } + } + return sURL+'&'+sContext; + } + var oUserPreferences = $sUserPrefs; // For disabling the CKEditor at init time when the corresponding textarea is disabled ! @@ -592,7 +606,6 @@ EOF - // Render the revision number if (ITOP_REVISION == '$WCREV$') { diff --git a/application/portalwebpage.class.inc.php b/application/portalwebpage.class.inc.php index a67c3150a..2148b1b40 100644 --- a/application/portalwebpage.class.inc.php +++ b/application/portalwebpage.class.inc.php @@ -56,6 +56,8 @@ class PortalWebPage extends NiceWebPage $this->add_linked_stylesheet("../css/jquery.treeview.css"); $this->add_linked_stylesheet("../css/jquery.autocomplete.css"); $sAbsURLAppRoot = addslashes(utils::GetAbsoluteUrlAppRoot()); // Pass it to Javascript scripts + $oAppContext = new ApplicationContext(); + $sAppContext = addslashes($oAppContext->GetForLink()); if ($sAlternateStyleSheet != '') { $this->add_linked_stylesheet("../portal/$sAlternateStyleSheet/portal.css"); @@ -157,6 +159,20 @@ EOF return '$sAbsURLAppRoot'; } + + function AddAppContext(sURL) + { + var sContext = '$sAppContext'; + if (sContext.length > 0) + { + if (sURL.indexOf('?') == -1) + { + return sURL+'?'+sContext; + } + } + return sURL+'&'+sContext; + } + function GoBack(sFormId) { var form = $('#'+sFormId); diff --git a/application/sqlblock.class.inc.php b/application/sqlblock.class.inc.php index 07f6c3efa..06d358284 100644 --- a/application/sqlblock.class.inc.php +++ b/application/sqlblock.class.inc.php @@ -214,6 +214,11 @@ class SqlBlock default: case 'table': $oAppContext = new ApplicationContext(); + $sContext = $oAppContext->GetForLink(); + if (!empty($sContext)) + { + $sContext = '&'.$sContext; + } $aDisplayConfig = array(); foreach($this->m_aColumns as $sName => $aColumnData) { @@ -236,7 +241,7 @@ class SqlBlock { $sFilter = str_replace(':'.$sColName, "'".addslashes( $aRow[$sColName] )."'", $sFilter); } - $sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=search_oql&search_form=0&oql_class='.$sClass.'&oql_clause='.urlencode($sFilter).'&format=html?'.$oAppContext->GetForLink(); + $sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=search_oql&search_form=0&oql_class='.$sClass.'&oql_clause='.urlencode($sFilter).'&format=html'.$sContext; $aDisplayRow[$sName] = ''.$aRow[$sName].""; } else diff --git a/js/extkeywidget.js b/js/extkeywidget.js index 4b82abddc..460267772 100644 --- a/js/extkeywidget.js +++ b/js/extkeywidget.js @@ -70,7 +70,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper me.StopPendingRequest(); // Run the query and get the result back directly in HTML - me.ajax_request = $.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap, + me.ajax_request = $.post( AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'), theMap, function(data) { $('#ac_dlg_'+me.id).html(data); @@ -163,7 +163,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper me.StopPendingRequest(); // Run the query and display the results - me.ajax_request = $.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap, + me.ajax_request = $.post( AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'), theMap, function(data) { $(sSearchAreaId).html(data); @@ -208,7 +208,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper me.StopPendingRequest(); // Run the query and get the result back directly in JSON - me.ajax_request = $.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap, + me.ajax_request = $.post( AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'), theMap, function(data) { $('#label_'+me.id).val(data.name); @@ -270,7 +270,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper me.StopPendingRequest(); // Run the query and get the result back directly in HTML - me.ajax_request = $.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap, + me.ajax_request = $.post( AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'), theMap, function(data) { $('#ajax_'+me.id).html(data); @@ -347,7 +347,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper me.StopPendingRequest(); // Run the query and get the result back directly in JSON - me.ajax_request = $.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap, + me.ajax_request = $.post( AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'), theMap, function(data) { if (me.bSelectMode) @@ -432,7 +432,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper me.StopPendingRequest(); // Run the query and display the results - me.ajax_request = $.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap, + me.ajax_request = $.post( AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'), theMap, function(data) { $('#ac_tree_'+me.id).html(data); @@ -490,7 +490,7 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper me.StopPendingRequest(); // Run the query and get the result back directly in JSON - me.ajax_request = $.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap, + me.ajax_request = $.post( AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'), theMap, function(data) { $('#label_'+me.id).val(data.name); diff --git a/js/jquery.tablesorter.pager.js b/js/jquery.tablesorter.pager.js index eafa8a0be..f818f3f64 100644 --- a/js/jquery.tablesorter.pager.js +++ b/js/jquery.tablesorter.pager.js @@ -167,7 +167,7 @@ function sprintf(format, etc) { s_order = (s[1] == 0) ? 'asc' : 'desc'; } $('#loading', table.config.container).html(''); - table.ajax_request = $.post(GetAbsoluteUrlAppRoot()+"pages/ajax.render.php", + table.ajax_request = $.post(AddAppContext(GetAbsoluteUrlAppRoot()+"pages/ajax.render.php"), { operation: 'pagination', filter: c.filter, extra_param: c.extra_params, diff --git a/pages/run_query.php b/pages/run_query.php index fbe8b04aa..1769ea15e 100644 --- a/pages/run_query.php +++ b/pages/run_query.php @@ -55,6 +55,8 @@ function ShowExamples($oP, $sExpression) ); $aDisplayData = array(); + $oAppContext = new ApplicationContext(); + $sContext = $oAppContext->GetForForm(); foreach($aExamples as $sTopic => $aQueries) { foreach($aQueries as $sDescription => $sOql) @@ -73,7 +75,7 @@ function ShowExamples($oP, $sExpression) $aDisplayData[Dict::S('UI:RunQuery:QueryExamples')][] = array( 'desc' => "
".htmlentities($sDescription, ENT_QUOTES, 'UTF-8')."
", 'oql' => "
".htmlentities($sOql, ENT_QUOTES, 'UTF-8')."
", - 'go' => "
\n", + 'go' => "
$sContext
\n", ); } } @@ -121,6 +123,7 @@ try $oP->add(Dict::S('UI:RunQuery:ExpressionToEvaluate')."
\n"); $oP->add("\n"); $oP->add("\n"); + $oP->add($oAppContext->GetForForm()); $oP->add("\n"); if (!empty($sExpression)) diff --git a/pages/schema.php b/pages/schema.php index 449337940..16a464f14 100644 --- a/pages/schema.php +++ b/pages/schema.php @@ -36,24 +36,24 @@ LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be /** * Helper for this page -> link to a class */ -function MakeClassHLink($sClass) +function MakeClassHLink($sClass, $sContext) { - return "".MetaModel::GetName($sClass).""; + return "".MetaModel::GetName($sClass).""; } /** * Helper for this page -> link to a class */ -function MakeRelationHLink($sRelCode) +function MakeRelationHLink($sRelCode, $sContext) { $sDesc = MetaModel::GetRelationDescription($sRelCode); - return "".$sRelCode.""; + return "".$sRelCode.""; } /** * Helper for the global list and the details of a given class */ -function DisplaySubclasses($oPage, $sClass) +function DisplaySubclasses($oPage, $sClass, $sContext) { $aChildClasses = MetaModel::EnumChildClasses($sClass); if (count($aChildClasses) != 0) @@ -75,8 +75,8 @@ function DisplaySubclasses($oPage, $sClass) // Skip indirect childs, they will be handled somewhere else if (MetaModel::GetParentPersistentClass($sClassName) == $sClass) { - $oPage->add("
  • ".MakeClassHLink($sClassName)."\n"); - DisplaySubclasses($oPage, $sClassName); + $oPage->add("
  • ".MakeClassHLink($sClassName, $sContext)."\n"); + DisplaySubclasses($oPage, $sClassName, $sContext); $oPage->add("
  • \n"); } } @@ -87,7 +87,7 @@ function DisplaySubclasses($oPage, $sClass) /** * Helper for the global list and the details of a given class */ -function DisplayReferencingClasses($oPage, $sClass) +function DisplayReferencingClasses($oPage, $sClass, $sContext) { $bSkipLinkingClasses = false; $aRefs = MetaModel::EnumReferencingClasses($sClass, $bSkipLinkingClasses); @@ -98,7 +98,7 @@ function DisplayReferencingClasses($oPage, $sClass) { foreach ($aRemoteKeys as $sExtKeyAttCode => $oExtKeyAttDef) { - $oPage->add("
  • ".Dict::Format('UI:Schema:Class_ReferencingClasses_From_By', $sClass, MakeClassHLink($sRemoteClass), $sExtKeyAttCode)."
  • \n"); + $oPage->add("
  • ".Dict::Format('UI:Schema:Class_ReferencingClasses_From_By', $sClass, MakeClassHLink($sRemoteClass, $sContext), $sExtKeyAttCode)."
  • \n"); } } $oPage->add("\n"); @@ -108,7 +108,7 @@ function DisplayReferencingClasses($oPage, $sClass) /** * Helper for the global list and the details of a given class */ -function DisplayLinkingClasses($oPage, $sClass) +function DisplayLinkingClasses($oPage, $sClass, $sContext) { $bSkipLinkingClasses = false; $aRefs = MetaModel::EnumLinkingClasses($sClass); @@ -119,7 +119,7 @@ function DisplayLinkingClasses($oPage, $sClass) { foreach($aRemoteClasses as $sExtKeyAttCode => $sRemoteClass) { - $oPage->add("
  • ".Dict::Format('UI:Schema:Class_IsLinkedTo_Class_Via_ClassAndAttribute', $sClass, MakeClassHLink($sRemoteClass), MakeClassHLink($sLinkClass), $sExtKeyAttCode)); + $oPage->add("
  • ".Dict::Format('UI:Schema:Class_IsLinkedTo_Class_Via_ClassAndAttribute', $sClass, MakeClassHLink($sRemoteClass, $sContext), MakeClassHLink($sLinkClass, $sContext), $sExtKeyAttCode)); } } $oPage->add("\n"); @@ -129,7 +129,7 @@ function DisplayLinkingClasses($oPage, $sClass) /** * Helper for the global list and the details of a given class */ -function DisplayRelatedClassesBestInClass($oPage, $sClass, $iLevels = 20, &$aVisitedClasses = array(), $bSubtree = true) +function DisplayRelatedClassesBestInClass($oPage, $sClass, $iLevels = 20, &$aVisitedClasses = array(), $bSubtree = true, $sContext) { if ($iLevels <= 0) return; $iLevels--; @@ -140,7 +140,7 @@ function DisplayRelatedClassesBestInClass($oPage, $sClass, $iLevels = 20, &$aVis if ($bSubtree) $oPage->add("\n"); @@ -319,7 +320,7 @@ function DisplayClassesList($oPage) $oPage->add("