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


PHP Horde_Mime_Part::setDisposition方法代码示例

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


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

示例1: load

 private function load()
 {
     $headers = [];
     $fetch_query = new \Horde_Imap_Client_Fetch_Query();
     $fetch_query->bodyPart($this->attachmentId);
     $fetch_query->mimeHeader($this->attachmentId);
     $headers = array_merge($headers, ['importance', 'list-post', 'x-priority']);
     $headers[] = 'content-type';
     $fetch_query->headers('imp', $headers, ['cache' => true]);
     // $list is an array of Horde_Imap_Client_Data_Fetch objects.
     $ids = new \Horde_Imap_Client_Ids($this->messageId);
     $headers = $this->conn->fetch($this->mailBox, $fetch_query, ['ids' => $ids]);
     /** @var $fetch Horde_Imap_Client_Data_Fetch */
     if (!isset($headers[$this->messageId])) {
         throw new DoesNotExistException('Unable to load the attachment.');
     }
     $fetch = $headers[$this->messageId];
     $mimeHeaders = $fetch->getMimeHeader($this->attachmentId, Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
     $this->mimePart = new \Horde_Mime_Part();
     // To prevent potential problems with the SOP we serve all files with the
     // MIME type "application/octet-stream"
     $this->mimePart->setType('application/octet-stream');
     // Serve all files with a content-disposition of "attachment" to prevent Cross-Site Scripting
     $this->mimePart->setDisposition('attachment');
     // Extract headers from part
     $contentDisposition = $mimeHeaders->getValue('content-disposition', \Horde_Mime_Headers::VALUE_PARAMS);
     if (!is_null($contentDisposition)) {
         $vars = ['filename'];
         foreach ($contentDisposition as $key => $val) {
             if (in_array($key, $vars)) {
                 $this->mimePart->setDispositionParameter($key, $val);
             }
         }
     } else {
         $contentDisposition = $mimeHeaders->getValue('content-type', \Horde_Mime_Headers::VALUE_PARAMS);
         $vars = ['name'];
         foreach ($contentDisposition as $key => $val) {
             if (in_array($key, $vars)) {
                 $this->mimePart->setContentTypeParameter($key, $val);
             }
         }
     }
     /* Content transfer encoding. */
     if ($tmp = $mimeHeaders->getValue('content-transfer-encoding')) {
         $this->mimePart->setTransferEncoding($tmp);
     }
     $body = $fetch->getBodyPart($this->attachmentId);
     $this->mimePart->setContents($body);
 }
开发者ID:matiasdelellis,项目名称:mail,代码行数:49,代码来源:attachment.php

示例2: _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']);
         $temp_part->setType($data['type'] . '/' . $data['subtype']);
         /* Short-circuit MIME-type guessing for winmail.dat parts;
          * we're showing enough entries for them already. */
         if (in_array($temp_part->getType(), array('application/octet-stream', 'application/base64'))) {
             $temp_part->setType(Horde_Mime_Magic::filenameToMIME($data['name']));
         }
         /* Set text parts to be displayed inline. */
         if ($temp_part->getPrimaryType() === 'text') {
             $temp_part->setDisposition('inline');
         }
         $mixed->addPart($temp_part);
     }
     return $mixed;
 }
开发者ID:horde,项目名称:horde,代码行数:44,代码来源:Tnef.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 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

