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


PHP Horde_Mime_Part::setDescription方法代码示例

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


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

示例1: _getEmbeddedMimeParts

 /**
  * If this MIME part can contain embedded MIME part(s), and those part(s)
  * exist, return a representation of that data.
  *
  * @return mixed  A Horde_Mime_Part object representing the embedded data.
  *                Returns null if no embedded MIME part(s) exist.
  */
 protected function _getEmbeddedMimeParts()
 {
     /* Get the data from the attachment. */
     try {
         if (!($tnef = $this->getConfigParam('tnef'))) {
             $tnef = Horde_Compress::factory('Tnef');
             $this->setConfigParam('tnef', $tnef);
         }
         $tnefData = $tnef->decompress($this->_mimepart->getContents());
     } catch (Horde_Compress_Exception $e) {
         $tnefData = array();
     }
     if (!count($tnefData)) {
         return null;
     }
     $mixed = new Horde_Mime_Part();
     $mixed->setType('multipart/mixed');
     reset($tnefData);
     while (list(, $data) = each($tnefData)) {
         $temp_part = new Horde_Mime_Part();
         $temp_part->setName($data['name']);
         $temp_part->setDescription($data['name']);
         $temp_part->setContents($data['stream']);
         /* Short-circuit MIME-type guessing for winmail.dat parts;
          * we're showing enough entries for them already. */
         $type = $data['type'] . '/' . $data['subtype'];
         if (in_array($type, array('application/octet-stream', 'application/base64'))) {
             $type = Horde_Mime_Magic::filenameToMIME($data['name']);
         }
         $temp_part->setType($type);
         $mixed->addPart($temp_part);
     }
     return $mixed;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:41,代码来源:Tnef.php

示例2: createMimePart

 /**
  * Generates a Horde_Mime_Part object, in accordance with RFC 3156, that
  * contains a public key.
  *
  * @return Horde_Mime_Part  Object that contains the armored public key.
  */
 public function createMimePart()
 {
     $part = new Horde_Mime_Part();
     $part->setType('application/pgp-keys');
     $part->setHeaderCharset('UTF-8');
     $part->setDescription(Horde_Pgp_Translation::t("PGP Public Key"));
     $part->setContents(strval($this), array('encoding' => '7bit'));
     return $part;
 }
开发者ID:horde,项目名称:horde,代码行数:15,代码来源:PublicKey.php

示例3: _parseBodystructure

 /**
  * Recursively parse BODYSTRUCTURE data from a FETCH return (see
  * RFC 3501 [7.4.2]).
  *
  * @param Horde_Imap_Client_Tokenize $data  Data returned from the server.
  *
  * @return Horde_Mime_Part  Mime part object.
  */
 protected function _parseBodystructure(Horde_Imap_Client_Tokenize $data)
 {
     $ob = new Horde_Mime_Part();
     // If index 0 is an array, this is a multipart part.
     if (($entry = $data->next()) === true) {
         do {
             $ob->addPart($this->_parseBodystructure($data));
         } while (($entry = $data->next()) === true);
         // The subpart type.
         $ob->setType('multipart/' . $entry);
         // After the subtype is further extension information. This
         // information MAY appear for BODYSTRUCTURE requests.
         // This is parameter information.
         if (($tmp = $data->next()) === false) {
             return $ob;
         } elseif ($tmp === true) {
             foreach ($this->_parseStructureParams($data, 'content-type') as $key => $val) {
                 $ob->setContentTypeParameter($key, $val);
             }
         }
     } else {
         $ob->setType($entry . '/' . $data->next());
         if ($data->next() === true) {
             foreach ($this->_parseStructureParams($data, 'content-type') as $key => $val) {
                 $ob->setContentTypeParameter($key, $val);
             }
         }
         if (!is_null($tmp = $data->next())) {
             $ob->setContentId($tmp);
         }
         if (!is_null($tmp = $data->next())) {
             $ob->setDescription(Horde_Mime::decode($tmp));
         }
         if (!is_null($tmp = $data->next())) {
             $ob->setTransferEncoding($tmp);
         }
         $ob->setBytes($data->next());
         // If the type is 'message/rfc822' or 'text/*', several extra
         // fields are included
         switch ($ob->getPrimaryType()) {
             case 'message':
                 if ($ob->getSubType() == 'rfc822') {
                     if ($data->next() === true) {
                         // Ignore: envelope
                         $data->flushIterator(false);
                     }
                     if ($data->next() === true) {
                         $ob->addPart($this->_parseBodystructure($data));
                     }
                     $data->next();
                     // Ignore: lines
                 }
                 break;
             case 'text':
                 $data->next();
                 // Ignore: lines
                 break;
         }
         // After the subtype is further extension information. This
         // information MAY appear for BODYSTRUCTURE requests.
         // Ignore: MD5
         if ($data->next() === false) {
             return $ob;
         }
     }
     // This is disposition information
     if (($tmp = $data->next()) === false) {
         return $ob;
     } elseif ($tmp === true) {
         $ob->setDisposition($data->next());
         if ($data->next() === true) {
             foreach ($this->_parseStructureParams($data, 'content-disposition') as $key => $val) {
                 $ob->setDispositionParameter($key, $val);
             }
         }
         $data->next();
     }
     // This is language information. It is either a single value or a list
     // of values.
     if (($tmp = $data->next()) === false) {
         return $ob;
     } elseif (!is_null($tmp)) {
         $ob->setLanguage($tmp === true ? $data->flushIterator() : $tmp);
     }
     // Ignore location (RFC 2557) and consume closing paren.
     $data->flushIterator(false);
     return $ob;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:96,代码来源:Socket.php

示例4: publicKeyPart

 /**
  * Generate a Horde_Mime_Part object that contains a public key (RFC
  * 3156 [7]).
  *
  * @param mixed $key  The public key.
  *
  * @return Horde_Mime_Part  An object that contains the public key.
  */
 public function publicKeyPart($key)
 {
     $key = Horde_Pgp_Element_PublicKey::create($key);
     $part = new Horde_Mime_Part();
     $part->setType('application/pgp-keys');
     $part->setHeaderCharset('UTF-8');
     $part->setDescription(Horde_Crypt_Translation::t("PGP Public Key"));
     $part->setContents(strval($key), array('encoding' => '7bit'));
     return $part;
 }
开发者ID:horde,项目名称:horde,代码行数:18,代码来源:Mime.php

示例5: _parseStructure

 /**
  * Recursively parse BODYSTRUCTURE data from a FETCH return (see
  * RFC 3501 [7.4.2]).
  *
  * @param array $data  The tokenized information from the server.
  *
  * @return array  The array of bodystructure information.
  */
 protected function _parseStructure($data)
 {
     $ob = new Horde_Mime_Part();
     // If index 0 is an array, this is a multipart part.
     if (is_array($data[0])) {
         // Keep going through array values until we find a non-array.
         for ($i = 0, $cnt = count($data); $i < $cnt; ++$i) {
             if (!is_array($data[$i])) {
                 break;
             }
             $ob->addPart($this->_parseStructure($data[$i]));
         }
         // The first string entry after an array entry gives us the
         // subpart type.
         $ob->setType('multipart/' . $data[$i]);
         // After the subtype is further extension information. This
         // information MAY not appear for BODYSTRUCTURE requests.
         // This is parameter information.
         if (isset($data[++$i]) && is_array($data[$i])) {
             foreach ($this->_parseStructureParams($data[$i], 'content-type') as $key => $val) {
                 $ob->setContentTypeParameter($key, $val);
             }
         }
         // This is disposition information.
         if (isset($data[++$i]) && is_array($data[$i])) {
             $ob->setDisposition($data[$i][0]);
             foreach ($this->_parseStructureParams($data[$i][1], 'content-disposition') as $key => $val) {
                 $ob->setDispositionParameter($key, $val);
             }
         }
         // This is language information. It is either a single value or
         // a list of values.
         if (isset($data[++$i])) {
             $ob->setLanguage($data[$i]);
         }
         // Ignore: location (RFC 2557)
         // There can be further information returned in the future, but
         // for now we are done.
     } else {
         $ob->setType($data[0] . '/' . $data[1]);
         foreach ($this->_parseStructureParams($data[2], 'content-type') as $key => $val) {
             $ob->setContentTypeParameter($key, $val);
         }
         if ($data[3] !== null) {
             $ob->setContentId($data[3]);
         }
         if ($data[4] !== null) {
             $ob->setDescription(Horde_Mime::decode($data[4]));
         }
         if ($data[5] !== null) {
             $ob->setTransferEncoding($data[5]);
         }
         if ($data[6] !== null) {
             $ob->setBytes($data[6]);
         }
         // If the type is 'message/rfc822' or 'text/*', several extra
         // fields are included
         switch ($ob->getPrimaryType()) {
             case 'message':
                 if ($ob->getSubType() == 'rfc822') {
                     // Ignore: envelope
                     $ob->addPart($this->_parseStructure($data[8]));
                     // Ignore: lines
                     $i = 10;
                 } else {
                     $i = 7;
                 }
                 break;
             case 'text':
                 // Ignore: lines
                 $i = 8;
                 break;
             default:
                 $i = 7;
                 break;
         }
         // After the subtype is further extension information. This
         // information MAY appear for BODYSTRUCTURE requests.
         // Ignore: MD5
         // This is disposition information
         if (isset($data[++$i]) && is_array($data[$i])) {
             $ob->setDisposition($data[$i][0]);
             foreach ($this->_parseStructureParams($data[$i][1], 'content-disposition') as $key => $val) {
                 $ob->setDispositionParameter($key, $val);
             }
         }
         // This is language information. It is either a single value or
         // a list of values.
         if (isset($data[++$i])) {
             $ob->setLanguage($data[$i]);
         }
         // Ignore: location (RFC 2557)
//.........这里部分代码省略.........
开发者ID:horde,项目名称:horde,代码行数:101,代码来源:Rcube.php

示例6: _parseBodystructure

 /**
  * Recursively parse BODYSTRUCTURE data from a FETCH return (see
  * RFC 3501 [7.4.2]).
  *
  * @param Horde_Imap_Client_Tokenize $data  Data returned from the server.
  *
  * @return array  The array of bodystructure information.
  */
 protected function _parseBodystructure(Horde_Imap_Client_Tokenize $data)
 {
     $ob = new Horde_Mime_Part();
     // If index 0 is an array, this is a multipart part.
     if (is_object($entry = $data->rewind())) {
         // Keep going through array values until we find a non-array.
         do {
             $ob->addPart($this->_parseBodystructure($entry));
         } while (is_object($entry = $data->next()));
         // The first string entry after an array entry gives us the
         // subpart type.
         $ob->setType('multipart/' . $entry);
         // After the subtype is further extension information. This
         // information MAY not appear for BODYSTRUCTURE requests.
         // This is parameter information.
         if (is_object($tmp = $data->next())) {
             foreach ($this->_parseStructureParams($tmp, 'content-type') as $key => $val) {
                 $ob->setContentTypeParameter($key, $val);
             }
         }
     } else {
         $ob->setType($entry . '/' . $data->next());
         if (is_object($tmp = $data->next())) {
             foreach ($this->_parseStructureParams($tmp, 'content-type') as $key => $val) {
                 $ob->setContentTypeParameter($key, $val);
             }
         }
         if (!is_null($tmp = $data->next())) {
             $ob->setContentId($tmp);
         }
         if (!is_null($tmp = $data->next())) {
             $ob->setDescription(Horde_Mime::decode($tmp));
         }
         if (!is_null($tmp = $data->next())) {
             $ob->setTransferEncoding($tmp);
         }
         $ob->setBytes($data->next());
         // If the type is 'message/rfc822' or 'text/*', several extra
         // fields are included
         switch ($ob->getPrimaryType()) {
             case 'message':
                 if ($ob->getSubType() == 'rfc822') {
                     $data->next();
                     // Ignore: envelope
                     $ob->addPart($this->_parseBodystructure($data->next()));
                     $data->next();
                     // Ignore: lines
                 }
                 break;
             case 'text':
                 $data->next();
                 // Ignore: lines
                 break;
         }
         // After the subtype is further extension information. This
         // information MAY appear for BODYSTRUCTURE requests.
         $data->next();
         // Ignore: MD5
     }
     // This is disposition information
     if (is_object($tmp = $data->next())) {
         $ob->setDisposition($tmp->rewind());
         foreach ($this->_parseStructureParams($tmp->next(), 'content-disposition') as $key => $val) {
             $ob->setDispositionParameter($key, $val);
         }
     }
     // This is language information. It is either a single value or a list
     // of values.
     if (($tmp = $data->next()) !== false) {
         $ob->setLanguage($tmp);
     }
     $data->next();
     // Ignore: location (RFC 2557)
     return $ob;
 }
开发者ID:netcon-source,项目名称:apps,代码行数:83,代码来源:Socket.php

示例7: publicKeyMIMEPart

 /**
  * Generates a Horde_Mime_Part object, in accordance with RFC 3156, that
  * contains a public key.
  *
  * @param string $key  The public key.
  *
  * @return Horde_Mime_Part  An object that contains the public key.
  */
 public function publicKeyMIMEPart($key)
 {
     $part = new Horde_Mime_Part();
     $part->setType('application/pgp-keys');
     $part->setHeaderCharset('UTF-8');
     $part->setDescription(Horde_Crypt_Translation::t("PGP Public Key"));
     $part->setContents($key, array('encoding' => '7bit'));
     return $part;
 }
开发者ID:horde,项目名称:horde,代码行数:17,代码来源:Pgp.php

示例8: send

 /**
  * Sends this message.
  *
  * @param Mail $mailer     A Mail object.
  * @param boolean $resend  If true, the message id and date are re-used;
  *                         If false, they will be updated.
  * @param boolean $flowed  Send message in flowed text format.
  *
  * @throws Horde_Mime_Exception
  */
 public function send($mailer, $resend = false, $flowed = true)
 {
     /* Add mandatory headers if missing. */
     $has_header = $this->_headers->getValue('Message-ID');
     if (!$resend || !$has_header) {
         if ($has_header) {
             $this->_headers->removeHeader('Message-ID');
         }
         $this->_headers->addMessageIdHeader();
     }
     if (!$this->_headers->getValue('User-Agent')) {
         $this->_headers->addUserAgentHeader();
     }
     $has_header = $this->_headers->getValue('Date');
     if (!$resend || !$has_header) {
         if ($has_header) {
             $this->_headers->removeHeader('Date');
         }
         $this->_headers->addHeader('Date', date('r'));
     }
     if (isset($this->_base)) {
         $basepart = $this->_base;
     } else {
         /* Send in flowed format. */
         if ($flowed && !empty($this->_body)) {
             $flowed = new Horde_Text_Flowed($this->_body->getContents(), $this->_body->getCharset());
             $flowed->setDelSp(true);
             $this->_body->setContentTypeParameter('format', 'flowed');
             $this->_body->setContentTypeParameter('DelSp', 'Yes');
             $this->_body->setContents($flowed->toFlowed());
         }
         /* Build mime message. */
         $body = new Horde_Mime_Part();
         if (!empty($this->_body) && !empty($this->_htmlBody)) {
             $body->setType('multipart/alternative');
             $this->_body->setDescription(Horde_Mime_Translation::t("Plaintext Version of Message"));
             $body->addPart($this->_body);
             $this->_htmlBody->setDescription(Horde_Mime_Translation::t("HTML Version of Message"));
             $body->addPart($this->_htmlBody);
         } elseif (!empty($this->_htmlBody)) {
             $body = $this->_htmlBody;
         } elseif (!empty($this->_body)) {
             $body = $this->_body;
         }
         if (count($this->_parts)) {
             $basepart = new Horde_Mime_Part();
             $basepart->setType('multipart/mixed');
             $basepart->isBasePart(true);
             if ($body) {
                 $basepart->addPart($body);
             }
             foreach ($this->_parts as $mime_part) {
                 $basepart->addPart($mime_part);
             }
         } else {
             $basepart = $body;
             $basepart->isBasePart(true);
         }
     }
     $basepart->setHeaderCharset($this->_charset);
     /* Build recipients. */
     $recipients = clone $this->_recipients;
     foreach (array('to', 'cc') as $header) {
         $recipients->add($this->_headers->getOb($header));
     }
     if ($this->_bcc) {
         $recipients->add($this->_bcc);
     }
     /* Trick Horde_Mime_Part into re-generating the message headers. */
     $this->_headers->removeHeader('MIME-Version');
     /* Send message. */
     $recipients->unique();
     $basepart->send($recipients->writeAddress(), $this->_headers, $mailer);
     /* Remember the basepart */
     $this->_base = $basepart;
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:86,代码来源:Mail.php

示例9: _decodeTnefData

 /**
  * Convert a TNEF attachment into a multipart/mixed part.
  *
  * @param  integer|Horde_Mime_part $data  Either a mime part id or a
  *                                        Horde_Mime_Part object containing
  *                                        the TNEF attachment.
  *
  * @return Horde_Mime_Part  The multipart/mixed MIME part containing any
  *                          attachment data we can decode.
  */
 protected function _decodeTnefData($data)
 {
     $wrapper = new Horde_Mime_Part();
     $wrapper->setType('multipart/mixed');
     if (!$data instanceof Horde_Mime_Part) {
         $mime_part = $this->getMimePart($data);
     } else {
         $mime_part = $data;
     }
     $tnef_parser = Horde_Compress::factory('Tnef');
     try {
         $tnef_data = $tnef_parser->decompress($mime_part->getContents());
     } catch (Horde_Compress_Exception $e) {
         return false;
     }
     if (!count($tnef_data)) {
         return false;
     }
     reset($tnef_data);
     while (list(, $data) = each($tnef_data)) {
         $tmp_part = new Horde_Mime_Part();
         $tmp_part->setName($data['name']);
         $tmp_part->setDescription($data['name']);
         $tmp_part->setContents($data['stream']);
         $type = $data['type'] . '/' . $data['subtype'];
         if (in_array($type, array('application/octet-stream', 'application/base64'))) {
             $type = Horde_Mime_Magic::filenameToMIME($data['name']);
         }
         $tmp_part->setType($type);
         $wrapper->addPart($tmp_part);
     }
     return $wrapper;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:43,代码来源:Message.php

示例10: _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

示例11: 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

示例12: encryptMIMEPart

 /**
  * Encrypt a MIME part using S/MIME. This produces S/MIME Version 3.2
  * compatible data (see RFC 5751 [3.3]).
  *
  * @param Horde_Mime_Part $mime_part  The object to encrypt.
  * @param array $params               The parameters required for
  *                                    encryption.
  *
  * @return Horde_Mime_Part  An encrypted MIME part object.
  * @throws Horde_Crypt_Exception
  */
 public function encryptMIMEPart($mime_part, $params = array())
 {
     /* Sign the part as a message */
     $message = $this->encrypt($mime_part->toString(array('headers' => true, 'canonical' => true)), $params);
     $msg = new Horde_Mime_Part();
     $msg->setCharset($this->_params['email_charset']);
     $msg->setHeaderCharset('UTF-8');
     $msg->setDescription(Horde_Crypt_Translation::t("S/MIME Encrypted Message"));
     $msg->setDisposition('inline');
     $msg->setType('application/pkcs7-mime');
     $msg->setContentTypeParameter('smime-type', 'enveloped-data');
     $msg->setContents(substr($message, strpos($message, "\n\n") + 2), array('encoding' => 'base64'));
     return $msg;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:25,代码来源:Smime.php

示例13: _getStructure

 /**
  * Creates a structure object from the text of one part of a MIME message.
  *
  * @param string $header      The header text.
  * @param string $body        The body text.
  * @param string $ctype       The default content-type.
  * @param boolean $forcemime  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.
  *
  * @return Horde_Mime_Part  TODO
  */
 protected static function _getStructure($header, $body, $ctype = 'application/octet-stream', $forcemime = false)
 {
     /* 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 (!$forcemime && !$hdrs->getValue('mime-version')) {
         $ob->setType('text/plain');
         if (!empty($body)) {
             $ob->setContents($body);
             $ob->setBytes(strlen(str_replace(array("\r\n", "\n"), array("\n", "\r\n"), $body)));
         }
         return $ob;
     }
     /* Content type. */
     if ($tmp = $hdrs->getValue('content-type', Horde_Mime_Headers::VALUE_BASE)) {
         $ob->setType($tmp);
         $ctype_params = $hdrs->getValue('content-type', Horde_Mime_Headers::VALUE_PARAMS);
         foreach ($ctype_params as $key => $val) {
             $ob->setContentTypeParameter($key, $val);
         }
     } else {
         $ob->setType($ctype);
         $ctype_params = array();
     }
     /* Content transfer encoding. */
     if ($tmp = $hdrs->getValue('content-transfer-encoding')) {
         $ob->setTransferEncoding($tmp);
     }
     /* Content-Description. */
     if ($tmp = $hdrs->getValue('content-description')) {
         $ob->setDescription($tmp);
     }
     /* Content-Disposition. */
     if ($tmp = $hdrs->getValue('content-disposition', Horde_Mime_Headers::VALUE_BASE)) {
         $ob->setDisposition($tmp);
         foreach ($hdrs->getValue('content-disposition', Horde_Mime_Headers::VALUE_PARAMS) as $key => $val) {
             $ob->setDispositionParameter($key, $val);
         }
     }
     /* Content-Duration */
     if ($tmp = $hdrs->getValue('content-duration')) {
         $ob->setDuration($tmp);
     }
     /* Content-ID. */
     if ($tmp = $hdrs->getValue('content-id')) {
         $ob->setContentId($tmp);
     }
     /* Get file size (if 'body' text is set). */
     if (!empty($body) && $ob->getPrimaryType() != 'multipart') {
         $ob->setContents($body);
         if ($ob->getType() != '/message/rfc822') {
             $ob->setBytes(strlen(str_replace(array("\r\n", "\n"), array("\n", "\r\n"), $body)));
         }
     }
     /* Process subparts. */
     switch ($ob->getPrimaryType()) {
         case 'message':
             if ($ob->getSubType() == 'rfc822') {
                 $ob->addPart(self::parseMessage($body, array('forcemime' => true)));
             }
             break;
         case 'multipart':
             if (isset($ctype_params['boundary'])) {
                 $b_find = self::_findBoundary($body, 0, $ctype_params['boundary']);
                 foreach ($b_find as $val) {
                     $subpart = substr($body, $val['start'], $val['length']);
                     list($hdr_pos, $eol) = self::_findHeader($subpart);
                     $ob->addPart(self::_getStructure(substr($subpart, 0, $hdr_pos), substr($subpart, $hdr_pos + $eol), $ob->getSubType() == 'digest' ? 'message/rfc822' : 'text/plain', true));
                 }
             }
             break;
     }
     return $ob;
 }
开发者ID:netcon-source,项目名称:apps,代码行数:87,代码来源:Part.php

示例14: _createMimeMessage


//.........这里部分代码省略.........
             if (is_null($html_trailer) && strlen($trailer)) {
                 $html_trailer = $this->text2html($trailer);
             }
             if (strlen($html_trailer)) {
                 $t_dom = new Horde_Domhtml($html_trailer, 'UTF-8');
                 foreach ($t_dom->getBody()->childNodes as $child) {
                     $body_html_body->appendChild($body_html->dom->importNode($child, true));
                 }
             }
         }
     }
     /* Convert text to sending charset. HTML text will be converted
      * via Horde_Domhtml. */
     $body = Horde_String::convertCharset($body, 'UTF-8', $this->charset);
     /* Set up the body part now. */
     $textBody = new Horde_Mime_Part();
     $textBody->setType('text/plain');
     $textBody->setCharset($this->charset);
     $textBody->setDisposition('inline');
     /* Send in flowed format. */
     $flowed = new Horde_Text_Flowed($body, $this->charset);
     $flowed->setDelSp(true);
     $textBody->setContentTypeParameter('format', 'flowed');
     $textBody->setContentTypeParameter('DelSp', 'Yes');
     $text_contents = $flowed->toFlowed();
     $textBody->setContents($text_contents);
     /* Determine whether or not to send a multipart/alternative
      * message with an HTML part. */
     if (!empty($options['html'])) {
         $htmlBody = new Horde_Mime_Part();
         $htmlBody->setType('text/html');
         $htmlBody->setCharset($this->charset);
         $htmlBody->setDisposition('inline');
         $htmlBody->setDescription(Horde_String::convertCharset(_("HTML Message"), 'UTF-8', $this->charset));
         /* Add default font CSS information here. */
         $styles = array();
         if ($font_family = $prefs->getValue('compose_html_font_family')) {
             $styles[] = 'font-family:' . $font_family;
         }
         if ($font_size = intval($prefs->getValue('compose_html_font_size'))) {
             $styles[] = 'font-size:' . $font_size . 'px';
         }
         if (!empty($styles)) {
             $body_html_body->setAttribute('style', implode(';', $styles));
         }
         if (empty($options['nofinal'])) {
             $this->_cleanHtmlOutput($body_html);
         }
         $to_add = $this->_convertToRelated($body_html, $htmlBody);
         /* Now, all parts referred to in the HTML data have been added
          * to the attachment list. Convert to multipart/related if
          * this is the case. Exception: if text representation is empty,
          * just send HTML part. */
         if (strlen(trim($text_contents))) {
             $textpart = new Horde_Mime_Part();
             $textpart->setType('multipart/alternative');
             $textpart[] = $textBody;
             $textpart[] = $to_add;
             $textpart->setHeaderCharset($this->charset);
             $textBody->setDescription(Horde_String::convertCharset(_("Plaintext Message"), 'UTF-8', $this->charset));
         } else {
             $textpart = $to_add;
         }
         $htmlBody->setContents($tfilter->filter($body_html->returnHtml(array('charset' => $this->charset, 'metacharset' => true)), 'Cleanhtml', array('charset' => $this->charset)));
         $base = $textpart;
     } else {
开发者ID:raz0rsdge,项目名称:horde,代码行数:67,代码来源:Compose.php

示例15: _createMimeMessage


//.........这里部分代码省略.........
             if (is_null($html_trailer) && strlen($trailer)) {
                 $html_trailer = $this->text2html($trailer);
             }
             if (strlen($html_trailer)) {
                 $t_dom = new Horde_Domhtml($html_trailer, 'UTF-8');
                 foreach ($t_dom->getBody()->childNodes as $child) {
                     $body_html_body->appendChild($body_html->dom->importNode($child, true));
                 }
             }
         }
     }
     /* Convert text to sending charset. HTML text will be converted
      * via Horde_Domhtml. */
     $body = Horde_String::convertCharset($body, 'UTF-8', $this->charset);
     /* Set up the body part now. */
     $textBody = new Horde_Mime_Part();
     $textBody->setType('text/plain');
     $textBody->setCharset($this->charset);
     $textBody->setDisposition('inline');
     /* Send in flowed format. */
     $flowed = new Horde_Text_Flowed($body, $this->charset);
     $flowed->setDelSp(true);
     $textBody->setContentTypeParameter('format', 'flowed');
     $textBody->setContentTypeParameter('DelSp', 'Yes');
     $text_contents = $flowed->toFlowed();
     $textBody->setContents($text_contents);
     /* Determine whether or not to send a multipart/alternative
      * message with an HTML part. */
     if (!empty($options['html'])) {
         $htmlBody = new Horde_Mime_Part();
         $htmlBody->setType('text/html');
         $htmlBody->setCharset($this->charset);
         $htmlBody->setDisposition('inline');
         $htmlBody->setDescription(Horde_String::convertCharset(_("HTML Message"), 'UTF-8', $this->charset));
         /* Add default font CSS information here. */
         $styles = array();
         if ($font_family = $prefs->getValue('compose_html_font_family')) {
             $styles[] = 'font-family:' . $font_family;
         }
         if ($font_size = intval($prefs->getValue('compose_html_font_size'))) {
             $styles[] = 'font-size:' . $font_size . 'px';
         }
         if (!empty($styles)) {
             $body_html_body->setAttribute('style', implode(';', $styles));
         }
         if (empty($options['nofinal'])) {
             $this->_cleanHtmlOutput($body_html);
         }
         $to_add = $this->_convertToRelated($body_html, $htmlBody);
         /* Now, all parts referred to in the HTML data have been added
          * to the attachment list. Convert to multipart/related if
          * this is the case. Exception: if text representation is empty,
          * just send HTML part. */
         if (strlen(trim($text_contents))) {
             $textpart = new Horde_Mime_Part();
             $textpart->setType('multipart/alternative');
             $textpart->addPart($textBody);
             $textpart->addPart($to_add);
             $textpart->setHeaderCharset($this->charset);
             $textBody->setDescription(Horde_String::convertCharset(_("Plaintext Message"), 'UTF-8', $this->charset));
         } else {
             $textpart = $to_add;
         }
         $htmlBody->setContents($tfilter->filter($body_html->returnHtml(array('charset' => $this->charset, 'metacharset' => true)), 'Cleanhtml', array('charset' => $this->charset)));
     } else {
         $textpart = $textBody;
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:67,代码来源:Compose.php


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