本文整理匯總了PHP中MailSo\Base\Utils::NormalizeContentType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::NormalizeContentType方法的具體用法?PHP Utils::NormalizeContentType怎麽用?PHP Utils::NormalizeContentType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::NormalizeContentType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: buildMessage
//.........這裏部分代碼省略.........
$sSensitivity = $this->getParamValue('Sensitivity', '');
// 0 1 2 3 4
$bReadingConfirmation = '1' === $this->getParamValue('ReadingConfirmation', '0');
$oMessage = \MailSo\Mime\Message::NewInstance();
$oMessage->RegenerateMessageId();
$sXMailer = \CApi::GetConf('webmail.xmailer-value', '');
if (0 < strlen($sXMailer)) {
$oMessage->SetXMailer($sXMailer);
}
if ($oIdentity) {
$oFrom = \MailSo\Mime\Email::NewInstance($oIdentity->Email, $oIdentity->FriendlyName);
} else {
$oFrom = $oFetcher ? \MailSo\Mime\Email::NewInstance($oFetcher->Email, $oFetcher->Name) : \MailSo\Mime\Email::NewInstance($oAccount->Email, $oAccount->FriendlyName);
}
$oMessage->SetFrom($oFrom)->SetSubject($sSubject);
$oToEmails = \MailSo\Mime\EmailCollection::NewInstance($sTo);
if ($oToEmails && $oToEmails->Count()) {
$oMessage->SetTo($oToEmails);
}
$oCcEmails = \MailSo\Mime\EmailCollection::NewInstance($sCc);
if ($oCcEmails && $oCcEmails->Count()) {
$oMessage->SetCc($oCcEmails);
}
$oBccEmails = \MailSo\Mime\EmailCollection::NewInstance($sBcc);
if ($oBccEmails && $oBccEmails->Count()) {
$oMessage->SetBcc($oBccEmails);
}
if ($bWithDraftInfo && is_array($aDraftInfo) && !empty($aDraftInfo[0]) && !empty($aDraftInfo[1]) && !empty($aDraftInfo[2])) {
$oMessage->SetDraftInfo($aDraftInfo[0], $aDraftInfo[1], $aDraftInfo[2]);
}
if (0 < strlen($sInReplyTo)) {
$oMessage->SetInReplyTo($sInReplyTo);
}
if (0 < strlen($sReferences)) {
$oMessage->SetReferences($sReferences);
}
if (0 < strlen($sImportance) && in_array((int) $sImportance, array(\MailSo\Mime\Enumerations\MessagePriority::HIGH, \MailSo\Mime\Enumerations\MessagePriority::NORMAL, \MailSo\Mime\Enumerations\MessagePriority::LOW))) {
$oMessage->SetPriority((int) $sImportance);
}
if (0 < strlen($sSensitivity) && in_array((int) $sSensitivity, array(\MailSo\Mime\Enumerations\Sensitivity::NOTHING, \MailSo\Mime\Enumerations\Sensitivity::CONFIDENTIAL, \MailSo\Mime\Enumerations\Sensitivity::PRIVATE_, \MailSo\Mime\Enumerations\Sensitivity::PERSONAL))) {
$oMessage->SetSensitivity((int) $sSensitivity);
}
if ($bReadingConfirmation) {
$oMessage->SetReadConfirmation($oFetcher ? $oFetcher->Email : $oAccount->Email);
}
$aFoundCids = array();
\CApi::Plugin()->RunHook('webmail.message-text-html-raw', array($oAccount, &$oMessage, &$sText, &$bTextIsHtml));
if ($bTextIsHtml) {
$sTextConverted = \MailSo\Base\HtmlUtils::ConvertHtmlToPlain($sText);
\CApi::Plugin()->RunHook('webmail.message-plain-part', array($oAccount, &$oMessage, &$sTextConverted));
$oMessage->AddText($sTextConverted, false);
}
$mFoundDataURL = array();
$aFoundedContentLocationUrls = array();
$sTextConverted = $bTextIsHtml ? \MailSo\Base\HtmlUtils::BuildHtml($sText, $aFoundCids, $mFoundDataURL, $aFoundedContentLocationUrls) : $sText;
\CApi::Plugin()->RunHook($bTextIsHtml ? 'webmail.message-html-part' : 'webmail.message-plain-part', array($oAccount, &$oMessage, &$sTextConverted));
$oMessage->AddText($sTextConverted, $bTextIsHtml);
if (is_array($aAttachments)) {
foreach ($aAttachments as $sTempName => $aData) {
if (is_array($aData) && isset($aData[0], $aData[1], $aData[2], $aData[3])) {
$sFileName = (string) $aData[0];
$sCID = (string) $aData[1];
$bIsInline = '1' === (string) $aData[2];
$bIsLinked = '1' === (string) $aData[3];
$sContentLocation = isset($aData[4]) ? (string) $aData[4] : '';
$rResource = $this->ApiFileCache()->getFile($oAccount, $sTempName);
if (is_resource($rResource)) {
$iFileSize = $this->ApiFileCache()->fileSize($oAccount, $sTempName);
$sCID = trim(trim($sCID), '<>');
$bIsFounded = 0 < strlen($sCID) ? in_array($sCID, $aFoundCids) : false;
if (!$bIsLinked || $bIsFounded) {
$oMessage->Attachments()->Add(\MailSo\Mime\Attachment::NewInstance($rResource, $sFileName, $iFileSize, $bIsInline, $bIsLinked, $bIsLinked ? '<' . $sCID . '>' : '', array(), $sContentLocation));
}
}
}
}
}
if ($mFoundDataURL && \is_array($mFoundDataURL) && 0 < \count($mFoundDataURL)) {
foreach ($mFoundDataURL as $sCidHash => $sDataUrlString) {
$aMatch = array();
$sCID = '<' . $sCidHash . '>';
if (\preg_match('/^data:(image\\/[a-zA-Z0-9]+\\+?[a-zA-Z0-9]+);base64,(.+)$/i', $sDataUrlString, $aMatch) && !empty($aMatch[1]) && !empty($aMatch[2])) {
$sRaw = \MailSo\Base\Utils::Base64Decode($aMatch[2]);
$iFileSize = \strlen($sRaw);
if (0 < $iFileSize) {
$sFileName = \preg_replace('/[^a-z0-9]+/i', '.', \MailSo\Base\Utils::NormalizeContentType($aMatch[1]));
// fix bug #68532 php < 5.5.21 or php < 5.6.5
$sRaw = $this->FixBase64EncodeOmitsPaddingBytes($sRaw);
$rResource = \MailSo\Base\ResourceRegistry::CreateMemoryResourceFromString($sRaw);
$sRaw = '';
unset($sRaw);
unset($aMatch);
$oMessage->Attachments()->Add(\MailSo\Mime\Attachment::NewInstance($rResource, $sFileName, $iFileSize, true, true, $sCID));
}
}
}
}
\CApi::Plugin()->RunHook('webmail.build-message', array(&$oMessage));
return $oMessage;
}