Explorar o código

$this->head_html(log)$ and $this->head(log)$ now support both text and HTML case logs.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4136 a333f486-631f-4898-b8df-5754b55c2be0
dflaven %!s(int64=9) %!d(string=hai) anos
pai
achega
d498d135e8
Modificáronse 2 ficheiros con 30 adicións e 4 borrados
  1. 2 2
      core/attributedef.class.inc.php
  2. 28 2
      core/ormcaselog.class.inc.php

+ 2 - 2
core/attributedef.class.inc.php

@@ -2915,10 +2915,10 @@ class AttributeCaseLog extends AttributeLongText
 			return $value->GetText();
 			
 			case 'head':
-			return $value->GetLatestEntry();
+			return $value->GetLatestEntry('text');
 
 			case 'head_html':
-			return '<div class="caselog_entry">'.str_replace( array( "\r\n", "\n", "\r"), "<br/>", htmlentities($value->GetLatestEntry(), ENT_QUOTES, 'UTF-8')).'</div>';
+			return $value->GetLatestEntry('html');
 			
 			case 'html':
 			return $value->GetAsEmailHtml();

+ 28 - 2
core/ormcaselog.class.inc.php

@@ -651,12 +651,38 @@ class ormCaseLog {
 
 	/**
 	 * Get the latest entry from the log
+	 * @param string The expected output format text|html
 	 * @return string
 	 */
-	public function GetLatestEntry()
+	public function GetLatestEntry($sFormat = 'text')
 	{
+		$sRes = '';
 		$aLastEntry = end($this->m_aIndex);
-		$sRes = substr($this->m_sLog, $aLastEntry['separator_length'], $aLastEntry['text_length']);
+		$sRaw = substr($this->m_sLog, $aLastEntry['separator_length'], $aLastEntry['text_length']);
+		switch($sFormat)
+		{
+			case 'text':
+			if ($aLastEntry['format'] == 'text')
+			{
+				$sRes = $sRaw;
+			}
+			else
+			{
+				$sRes = utils::HtmlToText($sRaw);
+			}
+			break;
+			
+			case 'html':
+			if ($aLastEntry['format'] == 'text')
+			{
+				$sRes = utils::TextToHtml($sRaw);
+			}
+			else
+			{
+				$sRes = $sRaw;
+			}
+			break;
+		}
 		return $sRes;
 	}