mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-20 15:52:24 +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)
|
public function GetAsHTML($value, $oHostObject = null, $bLocalize = true)
|
||||||
{
|
{
|
||||||
// TODO $bLocalize = true
|
|
||||||
if (is_object($value) && ($value instanceof ormTagSet))
|
if (is_object($value) && ($value instanceof ormTagSet))
|
||||||
|
{
|
||||||
|
if ($bLocalize)
|
||||||
|
{
|
||||||
|
$aValues = $value->GetLabel();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$aValues = $value->GetValue();
|
$aValues = $value->GetValue();
|
||||||
|
}
|
||||||
return implode(' ', $aValues);
|
return implode(' ', $aValues);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -6042,12 +6048,17 @@ class AttributeTagSet extends AttributeDBField
|
|||||||
*/
|
*/
|
||||||
public function GetAsXML($value, $oHostObject = null, $bLocalize = true)
|
public function GetAsXML($value, $oHostObject = null, $bLocalize = true)
|
||||||
{
|
{
|
||||||
// TODO $bLocalize = true
|
|
||||||
if (is_object($value) && ($value instanceof ormTagSet))
|
if (is_object($value) && ($value instanceof ormTagSet))
|
||||||
{
|
{
|
||||||
$sRes = "<Set>\n";
|
$sRes = "<Set>\n";
|
||||||
|
if ($bLocalize)
|
||||||
|
{
|
||||||
|
$aValues = $value->GetLabel();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$aValues = $value->GetValue();
|
$aValues = $value->GetValue();
|
||||||
if (!empty($aValuess))
|
} if (!empty($aValuess))
|
||||||
{
|
{
|
||||||
$sRes .= '<Tag>'.implode('</Tag><Tag>', $aValues).'</Tag>';
|
$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)
|
public function GetAsCSV($value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true, $bConvertToPlainText = false)
|
||||||
{
|
{
|
||||||
// TODO $bLocalize = true
|
|
||||||
if (is_object($value) && ($value instanceof ormTagSet))
|
if (is_object($value) && ($value instanceof ormTagSet))
|
||||||
|
{
|
||||||
|
if ($bLocalize)
|
||||||
|
{
|
||||||
|
$aValues = $value->GetLabel();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$aValues = $value->GetValue();
|
$aValues = $value->GetValue();
|
||||||
|
}
|
||||||
$sRes = implode(' ', $aValues);
|
$sRes = implode(' ', $aValues);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -6110,10 +6127,16 @@ class AttributeTagSet extends AttributeDBField
|
|||||||
*/
|
*/
|
||||||
public function GetForTemplate($value, $sVerb, $oHostObject = null, $bLocalize = true)
|
public function GetForTemplate($value, $sVerb, $oHostObject = null, $bLocalize = true)
|
||||||
{
|
{
|
||||||
// TODO $bLocalize = true
|
|
||||||
if (is_object($value) && ($value instanceof ormTagSet))
|
if (is_object($value) && ($value instanceof ormTagSet))
|
||||||
|
{
|
||||||
|
if ($bLocalize)
|
||||||
|
{
|
||||||
|
$aValues = $value->GetLabel();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$aValues = $value->GetValue();
|
$aValues = $value->GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
switch ($sVerb)
|
switch ($sVerb)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
final class ormTagSet
|
final class ormTagSet
|
||||||
{
|
{
|
||||||
private $sClass; // class of the tag
|
private $sClass; // class of the tag field
|
||||||
private $sAttCode; // attcode of the tag
|
private $sAttCode; // attcode of the tag field
|
||||||
|
|
||||||
private $aAllowedTags;
|
private $aAllowedTags;
|
||||||
private $oOriginalSet;
|
private $oOriginalSet;
|
||||||
@@ -119,12 +119,12 @@ final class ormTagSet
|
|||||||
*/
|
*/
|
||||||
public function GetValue()
|
public function GetValue()
|
||||||
{
|
{
|
||||||
$aValue = array();
|
$aValues = array();
|
||||||
foreach ($this->aPreserved as $oTag)
|
foreach ($this->aPreserved as $oTag)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$aValue[] = $oTag->Get('tag_code');
|
$aValues[] = $oTag->Get('tag_code');
|
||||||
} catch (CoreException $e)
|
} catch (CoreException $e)
|
||||||
{
|
{
|
||||||
IssueLog::Error($e->getMessage());
|
IssueLog::Error($e->getMessage());
|
||||||
@@ -134,16 +134,47 @@ final class ormTagSet
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$aValue[] = $oTag->Get('tag_code');
|
$aValues[] = $oTag->Get('tag_code');
|
||||||
} catch (CoreException $e)
|
} catch (CoreException $e)
|
||||||
{
|
{
|
||||||
IssueLog::Error($e->getMessage());
|
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