Enhancement / bug fix: allow the overload of the GetName method for building the short name of an object. This is also used when the object appears in a drop-down list.

SVN:trunk[325]
This commit is contained in:
Denis Flaven
2010-04-12 12:22:00 +00:00
parent 37ccd94828
commit 128f048800
2 changed files with 11 additions and 8 deletions

View File

@@ -214,7 +214,7 @@ abstract class cmdbAbstractObject extends CMDBObject
}
function GetBareDetails(WebPage $oPage)
{
{
$sHtml = '';
$oAppContext = new ApplicationContext();
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
@@ -266,7 +266,8 @@ abstract class cmdbAbstractObject extends CMDBObject
if (!empty($sTemplate))
{
$oTemplate = new DisplayTemplate($sTemplate);
$oTemplate->Render($oPage, array('class_name'=> MetaModel::GetName(get_class($this)),'class'=> get_class($this),'pkey'=> $this->GetKey(), 'name' => $this->GetName()));
$sNameAttCode = MetaModel::GetNameAttributeCode(get_class($this));
$oTemplate->Render($oPage, array('class_name'=> MetaModel::GetName(get_class($this)),'class'=> get_class($this),'pkey'=> $this->GetKey(), 'name' => $this->Get($sNameAttCode)));
}
else
{

View File

@@ -96,15 +96,17 @@ class ValueSetObjects extends ValueSetDefinition
$oFilter = DBObjectSearch::FromSibusQL($this->m_sFilterExpr, $aArgs);
if (!$oFilter) return false;
if (empty($this->m_sValueAttCode))
{
$this->m_sValueAttCode = MetaModel::GetNameAttributeCode($oFilter->GetClass());
}
$oObjects = new DBObjectSet($oFilter, $this->m_aOrderBy, $aArgs);
while ($oObject = $oObjects->Fetch())
{
$this->m_aValues[$oObject->GetKey()] = $oObject->GetAsHTML($this->m_sValueAttCode);
if (empty($this->m_sValueAttCode))
{
$this->m_aValues[$oObject->GetKey()] = $oObject->GetName();
}
else
{
$this->m_aValues[$oObject->GetKey()] = $oObject->GetAsHTML($this->m_sValueAttCode);
}
}
return true;
}