当前位置: 首页>>代码示例>>PHP>>正文


PHP Horde_Mime_Part::getContentTypeParameter方法代码示例

本文整理汇总了PHP中Horde_Mime_Part::getContentTypeParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Part::getContentTypeParameter方法的具体用法?PHP Horde_Mime_Part::getContentTypeParameter怎么用?PHP Horde_Mime_Part::getContentTypeParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Horde_Mime_Part的用法示例。


在下文中一共展示了Horde_Mime_Part::getContentTypeParameter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor.
  *
  * @param Horde_Mime_Part $mime_part  A MIME part object. Must be of
  *                                    type multipart/related.
  */
 public function __construct(Horde_Mime_Part $mime_part)
 {
     if ($mime_part->getType() != 'multipart/related') {
         throw new InvalidArgumentException('MIME part must be of type multipart/related');
     }
     $ids = array_keys($mime_part->contentTypeMap());
     $related_id = $mime_part->getMimeId();
     $id = null;
     /* Build a list of parts -> CIDs. */
     foreach ($ids as $val) {
         if (strcmp($related_id, $val) !== 0 && ($cid = $mime_part->getPart($val)->getContentId())) {
             $this->_cids[$val] = $cid;
         }
     }
     /* Look at the 'start' parameter to determine which part to start
      * with. If no 'start' parameter, use the first part (RFC 2387
      * [3.1]). */
     $start = $mime_part->getContentTypeParameter('start');
     if (!empty($start)) {
         $id = $this->cidSearch($start);
     }
     if (empty($id)) {
         reset($ids);
         $id = next($ids);
     }
     $this->_start = $id;
 }
开发者ID:netcon-source,项目名称:apps,代码行数:33,代码来源:Related.php

