Enabled localized strings (not only enums, but other types... to be defined)

SVN:trunk[359]
This commit is contained in:
Romain Quetiez
2010-04-27 12:38:56 +00:00
parent 0c328d227d
commit 7220052134
6 changed files with 63 additions and 61 deletions

View File

@@ -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);