mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
N°962: TagSet - add label support
SVN:b931[6031]
This commit is contained in:
committed by
Pierre Goiffon
parent
a03c553000
commit
1953c05b33
@@ -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 = "<Set>\n";
|
||||
$aValues = $value->GetValue();
|
||||
if (!empty($aValuess))
|
||||
if ($bLocalize)
|
||||
{
|
||||
$aValues = $value->GetLabel();
|
||||
}
|
||||
else
|
||||
{
|
||||
$aValues = $value->GetValue();
|
||||
} if (!empty($aValuess))
|
||||
{
|
||||
$sRes .= '<Tag>'.implode('</Tag><Tag>', $aValues).'</Tag>';
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user