mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
Make sure that the AJax calls use a full/absolute path to the page they call so that they can be embedded anywhere inside the application (i.e. in plug-ins supplied pages as well as 'regular' app pages).
SVN:trunk[1364]
This commit is contained in:
@@ -178,36 +178,6 @@ class DisplayBlock
|
||||
public function Display(WebPage $oPage, $sId, $aExtraParams = array())
|
||||
{
|
||||
$oPage->add($this->GetDisplay($oPage, $sId, $aExtraParams));
|
||||
/*
|
||||
$aExtraParams = array_merge($aExtraParams, $this->m_aParams);
|
||||
$aExtraParams['block_id'] = $sId;
|
||||
if (!$this->m_bAsynchronous)
|
||||
{
|
||||
// render now
|
||||
$oPage->add("<div id=\"$sId\" class=\"display_block\">\n");
|
||||
$this->RenderContent($oPage, $aExtraParams);
|
||||
$oPage->add("</div>\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// render it as an Ajax (asynchronous) call
|
||||
$sFilter = $this->m_oFilter->serialize();
|
||||
$oPage->add("<div id=\"$sId\" class=\"display_block loading\">\n");
|
||||
$oPage->p("<img src=\"../images/indicator_arrows.gif\"> Loading...");
|
||||
$oPage->add("</div>\n");
|
||||
$oPage->add('
|
||||
<script language="javascript">
|
||||
$.post("ajax.render.php?style='.$this->m_sStyle.'",
|
||||
{ operation: "ajax", filter: "$sFilter" },
|
||||
function(data){
|
||||
$("#'.$sId.'").empty();
|
||||
$("#'.$sId.'").append(data);
|
||||
$("#'.$sId.'").removeClass("loading");
|
||||
}
|
||||
);
|
||||
</script>'); // TO DO: add support for $aExtraParams in asynchronous/Ajax mode
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public function GetDisplay(WebPage $oPage, $sId, $aExtraParams = array())
|
||||
|
||||
@@ -50,6 +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
|
||||
$oAppContext = new ApplicationContext();
|
||||
$sExtraParams = $oAppContext->GetForLink();
|
||||
$this->add_header("Content-type: text/html; charset=utf-8");
|
||||
@@ -382,6 +383,11 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
function GetAbsoluteUrlAppRoot()
|
||||
{
|
||||
return '$sAbsURLAppRoot';
|
||||
}
|
||||
|
||||
var oUserPreferences = $sUserPrefs;
|
||||
|
||||
// For disabling the CKEditor at init time when the corresponding textarea is disabled !
|
||||
|
||||
@@ -55,6 +55,7 @@ class PortalWebPage extends NiceWebPage
|
||||
$this->add_header("Cache-control: no-cache");
|
||||
$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
|
||||
if ($sAlternateStyleSheet != '')
|
||||
{
|
||||
$this->add_linked_stylesheet("../portal/$sAlternateStyleSheet/portal.css");
|
||||
@@ -150,6 +151,12 @@ EOF
|
||||
return bResult;
|
||||
}
|
||||
|
||||
|
||||
function GetAbsoluteUrlAppRoot()
|
||||
{
|
||||
return '$sAbsURLAppRoot';
|
||||
}
|
||||
|
||||
function GoBack(sFormId)
|
||||
{
|
||||
var form = $('#'+sFormId);
|
||||
|
||||
@@ -132,7 +132,7 @@ class UILinksWizard
|
||||
function AddObjects()
|
||||
{
|
||||
// TO DO: compute the list of objects already linked with the current Object
|
||||
$.post( '../pages/ajax.render.php', { 'operation': 'addObjects',
|
||||
$.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', { 'operation': 'addObjects',
|
||||
'class': '{$this->m_sClass}',
|
||||
'linkageAttr': '{$this->m_sLinkageAttr}',
|
||||
'linkedClass': '{$this->m_sLinkedClass}',
|
||||
@@ -175,7 +175,7 @@ class UILinksWizard
|
||||
theMap['operation'] = 'searchObjectsToAdd';
|
||||
|
||||
// Run the query and display the results
|
||||
$.post( '../pages/ajax.render.php', theMap,
|
||||
$.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap,
|
||||
function(data)
|
||||
{
|
||||
$('#SearchResultsToAdd').html(data);
|
||||
@@ -223,7 +223,7 @@ class UILinksWizard
|
||||
theMap['operation'] = 'doAddObjects';
|
||||
|
||||
// Run the query and display the results
|
||||
$.post( '../pages/ajax.render.php', theMap,
|
||||
$.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap,
|
||||
function(data)
|
||||
{
|
||||
//console.log('Data: ' + data);
|
||||
|
||||
@@ -999,7 +999,7 @@ EOF
|
||||
<<<EOF
|
||||
function OnTruncatedHistoryToggle(bShowAll)
|
||||
{
|
||||
$.get('../pages/ajax.render.php?{$sAppContext}', {operation: 'displayCSVHistory', showall: bShowAll}, function(data)
|
||||
$.get(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?{$sAppContext}', {operation: 'displayCSVHistory', showall: bShowAll}, function(data)
|
||||
{
|
||||
$('#$sAjaxDivId').html(data);
|
||||
var table = $('#$sAjaxDivId .listResults');
|
||||
|
||||
@@ -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( '../pages/ajax.render.php', theMap,
|
||||
me.ajax_request = $.post( 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( '../pages/ajax.render.php', theMap,
|
||||
me.ajax_request = $.post( 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( '../pages/ajax.render.php', theMap,
|
||||
me.ajax_request = $.post( 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( '../pages/ajax.render.php', theMap,
|
||||
me.ajax_request = $.post( 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( '../pages/ajax.render.php', theMap,
|
||||
me.ajax_request = $.post( 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( '../pages/ajax.render.php', theMap,
|
||||
me.ajax_request = $.post( 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( '../pages/ajax.render.php', theMap,
|
||||
me.ajax_request = $.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap,
|
||||
function(data)
|
||||
{
|
||||
$('#label_'+me.id).val(data.name);
|
||||
|
||||
@@ -90,40 +90,12 @@ function ActivateStep(iTargetStep)
|
||||
//$('#wizStep'+(iTargetStep)).block({ message: null });
|
||||
}
|
||||
|
||||
|
||||
//function AjaxGetValuesDef(oObj, sClass, sAttCode, iFieldId)
|
||||
//{
|
||||
// var oJSON = document.getElementById(sJsonFieldId);
|
||||
// $.get('ajax.render.php?class=' + sClass + '&json_obj=' + oJSON.value + '&att_code=' + sAttCode,
|
||||
// { operation: "allowed_values" },
|
||||
// function(data){
|
||||
// //$('#field_'+iFieldId).html(data);
|
||||
// }
|
||||
// );
|
||||
//}
|
||||
//
|
||||
//function AjaxGetDefaultValue(oObj, sClass, sAttCode, iFieldId)
|
||||
//{
|
||||
// // Asynchronously call the server to provide a default value if the field is
|
||||
// // empty
|
||||
// if (oObj['m_aCurrValues'][sAttCode] == '')
|
||||
// {
|
||||
// var oJSON = document.getElementById(sJsonFieldId);
|
||||
// $.get('../pages/ajax.render.php?class=' + sClass + '&json_obj=' + oJSON.value + '&att_code=' + sAttCode,
|
||||
// { operation: "default_value" },
|
||||
// function(json_data){
|
||||
// var oObj = ReloadObjectFromServer(json_data);
|
||||
// UpdateFieldFromObject(iFieldId, aFieldsMap, oObj)
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
//}
|
||||
function OnUnload(sTransactionId)
|
||||
{
|
||||
if (!window.bInSubmit)
|
||||
{
|
||||
// If it's not a submit, then it's a "cancel" (Pressing the Cancel button, closing the window, using the back button...)
|
||||
$.post('../pages/ajax.render.php', {operation: 'on_form_cancel', transaction_id: sTransactionId }, function()
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', {operation: 'on_form_cancel', transaction_id: sTransactionId }, function()
|
||||
{
|
||||
// Do nothing for now...
|
||||
});
|
||||
|
||||
@@ -163,7 +163,7 @@ function sprintf(format, etc) {
|
||||
s_order = (s[1] == 0) ? 'asc' : 'desc';
|
||||
}
|
||||
$('#loading', table.config.container).html('<img src="../images/indicator.gif" />');
|
||||
table.ajax_request = $.post("../pages/ajax.render.php",
|
||||
table.ajax_request = $.post(GetAbsoluteUrlAppRoot()+"pages/ajax.render.php",
|
||||
{ operation: 'pagination',
|
||||
filter: c.filter,
|
||||
extra_param: c.extra_params,
|
||||
|
||||
@@ -98,7 +98,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates)
|
||||
$(sSearchAreaId).block();
|
||||
|
||||
// Run the query and display the results
|
||||
$.post( '../pages/ajax.render.php', theMap,
|
||||
$.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap,
|
||||
function(data)
|
||||
{
|
||||
$(sSearchAreaId).html(data);
|
||||
@@ -198,7 +198,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates)
|
||||
theMap['operation'] = 'doAddObjects';
|
||||
$('#busy_'+me.iInputId).html(' <img src="../images/indicator.gif"/>');
|
||||
// Run the query and display the results
|
||||
$.post( '../pages/ajax.render.php', theMap,
|
||||
$.post( GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', theMap,
|
||||
function(data)
|
||||
{
|
||||
//console.log('Data: ' + data);
|
||||
|
||||
@@ -76,7 +76,7 @@ function ReloadBlock(divId, sStyle, sSerializedFilter, sExtraParams)
|
||||
{
|
||||
$('#'+divId).block();
|
||||
//$('#'+divId).blockUI();
|
||||
$.post('../pages/ajax.render.php?style='+sStyle,
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?style='+sStyle,
|
||||
{ operation: 'ajax', filter: sSerializedFilter, extra_params: sExtraParams },
|
||||
function(data){
|
||||
$('#'+divId).empty();
|
||||
@@ -119,7 +119,7 @@ function ReloadSearchForm(divId, sClassName, sBaseClass, sContext)
|
||||
}
|
||||
sAction = $('#ds_'+divId+' form').attr('action');
|
||||
|
||||
$.post('../pages/ajax.render.php?'+sContext,
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?'+sContext,
|
||||
{ operation: 'search_form', className: sClassName, baseClass: sBaseClass, currentId: divId, action: sAction },
|
||||
function(data) {
|
||||
oDiv.empty();
|
||||
@@ -165,7 +165,7 @@ function SetUserPreference(sPreferenceCode, sPrefValue, bPersistent)
|
||||
oUserPreferences[sPreferenceCode] = sPrefValue;
|
||||
if (bPersistent && (sPrefValue != sPreviousValue))
|
||||
{
|
||||
ajax_request = $.post('../pages/ajax.render.php',
|
||||
ajax_request = $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php',
|
||||
{ operation: 'set_pref', code: sPreferenceCode, value: sPrefValue} ); // Make it persistent
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ function UpdateObjectList(sClass, sId, sExtKeyToRemote)
|
||||
aRelatedObjectIds[0] = 0;
|
||||
}
|
||||
var oql = "SELECT "+sClass+" AS c WHERE c.id IN (" + aRelatedObjectIds.join(", ") + ")";
|
||||
$.post("ajax.render.php?style=list&encoding=oql",
|
||||
$.post(GetAbsoluteUrlAppRoot()+"ajax.render.php?style=list&encoding=oql",
|
||||
{ operation: "ajax", filter: oql },
|
||||
function(data){
|
||||
$("#related_objects_"+sId).empty();
|
||||
@@ -42,7 +42,7 @@ function ManageObjects(sTitle, sClass, sId, sExtKeyToRemote)
|
||||
function Manage_LoadSelect(sSelectedId, sFilter)
|
||||
{
|
||||
$('#'+sSelectedId).addClass('loading');
|
||||
$.post('../pages/ajax.render.php',
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php',
|
||||
{ operation: 'combo_options', filter: sFilter },
|
||||
function(data){
|
||||
$('#'+sSelectedId).empty();
|
||||
|
||||
@@ -140,7 +140,7 @@ function WizardHelper(sClass, sFormPrefix, sState)
|
||||
{
|
||||
//console.log('data sent:', this.ToJSON());
|
||||
//console.log('oWizard:', this);
|
||||
$.post('../pages/ajax.render.php',
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php',
|
||||
{ operation: 'wizard_helper', json_obj: this.ToJSON() },
|
||||
function(html){
|
||||
$('#ajax_content').html(html);
|
||||
|
||||
@@ -1899,7 +1899,7 @@ EOF
|
||||
ajax_request = null;
|
||||
}
|
||||
|
||||
ajax_request = $.get('xml.navigator.php', { 'class': sClass, id: iId, relation: sRelation, format: 'html' },
|
||||
ajax_request = $.get(GetAbsoluteUrlAppRoot()+'pages/xml.navigator.php', { 'class': sClass, id: iId, relation: sRelation, format: 'html' },
|
||||
function(data)
|
||||
{
|
||||
$('#impacted_objects').empty();
|
||||
|
||||
@@ -927,7 +927,7 @@ EOF
|
||||
ajax_request = null;
|
||||
}
|
||||
|
||||
ajax_request = $.post('ajax.csvimport.php',
|
||||
ajax_request = $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.csvimport.php',
|
||||
{ operation: 'display_mapping_form', enctype: 'multipart/form-data', csvdata: csv_data, separator: separator,
|
||||
qualifier: text_qualifier, nb_lines_skipped: nb_lines_skipped, header_line: header_line, class_name: class_name,
|
||||
advanced: advanced, encoding: encoding },
|
||||
@@ -1225,7 +1225,7 @@ EOF
|
||||
ajax_request = null;
|
||||
}
|
||||
|
||||
ajax_request = $.post('ajax.csvimport.php',
|
||||
ajax_request = $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.csvimport.php',
|
||||
{ operation: 'parser_preview', enctype: 'multipart/form-data', csvdata: $("#csvdata_truncated").val(), separator: separator, qualifier: text_qualifier, nb_lines_skipped: nb_lines_skipped, header_line: header_line, encoding: encoding },
|
||||
function(data) {
|
||||
$('#preview').empty();
|
||||
@@ -1385,7 +1385,7 @@ if (ajax_request != null)
|
||||
ajax_request = null;
|
||||
}
|
||||
|
||||
ajax_request = $.post('ajax.csvimport.php',
|
||||
ajax_request = $.post(GetAbsoluteUrlAppRoot()+'pages/ajax.csvimport.php',
|
||||
{ operation: 'get_csv_template', class_name: sClassName },
|
||||
function(data) {
|
||||
$('#template').empty();
|
||||
|
||||
Reference in New Issue
Block a user