Subject smart highlighter

This commit is contained in:
RainLoop Team 2014-07-17 18:35:48 +04:00
parent cf80b8f21b
commit fd9c0e25d8
9 changed files with 116 additions and 17 deletions

View file

@ -6937,6 +6937,54 @@ class Actions
return isset($aLang[$sKey]) ? $aLang[$sKey] : $sKey;
}
/**
* @param string $sSubject
*
* @return array
*/
private function explodeSubject($sSubject)
{
$aResult = array('', '');
if (0 < \strlen($sSubject))
{
$sDrop = false;
$aPrefix = array();
$aSuffix = array();
$aParts = \explode(':', $sSubject);
foreach ($aParts as $sPart)
{
if (!$sDrop &&
(\preg_match('/^(RE|FWD)$/i', \trim($sPart)) || \preg_match('/^(RE|FWD)[\[\(][\d]+[\]\)]$/i', \trim($sPart))))
{
$aPrefix[] = $sPart;
}
else
{
$aSuffix[] = $sPart;
$sDrop = true;
}
}
if (0 < \count($aPrefix))
{
$aResult[0] = \rtrim(\trim(\implode(':', $aPrefix)), ':').': ';
}
if (0 < \count($aSuffix))
{
$aResult[1] = \trim(\implode(':', $aSuffix));
}
if (0 === \strlen($aResult[1]))
{
$aResult = array('', $sSubject);
}
}
return $aResult;
}
/**
* @param mixed $mResponse
* @param string $sParent
@ -6985,6 +7033,8 @@ class Actions
'ReadReceipt' => ''
));
$mResult['SubjectParts'] = $this->explodeSubject($mResult['Subject']);
$oAttachments = $mResponse->Attachments();
$iAttachmentsCount = $oAttachments ? $oAttachments->Count() : 0;
@ -7020,8 +7070,6 @@ class Actions
'FileName' => (0 === \strlen($sSubject) ? 'message-'.$mResult['Uid'] : \MailSo\Base\Utils::ClearXss($sSubject)).'.eml'
));
// Flags
$aFlags = $mResponse->FlagsLowerCase();
$mResult['IsSeen'] = \in_array('\\seen', $aFlags);