mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°3685 - Front-end performances: Split compatibility files for easier maintenance / inclusion
This commit is contained in:
@@ -1149,6 +1149,14 @@ class Config
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => true,
|
||||
],
|
||||
'compatibility.include_moved_js_files' => [
|
||||
'type' => 'bool',
|
||||
'description' => 'Include back JS files which are now only included when necessary to ease usage of not migrated extensions',
|
||||
'default' => false,
|
||||
'value' => false,
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => false,
|
||||
],
|
||||
'compatibility.include_deprecated_js_files' => [
|
||||
'type' => 'bool',
|
||||
'description' => 'Include the deprecated JS files to ease usage of not migrated extensions',
|
||||
@@ -1157,6 +1165,14 @@ class Config
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => false,
|
||||
],
|
||||
'compatibility.include_moved_css_files' => [
|
||||
'type' => 'bool',
|
||||
'description' => 'Include back CSS files which are now only included when necessary to ease usage of not migrated extensions',
|
||||
'default' => false,
|
||||
'value' => false,
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => false,
|
||||
],
|
||||
'compatibility.include_deprecated_css_files' => [
|
||||
'type' => 'bool',
|
||||
'description' => 'Include the deprecated CSS files to ease usage of not migrated extensions',
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
class NiceWebPage extends WebPage
|
||||
{
|
||||
/** @inheritDoc */
|
||||
protected const COMPATIBILITY_LINKED_SCRIPTS_REL_PATH = [
|
||||
// Moved files
|
||||
protected const COMPATIBILITY_MOVED_LINKED_SCRIPTS_REL_PATH = [
|
||||
// - DisplayableGraph, impact analysis
|
||||
'js/jquery.positionBy.js',
|
||||
'js/jquery.popupmenu.js',
|
||||
@@ -51,8 +50,9 @@ class NiceWebPage extends WebPage
|
||||
'js/clipboardwidget.js',
|
||||
// - SearchForm
|
||||
'js/searchformforeignkeys.js',
|
||||
|
||||
// Deprecated files
|
||||
];
|
||||
/** @inheritDoc */
|
||||
protected const COMPATIBILITY_DEPRECATED_LINKED_SCRIPTS_REL_PATH = [
|
||||
/** @deprecated since 3.0.0 Not used in the backoffice since the introduction of the new tooltip lib. */
|
||||
'js/hovertip.js',
|
||||
/** @deprecated since 3.0.0 N°2737 - Migrate table to DataTables plugin to be iso with the end-users portal, will be removed in 3.x */
|
||||
|
||||
@@ -61,15 +61,46 @@ class WebPage implements Page
|
||||
public const ENUM_SESSION_MESSAGE_SEVERITY_ERROR = 'error';
|
||||
|
||||
/**
|
||||
* @var array Script linked (externals) to the page through URIs, which were deprecated but can be added back if necessary {@see "compatibility.include_deprecated_js_files" conf. param.}
|
||||
* @var string
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected const COMPATIBILITY_LINKED_SCRIPTS_REL_PATH = [];
|
||||
protected const ENUM_COMPATIBILITY_FILE_TYPE_JS = 'js';
|
||||
/**
|
||||
* @var array Stylesheets linked (externals) to the page through URIs, which were deprecated but can be added back if necessary {@see "compatibility.include_deprecated_css_files" conf. param.}
|
||||
* @var string
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected const COMPATIBILITY_LINKED_STYLESHEETS_REL_PATH = [];
|
||||
protected const ENUM_COMPATIBILITY_FILE_TYPE_CSS = 'css';
|
||||
/**
|
||||
* @var string
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected const ENUM_COMPATIBILITY_MODE_MOVED_FILES = 'moved';
|
||||
/**
|
||||
* @var string
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected const ENUM_COMPATIBILITY_MODE_DEPRECATED_FILES = 'deprecated';
|
||||
|
||||
/**
|
||||
* @var array Script linked to the page through URIs, which are now included only were necessary instead of in all pages, but can be added back if necessary {@see "compatibility.include_moved_js_files" conf. param.}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected const COMPATIBILITY_MOVED_LINKED_SCRIPTS_REL_PATH = [];
|
||||
/**
|
||||
* @var array Script linked to the page through URIs, which were deprecated but can be added back if necessary {@see "compatibility.include_deprecated_js_files" conf. param.}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected const COMPATIBILITY_DEPRECATED_LINKED_SCRIPTS_REL_PATH = [];
|
||||
/**
|
||||
* @var array Stylesheets linked to the page through URIs, which are now included only were necessary instead of in all pages, but can be added back if necessary {@see "compatibility.include_moved_css_files" conf. param.}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected const COMPATIBILITY_MOVED_LINKED_STYLESHEETS_REL_PATH = [];
|
||||
/**
|
||||
* @var array Stylesheets linked to the page through URIs, which were deprecated but can be added back if necessary {@see "compatibility.include_deprecated_css_files" conf. param.}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected const COMPATIBILITY_DEPRECATED_LINKED_STYLESHEETS_REL_PATH = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
@@ -699,6 +730,7 @@ class WebPage implements Page
|
||||
/**
|
||||
* Initialize compatibility linked scripts for the page
|
||||
*
|
||||
* @see static::COMPATIBILITY_DEPRECATED_LINKED_SCRIPTS_REL_PATH
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
* @since 3.0.0
|
||||
@@ -706,20 +738,13 @@ class WebPage implements Page
|
||||
protected function InitializeCompatibilityLinkedScripts(): void
|
||||
{
|
||||
$bIncludeDeprecatedFiles = utils::GetConfig()->Get('compatibility.include_deprecated_js_files');
|
||||
if ($bIncludeDeprecatedFiles === false) {
|
||||
return;
|
||||
if ($bIncludeDeprecatedFiles) {
|
||||
$this->AddCompatibilityFiles(static::ENUM_COMPATIBILITY_FILE_TYPE_JS, static::ENUM_COMPATIBILITY_MODE_DEPRECATED_FILES);
|
||||
}
|
||||
|
||||
// Add ancestors files
|
||||
foreach (array_reverse(class_parents(static::class)) as $sParentClass) {
|
||||
foreach ($sParentClass::COMPATIBILITY_LINKED_SCRIPTS_REL_PATH as $sJSFile) {
|
||||
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sJSFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Add current class files
|
||||
foreach (static::COMPATIBILITY_LINKED_SCRIPTS_REL_PATH as $sJSFile) {
|
||||
$this->add_linked_script(utils::GetAbsoluteUrlAppRoot().$sJSFile);
|
||||
$bIncludeMovedFiles = utils::GetConfig()->Get('compatibility.include_moved_js_files');
|
||||
if ($bIncludeMovedFiles) {
|
||||
$this->AddCompatibilityFiles(static::ENUM_COMPATIBILITY_FILE_TYPE_JS, static::ENUM_COMPATIBILITY_MODE_MOVED_FILES);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -893,6 +918,8 @@ JS;
|
||||
/**
|
||||
* Initialize compatibility linked stylesheets for the page
|
||||
*
|
||||
* @see static::COMPATIBILITY_MOVED_LINKED_STYLESHEETS_REL_PATH
|
||||
* @see static::COMPATIBILITY_DEPRECATED_LINKED_STYLESHEETS_REL_PATH
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
* @since 3.0.0
|
||||
@@ -900,20 +927,40 @@ JS;
|
||||
protected function InitializeCompatibilityLinkedStylesheets(): void
|
||||
{
|
||||
$bIncludeDeprecatedFiles = utils::GetConfig()->Get('compatibility.include_deprecated_css_files');
|
||||
if ($bIncludeDeprecatedFiles === false) {
|
||||
return;
|
||||
if ($bIncludeDeprecatedFiles) {
|
||||
$this->AddCompatibilityFiles(static::ENUM_COMPATIBILITY_FILE_TYPE_CSS, static::ENUM_COMPATIBILITY_MODE_DEPRECATED_FILES);
|
||||
}
|
||||
|
||||
$bIncludeMovedFiles = utils::GetConfig()->Get('compatibility.include_moved_css_files');
|
||||
if ($bIncludeMovedFiles) {
|
||||
$this->AddCompatibilityFiles(static::ENUM_COMPATIBILITY_FILE_TYPE_CSS, static::ENUM_COMPATIBILITY_MODE_MOVED_FILES);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add compatibility files of $sFileType from $sMode (which are declared in {@see static::COMPATIBILITY_<MODE>_LINKED_<TYPE>_REL_PATH}) back to the page
|
||||
*
|
||||
* @param string $sFileType {@see static::ENUM_COMPATIBILITY_FILE_TYPE_XXX}
|
||||
* @param string $sMode {@see static::ENUM_COMPATIBILITY_MODE_XXX}
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected function AddCompatibilityFiles(string $sFileType, string $sMode): void
|
||||
{
|
||||
$sConstantName = 'COMPATIBILITY_'.strtoupper($sMode).'_LINKED_'. ($sFileType === static::ENUM_COMPATIBILITY_FILE_TYPE_CSS ? 'STYLESHEETS' : 'SCRIPTS') .'_REL_PATH';
|
||||
$sMethodName = 'add_linked_'.($sFileType === static::ENUM_COMPATIBILITY_FILE_TYPE_CSS ? 'stylesheet' : 'script');
|
||||
|
||||
// Add ancestors files
|
||||
foreach (array_reverse(class_parents(static::class)) as $sParentClass) {
|
||||
foreach ($sParentClass::COMPATIBILITY_LINKED_STYLESHEETS_REL_PATH as $sCSSFile) {
|
||||
$this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().$sCSSFile);
|
||||
foreach (constant($sParentClass.'::'.$sConstantName) as $sFile) {
|
||||
$this->$sMethodName(utils::GetAbsoluteUrlAppRoot().$sFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Add current class files
|
||||
foreach (static::COMPATIBILITY_LINKED_STYLESHEETS_REL_PATH as $sCSSFile) {
|
||||
$this->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().$sCSSFile);
|
||||
foreach (constant('static::'.$sConstantName) as $sFile) {
|
||||
$this->$sMethodName(utils::GetAbsoluteUrlAppRoot().$sFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,7 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage
|
||||
const DEFAULT_BREADCRUMB_ENTRY_ICON_TYPE = self::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_IMAGE;
|
||||
|
||||
/** @inheritDoc */
|
||||
protected const COMPATIBILITY_LINKED_SCRIPTS_REL_PATH = [
|
||||
// Moved files
|
||||
protected const COMPATIBILITY_MOVED_LINKED_SCRIPTS_REL_PATH = [
|
||||
// - TabContainer
|
||||
'js/jquery.ba-bbq.min.js',
|
||||
// - DashletGroupBy & other specific places
|
||||
@@ -46,15 +45,16 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage
|
||||
// - DisplayableGraph, impact analysis
|
||||
'js/raphael-min.js',
|
||||
'js/jquery.mousewheel.js',
|
||||
|
||||
// Deprecated files
|
||||
];
|
||||
/** @inheritDoc */
|
||||
protected const COMPATIBILITY_DEPRECATED_LINKED_SCRIPTS_REL_PATH = [
|
||||
'js/date.js',
|
||||
'js/jquery.layout.min.js',
|
||||
/** @deprecated since 3.0.0 N°3748 qTip will be removed in 3.x, use Tippy.js instead */
|
||||
'js/jquery.qtip-1.0.min.js',
|
||||
];
|
||||
/** @inheritDoc */
|
||||
protected const COMPATIBILITY_LINKED_STYLESHEETS_REL_PATH = [
|
||||
protected const COMPATIBILITY_MOVED_LINKED_STYLESHEETS_REL_PATH = [
|
||||
// Moved files
|
||||
// - DashletGroupBy & other specific places
|
||||
'css/c3.min.css',
|
||||
|
||||
Reference in New Issue
Block a user