浏览代码

Fixed issue in CSV export: null enums rendered as 'undefined' whereas '' is the value expected in the import (See an export of Organization/status)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2501 a333f486-631f-4898-b8df-5754b55c2be0
romainq 12 年之前
父节点
当前提交
596dda3af6
共有 2 个文件被更改,包括 19 次插入4 次删除
  1. 1 1
      application/cmdbabstract.class.inc.php
  2. 18 3
      core/attributedef.class.inc.php

+ 1 - 1
application/cmdbabstract.class.inc.php

@@ -1160,7 +1160,7 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
 							}
 							if ($bLocalize)
 							{
-								$outputValue = htmlentities($oFinalAttDef->GetValueLabel($rawValue), ENT_QUOTES, 'UTF-8');
+								$outputValue = htmlentities($oFinalAttDef->GetEditValue($rawValue), ENT_QUOTES, 'UTF-8');
 							}
 							else
 							{

+ 18 - 3
core/attributedef.class.inc.php

@@ -2286,7 +2286,11 @@ class AttributeEnum extends AttributeString
 
 	public function GetAsXML($value, $oHostObject = null, $bLocalize = true)
 	{
-		if ($bLocalize)
+		if (is_null($value))
+		{
+			$sFinalValue = '';
+		}
+		elseif ($bLocalize)
 		{
 			$sFinalValue = $this->GetValueLabel($value);
 		}
@@ -2300,7 +2304,11 @@ class AttributeEnum extends AttributeString
 
 	public function GetAsCSV($sValue, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true)
 	{
-		if ($bLocalize)
+		if (is_null($sValue))
+		{
+			$sFinalValue = '';
+		}
+		elseif ($bLocalize)
 		{
 			$sFinalValue = $this->GetValueLabel($sValue);
 		}
@@ -2315,7 +2323,14 @@ class AttributeEnum extends AttributeString
 
 	public function GetEditValue($sValue, $oHostObj = null)
 	{
-		return $this->GetValueLabel($sValue);
+		if (is_null($sValue))
+		{
+			return '';
+		}
+		else
+		{
+			return $this->GetValueLabel($sValue);
+		}
 	}
 
 	public function GetAsHTMLForHistory($sOldValue, $sNewValue, $sLabel = null)