Revert new method in itopdesignformat

This commit is contained in:
Stephen Abello
2021-03-24 11:18:01 +01:00
parent 1d0da38d40
commit 5d6194e679
5 changed files with 31 additions and 45 deletions

View File

@@ -825,14 +825,20 @@ class iTopDesignFormat
$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"]');
$sTestRedBannerBackgroundColorPath = '/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="backoffice-environment-banner-background-color"]';
$this->SetNodeAttribute($sTestRedBannerBackgroundColorPath, 'id', 'ibo-page-banner-background-color');
$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');
}
$oNodeList = $oXPath->query( '/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="backoffice-environment-banner-text-color"]');
foreach ($oNodeList as $oNode) {
$oNode->setAttribute('id', 'ibo-page-banner-text-color');
}
$sTestRedBannerTextColorPath = '/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="backoffice-environment-banner-text-color"]';
$this->SetNodeAttribute($sTestRedBannerTextColorPath, 'id', 'ibo-page-banner-text-color');
$sTestRedBannerTextContentPath = '/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="backoffice-environment-banner-text-content"]';
$this->SetNodeAttribute($sTestRedBannerTextContentPath, 'id', 'ibo-page-banner-text-content');
$oNodeList = $oXPath->query( '/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="backoffice-environment-banner-text-content"]');
foreach ($oNodeList as $oNode) {
$oNode->setAttribute('id', 'ibo-page-banner-text-content');
}
// Add new attribute to theme import nodes
$oNodeList = $oXPath->query('/itop_design/branding/themes/theme/imports/import');
@@ -928,14 +934,22 @@ class iTopDesignFormat
// N°3516 Bring back legacy themes
// Update test-red theme
$sTestRedBannerBackgroundColorPath = '/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="ibo-page-banner-background-color"]';
$this->SetNodeAttribute($sTestRedBannerBackgroundColorPath, 'id', 'backoffice-environment-banner-background-color');
$sTestRedBannerTextColorPath = '/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="ibo-page-banner-text-color"]';
$this->SetNodeAttribute($sTestRedBannerTextColorPath, 'id', 'backoffice-environment-banner-text-color');
$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');
}
$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');
}
$sTestRedBannerTextContentPath = '/itop_design/branding/themes/theme[@id="test-red"]/variables/variable[@id="ibo-page-banner-text-content"]';
$this->SetNodeAttribute($sTestRedBannerTextContentPath, 'id', 'backoffice-environment-banner-text-content');
// Add new attribute to theme import nodes
$oNodeList = $oXPath->query('/itop_design/branding/themes/theme/imports/import');
@@ -957,38 +971,6 @@ class iTopDesignFormat
}
}
}
/**
*
* Replace those weird setAttribute calls on DOMNode above 🤷
*
* @param string $sPath
* @param string $sAttributeName
* @param string $sAttributeValue
*
* @return void
*
* @since 3.0.0
*/
private function SetNodeAttribute($sPath, $sAttributeName, $sAttributeValue)
{
$oXPath = new DOMXPath($this->oDocument);
$oNodeList = $oXPath->query($sPath);
foreach ($oNodeList as $oNode)
{
if($oNode->attributes)
{
foreach ($oNode->attributes as $oAttribute)
{
if($oAttribute->nodeName === $sAttributeName)
{
$oAttribute->nodeValue = $sAttributeValue;
}
}
}
}
}
/**
* @param string $sPath

View File

@@ -4,6 +4,7 @@
<themes>
<theme id="test-red" _delta="define">
<variables>
<variable id="ibo-page-banner-background-color">#C53030</variable>
<variable id="var1">#C53030</variable>
</variables>
<imports>

View File

@@ -4,6 +4,7 @@
<themes>
<theme id="test-red" _delta="define">
<variables>
<variable id="backoffice-environment-banner-background-color">#C53030</variable>
<variable id="var1">#C53030</variable>
</variables>
<imports>

View File

@@ -4,6 +4,7 @@
<themes>
<theme id="test-red" _delta="define">
<variables>
<variable id="backoffice-environment-banner-background-color">#C53030</variable>
<variable id="var1">#C53030</variable>
</variables>
<imports>

View File

@@ -4,6 +4,7 @@
<themes>
<theme id="test-red" _delta="define">
<variables>
<variable id="ibo-page-banner-background-color">#C53030</variable>
<variable id="var1">#C53030</variable>
</variables>
<imports>