示例2: _msgBody

 /**
  * Return the body text of the original email from a smart request.
  *
  * @param array $body_data       The body data array of the source msg.
  * @param Horde_Mime_Part $part  The body mime part of the email to send.
  * @param boolean $html          Do we want an html body?
  * @param boolean $flow          Should the body be flowed?
  *
  * @return string  The properly formatted/flowed message body.
  */
 protected function _msgBody(array $body_data, Horde_Mime_Part $part, $html, $flow = false)
 {
     $subtype = $html == true ? 'html' : 'plain';
     $msg = Horde_String::convertCharset($body_data[$subtype]['body'], $body_data[$subtype]['charset'], 'UTF-8');
     trim($msg);
     if (!$html) {
         if ($part->getContentTypeParameter('format') == 'flowed') {
             $flowed = new Horde_Text_Flowed($msg, 'UTF-8');
             if (Horde_String::lower($part->getContentTypeParameter('delsp')) == 'yes') {
                 $flowed->setDelSp(true);
             }
             $flowed->setMaxLength(0);
             $msg = $flowed->toFixed(false);
         } else {
             // If not flowed, remove padding at eol
             $msg = preg_replace("/\\s*\n/U", "\n", $msg);
         }
         if ($flow) {
             $flowed = new Horde_Text_Flowed($msg, 'UTF-8');
             $msg = $flowed->toFlowed(true);
         }
     }
     return $msg;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:34,代码来源:Mail.php

示例3: _getStructure

 /**
  * Creates a MIME object from the text of one part of a MIME message.
  *
  * @param string $header  The header text.
  * @param string $body    The body text.
  * @param array $opts     Additional options:
  * <pre>
  *   - ctype: (string) The default content-type.
  *   - forcemime: (boolean) If true, the message data is assumed to be
  *                MIME data. If not, a MIME-Version header must exist to
  *                be parsed as a MIME message.
  *   - level: (integer) Current nesting level.
  *   - no_body: (boolean) If true, don't set body contents of parts.
  * </pre>
  *
  * @return Horde_Mime_Part  The MIME part object.
  */
 protected static function _getStructure($header, $body, array $opts = array())
 {
     $opts = array_merge(array('ctype' => 'text/plain', 'forcemime' => false, 'level' => 0, 'no_body' => false), $opts);
     /* Parse headers text into a Horde_Mime_Headers object. */
     $hdrs = Horde_Mime_Headers::parseHeaders($header);
     $ob = new Horde_Mime_Part();
     /* This is not a MIME message. */
     if (!$opts['forcemime'] && !isset($hdrs['MIME-Version'])) {
         $ob->setType('text/plain');
         if ($len = strlen($body)) {
             if ($opts['no_body']) {
                 $ob->setBytes($len);
             } else {
                 $ob->setContents($body);
             }
         }
         return $ob;
     }
     /* Content type. */
     if ($tmp = $hdrs['Content-Type']) {
         $ob->setType($tmp->value);
         foreach ($tmp->params as $key => $val) {
             $ob->setContentTypeParameter($key, $val);
         }
     } else {
         $ob->setType($opts['ctype']);
     }
     /* Content transfer encoding. */
     if ($tmp = $hdrs['Content-Transfer-Encoding']) {
         $ob->setTransferEncoding(strval($tmp));
     }
     /* Content-Description. */
     if ($tmp = $hdrs['Content-Description']) {
         $ob->setDescription(strval($tmp));
     }
     /* Content-Disposition. */
     if ($tmp = $hdrs['Content-Disposition']) {
         $ob->setDisposition($tmp->value);
         foreach ($tmp->params as $key => $val) {
             $ob->setDispositionParameter($key, $val);
         }
     }
     /* Content-Duration */
     if ($tmp = $hdrs['Content-Duration']) {
         $ob->setDuration(strval($tmp));
     }
     /* Content-ID. */
     if ($tmp = $hdrs['Content-Id']) {
         $ob->setContentId(strval($tmp));
     }
     if (($len = strlen($body)) && $ob->getPrimaryType() != 'multipart') {
         if ($opts['no_body']) {
             $ob->setBytes($len);
         } else {
             $ob->setContents($body);
         }
     }
     if (++$opts['level'] >= self::NESTING_LIMIT) {
         return $ob;
     }
     /* Process subparts. */
     switch ($ob->getPrimaryType()) {
         case 'message':
             if ($ob->getSubType() == 'rfc822') {
                 $ob[] = self::parseMessage($body, array('forcemime' => true, 'no_body' => $opts['no_body']));
             }
             break;
         case 'multipart':
             $boundary = $ob->getContentTypeParameter('boundary');
             if (!is_null($boundary)) {
                 foreach (self::_findBoundary($body, 0, $boundary) as $val) {
                     if (!isset($val['length'])) {
                         break;
                     }
                     $subpart = substr($body, $val['start'], $val['length']);
                     $hdr_pos = self::_findHeader($subpart, self::EOL);
                     $ob[] = self::_getStructure(substr($subpart, 0, $hdr_pos), substr($subpart, $hdr_pos + 2), array('ctype' => $ob->getSubType() == 'digest' ? 'message/rfc822' : 'text/plain', 'forcemime' => true, 'level' => $opts['level'], 'no_body' => $opts['no_body']));
                 }
             }
             break;
     }
     return $ob;
 }
开发者ID:x59,项目名称:horde-mime,代码行数:100,代码来源:Part.php

示例4: testNullCharactersNotAllowedInMimeHeaderData

 public function testNullCharactersNotAllowedInMimeHeaderData()
 {
     $part = new Horde_Mime_Part();
     $part->setType("text/plain");
     $this->assertEquals('text/plain', $part->getType());
     $part->setDisposition("inline");
     $this->assertEquals('inline', $part->getDisposition());
     $part->setDispositionParameter('size', '123' . "" . '456');
     $this->assertEquals(123456, $part->getDispositionParameter('size'));
     $part->setDispositionParameter('foo', "foobar");
     $this->assertEquals('foobar', $part->getDispositionParameter('foo'));
     $part->setCharset("utf-8");
     $this->assertEquals('utf-8', $part->getCharset());
     $part->setName("foobar");
     $this->assertEquals('foobar', $part->getName());
     $this->assertEquals('foobar', $part->getDispositionParameter('filename'));
     $this->assertEquals('foobar', $part->getContentTypeParameter('name'));
     $part->setLanguage("en");
     $this->assertEquals(array('en'), $part->getLanguage());
     $part->setLanguage(array("en", "de"));
     $this->assertEquals(array('en', 'de'), $part->getLanguage());
     $part->setDuration('123' . "" . '456');
     $this->assertEquals(123456, $part->getDuration());
     $part->setBytes('123' . "" . '456');
     $this->assertEquals(123456, $part->getBytes());
     $part->setDescription("foobar");
     $this->assertEquals('foobar', $part->getDescription());
     $part->setContentTypeParameter('foo', "foobar");
     $this->assertEquals('foobar', $part->getContentTypeParameter('foo'));
     $part->setContentId("foobar");
     $this->assertEquals('foobar', $part->getContentId());
 }
开发者ID:x59,项目名称:horde-mime,代码行数:32,代码来源:PartTest.php

示例5: _getSmimeType

 /**
  * Determines the S/MIME type of a part. Uses the smime-type content
  * parameter (if it exists), and falls back to ASN.1 parsing of data if
  * it doesn't exist.
  *
  * @param Horde_Mime_Part $part  MIME part with S/MIME data.
  *
  * @return string  'signed-data', 'enveloped-data', or null.
  */
 protected function _getSmimeType(Horde_Mime_Part $part)
 {
     if ($type = $part->getContentTypeParameter('smime-type')) {
         return strtolower($type);
     }
     if (!class_exists('File_ASN1')) {
         return null;
     }
     $asn1 = new File_ASN1();
     $decoded = $asn1->decodeBER($part->getContents());
     foreach ($decoded as $val) {
         if ($val['type'] == FILE_ASN1_TYPE_SEQUENCE) {
             foreach ($val['content'] as $val2) {
                 if ($val2['type'] == FILE_ASN1_TYPE_OBJECT_IDENTIFIER) {
                     /* ASN.1 values from STD 70/RFC 5652 - CMS syntax */
                     switch ($val2['content']) {
                         case '1.2.840.113549.1.7.2':
                             return 'signed-data';
                         case '1.2.840.113549.1.7.3':
                             return 'enveloped-data';
                         default:
                             // Other types not supported as of now.
                             return null;
                     }
                 }
             }
         }
     }
     return null;
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:39,代码来源:Smime.php

示例6: _msgBody

 /**
  * Return the body text of the original email from a smart request.
  *
  * @param array $body_data       The body data array of the source msg.
  * @param Horde_Mime_Part $part  The body mime part of the email to send.
  * @param boolean $html          Do we want an html body?
  * @param boolean $flow          Should the body be flowed?
  *
  * @return string  The properly formatted/flowed message body.
  */
 protected function _msgBody(array $body_data, Horde_Mime_Part $part, $html, $flow = false)
 {
     $subtype = $html == true ? 'html' : 'plain';
     $msg = Horde_String::convertCharset((string) $body_data[$subtype]['body'], $body_data[$subtype]['charset'], 'UTF-8');
     if (!$html) {
         if ($part->getContentTypeParameter('format') == 'flowed') {
             $flowed = new Horde_Text_Flowed($msg, 'UTF-8');
             if (Horde_String::lower($part->getContentTypeParameter('delsp')) == 'yes') {
                 $flowed->setDelSp(true);
             }
             $flowed->setMaxLength(0);
             $msg = $flowed->toFixed(false);
         } else {
             // If not flowed, remove padding at eol
             $msg = preg_replace("/\\s*\n/U", "\n", $msg);
         }
         if ($flow) {
             $flowed = new Horde_Text_Flowed($msg, 'UTF-8');
             $msg = $flowed->toFlowed(true);
         }
     } else {
         // This filter requires the tidy extenstion.
         if (Horde_Util::extensionExists('tidy')) {
             return Horde_Text_Filter::filter($msg, 'Cleanhtml', array('body_only' => true));
         } else {
             // If no tidy, use Horde_Dom.
             $dom = new Horde_Domhtml($msg, 'UTF-8');
             return $dom->returnBody();
         }
     }
     return $msg;
 }
开发者ID:horde,项目名称:horde,代码行数:42,代码来源:Mail.php


注:本文中的Horde_Mime_Part::getContentTypeParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。