示例4: getImagePart

 /**
  * Returns a MIME part for an image to be embedded into a HTML document.
  *
  * @param string $file  An image file name.
  *
  * @return Horde_Mime_Part  A MIME part representing the image.
  */
 public static function getImagePart($file)
 {
     $background = Horde_Themes::img($file);
     $image = new Horde_Mime_Part();
     $image->setType('image/png');
     $image->setContents(file_get_contents($background->fs));
     $image->setContentId();
     $image->setDisposition('attachment');
     return $image;
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:17,代码来源:Nag.php

示例5: encryptMIMEPart

 /**
  * Encrypts a MIME part using PGP.
  *
  * @param Horde_Mime_Part $mime_part  The object to encrypt.
  * @param array $params               The parameters required for
  *                                    encryption
  *                                    ({@see _encryptMessage()}).
  *
  * @return mixed  A Horde_Mime_Part object that is encrypted according to
  *                RFC 3156.
  * @throws Horde_Crypt_Exception
  */
 public function encryptMIMEPart($mime_part, $params = array())
 {
     $params = array_merge($params, array('type' => 'message'));
     $signenc_body = $mime_part->toString(array('canonical' => true, 'headers' => true));
     $message_encrypt = $this->encrypt($signenc_body, $params);
     /* Set up MIME Structure according to RFC 3156. */
     $part = new Horde_Mime_Part();
     $part->setType('multipart/encrypted');
     $part->setHeaderCharset('UTF-8');
     $part->setContentTypeParameter('protocol', 'application/pgp-encrypted');
     $part->setDescription(Horde_Crypt_Translation::t("PGP Encrypted Data"));
     $part->setContents("This message is in MIME format and has been PGP encrypted.\n");
     $part1 = new Horde_Mime_Part();
     $part1->setType('application/pgp-encrypted');
     $part1->setCharset(null);
     $part1->setContents("Version: 1\n", array('encoding' => '7bit'));
     $part->addPart($part1);
     $part2 = new Horde_Mime_Part();
     $part2->setType('application/octet-stream');
     $part2->setCharset(null);
     $part2->setContents($message_encrypt, array('encoding' => '7bit'));
     $part2->setDisposition('inline');
     $part->addPart($part2);
     return $part;
 }
开发者ID:horde,项目名称:horde,代码行数:37,代码来源:Pgp.php

示例6: _createMimeMessage


//.........这里部分代码省略.........
     }
     /* Add linked attachments. */
     if (empty($options['nofinal'])) {
         $this->_linkAttachments($body, $body_html);
     }
     /* Get trailer text (if any). */
     if (empty($options['nofinal'])) {
         try {
             $trailer = $hooks->callHook('trailer', 'imp', array(false, $options['identity'], $to));
             $html_trailer = $hooks->callHook('trailer', 'imp', array(true, $options['identity'], $to));
         } catch (Horde_Exception_HookNotSet $e) {
             $trailer = $html_trailer = null;
         }
         $body .= strval($trailer);
         if (!empty($options['html'])) {
             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
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:67,代码来源:Compose.php

示例7: stripPart

 /**
  * Strips one or all MIME parts out of a message.
  *
  * @param string $partid  The MIME ID of the part to strip. All parts are
  *                        stripped if null.
  *
  * @return IMP_Indices  Returns the new indices object.
  * @throws IMP_Exception
  */
 public function stripPart($partid = null)
 {
     global $injector;
     list($mbox, $uid) = $this->getSingle();
     if (!$uid) {
         return;
     }
     if ($mbox->readonly) {
         throw new IMP_Exception(_("Cannot strip the part as the mailbox is read-only."));
     }
     $uidvalidity = $mbox->uidvalid;
     $contents = $injector->getInstance('IMP_Factory_Contents')->create($this);
     $message = $contents->getMIMEMessage();
     $boundary = trim($message->getContentTypeParameter('boundary'), '"');
     $url = new Horde_Imap_Client_Url();
     $url->mailbox = $mbox;
     $url->uid = $uid;
     $url->uidvalidity = $uidvalidity;
     $imp_imap = $mbox->imp_imap;
     /* Always add the header to output. */
     $url->section = 'HEADER';
     $parts = array(array('t' => 'url', 'v' => strval($url)));
     for ($id = 1;; ++$id) {
         if (!($part = $message[$id])) {
             break;
         }
         $parts[] = array('t' => 'text', 'v' => "\r\n--" . $boundary . "\r\n");
         if ($id != 1 && is_null($partid) || $id == $partid) {
             $newPart = new Horde_Mime_Part();
             $newPart->setType('text/plain');
             /* Need to make sure all text is in the correct charset. */
             $newPart->setCharset('UTF-8');
             $newPart->setContents(sprintf(_("[Part stripped: Original part type: %s, name: %s]"), $part->getType(), $contents->getPartName($part)));
             $newPart->setDisposition('attachment');
             $parts[] = array('t' => 'text', 'v' => $newPart->toString(array('canonical' => true, 'headers' => true, 'stream' => true)));
         } else {
             $url->section = $id . '.MIME';
             $parts[] = array('t' => 'url', 'v' => strval($url));
             $url->section = $id;
             $parts[] = array('t' => 'url', 'v' => strval($url));
         }
     }
     $parts[] = array('t' => 'text', 'v' => "\r\n--" . $boundary . "--\r\n");
     /* Get the headers for the message. */
     $query = new Horde_Imap_Client_Fetch_Query();
     $query->imapDate();
     $query->flags();
     try {
         $res = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($uid)))->first();
         if (is_null($res)) {
             throw new IMP_Imap_Exception();
         }
         $flags = $res->getFlags();
         /* If in Virtual Inbox, we need to reset flag to unseen so that it
          * appears again in the mailbox list. */
         if ($mbox->vinbox) {
             $flags = array_values(array_diff($flags, array(Horde_Imap_Client::FLAG_SEEN)));
         }
         $new_uid = $imp_imap->append($mbox, array(array('data' => $parts, 'flags' => $flags, 'internaldate' => $res->getImapDate())))->ids;
         $new_uid = reset($new_uid);
     } catch (IMP_Imap_Exception $e) {
         throw new IMP_Exception(_("An error occured while attempting to strip the part."));
     }
     $this->delete(array('keeplog' => true, 'nuke' => true));
     $indices_ob = $mbox->getIndicesOb($new_uid);
     /* We need to replace the old UID(s) in the URL params. */
     $vars = $injector->getInstance('Horde_Variables');
     if (isset($vars->buid)) {
         list(, $vars->buid) = $mbox->toBuids($indices_ob)->getSingle();
     }
     if (isset($vars->uid)) {
         $vars->uid = $new_uid;
     }
     return $indices_ob;
 }
