|
@@ -136,7 +136,85 @@ class ormCaseLog {
|
|
|
{
|
|
|
$this->m_bModified = false;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Produces an HTML representation, aimed at being used within an email
|
|
|
+ */
|
|
|
+ public function GetAsEmailHtml()
|
|
|
+ {
|
|
|
+ $sStyleCaseLogHeader = '';
|
|
|
+ $sStyleCaseLogEntry = '';
|
|
|
+
|
|
|
+ $sHtml = '<table style="width:100%;table-layout:fixed"><tr><td>'; // Use table-layout:fixed to force the with to be independent from the actual content
|
|
|
+ $iPos = 0;
|
|
|
+ $aIndex = $this->m_aIndex;
|
|
|
+ for($index=count($aIndex)-1 ; $index >= 0 ; $index--)
|
|
|
+ {
|
|
|
+ $iPos += $aIndex[$index]['separator_length'];
|
|
|
+ $sTextEntry = substr($this->m_sLog, $iPos, $aIndex[$index]['text_length']);
|
|
|
+ $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "<br/>", htmlentities($sTextEntry, ENT_QUOTES, 'UTF-8'));
|
|
|
+ $iPos += $aIndex[$index]['text_length'];
|
|
|
+
|
|
|
+ $sEntry = '<div class="caselog_header" style="'.$sStyleCaseLogHeader.'">';
|
|
|
+ // Workaround: PHP < 5.3 cannot unserialize correctly DateTime objects,
|
|
|
+ // therefore we have changed the format. To preserve the compatibility with existing
|
|
|
+ // installations of iTop, both format are allowed:
|
|
|
+ // the 'date' item is either a DateTime object, or a unix timestamp
|
|
|
+ if (is_int($aIndex[$index]['date']))
|
|
|
+ {
|
|
|
+ // Unix timestamp
|
|
|
+ $sDate = date(Dict::S('UI:CaseLog:DateFormat'),$aIndex[$index]['date']);
|
|
|
+ }
|
|
|
+ elseif (is_object($aIndex[$index]['date']))
|
|
|
+ {
|
|
|
+ if (version_compare(phpversion(), '5.3.0', '>='))
|
|
|
+ {
|
|
|
+ // DateTime
|
|
|
+ $sDate = $aIndex[$index]['date']->format(Dict::S('UI:CaseLog:DateFormat'));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // No Warning... but the date is unknown
|
|
|
+ $sDate = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $sEntry .= sprintf(Dict::S('UI:CaseLog:Header_Date_UserName'), '<span class="caselog_header_date">'.$sDate.'</span>', '<span class="caselog_header_user">'.$aIndex[$index]['user_name'].'</span>');
|
|
|
+ $sEntry .= '</div>';
|
|
|
+ $sEntry .= '<div class="caselog_entry" style="'.$sStyleCaseLogEntry.'">';
|
|
|
+ $sEntry .= $sTextEntry;
|
|
|
+ $sEntry .= '</div>';
|
|
|
+ $sHtml = $sHtml.$sEntry;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Process the case of an eventual remainder (quick migration of AttributeText fields)
|
|
|
+ if ($iPos < (strlen($this->m_sLog) - 1))
|
|
|
+ {
|
|
|
+ $sTextEntry = substr($this->m_sLog, $iPos);
|
|
|
+ $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "<br/>", htmlentities($sTextEntry, ENT_QUOTES, 'UTF-8'));
|
|
|
+
|
|
|
+ if (count($this->m_aIndex) == 0)
|
|
|
+ {
|
|
|
+ $sHtml .= '<div class="caselog_entry" style="'.$sStyleCaseLogEntry.'"">';
|
|
|
+ $sHtml .= $sTextEntry;
|
|
|
+ $sHtml .= '</div>';
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $sHtml .= '<div class="caselog_header" style="'.$sStyleCaseLogHeader.'">';
|
|
|
+ $sHtml .= Dict::S('UI:CaseLog:InitialValue');
|
|
|
+ $sHtml .= '</div>';
|
|
|
+ $sHtml .= '<div class="caselog_entry" style="'.$sStyleCaseLogEntry.'">';
|
|
|
+ $sHtml .= $sTextEntry;
|
|
|
+ $sHtml .= '</div>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $sHtml .= '</td></tr></table>';
|
|
|
+ return $sHtml;
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * Produces an HTML representation, aimed at being used within the iTop framework
|
|
|
+ */
|
|
|
public function GetAsHTML(WebPage $oP = null, $bEditMode = false, $aTransfoHandler = null)
|
|
|
{
|
|
|
$sHtml = '<table style="width:100%;table-layout:fixed"><tr><td>'; // Use table-layout:fixed to force the with to be independent from the actual content
|