Browse Source

- New implementation of the n-n link edition widget... in progress.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@654 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 năm trước cách đây
mục cha
commit
68f30ef5d3
2 tập tin đã thay đổi với 34 bổ sung4 xóa
  1. 29 3
      core/dbobject.class.php
  2. 5 1
      core/metamodel.class.php

+ 29 - 3
core/dbobject.class.php

@@ -350,6 +350,28 @@ abstract class DBObject
 		return $this->m_aOrigValues[$sAttCode];
 	}
 
+	/**
+	 * Updates the value of an external field by (re)loading the object
+	 * corresponding to the external key and getting the value from it
+	 * @param string $sAttCode Attribute code of the external field to update
+	 * @return void
+	 */
+	protected function UpdateExternalField($sAttCode)
+	{
+		$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
+		if ($oAttDef->IsExternalField())
+		{
+			$sTargetClass = $oAttDef->GetTargetClass();
+			$objkey = $this->Get($oAttDef->GetKeyAttCode());
+			$oObj = MetaModel::GetObject($sTargetClass, $objkey);
+			if (is_object($oObj))
+			{
+				$value = $oObj->Get($oAttDef->GetExtAttCode());
+				$this->Set($sAttCode, $value);
+			}
+		}
+	}
+	
 	// Compute scalar attributes that depend on any other type of attribute
 	public function DoComputeValues()
 	{
@@ -495,10 +517,14 @@ abstract class DBObject
 		}
 		$this->m_iKey = $iNewKey;
 	}
-
-	public function GetIcon()
+	/**
+	 * Get the icon representing this object
+	 * @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined)
+	 * @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file
+	 */
+	public function GetIcon($bImgTag = true)
 	{
-		return MetaModel::GetClassIcon(get_class($this));
+		return MetaModel::GetClassIcon(get_class($this), $bImgTag);
 	}
 
 	public function GetName()

+ 5 - 1
core/metamodel.class.php

@@ -288,7 +288,7 @@ abstract class MetaModel
 			return self::GetClassDescription($sClass);
 		}
 	}
-	final static public function GetClassIcon($sClass)
+	final static public function GetClassIcon($sClass, $bImgTag = true)
 	{
 		self::_check_subclass($sClass);
 
@@ -305,6 +305,10 @@ abstract class MetaModel
 				return self::GetClassIcon($sParentClass);
 			}
 		}
+		if ($bImgTag && ($sIcon != ''))
+		{
+			$sIcon = "<img src=\"$sIcon\" style=\"vertical-align:middle;\"/>";
+		}
 		return $sIcon;
 	}
 	final static public function IsAutoIncrementKey($sClass)