diff --git a/core/ormtagset.class.inc.php b/core/ormtagset.class.inc.php index ab6e4aa78..8f8155016 100644 --- a/core/ormtagset.class.inc.php +++ b/core/ormtagset.class.inc.php @@ -138,7 +138,7 @@ final class ormTagSet extends ormSet } /** - * @return array of tags indexed by code + * @return array index: code, value: corresponding {@see \TagSetFieldData} */ public function GetTags() { diff --git a/sources/renderer/bootstrap/fieldrenderer/bssetfieldrenderer.class.inc.php b/sources/renderer/bootstrap/fieldrenderer/bssetfieldrenderer.class.inc.php index 59d6269db..4a1c39e03 100644 --- a/sources/renderer/bootstrap/fieldrenderer/bssetfieldrenderer.class.inc.php +++ b/sources/renderer/bootstrap/fieldrenderer/bssetfieldrenderer.class.inc.php @@ -21,6 +21,7 @@ namespace Combodo\iTop\Renderer\Bootstrap\FieldRenderer; use MetaModel; +use utils; /** * Description of BsSetFieldRenderer @@ -105,18 +106,36 @@ EOF // ... in view mode else { - $aItems = $oOrmItemSet->GetTags(); + if ($oOrmItemSet instanceof \ormTagSet) { + $aItems = $oOrmItemSet->GetTags(); + $fExtractTagData = static function($oTag, &$sItemLabel, &$sItemDescription) { + $sItemLabel = $oTag->Get('label'); + $sItemDescription = $oTag->Get('description'); + }; + } else { + $aItems = $oOrmItemSet->GetValues(); + $oAttDef = MetaModel::GetAttributeDef($oOrmItemSet->GetClass(), $oOrmItemSet->GetAttCode()); + $fExtractTagData = static function($sEnumSetValue, &$sItemLabel, &$sItemDescription) use ($oAttDef) { + $sItemLabel = $oAttDef->GetValueLabel($sEnumSetValue); + $sItemDescription = ''; + }; + } + $oOutput->AddHtml('
') ->AddHtml(''); - foreach($aItems as $sItemCode => $oItem) + foreach($aItems as $sItemCode => $value) { - $sItemLabel = $oItem->Get('label'); - $sItemDescription = $oItem->Get('description'); + $fExtractTagData($value, $sItemLabel, $sItemDescription); + + $sDescriptionAttr = (empty($sItemDescription)) + ? '' + : ' data-description="'.utils::HtmlEntities($sItemDescription).'"'; + $oOutput->AddHtml('') + ->AddHtml('"') + ->AddHtml($sDescriptionAttr) + ->AddHtml('>') ->AddHtml($sItemLabel, true) ->AddHtml(''); } diff --git a/sources/renderer/renderingoutput.class.inc.php b/sources/renderer/renderingoutput.class.inc.php index 44ffa13d4..59892860d 100644 --- a/sources/renderer/renderingoutput.class.inc.php +++ b/sources/renderer/renderingoutput.class.inc.php @@ -20,6 +20,8 @@ namespace Combodo\iTop\Renderer; +use utils; + /** * Description of RenderingOutput * @@ -118,7 +120,7 @@ class RenderingOutput */ public function AddHtml($sHtml, $bEncodeHtmlEntities = false) { - $this->sHtml .= ($bEncodeHtmlEntities) ? htmlentities($sHtml, ENT_QUOTES, 'UTF-8') : $sHtml; + $this->sHtml .= ($bEncodeHtmlEntities) ? utils::HtmlEntities($sHtml) : $sHtml; return $this; }