From 1953c05b3375ea4ac5858591240c994c41f2ec27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Espi=C3=A9?= Date: Wed, 29 Aug 2018 10:26:36 +0000 Subject: [PATCH] =?UTF-8?q?N=C2=B0962:=20TagSet=20-=20add=20label=20suppor?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SVN:b931[6031] --- core/attributedef.class.inc.php | 41 +++++++++++++++++++++++------- core/ormtagset.class.inc.php | 45 ++++++++++++++++++++++++++++----- 2 files changed, 70 insertions(+), 16 deletions(-) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 580bab4f45..637aee863b 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -6023,10 +6023,16 @@ class AttributeTagSet extends AttributeDBField */ public function GetAsHTML($value, $oHostObject = null, $bLocalize = true) { - // TODO $bLocalize = true if (is_object($value) && ($value instanceof ormTagSet)) { - $aValues = $value->GetValue(); + if ($bLocalize) + { + $aValues = $value->GetLabel(); + } + else + { + $aValues = $value->GetValue(); + } return implode(' ', $aValues); } return null; @@ -6042,12 +6048,17 @@ class AttributeTagSet extends AttributeDBField */ public function GetAsXML($value, $oHostObject = null, $bLocalize = true) { - // TODO $bLocalize = true if (is_object($value) && ($value instanceof ormTagSet)) { $sRes = "\n"; - $aValues = $value->GetValue(); - if (!empty($aValuess)) + if ($bLocalize) + { + $aValues = $value->GetLabel(); + } + else + { + $aValues = $value->GetValue(); + } if (!empty($aValuess)) { $sRes .= ''.implode('', $aValues).''; } @@ -6073,10 +6084,16 @@ class AttributeTagSet extends AttributeDBField */ public function GetAsCSV($value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true, $bConvertToPlainText = false) { - // TODO $bLocalize = true if (is_object($value) && ($value instanceof ormTagSet)) { - $aValues = $value->GetValue(); + if ($bLocalize) + { + $aValues = $value->GetLabel(); + } + else + { + $aValues = $value->GetValue(); + } $sRes = implode(' ', $aValues); } else @@ -6110,10 +6127,16 @@ class AttributeTagSet extends AttributeDBField */ public function GetForTemplate($value, $sVerb, $oHostObject = null, $bLocalize = true) { - // TODO $bLocalize = true if (is_object($value) && ($value instanceof ormTagSet)) { - $aValues = $value->GetValue(); + if ($bLocalize) + { + $aValues = $value->GetLabel(); + } + else + { + $aValues = $value->GetValue(); + } switch ($sVerb) { diff --git a/core/ormtagset.class.inc.php b/core/ormtagset.class.inc.php index afe67458a2..ead0212f2d 100644 --- a/core/ormtagset.class.inc.php +++ b/core/ormtagset.class.inc.php @@ -28,8 +28,8 @@ final class ormTagSet { - private $sClass; // class of the tag - private $sAttCode; // attcode of the tag + private $sClass; // class of the tag field + private $sAttCode; // attcode of the tag field private $aAllowedTags; private $oOriginalSet; @@ -119,12 +119,12 @@ final class ormTagSet */ public function GetValue() { - $aValue = array(); + $aValues = array(); foreach ($this->aPreserved as $oTag) { try { - $aValue[] = $oTag->Get('tag_code'); + $aValues[] = $oTag->Get('tag_code'); } catch (CoreException $e) { IssueLog::Error($e->getMessage()); @@ -134,16 +134,47 @@ final class ormTagSet { try { - $aValue[] = $oTag->Get('tag_code'); + $aValues[] = $oTag->Get('tag_code'); } catch (CoreException $e) { IssueLog::Error($e->getMessage()); } } - sort($aValue); + sort($aValues); - return $aValue; + return $aValues; + } + + public function GetLabel() + { + $aLabels = array(); + foreach ($this->aPreserved as $oTag) + { + try + { + $aValues[$oTag->Get('tag_code')] = $oTag->Get('tag_label'); + } catch (CoreException $e) + { + IssueLog::Error($e->getMessage()); + } + } + foreach ($this->aAdded as $oTag) + { + try + { + $aValues[$oTag->Get('tag_code')] = $oTag->Get('tag_label'); + } catch (CoreException $e) + { + IssueLog::Error($e->getMessage()); + } + } + ksort($aValues); + foreach($aValues as $sLabel) + { + $aLabels[] = $sLabel; + } + return $aLabels; } /**