N°4569 - Add itop-themes-compat

This commit is contained in:
Eric Espie
2022-03-02 17:14:08 +01:00
parent 6ac3539373
commit 45a8eb93e7
9 changed files with 132 additions and 38 deletions

View File

@@ -21,7 +21,8 @@
<module>combodo-db-tools</module>
<module>itop-core-update</module>
<module>itop-hub-connector</module>
<module>combodo-backoffice-darkmoon-theme</module>
<module>combodo-backoffice-darkmoon-theme</module>
<module>itop-themes-compat</module>
</modules>
<mandatory>true</mandatory>
</choice>

View File

@@ -0,0 +1,2 @@
# Extension Light grey and Test red themes compatibility

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design version="3.0">
<branding>
<themes>
<theme id="light-grey" _delta="define">
<variables>
</variables>
<imports>
<import id="css-variables">itop-themes-compat/assets/css/css-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="jqueryui">itop-themes-compat/assets/css/compat.scss</stylesheet>
<stylesheet id="main">itop-themes-compat/assets/css/compat.scss</stylesheet>
<stylesheet id="fullmoon">../css/backoffice/main.scss</stylesheet>
</stylesheets>
</theme>
<theme id="test-red" _delta="must_exist">
<variables>
<variable id="backoffice-environment-banner-background-color" _delta="define">#C53030</variable>
<variable id="backoffice-environment-banner-text-color" _delta="define">#F7FAFC</variable>
<variable id="backoffice-environment-banner-text-content" _delta="define">"THIS IS A TEST INSTANCE"</variable>
</variables>
<imports>
<import id="css-variables" _delta="define">itop-themes-compat/assets/css/css-variables.scss</import>
</imports>
<stylesheets>
<stylesheet id="jqueryui" _delta="define">itop-themes-compat/assets/css/compat.scss</stylesheet>
<stylesheet id="main" _delta="define">itop-themes-compat/assets/css/compat.scss</stylesheet>
</stylesheets>
</theme>
</themes>
</branding>
</itop_design>

View File

@@ -0,0 +1,11 @@
<?php
/**
* Localized data
*
* @copyright Copyright (C) 2013 XXXXX
* @license http://opensource.org/licenses/AGPL-3.0
*/
Dict::Add('EN US', 'English', 'English', array(
'theme:light-grey' => 'Light Grey (deprecated)',
));

View File

@@ -0,0 +1,17 @@
<?php
// PHP Data Model definition file
// WARNING - WARNING - WARNING
// DO NOT EDIT THIS FILE (unless you know what you are doing)
//
// If you provide a datamodel.xxxx.xml file with your module,
// this file WILL BE overwritten by the compilation of the
// module (during the setup) if the datamodel.xxxx.xml file
// contains the definition of new classes or menus.
//
// The recommended way to define new classes (for iTop 2.0 and later) is via the XML definition.
// This file remains in the module's template only for the cases where there is:
// - either no new class or menu defined in the XML file
// - or no XML file at all supplied by the module

View File

@@ -0,0 +1,52 @@
<?php
//
// iTop module definition file
//
SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-themes-compat/3.0.1',
array(
// Identification
//
'label' => 'Light grey and Test red themes compatibility',
'category' => 'business',
// Setup
//
'dependencies' => array(
'itop-structure/3.0.1',
),
'mandatory' => false,
'visible' => true,
// Components
//
'datamodel' => array(
'model.itop-themes-compat.php', // Contains the PHP code generated by the "compilation" of datamodel.itop-themes-compat.xml
),
'webservice' => array(
),
'data.struct' => array(
// add your 'structure' definition XML files here,
),
'data.sample' => array(
// add your sample data XML files here,
),
// Documentation
//
'doc.manual_setup' => '', // hyperlink to manual setup documentation, if any
'doc.more_information' => '', // hyperlink to more information, if any
// Default settings
//
'settings' => array(
// Module specific settings go here, if any
),
)
);
?>

View File