开发者ID:horde,项目名称:horde,代码行数:84,代码来源:Indices.php

示例8: saveObject


//.........这里部分代码省略.........
                             }
                             $mime_message->_generateIdMap($mime_message->_parts);
                         }
                     }
                 }
             }
         }
         $object = array_merge($old_object, $object);
         if (isset($attachments)) {
             foreach ($mime_message->getParts() as $part) {
                 $name = $part->getName();
                 foreach ($attachments as $attachment) {
                     if ($name === $attachment) {
                         $object['_attachments'][$attachment]['id'] = $part->getMimeId();
                     }
                 }
             }
         }
         /** Copy email header */
         if (!empty($mime_headers) && !$mime_headers === false) {
             foreach ($mime_headers as $header => $value) {
                 $new_headers->addheader($header, $value);
             }
         }
     } else {
         $mime_message = $this->_prepareNewMessage($new_headers);
         $mime_part_id = false;
     }
     if (isset($object['_attachments'])) {
         $attachments = array_keys($object['_attachments']);
         foreach ($attachments as $attachment) {
             $data = $object['_attachments'][$attachment];
             if (!isset($data['content']) && !isset($data['path'])) {
                 /**
                  * There no new content and no new path. Do not rewrite the
                  * attachment.
                  */
                 continue;
             }
             $part = new Horde_Mime_Part();
             $part->setType(isset($data['type']) ? $data['type'] : null);
             $part->setContents(isset($data['content']) ? $data['content'] : file_get_contents($data['path']));
             $part->setCharset('UTF-8');
             $part->setTransferEncoding('quoted-printable');
             $part->setDisposition('attachment');
             $part->setName($attachment);
             if (!isset($data['id'])) {
                 $mime_message->addPart($part);
             } else {
                 $mime_message->alterPart($data['id'], $part);
             }
         }
     }
     foreach ($formats as $type) {
         $new_content = $handlers[$type]->save($object);
         if (is_a($new_content, 'PEAR_Error')) {
             return $new_content;
         }
         /** Update mime part */
         $part = new Horde_Mime_Part();
         $part->setType($handlers[$type]->getMimeType());
         $part->setContents($new_content);
         $part->setCharset('UTF-8');
         $part->setTransferEncoding('quoted-printable');
         $part->setDisposition($handlers[$type]->getDisposition());
         $part->setDispositionParameter('x-kolab-type', $type);
         $part->setName($handlers[$type]->getName());
         if (!isset($part_ids) || $part_ids[$type] === false) {
             $mime_message->addPart($part);
         } else {
             $mime_message->alterPart($part_ids[$type], $part);
         }
     }
     // Update email headers
     $new_headers->addHeader('From', $this->_driver->getAuth());
     $new_headers->addHeader('To', $this->_driver->getAuth());
     $new_headers->addHeader('Date', date('r'));
     $new_headers->addHeader('X-Kolab-Type', $handlers['XML']->getMimeType());
     $new_headers->addHeader('Subject', $object['uid']);
     $new_headers->addHeader('User-Agent', 'Horde::Kolab::Storage v0.2');
     $new_headers->addHeader('MIME-Version', '1.0');
     $mime_message->addMimeHeaders(array('headers' => $new_headers));
     $msg = $new_headers->toString() . $mime_message->toString(array('canonical' => true, 'headers' => false));
     // delete old email?
     if ($id != null) {
         $this->_driver->deleteMessages($this->_path, $id);
     }
     // store new email
     try {
         $result = $this->_driver->appendMessage($this->_path, $msg);
     } catch (Horde_Kolab_Storage_Exception $e) {
         if ($id != null) {
             $this->_driver->undeleteMessages($id);
         }
     }
     // remove deleted object
     if ($id != null) {
         $this->_driver->expunge($this->_path);
     }
 }
