فهرست منبع

Could not bulk import with the "final class" (interactive import).

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4348 a333f486-631f-4898-b8df-5754b55c2be0
romainq 8 سال پیش
والد
کامیت
c093f0b356
1فایلهای تغییر یافته به همراه35 افزوده شده و 0 حذف شده
  1. 35 0
      core/attributedef.class.inc.php

+ 35 - 0
core/attributedef.class.inc.php

@@ -2116,6 +2116,41 @@ class AttributeFinalClass extends AttributeString
 		}
 	}
 
+	/**
+	 * An enum can be localized
+	 */
+	public function MakeValueFromString($sProposedValue, $bLocalizedValue = false, $sSepItem = null, $sSepAttribute = null, $sSepValue = null, $sAttributeQualifier = null)
+	{
+		if ($bLocalizedValue)
+		{
+			// Lookup for the value matching the input
+			//
+			$sFoundValue = null;
+			$aRawValues = self::GetAllowedValues();
+			if (!is_null($aRawValues))
+			{
+				foreach ($aRawValues as $sKey => $sValue)
+				{
+					if ($sProposedValue == $sValue)
+					{
+						$sFoundValue = $sKey;
+						break;
+					}
+				}
+			}
+			if (is_null($sFoundValue))
+			{
+				return null;
+			}
+			return $this->MakeRealValue($sFoundValue, null);
+		}
+		else
+		{
+			return parent::MakeValueFromString($sProposedValue, $bLocalizedValue, $sSepItem, $sSepAttribute, $sSepValue, $sAttributeQualifier);
+		}
+	}
+
+
 	// Because this is sometimes used to get a localized/string version of an attribute...
 	public function GetEditValue($sValue, $oHostObj = null)
 	{