mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°931: Tags data class display name
This commit is contained in:
@@ -964,6 +964,28 @@ abstract class DBObject implements iDisplay
|
||||
return MetaModel::GetClassIcon(get_class($this), $bImgTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name as defined in the dictionary
|
||||
* @return string (empty for default name scheme)
|
||||
*/
|
||||
public static function GetClassName($sClass)
|
||||
{
|
||||
$sStringCode = 'Class:'.$sClass;
|
||||
return Dict::S($sStringCode, str_replace('_', ' ', $sClass));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description as defined in the dictionary
|
||||
* @param string $sClass
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
final static public function GetClassDescription($sClass)
|
||||
{
|
||||
$sStringCode = 'Class:'.$sClass.'+';
|
||||
return Dict::S($sStringCode, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of an object in a safe manner for displaying inside a web page
|
||||
* @return string
|
||||
|
||||
@@ -116,6 +116,22 @@ class Dict
|
||||
self::$m_iErrorMode = $iErrorMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a dictionary entry exists or not
|
||||
* @param $sStringCode
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function Exists($sStringCode)
|
||||
{
|
||||
$sImpossibleString = 'aVlHYKEI3TZuDV5o0pghv7fvhYNYuzYkTk7WL0Zoqw8rggE7aq';
|
||||
if (static::S($sStringCode, $sImpossibleString) === $sImpossibleString)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a localised string from the dictonary
|
||||
*
|
||||
|
||||
@@ -320,8 +320,7 @@ abstract class MetaModel
|
||||
final static public function GetName($sClass)
|
||||
{
|
||||
self::_check_subclass($sClass);
|
||||
$sStringCode = 'Class:'.$sClass;
|
||||
return Dict::S($sStringCode, str_replace('_', ' ', $sClass));
|
||||
return $sClass::GetClassName($sClass);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,8 +410,7 @@ abstract class MetaModel
|
||||
final static public function GetClassDescription($sClass)
|
||||
{
|
||||
self::_check_subclass($sClass);
|
||||
$sStringCode = 'Class:'.$sClass.'+';
|
||||
return Dict::S($sStringCode, '');
|
||||
return $sClass::GetClassDescription($sClass);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -248,6 +248,22 @@ abstract class TagSetFieldData extends cmdbAbstractObject
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetClassName($sClass)
|
||||
{
|
||||
$aTagFieldInfo = TagSetFieldData::ExtractTagFieldName($sClass);
|
||||
$sClassDesc = MetaModel::GetName($aTagFieldInfo['tag_class']);
|
||||
$sAttDesc = MetaModel::GetAttributeDef($aTagFieldInfo['tag_class'], $aTagFieldInfo['tag_attcode'])->GetLabel();
|
||||
if (Dict::Exists("Class:$sClass"))
|
||||
{
|
||||
$sName = Dict::Format("Class:$sClass", $sClassDesc, $sAttDesc);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sName = Dict::Format('Class:TagSetFieldData', $sClassDesc, $sAttDesc);
|
||||
}
|
||||
return $sName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sClass
|
||||
* @param $sAttCode
|
||||
|
||||
@@ -915,13 +915,12 @@ Dict::Add('EN US', 'English', 'English', array(
|
||||
// Class: TagSetFieldData
|
||||
//
|
||||
Dict::Add('EN US', 'English', 'English', array(
|
||||
'Class:TagSetFieldData' => 'List of tags',
|
||||
'Class:TagSetFieldData' => '%2$s for class %1$s',
|
||||
'Class:TagSetFieldData+' => '',
|
||||
'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 20 alphanumeric characters',
|
||||
'Core:TagSetFieldData:ErrorTagLabelSyntax' => 'Tags label should not contain | nor be empty',
|
||||
'Core:TagSetFieldData:ErrorCodeUpdateNotAllowed' => 'Tags code cannot be changed',
|
||||
'Core:TagSetFieldData:FieldDescription' => '%2$s of class %1$s',
|
||||
'Core:TagSetFieldData:WhereIsThisTagTab' => 'Tag usage (%1$d)',
|
||||
));
|
||||
|
||||
@@ -765,11 +765,13 @@ Opérateurs :<br/>
|
||||
'Core:Validator:Mandatory' => 'Veuillez remplir ce champ',
|
||||
'Core:Validator:MustBeInteger' => 'Ce champ ne peut contenir qu\'un nombre entier',
|
||||
'Core:Validator:MustSelectOne' => 'Veuillez choisir une valeur',
|
||||
|
||||
'Class:TagSetFieldData' => '%2$s pour la classe %1$s',
|
||||
'Class:TagSetFieldData+' => '',
|
||||
'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 20 caractères alphanumériques.',
|
||||
'Core:TagSetFieldData:ErrorTagLabelSyntax' => 'Le nom de l\'étiquette ne doit pas être vide ni contenir le caractère \'|\'',
|
||||
'Core:TagSetFieldData:ErrorCodeUpdateNotAllowed' => 'Le code de l\'étiquette ne peut pas être changé',
|
||||
'Core:TagSetFieldData:FieldDescription' => '%2$s pour la classe %1$s',
|
||||
'Core:TagSetFieldData:WhereIsThisTagTab' => 'Utilisation (%1$d)',
|
||||
));
|
||||
|
||||
@@ -74,12 +74,8 @@ try
|
||||
{
|
||||
$sClass = $sCurrentClass;
|
||||
}
|
||||
$aTagFieldInfo = TagSetFieldData::ExtractTagFieldName($sCurrentClass);
|
||||
$sClassDesc = MetaModel::GetName($aTagFieldInfo['tag_class']);
|
||||
$sAttDesc = MetaModel::GetAttributeDef($aTagFieldInfo['tag_class'], $aTagFieldInfo['tag_attcode'])->GetLabel();
|
||||
$sDescription = Dict::Format('Core:TagSetFieldData:FieldDescription', $sClassDesc, $sAttDesc);
|
||||
$sSelected = ($sCurrentClass == $sClass) ? " SELECTED" : "";
|
||||
$sSearchHeaderForceDropdown .= "<option value=\"$sCurrentClass\" title=\"$sDescription\"$sSelected>$sDescription</option>";
|
||||
$sSearchHeaderForceDropdown .= "<option value=\"$sCurrentClass\" title=\"$sLabel\"$sSelected>$sLabel</option>";
|
||||
}
|
||||
$sSearchHeaderForceDropdown .= "</select>\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user