Przeglądaj źródła

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.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@325 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 lat temu
rodzic
commit
aa6839b8c1

+ 3 - 2
application/cmdbabstract.class.inc.php

@@ -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
 		{

+ 8 - 6
core/valuesetdef.class.inc.php

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