mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 10:08:45 +02:00
N°931: TagSet Fix CSV import
This commit is contained in:
@@ -5995,6 +5995,10 @@ class AttributeTagSet extends AttributeDBFieldVoid
|
||||
$aGoodTags = array();
|
||||
foreach($aTagCodes as $sTagCode)
|
||||
{
|
||||
if ($sTagCode === '')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ($oTagSet->IsValidTag($sTagCode))
|
||||
{
|
||||
$aGoodTags[] = $sTagCode;
|
||||
@@ -6048,7 +6052,20 @@ class AttributeTagSet extends AttributeDBFieldVoid
|
||||
*/
|
||||
public function MakeValueFromString($sProposedValue, $bLocalizedValue = false, $sSepItem = null, $sSepAttribute = null, $sSepValue = null, $sAttributeQualifier = null)
|
||||
{
|
||||
// TODO $bLocalizedValue
|
||||
if ($bLocalizedValue && !empty($sProposedValue))
|
||||
{
|
||||
$oTagSet = new ormTagSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()), $this->GetCode());
|
||||
$aLabels = explode('|', $sProposedValue);
|
||||
$aCodes = array();
|
||||
foreach($aLabels as $sTagLabel)
|
||||
{
|
||||
if (!empty($sTagLabel))
|
||||
{
|
||||
$aCodes[] = $oTagSet->GetTagFromLabel($sTagLabel);
|
||||
}
|
||||
}
|
||||
$sProposedValue = implode(' ', $aCodes);
|
||||
}
|
||||
return $this->MakeRealValue($sProposedValue, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -429,6 +429,26 @@ final class ormTagSet
|
||||
throw new CoreUnexpectedValue("{$sTagCode} is not defined as a valid tag for {$this->sClass}:{$this->sAttCode}");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sTagCode
|
||||
*
|
||||
* @return DBObject tag
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function GetTagFromLabel($sTagLabel)
|
||||
{
|
||||
$aAllowedTags = $this->GetAllowedTags();
|
||||
foreach($aAllowedTags as $oAllowedTag)
|
||||
{
|
||||
if ($oAllowedTag->Get('tag_label') === $sTagLabel)
|
||||
{
|
||||
return $oAllowedTag->Get('tag_code');
|
||||
}
|
||||
}
|
||||
throw new CoreUnexpectedValue("{$sTagLabel} is not defined as a valid tag for {$this->sClass}:{$this->sAttCode}");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \TagSetFieldData[]
|
||||
* @throws \CoreException
|
||||
|
||||
Reference in New Issue
Block a user