mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 14:37:02 +03:00
Subject smart highlighter
This commit is contained in:
parent
cf80b8f21b
commit
fd9c0e25d8
9 changed files with 116 additions and 17 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue