當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Horde_Mime_Part::getContents方法代碼示例

本文整理匯總了PHP中Horde_Mime_Part::getContents方法的典型用法代碼示例。如果您正苦於以下問題:PHP Horde_Mime_Part::getContents方法的具體用法?PHP Horde_Mime_Part::getContents怎麽用?PHP Horde_Mime_Part::getContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Horde_Mime_Part的用法示例。


在下文中一共展示了Horde_Mime_Part::getContents方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testBug10431

    public function testBug10431()
    {
        $text = 'Das könnte zum Beispiel so aussehen, dass wir bei entsprechenden Anfragen diese an eine Kontaktperson bei Euch weiterleiten. Oder Ihr schnürt ein entsprechendes Paket, dass wir in unseren Angeboten mit anführen. Bei erfolgreicher Vermittlung bekämen wir eine Vermittlungsgebühr.
Wir ständen dann weiterhin für 3rd-Level-Support zur Verfügung, d.h. für alle Anfragen des Kunden bzgl. Horde, die nicht zum Tagesgeschäft gehören.';
        $text = Horde_String::convertCharset($text, 'UTF-8', 'ISO-8859-1');
        $textBody = new Horde_Mime_Part();
        $textBody->setType('text/plain');
        $textBody->setCharset('ISO-8859-1');
        $flowed = new Horde_Text_Flowed($text, 'ISO-8859-1');
        $flowed->setDelSp(true);
        $textBody->setContents($flowed->toFlowed());
        $flowed_txt = $textBody->toString(array('headers' => false));
        $textBody2 = new Horde_Mime_Part();
        $textBody2->setType('text/plain');
        $textBody2->setCharset('ISO-8859-1');
        $textBody2->setContents($flowed_txt, array('encoding' => 'quoted-printable'));
        $flowed2 = new Horde_Text_Flowed($textBody2->getContents(), 'ISO-8859-1');
        $flowed2->setMaxLength(0);
        $flowed2->setDelSp(true);
        $this->assertEquals($text, trim($flowed2->toFixed()));
    }
開發者ID:jubinpatel,項目名稱:horde,代碼行數:21,代碼來源:ComposeTest.php

示例2: _getBodyPart

 /**
  * Build the data needed for the BodyPart part.
  *
  * @param  Horde_Imap_Client_Data_Fetch $data  The FETCH results.
  * @param  Horde_Mime_Part $mime  The plaintext MIME part.
  * @param boolean $to_html        If true, $id is assumed to be a text/plain
  *                                part and is converted to html.
  *
  * @return array  The BodyPart data.
  *     - charset:  (string)   The charset of the text.
  *     - body: (string)       The body text.
  *     - truncated: (boolean) True if text was truncated.
  *     - size: (integer)      The original part size, in bytes.
  */
 protected function _getBodyPart(Horde_Imap_Client_Data_Fetch $data, Horde_Mime_Part $mime, $to_html)
 {
     $id = $mime->getMimeId();
     $text = $data->getBodyPart($id);
     if (!$data->getBodyPartDecode($id)) {
         $mime->setContents($text);
         $text = $mime->getContents();
     }
     if ($to_html) {
         $text = Horde_Text_Filter::filter($text, 'Text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO, 'charset' => $mime->getCharset()));
         $size = strlen($text);
     } else {
         $size = !is_null($data->getBodyPartSize($id)) ? $data->getBodyPartSize($id) : strlen($text);
     }
     if (!empty($this->_options['bodypartprefs']['truncationsize'])) {
         $text = Horde_String::substr($text, 0, $this->_options['bodypartprefs']['truncationsize'], $mime->getCharset());
     }
     return array('charset' => $mime->getCharset(), 'body' => $text, 'truncated' => $size > strlen($text), 'size' => $size);
 }
開發者ID:horde,項目名稱:horde,代碼行數:33,代碼來源:MessageBodyData.php

示例3: process_message_part_attachment

 /**
  * Process a message again to add body and attachment data.
  *
  * @param \Horde_Imap_Client_Data_Fetch $messagedata The structure and part of the message body
  * @param \Horde_Mime_Part $partdata The part data
  * @param string $part The part ID.
  * @param string $filename The filename of the attachment
  * @return \stdClass
  * @throws \core\message\inbound\processing_failed_exception If the attachment can't be saved to disk.
  */
 private function process_message_part_attachment($messagedata, $partdata, $part, $filename)
 {
     global $CFG;
     // If a filename is present, assume that this part is an attachment.
     $attachment = new \stdClass();
     $attachment->filename = $filename;
     $attachment->type = $partdata->getType();
     $attachment->content = $partdata->getContents();
     $attachment->charset = $partdata->getCharset();
     $attachment->description = $partdata->getDescription();
     $attachment->contentid = $partdata->getContentId();
     $attachment->filesize = $messagedata->getBodyPartSize($part);
     if (!empty($CFG->antiviruses)) {
         mtrace("--> Attempting virus scan of '{$attachment->filename}'");
         // Store the file on disk - it will need to be virus scanned first.
         $itemid = rand(1, 999999999);
         $directory = make_temp_directory("/messageinbound/{$itemid}", false);
         $filepath = $directory . "/" . $attachment->filename;
         if (!($fp = fopen($filepath, "w"))) {
             // Unable to open the temporary file to write this to disk.
             mtrace("--> Unable to save the file to disk for virus scanning. Check file permissions.");
             throw new \core\message\inbound\processing_failed_exception('attachmentfilepermissionsfailed', 'tool_messageinbound');
         }
         fwrite($fp, $attachment->content);
         fclose($fp);
         // Perform a virus scan now.
         try {
             \core\antivirus\manager::scan_file($filepath, $attachment->filename, true);
         } catch (\core\antivirus\scanner_exception $e) {
             mtrace("--> A virus was found in the attachment '{$attachment->filename}'.");
             $this->inform_attachment_virus();
             return;
         }
     }
     return $attachment;
 }
開發者ID:Chocolate-lightning,項目名稱:moodle,代碼行數:46,代碼來源:manager.php

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

示例5: getContents

 /**
  * @return string
  */
 public function getContents()
 {
     return $this->mimePart->getContents();
 }
開發者ID:matiasdelellis,項目名稱:mail,代碼行數:7,代碼來源:attachment.php

示例6: testNoOverwriteOfPartContentsWithItsOwnStreamData

 public function testNoOverwriteOfPartContentsWithItsOwnStreamData()
 {
     $text = 'foo';
     $part = new Horde_Mime_Part();
     $part->setType('text/plain');
     $part->setContents($text);
     $stream = $part->getContents(array('stream' => true));
     $part->setContents($stream);
     $this->assertEquals($text, $part->getContents());
 }
開發者ID:x59,項目名稱:horde-mime,代碼行數:10,代碼來源:PartTest.php

示例7: _reEncodeMessageAttachment

 /**
  * Rebuilds $part and forces it to be a base64 encoded
  * application/octet-stream part.
  *
  * @param  Horde_Mime_Part $part   The MIME part.
  */
 protected function _reEncodeMessageAttachment(Horde_Mime_Part $part)
 {
     $new_part = Horde_Mime_Part::parseMessage($part->getContents());
     $part->setContents($new_part->getContents(array('stream' => true)), array('encoding' => self::ENCODE_BINARY));
     $part->setTransferEncoding('base64', array('send' => true));
 }
開發者ID:x59,項目名稱:horde-mime,代碼行數:12,代碼來源:Part.php

示例8: subMimeStructToFlatStruct

 /**
  *
  * @param unknown $struct
  * @param unknown $partno
  * @param unknown $outStruct
  */
 public function subMimeStructToFlatStruct(Horde_Mime_Part $struct, &$outStruct)
 {
     $partno = $struct->getMimeId();
     $outStruct[$partno] = array();
     $outStruct[$partno]['type'] = $struct->getType(false);
     $outStruct[$partno]['subtype'] = $struct->getSubType();
     $outStruct[$partno]['content'] = $struct->getContents(array('stream' => false));
     if ($v = $struct->getCharset()) {
         $outStruct[$partno]['charset'] = $v;
     }
     if ($v = $struct->getName(false)) {
         $outStruct[$partno]['name'] = $v;
     }
     if ($v = $struct->getSize(false)) {
         $outStruct[$partno]['bytes'] = $v;
     }
     if ($v = $struct->getContentId()) {
         $outStruct[$partno]['id'] = $v;
     }
     foreach ($struct->getParts() as $sStruct) {
         $this->subMimeStructToFlatStruct($sStruct, $outStruct);
     }
 }
開發者ID:micoli,項目名稱:qd_mail,代碼行數:29,代碼來源:QDImapHORDE.php

示例9: _renderReturn

 /**
  * Internal helper function to create render data array for a MIME Part
  * object that only has a single part.
  *
  * @param string $data  The rendered data.
  * @param string $type  The rendered type.
  *
  * @return array  See render().
  */
 protected function _renderReturn($data = null, $type = null)
 {
     return array($this->_mimepart->getMimeId() => array('data' => is_null($data) ? $this->_mimepart->getContents() : $data, 'status' => array(), 'type' => is_null($type) ? $this->_mimepart->getType() : $type));
 }
開發者ID:horde,項目名稱:horde,代碼行數:13,代碼來源:Base.php

示例10: loadBodyData

 /**
  * @param \Horde_Mime_Part $p
  * @param int $partNo
  * @return string
  * @throws DoesNotExistException
  * @throws \Exception
  */
 private function loadBodyData($p, $partNo)
 {
     // DECODE DATA
     $fetch_query = new \Horde_Imap_Client_Fetch_Query();
     $ids = new \Horde_Imap_Client_Ids($this->messageId);
     $fetch_query->bodyPart($partNo, ['peek' => true]);
     $fetch_query->bodyPartSize($partNo);
     $fetch_query->mimeHeader($partNo, ['peek' => true]);
     $headers = $this->conn->fetch($this->mailBox, $fetch_query, ['ids' => $ids]);
     /** @var $fetch \Horde_Imap_Client_Data_Fetch */
     $fetch = $headers[$this->messageId];
     if (is_null($fetch)) {
         throw new DoesNotExistException("Mail body for this mail({$this->messageId}) could not be loaded");
     }
     $mimeHeaders = $fetch->getMimeHeader($partNo, Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
     if ($enc = $mimeHeaders->getValue('content-transfer-encoding')) {
         $p->setTransferEncoding($enc);
     }
     $data = $fetch->getBodyPart($partNo);
     $p->setContents($data);
     $data = $p->getContents();
     $data = iconv($p->getCharset(), 'utf-8//IGNORE', $data);
     return $data;
 }
開發者ID:jakobsack,項目名稱:mail,代碼行數:31,代碼來源:message.php

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

示例12: addAttachmentFromPart

 /**
  * Adds an attachment from Horde_Mime_Part data.
  *
  * @param Horde_Mime_Part $part  The object that contains the attachment
  *                               data.
  *
  * @return IMP_Compose_Attachment  Attachment object.
  * @throws IMP_Compose_Exception
  */
 public function addAttachmentFromPart($part)
 {
     /* Extract the data from the Horde_Mime_Part. */
     $atc_file = Horde::getTempFile('impatt');
     $stream = $part->getContents(array('stream' => true));
     rewind($stream);
     if (file_put_contents($atc_file, $stream) === false) {
         throw new IMP_Compose_Exception(sprintf(_("Could not attach %s to the message."), $part->getName()));
     }
     return $this->_addAttachment($atc_file, ftell($stream), $part->getName(true), $part->getType());
 }
開發者ID:raz0rsdge,項目名稱:horde,代碼行數:20,代碼來源:Compose.php


注:本文中的Horde_Mime_Part::getContents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。