diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php
index 565580709..a4e6e60c3 100644
--- a/core/attributedef.class.inc.php
+++ b/core/attributedef.class.inc.php
@@ -3523,7 +3523,9 @@ class AttributeClassState extends AttributeString
$aValues = MetaModel::EnumStates($sChildClass);
if (in_array($sValue, $aValues))
{
- $sHTML = ''.$sValue.'';
+ $sLabelForHtmlAttribute = utils::EscapeHtml($sValue.' ('.MetaModel::GetStateLabel($sChildClass, $sValue).')');
+ $sHTML = ''.$sValue.'';
+
return $sHTML;
}
}
@@ -10207,25 +10209,37 @@ abstract class AttributeSet extends AttributeDBFieldVoid
{
if (empty($aValues)) {return '';}
$sHtml = '';
- foreach($aValues as $sValue)
- {
+ foreach($aValues as $sValue) {
$sClass = MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode());
$sAttCode = $this->GetCode();
- $sLabel = utils::HtmlEntities($this->GetValueLabel($sValue));
- $sDescription = utils::HtmlEntities($this->GetValueDescription($sValue));
+ $sLabel = utils::EscapeHtml($this->GetValueLabel($sValue));
+ $sDescription = utils::EscapeHtml($this->GetValueDescription($sValue));
$oFilter = DBSearch::FromOQL("SELECT $sClass WHERE $sAttCode MATCHES '$sValue'");
$oAppContext = new ApplicationContext();
$sContext = $oAppContext->GetForLink();
$sUIPage = cmdbAbstractObject::ComputeStandardUIPage($oFilter->GetClass());
$sFilter = rawurlencode($oFilter->serialize());
$sLink = '';
- if ($bWithLink && $this->bDisplayLink)
- {
+ if ($bWithLink && $this->bDisplayLink) {
$sUrl = utils::GetAbsoluteUrlAppRoot()."pages/$sUIPage?operation=search&filter=".$sFilter."&{$sContext}";
$sLink = ' href="'.$sUrl.'"';
}
- $sHtml .= ''.$sLabel.'';
+
+ // Prepare tooltip
+ if (empty($sDescription)) {
+ $sTooltipContent = $sLabel;
+ $sTooltipHtmlEnabled = 'false';
+ } else {
+ $sTooltipContent = <<$sLabel
+
+$sDescription
+HTML;
+ $sTooltipHtmlEnabled = 'true';
+ }
+ $sTooltipContent = utils::EscapeHtml($sTooltipContent);
+
+ $sHtml .= ''.$sLabel.'';
}
$sHtml .= '';
@@ -10758,16 +10772,15 @@ class AttributeClassAttCodeSet extends AttributeSet
$sAttClass = $sClass;
// Look for the first class (current or children) that have this attcode
- foreach(MetaModel::EnumChildClasses($sClass, ENUM_CHILD_CLASSES_ALL) as $sChildClass)
- {
- if(MetaModel::IsValidAttCode($sChildClass, $sAttCode))
- {
+ foreach (MetaModel::EnumChildClasses($sClass, ENUM_CHILD_CLASSES_ALL) as $sChildClass) {
+ if (MetaModel::IsValidAttCode($sChildClass, $sAttCode)) {
$sAttClass = $sChildClass;
break;
}
}
- $aLocalizedValues[] = ''.$sAttCode.'';
+ $sLabelForHtmlAttribute = MetaModel::GetLabel($sAttClass, $sAttCode)." ($sAttCode)";
+ $aLocalizedValues[] = ''.$sAttCode.'';
} catch (Exception $e)
{
// Ignore bad values
@@ -10952,17 +10965,15 @@ class AttributeQueryAttCodeSet extends AttributeSet
}
if (is_array($value))
{
- if (!empty($oHostObject) && $bLocalize)
- {
+ if (!empty($oHostObject) && $bLocalize) {
$aArgs['this'] = $oHostObject;
$aAllowedAttributes = $this->GetAllowedValues($aArgs);
$aLocalizedValues = array();
- foreach($value as $sAttCode)
- {
- if (isset($aAllowedAttributes[$sAttCode]))
- {
- $aLocalizedValues[] = ''.$sAttCode.'';
+ foreach ($value as $sAttCode) {
+ if (isset($aAllowedAttributes[$sAttCode])) {
+ $sLabelForHtmlAttribute = $aAllowedAttributes[$sAttCode];
+ $aLocalizedValues[] = ''.$sAttCode.'';
}
}
$value = $aLocalizedValues;
@@ -11499,15 +11510,27 @@ class AttributeTagSet extends AttributeSet
$sFilter = rawurlencode($oFilter->serialize());
$sLink = '';
- if ($bWithLink && $this->bDisplayLink)
- {
+ if ($bWithLink && $this->bDisplayLink) {
$sUrl = utils::GetAbsoluteUrlAppRoot()."pages/$sUIPage?operation=search&filter=".$sFilter."&{$sContext}";
$sLink = ' href="'.$sUrl.'"';
}
- $sHtml .= ''.htmlentities($sTagLabel, ENT_QUOTES, 'UTF-8').'';
+ $sLabelForHtml = utils::EscapeHtml($sTagLabel);
+ $sDescriptionForHtml = utils::EscapeHtml($sTagDescription);
+ if (empty($sTagDescription)) {
+ $sTooltipContent = $sTagLabel;
+ $sTooltipHtmlEnabled = 'false';
+ } else {
+ $sTooltipContent = <<$sTagLabel
+
+
$sTagDescription
+HTML;
+ $sTooltipHtmlEnabled = 'true';
+ }
+ $sTooltipContent = utils::EscapeHtml($sTooltipContent);
+
+ $sHtml .= ''.$sLabelForHtml.'';
}
else
{
diff --git a/sources/application/WebPage/iTopWebPage.php b/sources/application/WebPage/iTopWebPage.php
index 2f3db3612..ec2a85be0 100644
--- a/sources/application/WebPage/iTopWebPage.php
+++ b/sources/application/WebPage/iTopWebPage.php
@@ -292,40 +292,6 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage
JS
);
- // TODO 3.0.0: This is for tag sets, refactor the attribute markup so it contains the necessary
- // TODO 3.0.0: data-tooltip-* attributes to activate the tooltips automatically (see /js/pages/backoffice/toolbox.js)
- // Attribute set tooltip on items
- $this->add_ready_script(
- <<').text($(this).attr('data-label')).html();
- var sDescription = $(this).attr('data-description');
-
- var oContent = {};
-
- // Make nice tooltip if item has a description, otherwise just make a title attribute so the truncated label can be read.
- if(sDescription !== '')
- {
- oContent.title = { text: sLabel };
- oContent.text = sDescription;
- }
- else
- {
- oContent.text = sLabel;
- }
-
- $(this).qtip({
- content: oContent,
- show: { delay: 300, when: 'mouseover' },
- hide: { delay: 140, when: 'mouseout', fixed: true },
- style: { name: 'dark', tip: 'bottomLeft' },
- position: { corner: { target: 'topMiddle', tooltip: 'bottomLeft' }}
- });
- });
-JS
- );
-
// TODO 3.0.0: Change CSS class and extract this in backoffice/toolbox.js
// Make image attributes zoomable
$this->add_ready_script(
@@ -493,8 +459,6 @@ JS
}
JS
);
-
-
}