开发者ID:horde,项目名称:horde,代码行数:101,代码来源:Folder.php

示例9: createFreshKolabPart

 /**
  * Embed the Kolab content into a new MIME Part.
  *
  * @param resource $content The Kolab content.
  *
  * @return Horde_Mime_Part The MIME part that encapsules the Kolab content.
  */
 protected function createFreshKolabPart($content)
 {
     $part = new Horde_Mime_Part();
     $part->setCharset('utf-8');
     $part->setDisposition('inline');
     $part->setDispositionParameter('x-kolab-type', 'xml');
     $part->setName('kolab.xml');
     $part->setType(Horde_Kolab_Storage_Object_MimeType::getMimeTypeFromObjectType($this->getType()));
     $part->setContents($content, array('encoding' => 'quoted-printable'));
     return $part;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:18,代码来源:Object.php

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

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

示例13:

<?php

$part1 = new Horde_Mime_Part();
$part1->setType('text/plain');
$part1->setTransferEncoding('quoted-printable');
$part1->setCharset('UTF-8');
$part1->setDisposition('inline');
$part1->setBytes(249);
$part2 = new Horde_Mime_Part();
$part2->setType('application/x-vnd.kolab.note');
$part2->setTransferEncoding('quoted-printable');
$part2->setName('kolab.xml');
$part2->setDisposition('attachment');
$part2->setBytes(704);
$message = new Horde_Mime_Part();
$message->setType('multipart/mixed');
$message->addPart($part1);
$message->addPart($part2);
$message->buildMimeIds(0);
return $message;
开发者ID:jubinpatel,项目名称:horde,代码行数:20,代码来源:note.php

示例14: _createMimeMessage


//.........这里部分代码省略.........
     }
     /* Add linked attachments. */
     if (empty($options['nofinal'])) {
         $this->_linkAttachments($body, $body_html);
     }
     /* Get trailer text (if any). */
     if (empty($options['nofinal']) && !empty($options['recip'])) {
         try {
             $trailer = $hooks->callHook('trailer', 'imp', array(false, $options['identity'], $options['recip']));
             $html_trailer = $hooks->callHook('trailer', 'imp', array(true, $options['identity'], $options['recip']));
         } catch (Horde_Exception_HookNotSet $e) {
             $trailer = $html_trailer = null;
         }
         $body .= strval($trailer);
         if (!empty($options['html'])) {
             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
开发者ID:raz0rsdge,项目名称:horde,代码行数:67,代码来源:Compose.php

示例15: _parseStructure

 /**
  * Parse the output from imap_fetchstructure() into a MIME Part object.
  *
  * @param object $data  Data from imap_fetchstructure().
  *
  * @return Horde_Mime_Part  A MIME Part object.
  */
 protected function _parseStructure($data)
 {
     $ob = new Horde_Mime_Part();
     $ob->setType(Horde_String::lower($data->type) . '/' . Horde_String::lower($data->subType));
     // Optional for multipart-parts, required for all others
     if (isset($data->parameters)) {
         $params = array();
         foreach ($data->parameters as $key => $value) {
             $params[Horde_String::lower($key)] = $value;
         }
         $params = Horde_Mime::decodeParam('content-type', $params);
         foreach ($params['params'] as $key => $value) {
             $ob->setContentTypeParameter($key, $value);
         }
     }
     // Optional entries. 'location' and 'language' not supported
     if (isset($data->disposition)) {
         $ob->setDisposition($data->disposition);
         if (isset($data->dparameters)) {
             $dparams = array();
             foreach ($data->dparameters as $key => $value) {
                 $dparams[Horde_String::lower($key)] = $value;
             }
             $dparams = Horde_Mime::decodeParam('content-disposition', $dparams);
             foreach ($dparams['params'] as $key => $value) {
                 $ob->setDispositionParameter($key, $value);
             }
         }
     }
     if ($ob->getPrimaryType() == 'multipart') {
         // multipart/* specific entries
         foreach ($data->subParts as $val) {
             $ob->addPart($this->_parseStructure($val));
         }
     } else {
         // Required options
         if (isset($data->partID)) {
             $ob->setContentId($data->partID);
         }
         $ob->setTransferEncoding(Horde_String::lower($data->encoding));
         $ob->setBytes($data->bytes);
         if ($ob->getType() == 'message/rfc822') {
             $ob->addPart($this->_parseStructure(reset($data->subParts)));
         }
     }
     return $ob;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:54,代码来源:Pear.php


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