Merge branch 'feature/b931' of https://github.com/Combodo/iTop into feature/b931

This commit is contained in:
Molkobain
2018-09-21 17:24:56 +02:00
4 changed files with 48 additions and 8 deletions

View File

@@ -6696,7 +6696,6 @@ class AttributeExternalField extends AttributeDefinition
{
return false;
}
}
@@ -7021,7 +7020,7 @@ class AttributeTagSet extends AttributeDBFieldVoid
{
$aValues = $sValue->GetLabels();
return implode(' ', $aValues);
return implode(', ', $aValues);
}
throw new CoreWarning('Expected the attribute value to be a TagSet', array(
'found_type' => gettype($sValue),
@@ -7328,7 +7327,7 @@ class AttributeTagSet extends AttributeDBFieldVoid
public function EnumTemplateVerbs()
{
return array(
'' => 'Plain text (unlocalized) representation',
'' => 'Plain text representation',
'html' => 'HTML representation (unordered list)',
);
}
@@ -7351,16 +7350,18 @@ class AttributeTagSet extends AttributeDBFieldVoid
if ($bLocalize)
{
$aValues = $value->GetLabels();
$sSep = ', ';
}
else
{
$aValues = $value->GetValue();
$sSep = ' ';
}
switch ($sVerb)
{
case '':
return implode(' ', $aValues);
return implode($sSep, $aValues);
case 'html':
return '<ul><li>'.implode("</li><li>", $aValues).'</li></ul>';

View File

@@ -56,7 +56,8 @@ abstract class TagSetFieldData extends cmdbAbstractObject
"sql" => 'code',
"default_value" => '',
"is_null_allowed" => false,
"depends_on" => array()
"depends_on" => array(),
"validation_pattern" => '^[a-zA-Z0-9]{3,}$',
)));
MetaModel::Init_AddAttribute(new AttributeString("label", array(
"allowed_values" => null,
@@ -180,6 +181,26 @@ abstract class TagSetFieldData extends cmdbAbstractObject
$this->m_aCheckIssues[] = Dict::Format('Core:TagSetFieldData:ErrorTagCodeSyntax', $iMaxLen);
}
// Check that the code is not a MySQL stop word
$sSQL = "SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DEFAULT_STOPWORD";
try
{
$aResults = CMDBSource::QueryToArray($sSQL);
} catch (MySQLException $e)
{
IssueLog::Warning($e->getMessage());
$aResults = array();
}
foreach($aResults as $aResult)
{
if ($aResult['value'] == $sTagCode)
{
$this->m_aCheckIssues[] = Dict::S('Core:TagSetFieldData:ErrorTagCodeReservedWord');
break;
}
}
$sTagLabel = $this->Get('label');
$sSepItem = MetaModel::GetConfig()->Get('tag_set_item_separator');
if (empty($sTagLabel) || (strpos($sTagLabel, $sSepItem) !== false))

View File

@@ -917,11 +917,20 @@ Dict::Add('EN US', 'English', 'English', array(
Dict::Add('EN US', 'English', 'English', array(
'Class:TagSetFieldData' => '%2$s for class %1$s',
'Class:TagSetFieldData+' => '',
'Class:TagSetFieldData/Attribute:code' => 'Code',
'Class:TagSetFieldData/Attribute:code+' => 'Internal code. Must contain at least 3 alphanumeric characters',
'Class:TagSetFieldData/Attribute:label' => 'Label',
'Class:TagSetFieldData/Attribute:label+' => 'Displayed label',
'Class:TagSetFieldData/Attribute:description' => 'Description',
'Class:TagSetFieldData/Attribute:description+' => 'Description',
'Core:TagSetFieldData:ErrorDeleteUsedTag' => 'Used tags cannot be deleted',
'Core:TagSetFieldData:ErrorDuplicateTagCodeOrLabel' => 'Tags codes or labels must be unique',
'Core:TagSetFieldData:ErrorTagCodeSyntax' => 'Tags code should contain between 3 and %1$d alphanumeric characters',
'Core:TagSetFieldData:ErrorTagLabelSyntax' => 'Tags label should not contain \'%1$s\' nor be empty',
'Core:TagSetFieldData:ErrorCodeUpdateNotAllowed' => 'Tags "Code" cannot be changed',
'Core:TagSetFieldData:ErrorTagCodeSyntax' => 'Tags code must contain between 3 and %1$d alphanumeric characters',
'Core:TagSetFieldData:ErrorTagCodeReservedWord' => 'The chosen tag code is a reserved word',
'Core:TagSetFieldData:ErrorTagLabelSyntax' => 'Tags label must not contain \'%1$s\' nor be empty',
'Core:TagSetFieldData:ErrorCodeUpdateNotAllowed' => 'Tags Code cannot be changed when used',
'Core:TagSetFieldData:ErrorClassUpdateNotAllowed' => 'Tags "Object Class" cannot be changed',
'Core:TagSetFieldData:ErrorAttCodeUpdateNotAllowed' => 'Tags "Attribute Code" cannot be changed',
'Core:TagSetFieldData:WhereIsThisTagTab' => 'Tag usage (%1$d)',

View File

@@ -768,9 +768,18 @@ Opérateurs :<br/>
'Class:TagSetFieldData' => '%2$s pour la classe %1$s',
'Class:TagSetFieldData+' => '',
'Class:TagSetFieldData/Attribute:code' => 'Code',
'Class:TagSetFieldData/Attribute:code+' => 'Code interne. Doit contenir au moins 3 caractères alphanumériques',
'Class:TagSetFieldData/Attribute:label' => 'Label',
'Class:TagSetFieldData/Attribute:label+' => 'Label',
'Class:TagSetFieldData/Attribute:description' => 'Description',
'Class:TagSetFieldData/Attribute:description+' => 'Description',
'Core:TagSetFieldData:ErrorDeleteUsedTag' => 'Impossible de supprimer une étiquette utilisée',
'Core:TagSetFieldData:ErrorDuplicateTagCodeOrLabel' => 'Les codes et noms des étiquettes doivent être unique',
'Core:TagSetFieldData:ErrorTagCodeSyntax' => 'Le code de l\'étiquette doit contenir entre 3 et %1$d caractères alphanumériques.',
'Core:TagSetFieldData:ErrorTagCodeReservedWord' => 'Le code de l\'étiquette un mot réservé.',
'Core:TagSetFieldData:ErrorTagLabelSyntax' => 'Le nom de l\'étiquette ne doit pas être vide ni contenir le caractère \'%1$s\'',
'Core:TagSetFieldData:ErrorCodeUpdateNotAllowed' => 'Le code de l\'étiquette ne peut pas être changé',
'Core:TagSetFieldData:ErrorClassUpdateNotAllowed' => 'La classe de l\'étiquette ne peut pas être changée',