Преглед изворни кода

Class icon defined in the data model, use either the static method GetClassIcon, or GetIcon (this one could be overloaded for an icon depending on the object state)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@462 a333f486-631f-4898-b8df-5754b55c2be0
romainq пре 15 година
родитељ
комит
df84916019
2 измењених фајлова са 24 додато и 0 уклоњено
  1. 5 0
      core/dbobject.class.php
  2. 19 0
      core/metamodel.class.php

+ 5 - 0
core/dbobject.class.php

@@ -492,6 +492,11 @@ abstract class DBObject
 		$this->m_iKey = $iNewKey;
 	}
 
+	public function GetIcon()
+	{
+		return MetaModel::GetClassIcon(get_class($this));
+	}
+
 	public function GetName()
 	{
 		$sNameAttCode = MetaModel::GetNameAttributeCode(get_class($this));

+ 19 - 0
core/metamodel.class.php

@@ -280,6 +280,25 @@ abstract class MetaModel
 			return self::GetClassDescription($sClass);
 		}
 	}
+	final static public function GetClassIcon($sClass)
+	{
+		self::_check_subclass($sClass);
+
+		$sIcon = '';
+		if (array_key_exists('icon', self::$m_aClassParams[$sClass]))
+		{
+			$sIcon = self::$m_aClassParams[$sClass]['icon'];
+		}
+		if (strlen($sIcon) == 0)
+		{
+			$sParentClass = self::GetParentPersistentClass($sClass);
+			if (strlen($sParentClass) > 0)
+			{
+				return self::GetClassIcon($sParentClass);
+			}
+		}
+		return $sIcon;
+	}
 	final static public function IsAutoIncrementKey($sClass)
 	{
 		self::_check_subclass($sClass);