本文整理匯總了PHP中MailSo\Base\Utils::IsRTL方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::IsRTL方法的具體用法?PHP Utils::IsRTL怎麽用?PHP Utils::IsRTL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::IsRTL方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: responseObject
/**
* @param \CAccount $oAccount
* @param mixed $mResponse
* @param string $sParent
* @param array $aParameters = array()
*
* @return mixed
*/
protected function responseObject($oAccount, $mResponse, $sParent, $aParameters = array())
{
$mResult = $mResponse;
if (is_object($mResponse)) {
$sClassName = get_class($mResponse);
if ('CApiMailMessage' === $sClassName) {
$iTrimmedLimit = \CApi::GetConf('labs.message-body-size-limit', 0);
$oAttachments = $mResponse->getAttachments();
$iInternalTimeStampInUTC = $mResponse->getInternalTimeStamp();
$iReceivedOrDateTimeStampInUTC = $mResponse->getReceivedOrDateTimeStamp();
$aFlags = $mResponse->getFlagsLowerCase();
$mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Folder' => $mResponse->getFolder(), 'Uid' => $mResponse->getUid(), 'Subject' => $mResponse->getSubject(), 'MessageId' => $mResponse->getMessageId(), 'Size' => $mResponse->getSize(), 'TextSize' => $mResponse->getTextSize(), 'InternalTimeStampInUTC' => $iInternalTimeStampInUTC, 'ReceivedOrDateTimeStampInUTC' => $iReceivedOrDateTimeStampInUTC, 'TimeStampInUTC' => \CApi::GetConf('labs.use-date-from-headers', false) && 0 < $iReceivedOrDateTimeStampInUTC ? $iReceivedOrDateTimeStampInUTC : $iInternalTimeStampInUTC, 'From' => $this->responseObject($oAccount, $mResponse->getFrom(), $sParent, $aParameters), 'To' => $this->responseObject($oAccount, $mResponse->getTo(), $sParent, $aParameters), 'Cc' => $this->responseObject($oAccount, $mResponse->getCc(), $sParent, $aParameters), 'Bcc' => $this->responseObject($oAccount, $mResponse->getBcc(), $sParent, $aParameters), 'Sender' => $this->responseObject($oAccount, $mResponse->getSender(), $sParent, $aParameters), 'ReplyTo' => $this->responseObject($oAccount, $mResponse->getReplyTo(), $sParent, $aParameters), 'IsSeen' => in_array('\\seen', $aFlags), 'IsFlagged' => in_array('\\flagged', $aFlags), 'IsAnswered' => in_array('\\answered', $aFlags), 'IsForwarded' => false, 'HasAttachments' => $oAttachments && $oAttachments->hasNotInlineAttachments(), 'HasVcardAttachment' => $oAttachments && $oAttachments->hasVcardAttachment(), 'HasIcalAttachment' => $oAttachments && $oAttachments->hasIcalAttachment(), 'Priority' => $mResponse->getPriority(), 'DraftInfo' => $mResponse->getDraftInfo(), 'Sensitivity' => $mResponse->getSensitivity()));
$mResult['TrimmedTextSize'] = $mResult['TextSize'];
if (0 < $iTrimmedLimit && $mResult['TrimmedTextSize'] > $iTrimmedLimit) {
$mResult['TrimmedTextSize'] = $iTrimmedLimit;
}
$sLowerForwarded = strtolower(\CApi::GetConf('webmail.forwarded-flag-name', ''));
if (!empty($sLowerForwarded)) {
$mResult['IsForwarded'] = in_array($sLowerForwarded, $aFlags);
}
$mResult['Hash'] = \CApi::EncodeKeyValues(array('AccountID' => $oAccount ? $oAccount->IdAccount : 0, 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeType' => 'message/rfc822', 'FileName' => $mResult['Subject'] . '.eml'));
if ('MessageGet' === $sParent || 'MessagesGetBodies' === $sParent) {
$mResult['Headers'] = \MailSo\Base\Utils::Utf8Clear($mResponse->getHeaders());
$mResult['InReplyTo'] = $mResponse->getInReplyTo();
$mResult['References'] = $mResponse->getReferences();
$mResult['ReadingConfirmation'] = $mResponse->getReadingConfirmation();
if (!empty($mResult['ReadingConfirmation']) && in_array('$readconfirm', $aFlags)) {
$mResult['ReadingConfirmation'] = '';
}
$bHasExternals = false;
$aFoundedCIDs = array();
$sPlain = '';
$sHtml = trim($mResponse->getHtml());
if (0 === strlen($sHtml)) {
$sPlain = $mResponse->getPlain();
}
$aContentLocationUrls = array();
$aFoundedContentLocationUrls = array();
if ($oAttachments && 0 < $oAttachments->Count()) {
$aList =& $oAttachments->GetAsArray();
foreach ($aList as $oAttachment) {
if ($oAttachment) {
$sContentLocation = $oAttachment->getContentLocation();
if ($sContentLocation && 0 < \strlen($sContentLocation)) {
$aContentLocationUrls[] = $oAttachment->getContentLocation();
}
}
}
}
$iTextSizeLimit = 500000;
if ($iTextSizeLimit < \strlen($sHtml)) {
$iSpacePost = \strpos($sHtml, ' ', $iTextSizeLimit);
$sHtml = \substr($sHtml, 0, false !== $iSpacePost && $iSpacePost > $iTextSizeLimit ? $iSpacePost : $iTextSizeLimit);
}
if ($iTextSizeLimit < \strlen($sPlain)) {
$iSpacePost = \strpos($sPlain, ' ', $iTextSizeLimit);
$sPlain = \substr($sPlain, 0, false !== $iSpacePost && $iSpacePost > $iTextSizeLimit ? $iSpacePost : $iTextSizeLimit);
}
if (0 < \strlen($sHtml) && \CApi::GetConf('labs.webmail.display-inline-css', false)) {
include_once PSEVEN_APP_ROOT_PATH . 'libraries/other/CssToInlineStyles.php';
$oCssToInlineStyles = new \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($sHtml);
$oCssToInlineStyles->setEncoding('utf-8');
$oCssToInlineStyles->setUseInlineStylesBlock(true);
$mResult['Html'] = \MailSo\Base\HtmlUtils::ClearHtml($oCssToInlineStyles->convert(), $bHasExternals, $aFoundedCIDs, $aContentLocationUrls, $aFoundedContentLocationUrls, false, true);
} else {
$mResult['Html'] = 0 === strlen($sHtml) ? '' : \MailSo\Base\HtmlUtils::ClearHtml($sHtml, $bHasExternals, $aFoundedCIDs, $aContentLocationUrls, $aFoundedContentLocationUrls, false, true);
}
$mResult['Trimmed'] = false;
$mResult['Plain'] = 0 === strlen($sPlain) ? '' : \MailSo\Base\HtmlUtils::ConvertPlainToHtml($sPlain);
$mResult['PlainRaw'] = \trim($sPlain);
$mResult['Rtl'] = 0 < \strlen($mResult['Plain']) ? \MailSo\Base\Utils::IsRTL($mResult['Plain']) : false;
if (0 < $iTrimmedLimit && 'Messages' === $sParent) {
if ($iTrimmedLimit < strlen($mResult['Plain'])) {
$iPos = strpos($mResult['Plain'], ' ', $iTrimmedLimit);
if (false !== $iPos && $iTrimmedLimit <= $iPos) {
$mResult['Plain'] = substr($mResult['Plain'], 0, $iPos);
$mResult['Trimmed'] = true;
}
}
if ($iTrimmedLimit < strlen($mResult['Html'])) {
$iPos = strpos($mResult['Html'], ' <', $iTrimmedLimit);
if (false !== $iPos && $iTrimmedLimit <= $iPos) {
$mResult['Html'] = substr($mResult['Html'], 0, $iPos) . '<!-- cutted -->';
$mResult['Trimmed'] = true;
}
}
}
$mResult['ICAL'] = $this->responseObject($oAccount, $mResponse->getExtend('ICAL'), $sParent, $aParameters);
$mResult['VCARD'] = $this->responseObject($oAccount, $mResponse->getExtend('VCARD'), $sParent, $aParameters);
$mResult['Safety'] = $mResponse->getSafety();
$mResult['HasExternals'] = $bHasExternals;
$mResult['FoundedCIDs'] = $aFoundedCIDs;
//.........這裏部分代碼省略.........
示例2: BuildHtml
/**
* @param string $sHtml
* @param array $aFoundCids = array()
* @param array|null $mFoundDataURL = null
* @param array $aFoundedContentLocationUrls = array()
*
* @return string
*/
public static function BuildHtml($sHtml, &$aFoundCids = array(), &$mFoundDataURL = null, &$aFoundedContentLocationUrls = array())
{
$bRtl = \MailSo\Base\Utils::IsRTL($sHtml);
$oDom = \MailSo\Base\HtmlUtils::GetDomFromText($sHtml);
unset($sHtml);
$aNodes = $oDom->getElementsByTagName('*');
foreach ($aNodes as $oElement) {
$sTagNameLower = \strtolower($oElement->tagName);
if ($oElement->hasAttribute('data-x-src-cid')) {
$sCid = $oElement->getAttribute('data-x-src-cid');
$oElement->removeAttribute('data-x-src-cid');
if (!empty($sCid)) {
$aFoundCids[] = $sCid;
@$oElement->removeAttribute('src');
$oElement->setAttribute('src', 'cid:' . $sCid);
}
}
if ($oElement->hasAttribute('data-x-src-location')) {
$sSrc = $oElement->getAttribute('data-x-src-location');
$oElement->removeAttribute('data-x-src-location');
if (!empty($sSrc)) {
$aFoundedContentLocationUrls[] = $sSrc;
@$oElement->removeAttribute('src');
$oElement->setAttribute('src', $sSrc);
}
}
if ($oElement->hasAttribute('data-x-broken-src')) {
$oElement->setAttribute('src', $oElement->getAttribute('data-x-broken-src'));
$oElement->removeAttribute('data-x-broken-src');
}
if ($oElement->hasAttribute('data-x-src')) {
$oElement->setAttribute('src', $oElement->getAttribute('data-x-src'));
$oElement->removeAttribute('data-x-src');
}
if ($oElement->hasAttribute('data-x-href')) {
$oElement->setAttribute('href', $oElement->getAttribute('data-x-href'));
$oElement->removeAttribute('data-x-href');
}
if ($oElement->hasAttribute('data-x-style-cid-name') && $oElement->hasAttribute('data-x-style-cid')) {
$sCidName = $oElement->getAttribute('data-x-style-cid-name');
$sCid = $oElement->getAttribute('data-x-style-cid');
$oElement->removeAttribute('data-x-style-cid-name');
$oElement->removeAttribute('data-x-style-cid');
if (!empty($sCidName) && !empty($sCid) && \in_array($sCidName, array('background-image', 'background', 'list-style-image', 'content'))) {
$sStyles = '';
if ($oElement->hasAttribute('style')) {
$sStyles = \trim(\trim($oElement->getAttribute('style')), ';');
}
$sBack = $sCidName . ': url(cid:' . $sCid . ')';
$sStyles = \preg_replace('/' . \preg_quote($sCidName, '/') . ':\\s?[^;]+/i', $sBack, $sStyles);
if (false === \strpos($sStyles, $sBack)) {
$sStyles .= empty($sStyles) ? '' : '; ';
$sStyles .= $sBack;
}
$oElement->setAttribute('style', $sStyles);
$aFoundCids[] = $sCid;
}
}
if ($oElement->hasAttribute('data-x-style-url')) {
$sAddStyles = $oElement->getAttribute('data-x-style-url');
$oElement->removeAttribute('data-x-style-url');
if (!empty($sAddStyles)) {
$sStyles = '';
if ($oElement->hasAttribute('style')) {
$sStyles = \trim(\trim($oElement->getAttribute('style')), ';');
}
$oElement->setAttribute('style', (empty($sStyles) ? '' : $sStyles . '; ') . $sAddStyles);
}
}
if ('img' === $sTagNameLower && \is_array($mFoundDataURL)) {
$sSrc = $oElement->getAttribute('src');
if ('data:image/' === \strtolower(\substr($sSrc, 0, 11))) {
$sHash = \md5($sSrc);
$mFoundDataURL[$sHash] = $sSrc;
$oElement->setAttribute('src', 'cid:' . $sHash);
}
}
}
$sResult = $oDom->saveHTML();
unset($oDom);
$sResult = \MailSo\Base\HtmlUtils::ClearTags($sResult);
$sResult = \MailSo\Base\HtmlUtils::ClearBodyAndHtmlTag($sResult);
return '<!DOCTYPE html><html' . ($bRtl ? ' dir="rtl"' : '') . '><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><head>' . '<body>' . \trim($sResult) . '</body></html>';
}