From 33ba7542771b0190464f04a47d42ae1224fdaf21 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Tue, 5 Mar 2024 22:15:02 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B07315=20-=20Migrate=20deprecated=20usages?= =?UTF-8?q?=20of=20WebPage::add=5Flinked=5Fscript()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/cmdbabstract.class.inc.php | 18 ++++---- application/dashboard.class.inc.php | 8 ++-- application/ui.extkeywidget.class.inc.php | 10 ++--- core/ormcaselog.class.inc.php | 2 +- .../renderers.itop-attachments.php | 4 +- datamodels/2.x/itop-config/config.php | 8 ++-- .../hubconnectorpage.class.inc.php | 2 +- datamodels/2.x/itop-hub-connector/land.php | 2 +- datamodels/2.x/itop-hub-connector/launch.php | 2 +- pages/UI.php | 2 +- pages/UniversalSearch.php | 10 ++--- pages/ajax.render.php | 2 +- pages/tagadmin.php | 10 ++--- setup/setuppage.class.inc.php | 8 ++-- setup/wizardcontroller.class.inc.php | 2 +- setup/wizardsteps.class.inc.php | 2 +- .../Application/Helper/WebResourcesHelper.php | 18 ++++---- sources/Application/WebPage/ErrorPage.php | 4 +- sources/Application/WebPage/NiceWebPage.php | 16 +++---- .../WebPage/UnauthenticatedWebPage.php | 7 ++- sources/Application/WebPage/iTopWebPage.php | 44 +++++++++---------- .../Base/Layout/ObjectController.php | 4 +- .../Newsroom/iTopNewsroomController.php | 2 +- .../NotificationsCenterController.php | 2 +- .../Renderer/Console/ConsoleBlockRenderer.php | 2 +- webservices/export-v2.php | 4 +- 26 files changed, 97 insertions(+), 98 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index c23ec696a..f4cb1ddbe 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -2429,7 +2429,7 @@ HTML; $sInputType = self::ENUM_INPUT_TYPE_IMAGE; $aEventsList[] = 'validate'; $aEventsList[] = 'change'; - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/edit_image.js'); + $oPage->LinkScriptFromAppRoot('js/edit_image.js'); $oDocument = $value; // Value is an ormDocument objectm $sDefaultUrl = $oAttDef->Get('default_image'); if (is_object($oDocument) && !$oDocument->IsEmpty()) { @@ -2545,11 +2545,11 @@ HTML; $sHTMLValue .= ''; $sHTMLValue .= '
'.$sReloadSpan.'
'; // No validation span for this one: it does handle its own validation! $sHTMLValue .= "\n"; - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/form_handler.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/console_form_handler.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/field_set.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/form_field.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/subform_field.js'); + $oPage->LinkScriptFromAppRoot('js/form_handler.js'); + $oPage->LinkScriptFromAppRoot('js/console_form_handler.js'); + $oPage->LinkScriptFromAppRoot('js/field_set.js'); + $oPage->LinkScriptFromAppRoot('js/form_field.js'); + $oPage->LinkScriptFromAppRoot('js/subform_field.js'); $oPage->add_ready_script( <<add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/selectize.min.js'); + $oPage->LinkScriptFromAppRoot('js/selectize.min.js'); $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/selectize.default.css'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.itop-set-widget.js'); + $oPage->LinkScriptFromAppRoot('js/jquery.itop-set-widget.js'); $oPage->add_dict_entry('Core:AttributeSet:placeholder'); @@ -3452,7 +3452,7 @@ EOF // Dummy collapsible section created in order to get JS files $oCollapsibleSection = new CollapsibleSection(''); foreach ($oCollapsibleSection->GetJsFilesUrlRecursively(true) as $sJSFile) { - $oPage->add_linked_script($sJSFile); + $oPage->LinkScriptFromURI($sJSFile); } } $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs); diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php index bae51a7f9..7ad64b7f7 100644 --- a/application/dashboard.class.inc.php +++ b/application/dashboard.class.inc.php @@ -563,8 +563,8 @@ JS } if (!$bEditMode) { - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/dashlet.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/dashboard.js'); + $oPage->LinkScriptFromAppRoot('js/dashlet.js'); + $oPage->LinkScriptFromAppRoot('js/dashboard.js'); } return $oDashboard; @@ -1118,8 +1118,8 @@ JS */ protected function RenderEditionTools(WebPage $oPage, DashboardLayoutUIBlock $oDashboard, $aExtraParams) { - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/blueimp-file-upload/js/jquery.iframe-transport.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/blueimp-file-upload/js/jquery.fileupload.js'); + $oPage->LinkScriptFromAppRoot('node_modules/blueimp-file-upload/js/jquery.iframe-transport.js'); + $oPage->LinkScriptFromAppRoot('node_modules/blueimp-file-upload/js/jquery.fileupload.js'); $sId = utils::Sanitize($this->GetId(), '', 'element_identifier'); $sMenuTogglerId = "ibo-dashboard-menu-toggler-{$sId}"; diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index 87ca6934f..3eb0131cd 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -161,8 +161,8 @@ class UIExtKeyWidget public function DisplaySelect(WebPage $oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, DBObjectset $oAllowedValues, $value, $bMandatory, $sFieldName, $sFormPrefix = '', $aArgs = array(), &$sInputType = '') { $sTitle = addslashes($sTitle); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/extkeywidget.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/forms-json-utils.js'); + $oPage->LinkScriptFromAppRoot('js/extkeywidget.js'); + $oPage->LinkScriptFromAppRoot('js/forms-json-utils.js'); $bCreate = (!$this->bSearchMode) && (UserRights::IsActionAllowed($this->sTargetClass, UR_ACTION_MODIFY) && $bAllowTargetCreation); $bExtensions = true; @@ -368,7 +368,7 @@ JS */ public function DisplayRadio(WebPage $oPage, $iMaxComboLength, $bAllowTargetCreation, DBObjectset $oAllowedValues, $value, $sFieldName, $sDisplayStyle) { - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/forms-json-utils.js'); + $oPage->LinkScriptFromAppRoot('js/forms-json-utils.js'); $bCreate = (!$this->bSearchMode) && (UserRights::IsActionAllowed($this->sTargetClass, UR_ACTION_BULK_MODIFY) && $bAllowTargetCreation); $bExtensions = true; @@ -477,8 +477,8 @@ JS $this->bSearchMode = $bSearchMode; } $sTitle = addslashes($sTitle); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/extkeywidget.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'js/forms-json-utils.js'); + $oPage->LinkScriptFromAppRoot('js/extkeywidget.js'); + $oPage->LinkScriptFromAppRoot('js/forms-json-utils.js'); $bCreate = (!$this->bSearchMode) && (UserRights::IsActionAllowed($this->sTargetClass, UR_ACTION_BULK_MODIFY) && $bAllowTargetCreation); $bExtensions = true; diff --git a/core/ormcaselog.class.inc.php b/core/ormcaselog.class.inc.php index 86a93644e..a76fb3c11 100644 --- a/core/ormcaselog.class.inc.php +++ b/core/ormcaselog.class.inc.php @@ -516,7 +516,7 @@ class ormCaseLog { $sScript = ''; $sHtml .= $sScript; } else { - $oP->add_linked_script($sFileAbsUrl); + $oP->LinkScriptFromURI($sFileAbsUrl); } } } diff --git a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php index 0400ab68d..4407d68a8 100644 --- a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php +++ b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php @@ -203,8 +203,8 @@ abstract class AbstractAttachmentsRenderer $this->oPage->add(Dict::S('UI:Attachments:DropYourFileHint').''); - $this->oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/blueimp-file-upload/js/jquery.iframe-transport.js'); - $this->oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/blueimp-file-upload/js/jquery.fileupload.js'); + $this->oPage->LinkScriptFromAppRoot('node_modules/blueimp-file-upload/js/jquery.iframe-transport.js'); + $this->oPage->LinkScriptFromAppRoot('node_modules/blueimp-file-upload/js/jquery.fileupload.js'); $this->oPage->add_ready_script( <<set_base(utils::GetAbsoluteUrlAppRoot().'pages/'); $sAceDir = 'node_modules/ace-builds/src-min/'; -$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sAceDir.'ace.js'); -$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sAceDir.'mode-php.js'); -$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sAceDir.'theme-eclipse.js'); -$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sAceDir.'ext-searchbox.js'); +$oP->LinkScriptFromAppRoot($sAceDir.'ace.js'); +$oP->LinkScriptFromAppRoot($sAceDir.'mode-php.js'); +$oP->LinkScriptFromAppRoot($sAceDir.'theme-eclipse.js'); +$oP->LinkScriptFromAppRoot($sAceDir.'ext-searchbox.js'); try { $sOperation = utils::ReadParam('operation', ''); diff --git a/datamodels/2.x/itop-hub-connector/hubconnectorpage.class.inc.php b/datamodels/2.x/itop-hub-connector/hubconnectorpage.class.inc.php index 7377dedfe..257080513 100644 --- a/datamodels/2.x/itop-hub-connector/hubconnectorpage.class.inc.php +++ b/datamodels/2.x/itop-hub-connector/hubconnectorpage.class.inc.php @@ -17,7 +17,7 @@ class HubConnectorPage extends NiceWebPage $sModuleImagesDir = utils::GetAbsoluteUrlModulesRoot().'itop-hub-connector/images'; $sUserPrefs = appUserPreferences::GetAsJSON(); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/utils.js'); + $this->LinkScriptFromAppRoot('js/utils.js'); $this->add_script(<<add_linked_script(utils::GetAbsoluteUrlModulesRoot().'itop-hub-connector/js/hub.js'); + $oPage->LinkScriptFromModule('itop-hub-connector/js/hub.js'); $oPage->add_linked_stylesheet('../css/font-combodo/font-combodo.css'); $oPage->add_style(<<add_linked_script(utils::GetAbsoluteUrlModulesRoot().'itop-hub-connector/js/hub.js'); + $oPage->LinkScriptFromModule('itop-hub-connector/js/hub.js'); $oPage->add_linked_stylesheet('../css/font-combodo/font-combodo.css'); $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlModulesRoot().'itop-hub-connector/css/hub.css'); diff --git a/pages/UI.php b/pages/UI.php index 2ef41873d..5eeb47bb4 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -350,7 +350,7 @@ try case 'stimulus': // Form displayed when applying a stimulus (state change) case 'apply_stimulus': // Form displayed when applying a stimulus (state change) foreach (ObjectController::EnumRequiredForModificationJsFilesRelPaths() as $sJsFileRelPath) { - $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "$sJsFileRelPath"); + $oP->LinkScriptFromAppRoot($sJsFileRelPath); } break; } diff --git a/pages/UniversalSearch.php b/pages/UniversalSearch.php index f1ea3bc40..c1b610cd3 100644 --- a/pages/UniversalSearch.php +++ b/pages/UniversalSearch.php @@ -33,11 +33,11 @@ ApplicationMenu::CheckMenuIdEnabled('UniversalSearchMenu'); $oAppContext = new ApplicationContext(); $oP = new iTopWebPage(Dict::S('UI:UniversalSearchTitle')); -$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/forms-json-utils.js"); -$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/wizardhelper.js"); -$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/wizard.utils.js"); -$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/extkeywidget.js"); -$oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/jquery.blockUI.js"); +$oP->LinkScriptFromAppRoot("js/forms-json-utils.js"); +$oP->LinkScriptFromAppRoot("js/wizardhelper.js"); +$oP->LinkScriptFromAppRoot("js/wizard.utils.js"); +$oP->LinkScriptFromAppRoot("js/extkeywidget.js"); +$oP->LinkScriptFromAppRoot("js/jquery.blockUI.js"); // From now on the context is limited to the the selected organization ?? diff --git a/pages/ajax.render.php b/pages/ajax.render.php index 931736d3d..0015ebf59 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -2208,7 +2208,7 @@ EOF case 'cke_browse': $oPage = new NiceWebPage(Dict::S('UI:BrowseInlineImages')); $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'node_modules/magnific-popup/dist/magnific-popup.css'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/magnific-popup/dist/jquery.magnific-popup.min.js'); + $oPage->LinkScriptFromAppRoot('node_modules/magnific-popup/dist/jquery.magnific-popup.min.js'); $sAppRootUrl = utils::GetAbsoluteUrlAppRoot(); $sImgUrl = $sAppRootUrl.INLINEIMAGE_DOWNLOAD_URL; diff --git a/pages/tagadmin.php b/pages/tagadmin.php index 324b153a6..d16fccf3f 100644 --- a/pages/tagadmin.php +++ b/pages/tagadmin.php @@ -37,11 +37,11 @@ try // Main program // $oP = new iTopWebPage(Dict::S('Menu:TagAdminMenu+')); - $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/forms-json-utils.js"); - $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/wizardhelper.js"); - $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/wizard.utils.js"); - $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/extkeywidget.js"); - $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/jquery.blockUI.js"); + $oP->LinkScriptFromAppRoot("js/forms-json-utils.js"); + $oP->LinkScriptFromAppRoot("js/wizardhelper.js"); + $oP->LinkScriptFromAppRoot("js/wizard.utils.js"); + $oP->LinkScriptFromAppRoot("js/extkeywidget.js"); + $oP->LinkScriptFromAppRoot("js/jquery.blockUI.js"); $sBaseClass = 'TagSetFieldData'; $sClass = utils::ReadParam('class', '', false, 'class'); diff --git a/setup/setuppage.class.inc.php b/setup/setuppage.class.inc.php index bc3c5d2df..27b837517 100644 --- a/setup/setuppage.class.inc.php +++ b/setup/setuppage.class.inc.php @@ -39,10 +39,10 @@ class SetupPage extends NiceWebPage public function __construct($sTitle) { parent::__construct($sTitle); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/jquery.blockUI.js"); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/@popperjs/core/dist/umd/popper.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/tippy.js/dist/tippy-bundle.umd.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "setup/setup.js"); + $this->LinkScriptFromAppRoot("js/jquery.blockUI.js"); + $this->LinkScriptFromAppRoot('node_modules/@popperjs/core/dist/umd/popper.js'); + $this->LinkScriptFromAppRoot('node_modules/tippy.js/dist/tippy-bundle.umd.js'); + $this->LinkScriptFromAppRoot("setup/setup.js"); $this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/font-awesome/css/all.min.css'); $this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/font-combodo/font-combodo.css'); $this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'node_modules/tippy.js/dist/tippy.css'); diff --git a/setup/wizardcontroller.class.inc.php b/setup/wizardcontroller.class.inc.php index 25a912b67..dff6c6e35 100644 --- a/setup/wizardcontroller.class.inc.php +++ b/setup/wizardcontroller.class.inc.php @@ -217,7 +217,7 @@ HTML; } } } - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'setup/setup.js'); + $oPage->LinkScriptFromAppRoot('setup/setup.js'); $oPage->add_script("function CanMoveForward()\n{\n".$oStep->JSCanMoveForward()."\n}\n"); $oPage->add_script("function CanMoveBackward()\n{\n".$oStep->JSCanMoveBackward()."\n}\n"); $oPage->add('
'); diff --git a/setup/wizardsteps.class.inc.php b/setup/wizardsteps.class.inc.php index e45a0c948..75850cb7b 100644 --- a/setup/wizardsteps.class.inc.php +++ b/setup/wizardsteps.class.inc.php @@ -2307,7 +2307,7 @@ class WizStepSummary extends WizardStep $oPage->add('
Progress of the installation'); $oPage->add('
'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . 'setup/jquery.progression.js'); + $oPage->LinkScriptFromAppRoot('setup/jquery.progression.js'); $oPage->add('

Ready to start...

0%
'); $oPage->add('
'); // progress_content $oPage->add('
'); diff --git a/sources/Application/Helper/WebResourcesHelper.php b/sources/Application/Helper/WebResourcesHelper.php index f0228a39f..8a45dbea6 100644 --- a/sources/Application/Helper/WebResourcesHelper.php +++ b/sources/Application/Helper/WebResourcesHelper.php @@ -62,7 +62,7 @@ class WebResourcesHelper //when ckeditor is loaded in ajax, CKEDITOR_BASEPATH is not well defined (this constant is used to load additional js) $oPage->add_script("if (! window.CKEDITOR_BASEPATH) { var CKEDITOR_BASEPATH = '".utils::GetAbsoluteUrlAppRoot()."js/ckeditor/';}"); foreach (static::GetJSFilesRelPathsForCKEditor() as $sFile) { - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sFile); + $oPage->LinkScriptFromAppRoot($sFile); } } @@ -97,7 +97,7 @@ class WebResourcesHelper } foreach (static::GetJSFilesRelPathsForC3JS() as $sFile) { - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sFile); + $oPage->LinkScriptFromAppRoot($sFile); } } @@ -135,13 +135,13 @@ class WebResourcesHelper */ public static function EnableSimpleGraphInWebPage(WebPage &$oPage): void { - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/raphael-min.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/fraphael.js'); + $oPage->LinkScriptFromAppRoot('js/raphael-min.js'); + $oPage->LinkScriptFromAppRoot('js/fraphael.js'); $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'node_modules/jquery-contextmenu/src/jquery.contextMenu.css'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/jquery-contextmenu/src/jquery.contextMenu.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.positionBy.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.popupmenu.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.mousewheel.js'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/simple_graph.js'); + $oPage->LinkScriptFromAppRoot('node_modules/jquery-contextmenu/src/jquery.contextMenu.js'); + $oPage->LinkScriptFromAppRoot('js/jquery.positionBy.js'); + $oPage->LinkScriptFromAppRoot('js/jquery.popupmenu.js'); + $oPage->LinkScriptFromAppRoot('js/jquery.mousewheel.js'); + $oPage->LinkScriptFromAppRoot('js/simple_graph.js'); } } \ No newline at end of file diff --git a/sources/Application/WebPage/ErrorPage.php b/sources/Application/WebPage/ErrorPage.php index bc8370419..7119f4067 100644 --- a/sources/Application/WebPage/ErrorPage.php +++ b/sources/Application/WebPage/ErrorPage.php @@ -26,8 +26,8 @@ class ErrorPage extends NiceWebPage { $oKpi = new ExecutionKPI(); parent::__construct($sTitle); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "js/jquery.blockUI.js"); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "setup/setup.js"); + $this->LinkScriptFromAppRoot("js/jquery.blockUI.js"); + $this->LinkScriptFromAppRoot("setup/setup.js"); $this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/font-awesome/css/all.min.css'); $this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/font-combodo/font-combodo.css'); $this->add_saas("css/setup.scss"); diff --git a/sources/Application/WebPage/NiceWebPage.php b/sources/Application/WebPage/NiceWebPage.php index b66ab61ba..d00a49663 100644 --- a/sources/Application/WebPage/NiceWebPage.php +++ b/sources/Application/WebPage/NiceWebPage.php @@ -152,20 +152,20 @@ JS parent::InitializeLinkedScripts(); // Used throughout the app. - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/jquery/dist/jquery.min.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.blockUI.js'); + $this->LinkScriptFromAppRoot('node_modules/jquery/dist/jquery.min.js'); + $this->LinkScriptFromAppRoot('js/jquery.blockUI.js'); if (utils::IsDevelopmentEnvironment()) // Needed since many other plugins still rely on oldies like $.browser { - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery-migrate.dev-params.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery-migrate.dev.js'); + $this->LinkScriptFromAppRoot('js/jquery-migrate.dev-params.js'); + $this->LinkScriptFromAppRoot('js/jquery-migrate.dev.js'); } else { - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery-migrate.prod.min.js'); + $this->LinkScriptFromAppRoot('js/jquery-migrate.prod.min.js'); } - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/jquery-ui-dist/jquery-ui.min.js'); + $this->LinkScriptFromAppRoot('node_modules/jquery-ui-dist/jquery-ui.min.js'); // Used throughout the app. - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/utils.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/latinise/latinise.min.js'); + $this->LinkScriptFromAppRoot('js/utils.js'); + $this->LinkScriptFromAppRoot('js/latinise/latinise.min.js'); } /** diff --git a/sources/Application/WebPage/UnauthenticatedWebPage.php b/sources/Application/WebPage/UnauthenticatedWebPage.php index d81b0df7a..f085fcebe 100644 --- a/sources/Application/WebPage/UnauthenticatedWebPage.php +++ b/sources/Application/WebPage/UnauthenticatedWebPage.php @@ -77,13 +77,12 @@ class UnauthenticatedWebPage extends NiceWebPage $this->SetContentType('text/html'); // - bootstrap - $this->add_linked_script(UAWP_PORTAL_PUBLIC_FOLDER_ABSOLUTE_URL . 'lib/bootstrap/js/bootstrap.min.js'); + $this->LinkScriptFromURI(UAWP_PORTAL_PUBLIC_FOLDER_ABSOLUTE_URL . 'lib/bootstrap/js/bootstrap.min.js'); // Note: Since 2.6.0 moment was moved from portal to iTop core - $sMomentURL = utils::GetAbsoluteUrlAppRoot().'/js/moment-with-locales.min.js'; - $this->add_linked_script($sMomentURL); + $this->LinkScriptFromAppRoot('js/moment-with-locales.min.js'); - $this->add_linked_script(UAWP_PORTAL_PUBLIC_FOLDER_ABSOLUTE_URL . 'lib/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'); + $this->LinkScriptFromURI(UAWP_PORTAL_PUBLIC_FOLDER_ABSOLUTE_URL . 'lib/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'); // CSS files $this->add_linked_stylesheet(UAWP_PORTAL_PUBLIC_FOLDER_ABSOLUTE_URL . 'lib/bootstrap/css/bootstrap.min.css'); diff --git a/sources/Application/WebPage/iTopWebPage.php b/sources/Application/WebPage/iTopWebPage.php index d37aa108e..c56fe19ae 100644 --- a/sources/Application/WebPage/iTopWebPage.php +++ b/sources/Application/WebPage/iTopWebPage.php @@ -172,49 +172,49 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage parent::InitializeLinkedScripts(); // Used by forms - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/leave_handler.js'); + $this->LinkScriptFromAppRoot('js/leave_handler.js'); // Used by external keys, DM viewer - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.treeview.min.js'); + $this->LinkScriptFromAppRoot('js/jquery.treeview.min.js'); // Used by advanced search, date(time) attributes. Coupled to the PrepareWidgets() JS function. - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery-ui-timepicker-addon.min.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery-ui-timepicker-addon-i18n.min.js'); + $this->LinkScriptFromAppRoot('js/jquery-ui-timepicker-addon.min.js'); + $this->LinkScriptFromAppRoot('js/jquery-ui-timepicker-addon-i18n.min.js'); // Used by external keys and other drop down lists - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/selectize.min.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/selectize-plugin-a11y/selectize-plugin-a11y.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.multiselect.js'); + $this->LinkScriptFromAppRoot('js/selectize.min.js'); + $this->LinkScriptFromAppRoot('node_modules/selectize-plugin-a11y/selectize-plugin-a11y.js'); + $this->LinkScriptFromAppRoot('js/jquery.multiselect.js'); // Used by inline image, CKEditor and other places - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/magnific-popup/dist/jquery.magnific-popup.min.js'); + $this->LinkScriptFromAppRoot('node_modules/magnific-popup/dist/jquery.magnific-popup.min.js'); // Used by date(time) attibutes, activity panel, ... - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/moment-with-locales.min.js'); + $this->LinkScriptFromAppRoot('js/moment-with-locales.min.js'); // Used by the newsroom - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/showdown/dist/showdown.min.js'); + $this->LinkScriptFromAppRoot('node_modules/showdown/dist/showdown.min.js'); // Tooltips - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/@popperjs/core/dist/umd/popper.min.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/tippy.js/dist/tippy-bundle.umd.min.js'); + $this->LinkScriptFromAppRoot('node_modules/@popperjs/core/dist/umd/popper.min.js'); + $this->LinkScriptFromAppRoot('node_modules/tippy.js/dist/tippy-bundle.umd.min.js'); // Toasts - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/toastify-js/src/toastify.js'); + $this->LinkScriptFromAppRoot('node_modules/toastify-js/src/toastify.js'); // Keyboard shortcuts - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/mousetrap/mousetrap.min.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'node_modules/mousetrap/plugins/record/mousetrap-record.min.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/pages/backoffice/keyboard-shortcuts.js'); + $this->LinkScriptFromAppRoot('node_modules/mousetrap/mousetrap.min.js'); + $this->LinkScriptFromAppRoot('node_modules/mousetrap/plugins/record/mousetrap-record.min.js'); + $this->LinkScriptFromAppRoot('js/pages/backoffice/keyboard-shortcuts.js'); // Used throughout the app. - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/pages/backoffice/toolbox.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/pages/backoffice/on-ready.js'); + $this->LinkScriptFromAppRoot('js/pages/backoffice/toolbox.js'); + $this->LinkScriptFromAppRoot('js/pages/backoffice/on-ready.js'); // Used by dashboard editor - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/property_field.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/icon_select.js'); - $this->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/ajaxfileupload.js'); + $this->LinkScriptFromAppRoot('js/property_field.js'); + $this->LinkScriptFromAppRoot('js/icon_select.js'); + $this->LinkScriptFromAppRoot('js/ajaxfileupload.js'); } /** @@ -871,7 +871,7 @@ HTML; /** @var \iBackofficeLinkedScriptsExtension $oExtensionInstance */ foreach (MetaModel::EnumPlugins('iBackofficeLinkedScriptsExtension') as $oExtensionInstance) { foreach ($oExtensionInstance->GetLinkedScriptsAbsUrls() as $sScriptUrl) { - $this->add_linked_script($sScriptUrl); + $this->LinkScriptFromURI($sScriptUrl); } } // - API: Early inline scripts diff --git a/sources/Controller/Base/Layout/ObjectController.php b/sources/Controller/Base/Layout/ObjectController.php index 3c45090ab..bd230de5f 100644 --- a/sources/Controller/Base/Layout/ObjectController.php +++ b/sources/Controller/Base/Layout/ObjectController.php @@ -315,7 +315,7 @@ JS; } // - JS files foreach (static::EnumRequiredForModificationJsFilesRelPaths() as $sJsFileRelPath) { - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sJsFileRelPath); + $oPage->LinkScriptFromAppRoot($sJsFileRelPath); } // Note: Code duplicated to the case 'apply_modify' in UI.php when a data integrity issue has been found @@ -771,7 +771,7 @@ JS; protected function AddRequiredForModificationJsFilesToPage(iTopWebPage &$oPage): void { foreach (static::EnumRequiredForModificationJsFilesRelPaths() as $sJsFileRelPath) { - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot() . "$sJsFileRelPath"); + $oPage->LinkScriptFromAppRoot($sJsFileRelPath); } } diff --git a/sources/Controller/Newsroom/iTopNewsroomController.php b/sources/Controller/Newsroom/iTopNewsroomController.php index 5dc1e6cdd..4a061f657 100644 --- a/sources/Controller/Newsroom/iTopNewsroomController.php +++ b/sources/Controller/Newsroom/iTopNewsroomController.php @@ -56,7 +56,7 @@ class iTopNewsroomController extends Controller public function OperationViewAll() { $oPage = new iTopWebPage(Dict::S('UI:Newsroom:iTopNotification:ViewAllPage:Title')); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/pages/backoffice/itop-newsroom.view-all.js'); + $oPage->LinkScriptFromAppRoot('js/pages/backoffice/itop-newsroom.view-all.js'); // Add title block // Make bulk actions block $oBulkActionsBlock = PanelUIBlockFactory::MakeForInformation(Dict::S('UI:Newsroom:iTopNotification:ViewAllPage:Title')); diff --git a/sources/Controller/Notifications/NotificationsCenterController.php b/sources/Controller/Notifications/NotificationsCenterController.php index aaa129ea2..d121af6bf 100644 --- a/sources/Controller/Notifications/NotificationsCenterController.php +++ b/sources/Controller/Notifications/NotificationsCenterController.php @@ -255,7 +255,7 @@ JS // Add Set JS files to the page as we used a renderer ourselves, they are not added automatically by the page foreach (Set::DEFAULT_JS_FILES_REL_PATH as $sJsFile) { - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sJsFile); + $oPage->LinkScriptFromAppRoot($sJsFile); } $oPage->AddSubBlock($oNotificationsPanel); diff --git a/sources/Renderer/Console/ConsoleBlockRenderer.php b/sources/Renderer/Console/ConsoleBlockRenderer.php index a82b2c629..41470f996 100644 --- a/sources/Renderer/Console/ConsoleBlockRenderer.php +++ b/sources/Renderer/Console/ConsoleBlockRenderer.php @@ -84,7 +84,7 @@ class ConsoleBlockRenderer extends BlockRenderer } // JS files foreach ($oBlock->GetJsFilesUrlRecursively(true) as $sFileAbsUrl) { - $oPage->add_linked_script($sFileAbsUrl); + $oPage->LinkScriptFromURI($sFileAbsUrl); } static::AddCssJsTemplatesToPageRecursively($oPage, $oBlock, $aContextParams); } diff --git a/webservices/export-v2.php b/webservices/export-v2.php index bba14e0ce..d5d638a70 100644 --- a/webservices/export-v2.php +++ b/webservices/export-v2.php @@ -235,8 +235,8 @@ function FormatDatesInPreview(sRadioSelector, sPreviewSelector) } EOF ); - $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/tabularfieldsselector.js'); - $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.dragtable.js'); + $oP->LinkScriptFromAppRoot('js/tabularfieldsselector.js'); + $oP->LinkScriptFromAppRoot('js/jquery.dragtable.js'); $oP->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/dragtable.css'); $oForm = FormUIBlockFactory::MakeStandard("export-form");