本文整理汇总了PHP中Zend_Mime_Decode::splitHeaderField方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Mime_Decode::splitHeaderField方法的具体用法?PHP Zend_Mime_Decode::splitHeaderField怎么用?PHP Zend_Mime_Decode::splitHeaderField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Mime_Decode
的用法示例。
在下文中一共展示了Zend_Mime_Decode::splitHeaderField方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSplitHeaderFieldReturnsArrayWithFirstName
public function testSplitHeaderFieldReturnsArrayWithFirstName()
{
$boundary = "----=_Alternative_1211565553483705f1280701.15526894A";
$header = "Content-Type: multipart/alternative; " . "boundary=\"{$boundary}\"";
$split = Zend_Mime_Decode::splitHeaderField($header, null, 'content-type');
$this->assertEquals(2, count($split));
$this->assertTrue(isset($split['content-type']), "'content-type' element is set");
$this->assertEquals($boundary, $split['boundary']);
}
示例2: getHeaderField
/**
* Get a specific field from a header like content type or all fields as array
*
* If the header occurs more than once, only the value from the first header
* is returned.
*
* Throws a Zend_Mail_Exception if the requested header does not exist. If
* the specific header field does not exist, returns null.
*
* @param string $name name of header, like in getHeader()
* @param string $wantedPart the wanted part, default is first, if null an array with all parts is returned
* @param string $firstName key name for the first part
* @return string|array wanted part or all parts as array($firstName => firstPart, partname => value)
* @throws Zend_Exception, Zend_Mail_Exception
*/
public function getHeaderField($name, $wantedPart = 0, $firstName = 0)
{
return Zend_Mime_Decode::splitHeaderField(current($this->getHeader($name, 'array')), $wantedPart, $firstName);
}
示例3: _getMetaDataFromZMM
/**
* get meta data (like contentype, charset, ...) from zmm and set it in zmp
*
* @param Zend_Mail_Message $zmm
* @param Zend_Mime_Part $zmp
*/
protected static function _getMetaDataFromZMM(Zend_Mail_Message $zmm, Zend_Mime_Part $zmp)
{
if ($zmm->headerExists('content-transfer-encoding')) {
$zmp->encoding = $zmm->getHeader('content-transfer-encoding');
} else {
$zmp->encoding = Zend_Mime::ENCODING_7BIT;
}
if ($zmm->headerExists('content-type')) {
$contentTypeHeader = Zend_Mime_Decode::splitHeaderField($zmm->getHeader('content-type'));
$zmp->type = $contentTypeHeader[0];
if (isset($contentTypeHeader['boundary'])) {
$zmp->boundary = $contentTypeHeader['boundary'];
}
if (isset($contentTypeHeader['charset'])) {
$zmp->charset = $contentTypeHeader['charset'];
}
} else {
$zmp->type = Zend_Mime::TYPE_TEXT;
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Encoding: ' . $zmp->encoding . ' / type: ' . $zmp->type . ' / charset: ' . $zmp->charset);
}
}
示例4: testSplitInvalidHeader
public function testSplitInvalidHeader()
{
$header = '';
try {
Zend_Mime_Decode::splitHeaderField($header);
} catch (Zend_Exception $e) {
return;
// ok
}
$this->fail('no exception raised while decoding invalid header field');
}
示例5: testSpaceInFieldName
public function testSpaceInFieldName()
{
$header = 'test; foo =bar; baz =42';
$this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'foo'), 'bar');
$this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'baz'), 42);
}
示例6: testCaseInsensitiveField
public function testCaseInsensitiveField()
{
$header = 'test; fOO="this is a test"';
$this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'Foo'), 'this is a test');
$this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'bar'), null);
}
示例7: createFromZMM
/**
* create Tinebase_Mail from Zend_Mail_Message
*
* @param Zend_Mail_Message $_zmm
* @param string $_replyBody
* @return Tinebase_Mail
*/
public static function createFromZMM(Zend_Mail_Message $_zmm, $_replyBody = null)
{
$contentStream = fopen("php://temp", 'r+');
if (preg_match('/application\\/(x\\-){0,1}pkcs7-mime/i', $_zmm->getHeader('content-type')) > 0) {
$mp = new Zend_Mime_Part($_zmm->getContent());
} else {
fputs($contentStream, $_zmm->getContent());
rewind($contentStream);
$mp = new Zend_Mime_Part($contentStream);
}
if ($_zmm->headerExists('content-transfer-encoding')) {
$mp->encoding = $_zmm->getHeader('content-transfer-encoding');
$mp->decodeContent();
} else {
$mp->encoding = Zend_Mime::ENCODING_7BIT;
}
// append old body when no multipart/mixed
if ($_replyBody !== null && $_zmm->headerExists('content-transfer-encoding')) {
$mp = self::_appendReplyBody($mp, $_replyBody);
$mp->encoding = $_zmm->getHeader('content-transfer-encoding');
}
if ($_zmm->headerExists('content-type')) {
$contentTypeHeader = Zend_Mime_Decode::splitHeaderField($_zmm->getHeader('content-type'));
if ($mp->type = strtolower($contentTypeHeader[0]) === 'application/pkcs7-mime') {
$mp->type = $_zmm->getHeader('content-type');
} else {
$mp->type = $contentTypeHeader[0];
}
if (isset($contentTypeHeader['boundary'])) {
$mp->boundary = $contentTypeHeader['boundary'];
}
if (isset($contentTypeHeader['charset'])) {
$mp->charset = $contentTypeHeader['charset'];
}
} else {
$mp->type = Zend_Mime::TYPE_TEXT;
}
$result = new Expressomail_Mail('utf-8');
$result->setBodyText($mp);
foreach ($_zmm->getHeaders() as $header => $values) {
foreach ((array) $values as $value) {
switch ($header) {
case 'content-transfer-encoding':
// these are implicitly set by Zend_Mail_Transport_Abstract::_getHeaders()
// these are implicitly set by Zend_Mail_Transport_Abstract::_getHeaders()
case 'content-type':
case 'mime-version':
// do nothing
break;
case 'bcc':
$addresses = Expressomail_Message::parseAdresslist($value);
foreach ($addresses as $address) {
$result->addBcc($address['address'], $address['name']);
}
break;
case 'cc':
$addresses = Expressomail_Message::parseAdresslist($value);
foreach ($addresses as $address) {
$result->addCc($address['address'], $address['name']);
}
break;
case 'date':
try {
$result->setDate($value);
} catch (Zend_Mail_Exception $zme) {
if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . " Could not set date: " . $value);
}
if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . " " . $zme);
}
$result->setDate();
}
break;
case 'from':
$addresses = Expressomail_Message::parseAdresslist($value);
foreach ($addresses as $address) {
$result->setFrom($address['address'], $address['name']);
}
break;
case 'message-id':
$result->setMessageId($value);
break;
case 'return-path':
$result->setReturnPath($value);
break;
case 'subject':
$result->setSubject($value);
break;
case 'to':
$addresses = Expressomail_Message::parseAdresslist($value);
foreach ($addresses as $address) {
$result->addTo($address['address'], $address['name']);
//.........这里部分代码省略.........