diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php
index 4919c6c757..0ccac79629 100644
--- a/application/cmdbabstract.class.inc.php
+++ b/application/cmdbabstract.class.inc.php
@@ -863,7 +863,7 @@ EOF
if ($oAttDef->IsWritable()) {
if (($sStateAttCode === $sAttCode) && (MetaModel::HasLifecycle($sClass))) {
// State attribute is always read-only from the UI
- $sHTMLValue = $this->GetStateLabel();
+ $sHTMLValue = $this->GetAsHTML($sAttCode);
$val = array(
'label' => '',
'value' => $sHTMLValue,
@@ -3227,28 +3227,20 @@ HTML;
// Then prepare the value
// - The field is visible in the current state of the object
- if ($oAttDef->GetEditClass() == 'Document')
- {
+ if ($oAttDef->GetEditClass() == 'Document') {
$oDocument = $this->Get($sAttCode);
- if (!$oDocument->IsEmpty())
- {
+ if (!$oDocument->IsEmpty()) {
$sDisplayValue = $this->GetAsHTML($sAttCode);
$sDisplayValue .= "
".Dict::Format('UI:OpenDocumentInNewWindow_',
$oDocument->GetDisplayLink(get_class($this), $this->GetKey(), $sAttCode)).", \n";
$sDisplayValue .= "
".Dict::Format('UI:DownloadDocument_',
$oDocument->GetDownloadLink(get_class($this), $this->GetKey(), $sAttCode)).", \n";
+ } else {
+ $sDisplayValue = '';
}
- else
- {
- $sDisplayValue ='';
- }
- }
- elseif ($oAttDef instanceof AttributeDashboard)
- {
+ } elseif ($oAttDef instanceof AttributeDashboard) {
$sDisplayValue = '';
- }
- else
- {
+ } else {
$sDisplayValue = $this->GetAsHTML($sAttCode);
}
$sValueAsHtml = $sDisplayValue;
diff --git a/core/dbobject.class.php b/core/dbobject.class.php
index a8cdc03fd6..8c0f31402c 100644
--- a/core/dbobject.class.php
+++ b/core/dbobject.class.php
@@ -1582,7 +1582,8 @@ abstract class DBObject implements iDisplay
}
/**
- * Get the label of the current state
+ * Get the label (raw text) of the current state
+ * helper for MetaModel::GetStateLabel()
*
* @api
*
diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php
index 45f83b21b3..3d3e31c495 100644
--- a/setup/compiler.class.inc.php
+++ b/setup/compiler.class.inc.php
@@ -786,16 +786,21 @@ EOF
/**
* @param $oNode
* @param $sTag
+ * @param bool $bAddQuotes
*
* @return string
* @throws \DOMFormatException
*/
- protected function GetMandatoryPropString($oNode, $sTag)
+ protected function GetMandatoryPropString($oNode, $sTag, $bAddQuotes = true)
{
$val = $oNode->GetChildText($sTag);
if (!is_null($val) && ($val !== ''))
{
- return "'".$val."'";
+ if ($bAddQuotes) {
+ return "'".$val."'";
+ } else {
+ return $val;
+ }
}
else
{
@@ -1343,13 +1348,15 @@ EOF
foreach($oValueNodes as $oValue)
{
// New in 3.0 the format of values changed
- $sCode = $this->GetMandatoryPropString($oValue, 'enum_code');
- $oStyleNode = $oValue->getElementsByTagName('style')->item(0);
- $sMainColor = $this->GetMandatoryPropString($oStyleNode, 'main_color');
- $sComplementaryColor = $this->GetMandatoryPropString($oStyleNode, 'complementary_color');
- $sDecorationClasses = $this->GetPropString($oStyleNode, 'decoration_classes', '');
- $aValues[] = self::RemoveSurroundingQuotes($sCode);
- $aStyledValues[] = "$sCode => new ormStyle($sMainColor, $sComplementaryColor, $sDecorationClasses)";
+ $sCode = $this->GetMandatoryPropString($oValue, 'enum_code', false);
+ $aValues[] = $sCode;
+ $oStyleNode = $oValue->GetOptionalElement('style');
+ if ($oStyleNode) {
+ $sMainColor = $this->GetMandatoryPropString($oStyleNode, 'main_color');
+ $sComplementaryColor = $this->GetMandatoryPropString($oStyleNode, 'complementary_color');
+ $sDecorationClasses = $this->GetPropString($oStyleNode, 'decoration_classes', '');
+ $aStyledValues[] = "'$sCode' => new ormStyle($sMainColor, $sComplementaryColor, $sDecorationClasses)";
+ }
}
$sValues = '"'.implode(',', $aValues).'"';
$aParameters['allowed_values'] = "new ValueSetEnum($sValues)";
@@ -1365,14 +1372,25 @@ EOF
{
$oValues = $oField->GetUniqueElement('values');
$oValueNodes = $oValues->getElementsByTagName('value');
- $aValues = array();
+ $aValues = [];
+ $aStyledValues = [];
foreach($oValueNodes as $oValue)
{
- // new style... $aValues[] = self::QuoteForPHP($oValue->textContent);
- $aValues[] = $oValue->textContent;
+ // New in 3.0 the format of values changed
+ $sCode = $this->GetMandatoryPropString($oValue, 'enum_code', false);
+ $aValues[] = $sCode;
+ $oStyleNode = $oValue->GetOptionalElement('style');
+ if ($oStyleNode) {
+ $sMainColor = $this->GetMandatoryPropString($oStyleNode, 'main_color');
+ $sComplementaryColor = $this->GetMandatoryPropString($oStyleNode, 'complementary_color');
+ $sDecorationClasses = $this->GetPropString($oStyleNode, 'decoration_classes', '');
+ $aStyledValues[] = "'$sCode' => new ormStyle($sMainColor, $sComplementaryColor, $sDecorationClasses)";
+ }
}
// new style... $sValues = 'array('.implode(', ', $aValues).')';
$sValues = '"'.implode(',', $aValues).'"';
+ $sStyledValues = "[".implode(',', $aStyledValues)."]";
+ $aParameters['styled_values'] = "$sStyledValues";
$aParameters['allowed_values'] = "new ValueSetEnum($sValues)";
$aParameters['sql'] = $this->GetMandatoryPropString($oField, 'sql');
$aParameters['default_value'] = $this->GetPropString($oField, 'default_value', '');