m_sLog = $sLog;
$this->m_aIndex = $aIndex;
}
public function GetText()
{
return $this->m_sLog;
}
public function GetIndex()
{
return $this->m_aIndex;
}
public function GetAsHTML(WebPage $oP = null, $bEditMode = false)
{
$sHtml = '';
$iPos = strlen($this->m_sLog);
for($index=0; $index < count($this->m_aIndex); $index++)
{
if ($index < count($this->m_aIndex) - CASELOG_VISIBLE_ITEMS)
{
$sOpen = '';
$sDisplay = 'style="display:none;"';
}
else
{
$sOpen = ' open';
$sDisplay = '';
}
$iStart = $iPos - $this->m_aIndex[$index]['text_length'];
$sTextEntry = substr($this->m_sLog, $iStart, $this->m_aIndex[$index]['text_length']);
$iPos = $iStart - $this->m_aIndex[$index]['separator_length'];
$sEntry = '
';
$sEntry .= '';
$sEntry .= str_replace("\n", "
", htmlentities($sTextEntry, ENT_QUOTES, 'UTF-8'));
$sEntry .= '
';
$sHtml = $sEntry . $sHtml;
}
$sHtml = ''.$sHtml.'
';
return $sHtml;
}
/**
* Add a new entry to the log and updates the internal index
* @param $sText string The text of the new entry
*/
public function AddLogEntry($sText)
{
$sDate = date(CASELOG_DATE_FORMAT);
$sSeparator = sprintf(CASELOG_SEPARATOR, $sDate, UserRights::GetUserFriendlyName(), UserRights::GetUserId());
$iSepLength = strlen($sSeparator);
$iTextlength = strlen($sText);
$this->m_sLog = $sSeparator.$sText.$this->m_sLog; // Latest entry printed first
$this->m_aIndex[] = array(
'user_name' => UserRights::GetUserFriendlyName(),
'user_id' => UserRights::GetUserId(),
'date' => new DateTime(),
'text_length' => $iTextlength,
'separator_length' => $iSepLength,
);
}
}
?>