mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
Enabled localized strings (not only enums, but other types... to be defined)
SVN:trunk[359]
This commit is contained in:
@@ -77,60 +77,6 @@ abstract class cmdbAbstractObject extends CMDBObject
|
||||
return "<a href=\"{$sAbsoluteUrl}{$sPage}?operation=details&class=$sObjClass&id=$sObjKey&".$oAppContext->GetForLink()."\" title=\"$sHint\">$sLabel</a>";
|
||||
}
|
||||
|
||||
public function GetDisplayValue($sAttCode)
|
||||
{
|
||||
$sDisplayValue = "";
|
||||
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
|
||||
if ($sStateAttCode == $sAttCode)
|
||||
{
|
||||
$sDisplayValue = MetaModel::GetStateLabel(get_class($this), $this->Get($sAttCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
$oAtt = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
|
||||
|
||||
if ($oAtt->IsExternalKey())
|
||||
{
|
||||
$sTargetClass = $oAtt->GetTargetClass();
|
||||
if ($this->IsNew())
|
||||
{
|
||||
// The current object exists only in memory, don't try to query it in the DB !
|
||||
// instead let's query for the object pointed by the external key, and get its name
|
||||
$targetObjId = $this->Get($sAttCode);
|
||||
$oTargetObj = MetaModel::GetObject($sTargetClass, $targetObjId, false); // false => not sure it exists
|
||||
if (is_object($oTargetObj))
|
||||
{
|
||||
$sDisplayValue = $oTargetObj->GetName();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// retrieve the "external fields" linked to this external key
|
||||
foreach (MetaModel::GetExternalFields(get_class($this), $sAttCode) as $oExtField)
|
||||
{
|
||||
$aAvailableFields[$oExtField->GetExtAttCode()] = $oExtField->GetAsHTML($this->Get($oExtField->GetCode()));
|
||||
}
|
||||
// Use the "name" of the target class as the label of the hyperlink
|
||||
// unless it's not available in the external fields...
|
||||
$sExtClassNameAtt = MetaModel::GetNameAttributeCode($sTargetClass);
|
||||
if (isset($aAvailableFields[$sExtClassNameAtt]))
|
||||
{
|
||||
$sDisplayValue = $aAvailableFields[$sExtClassNameAtt];
|
||||
}
|
||||
else
|
||||
{
|
||||
$sDisplayValue = implode(' / ', $aAvailableFields);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sDisplayValue = $this->GetAsHTML($sAttCode);
|
||||
}
|
||||
}
|
||||
return $sDisplayValue;
|
||||
}
|
||||
|
||||
function DisplayBareHeader(WebPage $oPage)
|
||||
{
|
||||
// Standard Header with name, actions menu and history block
|
||||
@@ -592,8 +538,7 @@ abstract class cmdbAbstractObject extends CMDBObject
|
||||
}
|
||||
}
|
||||
}
|
||||
$sHtml = '#'.$oSet->GetFilter()->ToOQL()."\n";
|
||||
$sHtml .= implode($sSeparator, $aHeader)."\n";
|
||||
$sHtml = implode($sSeparator, $aHeader)."\n";
|
||||
$oSet->Seek(0);
|
||||
while ($aObjects = $oSet->FetchAssoc())
|
||||
{
|
||||
@@ -973,7 +918,7 @@ abstract class cmdbAbstractObject extends CMDBObject
|
||||
else
|
||||
{
|
||||
$sValue = $this->Get($sAttCode);
|
||||
$sDisplayValue = $this->GetDisplayValue($sAttCode);
|
||||
$sDisplayValue = $this->GetEditValue($sAttCode);
|
||||
$aArgs = array('this' => $this);
|
||||
$sHTMLValue = self::GetFormElementForField($oPage, get_class($this), $sAttCode, $oAttDef, $sValue, $sDisplayValue, '', '', $iFlags, $aArgs);
|
||||
}
|
||||
@@ -1032,7 +977,7 @@ abstract class cmdbAbstractObject extends CMDBObject
|
||||
else if (!$oAttDef->IsExternalField())
|
||||
{
|
||||
$sValue = ($oObjectToClone == null) ? '' : $oObjectToClone->Get($sAttCode);
|
||||
$sDisplayValue = ($oObjectToClone == null) ? '' : $oObjectToClone->GetDisplayValue($sAttCode);
|
||||
$sDisplayValue = ($oObjectToClone == null) ? '' : $oObjectToClone->GetEditValue($sAttCode);
|
||||
$iOptions = isset($aStates[$sTargetState]['attribute_list'][$sAttCode]) ? $aStates[$sTargetState]['attribute_list'][$sAttCode] : 0;
|
||||
|
||||
$sHTMLValue = self::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $sValue, $sDisplayValue, '', '', $iOptions, $aArgs);
|
||||
|
||||
@@ -307,7 +307,7 @@ EOF;
|
||||
else
|
||||
{
|
||||
$sValue = ""; //$this->Get($sAttCode);
|
||||
$sDisplayValue = ""; //$this->GetDisplayValue($sAttCode);
|
||||
$sDisplayValue = ""; //$this->GetEditValue($sAttCode);
|
||||
$sSubId = $sId.'_'.$index;
|
||||
$aAttrsMap[$sAttCode] = $sSubId;
|
||||
$index++;
|
||||
|
||||
@@ -210,6 +210,11 @@ abstract class AttributeDefinition
|
||||
//abstract protected GetBasicFilterHTMLInput();
|
||||
abstract public function GetBasicFilterSQLExpr($sOpCode, $value);
|
||||
|
||||
public function GetEditValue($sValue)
|
||||
{
|
||||
return (string)$sValue;
|
||||
}
|
||||
|
||||
public function GetAsHTML($sValue)
|
||||
{
|
||||
return Str::pure2html((string)$sValue);
|
||||
@@ -840,6 +845,12 @@ class AttributeEnum extends AttributeString
|
||||
return "<span title=\"\">".parent::GetAsHtml($sLabel)."</span>";
|
||||
}
|
||||
|
||||
public function GetEditValue($sValue)
|
||||
{
|
||||
$sLabel = Dict::S('Class:'.$this->GetHostClass().'/Attribute:'.$this->GetCode().'/Value:'.$sValue, $sValue);
|
||||
return $sLabel;
|
||||
}
|
||||
|
||||
public function GetAllowedValues($aArgs = array(), $sBeginsWith = '')
|
||||
{
|
||||
$aRawValues = parent::GetAllowedValues($aArgs, $sBeginsWith);
|
||||
|
||||
@@ -382,6 +382,52 @@ abstract class DBObject
|
||||
return $oAtt->GetAsHTML($this->Get($sAttCode));
|
||||
}
|
||||
|
||||
public function GetEditValue($sAttCode)
|
||||
{
|
||||
$sClass = get_class($this);
|
||||
$oAtt = MetaModel::GetAttributeDef($sClass, $sAttCode);
|
||||
|
||||
if ($oAtt->IsExternalKey())
|
||||
{
|
||||
$sTargetClass = $oAtt->GetTargetClass();
|
||||
if ($this->IsNew())
|
||||
{
|
||||
// The current object exists only in memory, don't try to query it in the DB !
|
||||
// instead let's query for the object pointed by the external key, and get its name
|
||||
$targetObjId = $this->Get($sAttCode);
|
||||
$oTargetObj = MetaModel::GetObject($sTargetClass, $targetObjId, false); // false => not sure it exists
|
||||
if (is_object($oTargetObj))
|
||||
{
|
||||
$sEditValue = $oTargetObj->GetName();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// retrieve the "external fields" linked to this external key
|
||||
foreach (MetaModel::GetExternalFields(get_class($this), $sAttCode) as $oExtField)
|
||||
{
|
||||
$aAvailableFields[$oExtField->GetExtAttCode()] = $oExtField->GetAsHTML($this->Get($oExtField->GetCode()));
|
||||
}
|
||||
// Use the "name" of the target class as the label of the hyperlink
|
||||
// unless it's not available in the external fields...
|
||||
$sExtClassNameAtt = MetaModel::GetNameAttributeCode($sTargetClass);
|
||||
if (isset($aAvailableFields[$sExtClassNameAtt]))
|
||||
{
|
||||
$sEditValue = $aAvailableFields[$sExtClassNameAtt];
|
||||
}
|
||||
else
|
||||
{
|
||||
$sEditValue = implode(' / ', $aAvailableFields);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sEditValue = $oAtt->GetEditValue($this->Get($sAttCode));
|
||||
}
|
||||
return $sEditValue;
|
||||
}
|
||||
|
||||
public function GetAsXML($sAttCode)
|
||||
{
|
||||
$oAtt = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
|
||||
|
||||
@@ -913,7 +913,7 @@ try
|
||||
$aAttributesDef = MetaModel::ListAttributeDefs($sClass);
|
||||
$oAttDef = $aAttributesDef[$sAttCode];
|
||||
$aArgs = array('this' => $oObj);
|
||||
$sHTMLValue = cmdbAbstractObject::GetFormElementForField($oP, $sClass, $sAttCode, $oAttDef, $oObj->Get($sAttCode), $oObj->GetDisplayValue($sAttCode), '', '', $iExpectCode, $aArgs);
|
||||
$sHTMLValue = cmdbAbstractObject::GetFormElementForField($oP, $sClass, $sAttCode, $oAttDef, $oObj->Get($sAttCode), $oObj->GetEditValue($sAttCode), '', '', $iExpectCode, $aArgs);
|
||||
$aDetails[] = array('label' => $oAttDef->GetLabel(), 'value' => $sHTMLValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ switch($operation)
|
||||
{
|
||||
$sId = $oWizardHelper->GetIdForField($sAttCode);
|
||||
$value = $oObj->Get($sAttCode);
|
||||
$displayValue = $oObj->GetDisplayValue($sAttCode);
|
||||
$displayValue = $oObj->GetEditValue($sAttCode);
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
|
||||
$sHTMLValue = cmdbAbstractObject::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value, $displayValue, 'att_'.$sId, '', 0, array('this' => $oObj));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user