本文整理匯總了PHP中MailSo\Base\Utils::DecodeEncodingValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::DecodeEncodingValue方法的具體用法?PHP Utils::DecodeEncodingValue怎麽用?PHP Utils::DecodeEncodingValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::DecodeEncodingValue方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: InitByFetchResponse
//.........這裏部分代碼省略.........
if (0 < \strlen($sType) && 0 < \strlen($sFolder) && 0 < \strlen($sUid)) {
$this->aDraftInfo = array($sType, $sUid, $sFolder);
}
}
} else {
if ($oFetchResponse->GetEnvelope()) {
if (0 === \strlen($sCharset) && $oBodyStructure) {
$sCharset = $oBodyStructure->SearchCharset();
$sCharset = \MailSo\Base\Utils::NormalizeCharset($sCharset);
}
if (0 === \strlen($sCharset)) {
$sCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1;
}
// date, subject, from, sender, reply-to, to, cc, bcc, in-reply-to, message-id
$this->sMessageId = $oFetchResponse->GetFetchEnvelopeValue(9, '');
$this->sSubject = \MailSo\Base\Utils::DecodeHeaderValue($oFetchResponse->GetFetchEnvelopeValue(1, ''), $sCharset);
$this->oFrom = $oFetchResponse->GetFetchEnvelopeEmailCollection(2, $sCharset);
$this->oSender = $oFetchResponse->GetFetchEnvelopeEmailCollection(3, $sCharset);
$this->oReplyTo = $oFetchResponse->GetFetchEnvelopeEmailCollection(4, $sCharset);
$this->oTo = $oFetchResponse->GetFetchEnvelopeEmailCollection(5, $sCharset);
$this->oCc = $oFetchResponse->GetFetchEnvelopeEmailCollection(6, $sCharset);
$this->oBcc = $oFetchResponse->GetFetchEnvelopeEmailCollection(7, $sCharset);
$this->sInReplyTo = $oFetchResponse->GetFetchEnvelopeValue(8, '');
}
}
$aTextParts = $oBodyStructure ? $oBodyStructure->SearchHtmlOrPlainParts() : null;
if (\is_array($aTextParts) && 0 < \count($aTextParts)) {
if (0 === \strlen($sCharset)) {
$sCharset = \MailSo\Base\Enumerations\Charset::UTF_8;
}
$sHtmlParts = array();
$sPlainParts = array();
foreach ($aTextParts as $oPart) {
$sText = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::BODY . '[' . $oPart->PartID() . ']');
if (null === $sText) {
$sText = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::BODY . '[' . $oPart->PartID() . ']<0>');
if (\is_string($sText) && 0 < \strlen($sText)) {
$this->bTextPartIsTrimmed = true;
}
}
if (\is_string($sText) && 0 < \strlen($sText)) {
$sTextCharset = $oPart->Charset();
if (empty($sTextCharset)) {
$sTextCharset = $sCharset;
}
$sTextCharset = \MailSo\Base\Utils::NormalizeCharset($sTextCharset, true);
$sText = \MailSo\Base\Utils::DecodeEncodingValue($sText, $oPart->MailEncodingName());
$sText = \MailSo\Base\Utils::ConvertEncoding($sText, $sTextCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
$sText = \MailSo\Base\Utils::Utf8Clear($sText);
if ('text/html' === $oPart->ContentType()) {
$sHtmlParts[] = $sText;
} else {
$sPlainParts[] = $sText;
}
}
}
if (0 < \count($sHtmlParts)) {
$this->sHtml = \implode('<br />', $sHtmlParts);
} else {
$this->sPlain = \trim(\implode("\n", $sPlainParts));
}
$aMatch = array();
if (\preg_match('/-----BEGIN PGP SIGNATURE-----(.+)-----END PGP SIGNATURE-----/ism', $this->sPlain, $aMatch) && !empty($aMatch[0])) {
$this->sPgpSignature = \trim($aMatch[0]);
$this->bPgpSigned = true;
}
$aMatch = array();
if (\preg_match('/-----BEGIN PGP MESSAGE-----/ism', $this->sPlain, $aMatch) && !empty($aMatch[0])) {
$this->bPgpEncrypted = true;
}
unset($sHtmlParts, $sPlainParts, $aMatch);
}
// if (empty($this->sPgpSignature) && 'multipart/signed' === \strtolower($this->sContentType) &&
// 'application/pgp-signature' === \strtolower($oHeaders->ParameterValue(
// \MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
// \MailSo\Mime\Enumerations\Parameter::PROTOCOL
// )))
// {
// $aPgpSignatureParts = $oBodyStructure ? $oBodyStructure->SearchByContentType('application/pgp-signature') : null;
// if (\is_array($aPgpSignatureParts) && 0 < \count($aPgpSignatureParts) && isset($aPgpSignatureParts[0]))
// {
// $sPgpSignatureText = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::BODY.'['.$aPgpSignatureParts[0]->PartID().']');
// if (\is_string($sPgpSignatureText) && 0 < \strlen($sPgpSignatureText) && 0 < \strpos($sPgpSignatureText, 'BEGIN PGP SIGNATURE'))
// {
// $this->sPgpSignature = \trim($sPgpSignatureText);
// $this->bPgpSigned = true;
// }
// }
// }
if ($oBodyStructure) {
$aAttachmentsParts = $oBodyStructure->SearchAttachmentsParts();
if ($aAttachmentsParts && 0 < count($aAttachmentsParts)) {
$this->oAttachments = AttachmentCollection::NewInstance();
foreach ($aAttachmentsParts as $oAttachmentItem) {
$this->oAttachments->Add(\MailSo\Mail\Attachment::NewBodyStructureInstance($this->sFolder, $this->iUid, $oAttachmentItem));
}
}
}
return $this;
}
示例2: InitByFetchResponse
/**
* @param string $sRawFolderFullName
* @param \MailSo\Imap\FetchResponse $oFetchResponse
* @param \MailSo\Imap\BodyStructure $oBodyStructure = null
* @param array $aAscPartsIds = array()
*
* @return CApiMailMessage
*/
public function InitByFetchResponse($sRawFolderFullName, $oFetchResponse, $oBodyStructure = null, $sRfc822SubMimeIndex = '', $aAscPartsIds = array())
{
if (!$oBodyStructure) {
$oBodyStructure = $oFetchResponse->GetFetchBodyStructure();
}
$aTextParts = $oBodyStructure ? $oBodyStructure->SearchHtmlOrPlainParts() : array();
$aICalPart = $oBodyStructure ? $oBodyStructure->SearchByContentType('text/calendar') : null;
$oICalPart = is_array($aICalPart) && 0 < count($aICalPart) ? $aICalPart[0] : null;
$aVCardPart = $oBodyStructure ? $oBodyStructure->SearchByContentType('text/vcard') : null;
$aVCardPart = $aVCardPart ? $aVCardPart : ($oBodyStructure ? $oBodyStructure->SearchByContentType('text/x-vcard') : null);
$oVCardPart = is_array($aVCardPart) && 0 < count($aVCardPart) ? $aVCardPart[0] : null;
$sUid = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
$sSize = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::RFC822_SIZE);
$sInternalDate = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::INTERNALDATE);
$aFlags = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::FLAGS);
$this->sFolder = $sRawFolderFullName;
$this->iUid = is_numeric($sUid) ? (int) $sUid : 0;
$this->iSize = is_numeric($sSize) ? (int) $sSize : 0;
$this->iTextSize = 0;
$this->aFlags = is_array($aFlags) ? $aFlags : array();
$this->aFlagsLowerCase = array_map('strtolower', $this->aFlags);
$this->iInternalTimeStampInUTC = \MailSo\Base\DateTimeHelper::ParseInternalDateString($sInternalDate);
if ($oICalPart) {
$sICal = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::BODY . '[' . $oICalPart->PartID() . ']');
if (!empty($sICal)) {
$sICal = \MailSo\Base\Utils::DecodeEncodingValue($sICal, $oICalPart->MailEncodingName());
$sICal = \MailSo\Base\Utils::ConvertEncoding($sICal, \MailSo\Base\Utils::NormalizeCharset($oICalPart->Charset(), true), \MailSo\Base\Enumerations\Charset::UTF_8);
if (!empty($sICal) && false !== strpos($sICal, 'BEGIN:VCALENDAR')) {
$sICal = preg_replace('/(.*)(BEGIN[:]VCALENDAR(.+)END[:]VCALENDAR)(.*)/ms', '$2', $sICal);
} else {
$sICal = '';
}
if (!empty($sICal)) {
$this->AddExtend('ICAL_RAW', $sICal);
}
}
}
if ($oVCardPart) {
$sVCard = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::BODY . '[' . $oVCardPart->PartID() . ']');
if (!empty($sVCard)) {
$sVCard = \MailSo\Base\Utils::DecodeEncodingValue($sVCard, $oVCardPart->MailEncodingName());
$sVCard = \MailSo\Base\Utils::ConvertEncoding($sVCard, \MailSo\Base\Utils::NormalizeCharset($oVCardPart->Charset(), true), \MailSo\Base\Enumerations\Charset::UTF_8);
if (!empty($sVCard) && false !== strpos($sVCard, 'BEGIN:VCARD')) {
$sVCard = preg_replace('/(.*)(BEGIN\\:VCARD(.+)END\\:VCARD)(.*)/ms', '$2', $sVCard);
} else {
$sVCard = '';
}
if (!empty($sVCard)) {
$this->AddExtend('VCARD_RAW', $sVCard);
}
}
}
$sCharset = $oBodyStructure ? $oBodyStructure->SearchCharset() : '';
$sCharset = \MailSo\Base\Utils::NormalizeCharset($sCharset);
$this->sHeaders = trim($oFetchResponse->GetHeaderFieldsValue($sRfc822SubMimeIndex));
if (!empty($this->sHeaders)) {
$oHeaders = \MailSo\Mime\HeaderCollection::NewInstance()->Parse($this->sHeaders, false, $sCharset);
$sContentTypeCharset = $oHeaders->ParameterValue(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE, \MailSo\Mime\Enumerations\Parameter::CHARSET);
if (!empty($sContentTypeCharset)) {
$sCharset = $sContentTypeCharset;
$sCharset = \MailSo\Base\Utils::NormalizeCharset($sCharset);
}
if (!empty($sCharset)) {
$oHeaders->SetParentCharset($sCharset);
}
$bCharsetAutoDetect = 0 === \strlen($sCharset);
$this->sSubject = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::SUBJECT, $bCharsetAutoDetect);
$this->sMessageId = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::MESSAGE_ID);
$this->sContentType = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE);
$aReceived = $oHeaders->ValuesByName(\MailSo\Mime\Enumerations\Header::RECEIVED);
$sReceived = !empty($aReceived[0]) ? trim($aReceived[0]) : '';
$sDate = '';
if (!empty($sReceived)) {
$aParts = explode(';', $sReceived);
if (0 < count($aParts)) {
$aParts = array_reverse($aParts);
foreach ($aParts as $sReceiveLine) {
$sReceiveLine = trim($sReceiveLine);
if (preg_match('/[\\d]{4} [\\d]{2}:[\\d]{2}:[\\d]{2} /', $sReceiveLine)) {
$sDate = $sReceiveLine;
break;
}
}
}
}
if (empty($sDate)) {
$sDate = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::DATE);
}
if (!empty($sDate)) {
$this->iReceivedOrDateTimeStampInUTC = \MailSo\Base\DateTimeHelper::ParseRFC2822DateString($sDate);
}
$this->oFrom = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::FROM_, $bCharsetAutoDetect);
//.........這裏部分代碼省略.........