mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
N°4176 - Portal: Deprecate "AddParameterToUrl" function
This commit is contained in:
@@ -103,7 +103,7 @@
|
||||
break;
|
||||
case '{{ constant('Combodo\\iTop\\Portal\\Brick\\BrowseBrick::ENUM_ACTION_CREATE_FROM_THIS') }}':
|
||||
url = levelPrimaryAction.url.replace(/-objectClass-/, data.class).replace(/-objectId-/, data.id);
|
||||
url = AddParameterToUrl(url, 'ar_token', data.action_rules_token[levelPrimaryAction.type]);
|
||||
url = CombodoGlobalToolbox.AddParameterToUrl(url, 'ar_token', data.action_rules_token[levelPrimaryAction.type]);
|
||||
break;
|
||||
default:
|
||||
url = '#';
|
||||
@@ -151,7 +151,7 @@
|
||||
break;
|
||||
case '{{ constant('Combodo\\iTop\\Portal\\Brick\\BrowseBrick::ENUM_ACTION_CREATE_FROM_THIS') }}':
|
||||
url = action.url.replace(/-objectClass-/, data.class).replace(/-objectId-/, data.id);
|
||||
url = AddParameterToUrl(url, 'ar_token', data.action_rules_token[action.type]);
|
||||
url = CombodoGlobalToolbox.AddParameterToUrl(url, 'ar_token', data.action_rules_token[action.type]);
|
||||
break;
|
||||
default:
|
||||
url = '#';
|
||||
|
||||
@@ -238,7 +238,7 @@
|
||||
break;
|
||||
case '{{ constant('Combodo\\iTop\\Portal\\Brick\\BrowseBrick::ENUM_ACTION_CREATE_FROM_THIS') }}':
|
||||
url = levelPrimaryAction.url.replace(/-objectClass-/, item.class).replace(/-objectId-/, item.id);
|
||||
url = AddParameterToUrl(url, 'ar_token', item.action_rules_token[levelPrimaryAction.type]);
|
||||
url = CombodoGlobalToolbox.AddParameterToUrl(url, 'ar_token', item.action_rules_token[levelPrimaryAction.type]);
|
||||
SetActionUrl(aElem, url);
|
||||
SetActionOpeningTarget(aElem, levelPrimaryAction.opening_target);
|
||||
break;
|
||||
@@ -284,7 +284,7 @@
|
||||
break;
|
||||
case '{{ constant('Combodo\\iTop\\Portal\\Brick\\BrowseBrick::ENUM_ACTION_CREATE_FROM_THIS') }}':
|
||||
url = action.url.replace(/-objectClass-/, item.class).replace(/-objectId-/, item.id);
|
||||
url = AddParameterToUrl(url, 'ar_token', item.action_rules_token[action.type]);
|
||||
url = CombodoGlobalToolbox.AddParameterToUrl(url, 'ar_token', item.action_rules_token[action.type]);
|
||||
break;
|
||||
default:
|
||||
url = '#';
|
||||
|
||||
@@ -233,7 +233,7 @@
|
||||
break;
|
||||
case '{{ constant('Combodo\\iTop\\Portal\\Brick\\BrowseBrick::ENUM_ACTION_CREATE_FROM_THIS') }}':
|
||||
url = levelPrimaryAction.url.replace(/-objectClass-/, item.class).replace(/-objectId-/, item.id);
|
||||
url = AddParameterToUrl(url, 'ar_token', item.action_rules_token[levelPrimaryAction.type]);
|
||||
url = CombodoGlobalToolbox.AddParameterToUrl(url, 'ar_token', item.action_rules_token[levelPrimaryAction.type]);
|
||||
SetActionUrl(aElem, url);
|
||||
SetActionOpeningTarget(aElem, levelPrimaryAction.opening_target);
|
||||
break;
|
||||
@@ -279,7 +279,7 @@
|
||||
break;
|
||||
case '{{ constant('Combodo\\iTop\\Portal\\Brick\\BrowseBrick::ENUM_ACTION_CREATE_FROM_THIS') }}':
|
||||
url = action.url.replace(/-objectClass-/, item.class).replace(/-objectId-/, item.id);
|
||||
url = AddParameterToUrl(url, 'ar_token', item.action_rules_token[action.type]);
|
||||
url = CombodoGlobalToolbox.AddParameterToUrl(url, 'ar_token', item.action_rules_token[action.type]);
|
||||
break;
|
||||
default:
|
||||
url = '#';
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
// Preparing target class url
|
||||
var sUrl = '{{ app['url_generator'].generate('p_object_create', {sObjectClass : '-sObjectClass-'})|raw }}';
|
||||
sUrl = sUrl.replace(/-sObjectClass-/, $(this).attr('data-target-class') );
|
||||
sUrl = AddParameterToUrl(sUrl, 'ar_token', '{{ ar_token }}');
|
||||
sUrl = CombodoGlobalToolbox.AddParameterToUrl(sUrl, 'ar_token', '{{ ar_token }}');
|
||||
|
||||
// Creating a new modal
|
||||
CombodoPortalToolbox.OpenModal({
|
||||
|
||||
@@ -420,8 +420,13 @@
|
||||
{
|
||||
return '{{ app['url_generator'].generate('p_session_message_add')|raw }}';
|
||||
};
|
||||
// Helper to add a parameter to an url
|
||||
// TODO 3.0.0: Move to CombodoGlobalToolbox and deprecate this one
|
||||
/**
|
||||
* @param sUrl {string} The URL to append the new param to
|
||||
* @param sParamName {string} Name of the parameter
|
||||
* @param sParamValue {string} Value of the param, needs to be already URL encoded
|
||||
* @return {string} The sUrl parameters with the sParamName / sParamValue append at the right place
|
||||
* @deprecated 3.0.0 N°4176
|
||||
*/
|
||||
var AddParameterToUrl = function(sUrl, sParamName, sParamValue)
|
||||
{
|
||||
sUrl += (sUrl.split('?')[1] ? '&':'?') + sParamName + '=' + sParamValue;
|
||||
|
||||
20
js/utils.js
20
js/utils.js
@@ -710,6 +710,26 @@ const CombodoGlobalToolbox = {
|
||||
);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param sUrl {string} The URL to append the new param to
|
||||
* @param sParamName {string} Name of the parameter
|
||||
* @param sParamValue {string} Value of the param, needs to be already URL encoded
|
||||
* @return {string} The sUrl parameters with the sParamName / sParamValue append at the right place
|
||||
*/
|
||||
AddParameterToUrl: function(sUrl, sParamName, sParamValue)
|
||||
{
|
||||
const bHasHash = sUrl.split('#')[1] !== undefined;
|
||||
const bHasSomeParameters = sUrl.split('?')[1] !== undefined;
|
||||
const sNewParamForUrl = sParamName + '=' + sParamValue;
|
||||
|
||||
if (bHasHash || bHasSomeParameters) {
|
||||
sUrl += '&' + sNewParamForUrl;
|
||||
} else {
|
||||
sUrl += '?' + sNewParamForUrl;
|
||||
}
|
||||
|
||||
return sUrl;
|
||||
},
|
||||
/**
|
||||
* This method should be a JS mirror of the PHP {@see utils::FilterXSS} method
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user