@@ -667,8 +667,6 @@ class iTopDesignFormat
*/
protected function From16To15($oFactory)
{
$oXPath = new DOMXPath($this->oDocument);
// Remove AttributeTagSet nodes
//
$sPath = "/itop_design/classes/class/fields/field[@xsi:type='AttributeTagSet']";
@@ -805,15 +803,7 @@ class iTopDesignFormat
$oNode->appendChild($oCodeNode);
}
// N°3516 Remove legacy backoffice theme
// Remove completely light-grey theme
$this->RemoveNodeFromXPath('/itop_design/branding/themes/theme[@id="light-grey"]');
// Update test-red theme
$this->RemoveNodeFromXPath('/itop_design/branding/themes/theme[@id="test-red"]/imports/import[@id="css-variables"]');
$this->RemoveNodeFromXPath('/itop_design/branding/themes/theme[@id="test-red"]/stylesheets/stylesheet[@id="jqueryui"]');
$this->RemoveNodeFromXPath('/itop_design/branding/themes/theme[@id="test-red"]/stylesheets/stylesheet[@id="main"]');
$oNodeList = $oXPath->query('/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="backoffice-environment-banner-background-color"]');
foreach ($oNodeList as $oNode) {
$oNode->setAttribute('id', 'ibo-page-banner--background-color');
@@ -829,21 +819,6 @@ class iTopDesignFormat
$oNode->setAttribute('id', 'ibo-page-banner--text-content');
}
$this->RemoveNodeFromXPath('/itop_design/branding/themes/theme[@id="test-red"]/stylesheets/stylesheet[@id="environment-banner"]');
// Add new stylesheets
$oStyleSheetsNode = $oXPath->query('/itop_design/branding/themes/theme[@id="test-red"]/stylesheets')->item(0);
if ($oStyleSheetsNode) {
$oStyleSheetNode = $oStyleSheetsNode->ownerDocument->createElement("stylesheet");
$oStyleSheetNode->setAttribute('id', 'environment-banner');
$oStyleSheetNode->appendChild(new DOMText('../css/backoffice/themes/page-banner.scss'));
$oStyleSheetsNode->appendChild($oStyleSheetNode);
$oStyleSheetNode = $oStyleSheetsNode->ownerDocument->createElement("stylesheet");
$oStyleSheetNode->setAttribute('id', 'fullmoon');
$oStyleSheetNode->appendChild(new DOMText('../css/backoffice/main.scss'));
$oStyleSheetsNode->appendChild($oStyleSheetNode);
}
// Add new attribute to theme import nodes
$oNodeList = $oXPath->query('/itop_design/branding/themes/theme/imports/import');
foreach ($oNodeList as $oNode) {
@@ -923,24 +898,27 @@ class iTopDesignFormat
// N°3516 Bring back legacy themes
// Update test-red theme
$oNodeList = $oXPath->query('/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="ibo-page-banner--background-color"]');
foreach ($oNodeList as $oNode) {
$oNode->setAttribute('id', 'backoffice-environment-banner-background-color');
if (!$oXPath->query('/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="backoffice-environment-banner-background-color"]')->item(0)) {
$oNodeList = $oXPath->query('/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="ibo-page-banner--background-color"]');
foreach ($oNodeList as $oNode) {
$oNode->setAttribute('id', 'backoffice-environment-banner-background-color');
}
}
$oNodeList = $oXPath->query('/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="ibo-page-banner--text-color"]');
foreach ($oNodeList as $oNode) {
$oNode->setAttribute('id', 'backoffice-environment-banner-text-color');
if (!$oXPath->query('/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="backoffice-environment-banner-text-color"]')->item(0)) {
$oNodeList = $oXPath->query('/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="ibo-page-banner--text-color"]');
foreach ($oNodeList as $oNode) {
$oNode->setAttribute('id', 'backoffice-environment-banner-text-color');
}
}
$oNodeList = $oXPath->query( '/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="ibo-page-banner--text-content"]');
foreach ($oNodeList as $oNode) {
$oNode->setAttribute('id', 'backoffice-environment-banner-text-content');
if (!$oXPath->query('/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="backoffice-environment-banner-text-content"]')->item(0)) {
$oNodeList = $oXPath->query('/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="ibo-page-banner--text-content"]');
foreach ($oNodeList as $oNode) {
$oNode->setAttribute('id', 'backoffice-environment-banner-text-content');
}
}
$this->RemoveNodeFromXPath('/itop_design/branding/themes/theme[@id="test-red"]/stylesheets/stylesheet[@id="environment-banner"]');
$this->RemoveNodeFromXPath('/itop_design/branding/themes/theme[@id="test-red"]/stylesheets/stylesheet[@id="fullmoon"]');
// Add new attribute to theme import nodes
$oNodeList = $oXPath->query('/itop_design/branding/themes/theme/imports/import');