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


PHP Horde_Mime_Part类代码示例

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


在下文中一共展示了Horde_Mime_Part类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
     }
     $id = null;
     $ids = array();
     $related_id = $mime_part->getMimeId();
     /* Build a list of parts -> CIDs. */
     foreach ($mime_part->partIterator() as $val) {
         $part_id = $val->getMimeId();
         $ids[] = $part_id;
         if (strcmp($related_id, $part_id) !== 0 && ($cid = $val->getContentId())) {
             $this->_cids[$part_id] = $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]). */
     if ($start = $mime_part->getContentTypeParameter('start')) {
         $id = $this->cidSearch(trim($start, '<> '));
     }
     if (empty($id)) {
         reset($ids);
         $id = next($ids);
     }
     $this->_start = $id;
 }
开发者ID:x59,项目名称:horde-mime,代码行数:34,代码来源:Related.php

示例2: verifyIdentity

 /**
  * Sends a message to an email address supposed to be added to the
  * identity.
  *
  * A message is send to this address containing a time-sensitive link to
  * confirm that the address really belongs to that user.
  *
  * @param integer $id       The identity's ID.
  * @param string $old_addr  The old From: address.
  *
  * @throws Horde_Mime_Exception
  */
 public function verifyIdentity($id, $old_addr)
 {
     global $injector, $notification, $registry;
     $hash = strval(new Horde_Support_Randomid());
     $pref = $this->_confirmEmail();
     $pref[$hash] = $this->get($id);
     $pref[$hash][self::EXPIRE] = time() + self::EXPIRE_SECS;
     $this->_confirmEmail($pref);
     $new_addr = $this->getValue($this->_prefnames['from_addr'], $id);
     $confirm = Horde::url($registry->getServiceLink('emailconfirm')->add('h', $hash)->setRaw(true), true);
     $message = sprintf(Horde_Core_Translation::t("You have requested to add the email address \"%s\" to the list of your personal email addresses.\n\nGo to the following link to confirm that this is really your address:\n%s\n\nIf you don't know what this message means, you can delete it."), $new_addr, $confirm);
     $msg_headers = new Horde_Mime_Headers();
     $msg_headers->addHeaderOb(Horde_Mime_Headers_MessageId::create());
     $msg_headers->addHeaderOb(Horde_Mime_Headers_UserAgent::create());
     $msg_headers->addHeaderOb(Horde_Mime_Headers_Date::create());
     $msg_headers->addHeader('To', $new_addr);
     $msg_headers->addHeader('From', $old_addr);
     $msg_headers->addHeader('Subject', Horde_Core_Translation::t("Confirm new email address"));
     $body = new Horde_Mime_Part();
     $body->setType('text/plain');
     $body->setContents(Horde_String::wrap($message, 76));
     $body->setCharset('UTF-8');
     $body->send($new_addr, $msg_headers, $injector->getInstance('Horde_Mail'));
     $notification->push(sprintf(Horde_Core_Translation::t("A message has been sent to \"%s\" to verify that this is really your address. The new email address is activated as soon as you confirm this message."), $new_addr), 'horde.message');
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:37,代码来源:Identity.php

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

示例4: matchStructure

 /**
  */
 public function matchStructure(Horde_Mime_Part $data)
 {
     foreach ($data->partIterator() as $val) {
         if (IMP_Mime_Attachment::isAttachment($val)) {
             return true;
         }
     }
     return false;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:11,代码来源:Attachment.php

示例5: token

 /**
  * Renders a token into text matching the requested format.
  *
  * @param array $options The "options" portion of the token (second
  * element).
  *
  * @return string The text rendered from the token options.
  */
 public function token($options)
 {
     $part = new Horde_Mime_Part();
     $part->setContents($options['text']);
     $part->setType('application/x-extension-' . $options['attr']['type']);
     $viewer = Horde_Mime_Viewer::factory('Horde_Core_Mime_Viewer_Syntaxhighlighter', $part, array('registry' => $GLOBALS['registry']));
     $data = $viewer->render('inline');
     $data = reset($data);
     return $data['data'];
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:18,代码来源:Code2.php

示例6: testStructure

 public function testStructure()
 {
     $this->assertInstanceOf('Horde_Mime_Part', $this->ob->getStructure());
     $test = new Horde_Mime_Part();
     $test->setType('image/foo');
     $this->ob->setStructure($test);
     $serialize_ob = unserialize(serialize($this->ob));
     foreach (array($this->ob, $serialize_ob) as $val) {
         $ret = $val->getStructure();
         $this->assertInstanceOf('Horde_Mime_Part', $ret);
         $this->assertEquals('image/foo', $ret->getType('image/foo'));
     }
 }
开发者ID:horde,项目名称:horde,代码行数:13,代码来源:TestBase.php

示例7: getMultipartMimeMessage

 private function getMultipartMimeMessage($mime_type)
 {
     $envelope = new Horde_Mime_Part();
     $envelope->setType('multipart/mixed');
     $foo = new Horde_Mime_Part();
     $foo->setType('foo/bar');
     $envelope->addPart($foo);
     $kolab = new Horde_Mime_Part();
     $kolab->setType($mime_type);
     $envelope->addPart($kolab);
     $envelope->buildMimeIds();
     return $envelope;
 }
开发者ID:horde,项目名称:horde,代码行数:13,代码来源:MimeTypeTest.php

示例8: report

 /**
  */
 public function report(IMP_Contents $contents, $action)
 {
     global $injector, $registry;
     $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create();
     switch ($this->_format) {
         case 'redirect':
             /* Send the message. */
             try {
                 $imp_compose->redirectMessage($contents->getIndicesOb());
                 $imp_compose->sendRedirectMessage($this->_email, false);
                 return true;
             } catch (IMP_Compose_Exception $e) {
                 $e->log();
             }
             break;
         case 'digest':
         default:
             try {
                 $from_line = $injector->getInstance('IMP_Identity')->getFromLine();
             } catch (Horde_Exception $e) {
                 $from_line = null;
             }
             /* Build the MIME structure. */
             $mime = new Horde_Mime_Part();
             $mime->setType('multipart/digest');
             $rfc822 = new Horde_Mime_Part();
             $rfc822->setType('message/rfc822');
             $rfc822->setContents($contents->fullMessageText(array('stream' => true)));
             $mime->addPart($rfc822);
             $spam_headers = new Horde_Mime_Headers();
             $spam_headers->addMessageIdHeader();
             $spam_headers->addHeader('Date', date('r'));
             $spam_headers->addHeader('To', $this->_email);
             if (!is_null($from_line)) {
                 $spam_headers->addHeader('From', $from_line);
             }
             $spam_headers->addHeader('Subject', sprintf(_("%s report from %s"), $action == IMP_Spam::SPAM ? 'spam' : 'innocent', $registry->getAuth()));
             /* Send the message. */
             try {
                 $recip_list = $imp_compose->recipientList(array('to' => $this->_email));
                 $imp_compose->sendMessage($recip_list['list'], $spam_headers, $mime, 'UTF-8');
                 $rfc822->clearContents();
                 return true;
             } catch (IMP_Compose_Exception $e) {
                 $e->log();
                 $rfc822->clearContents();
             }
             break;
     }
     return false;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:53,代码来源:Email.php

示例9: testvTodo

 /**
  * @requires extension bcmath
  */
 public function testvTodo()
 {
     $tnef = Horde_Compress::factory('Tnef');
     $mime = Horde_Mime_Part::parseMessage(file_get_contents(__DIR__ . '/fixtures/tnef_task.eml'));
     try {
         $tnef_data = $tnef->decompress($mime->getPart(2)->getContents());
     } catch (Horde_Mapi_Exception $e) {
         $this->markTestSkipped('Horde_Mapi is not available');
     } catch (Horde_Compress_Exception $e) {
         var_dump($e);
     }
     // Test the generated iCalendar.
     $iCal = new Horde_Icalendar();
     if (!$iCal->parsevCalendar($tnef_data[0]['stream'])) {
         throw new Horde_Compress_Exception(_("There was an error importing the iCalendar data."));
     }
     $this->assertEquals($iCal->getAttribute('METHOD'), 'REQUEST');
     $components = $iCal->getComponents();
     if (count($components) == 0) {
         throw new Horde_Compress_Exception(_("No iCalendar data was found."));
     }
     $vTodo = current($components);
     $this->assertEquals($vTodo->getAttribute('SUMMARY'), 'Test Task');
     $this->assertEquals($vTodo->getAttribute('UID'), 'EDF71E6FA6FB69A79D79FE1D6DCDBBD300000000DFD9B6FB');
     $this->assertEquals($vTodo->getAttribute('ATTENDEE'), 'Michael Rubinsky <mrubinsk@horde.org>');
     $params = $vTodo->getAttribute('ATTENDEE', true);
     if (!$params) {
         throw new Horde_Compress_Exception('Could not find expected parameters.');
     }
     $this->assertEquals($params[0]['ROLE'], 'REQ-PARTICIPANT');
     $this->assertEquals($vTodo->getAttribute('ORGANIZER'), 'mailto: mike@theupstairsroom.com');
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:35,代码来源:TnefTest.php

示例10: testIconvHtmlMessage

 public function testIconvHtmlMessage()
 {
     $conn = $this->getMockBuilder('Horde_Imap_Client_Socket')->disableOriginalConstructor()->setMethods(['fetch'])->getMock();
     $urlGenerator = $this->getMockBuilder('\\OCP\\IURLGenerator')->disableOriginalConstructor()->getMock();
     //linkToRoute 'mail.proxy.proxy'
     $urlGenerator->expects($this->any())->method('linkToRoute')->will($this->returnCallback(function ($url) {
         return "https://docs.example.com/server/go.php?to={$url}";
     }));
     $htmlService = new \OCA\Mail\Service\Html($urlGenerator);
     // mock first fetch
     $firstFetch = new Horde_Imap_Client_Data_Fetch();
     $firstPart = Horde_Mime_Part::parseMessage(file_get_contents(__DIR__ . '/data/mail-message-123.txt'), ['level' => 1]);
     $firstFetch->setStructure($firstPart);
     $firstFetch->setBodyPart(1, $firstPart->getPart(1)->getContents());
     $firstFetch->setBodyPart(2, $firstPart->getPart(2)->getContents());
     $firstResult = new Horde_Imap_Client_Fetch_Results();
     $firstResult[123] = $firstFetch;
     $conn->expects($this->any())->method('fetch')->willReturn($firstResult);
     $message = new \OCA\Mail\Message($conn, 'INBOX', 123, null, true, $htmlService);
     $htmlBody = $message->getHtmlBody(0, 0, 123, function () {
         return null;
     });
     $this->assertTrue(strlen($htmlBody) > 1000);
     $plainTextBody = $message->getPlainBody();
     $this->assertTrue(strlen($plainTextBody) > 1000);
 }
开发者ID:jakobsack,项目名称:mail,代码行数:26,代码来源:messagetest.php

示例11: test_messageinbound_handler_trim

 /**
  * @dataProvider message_inbound_handler_trim_testprovider
  */
 public function test_messageinbound_handler_trim($file, $source, $expectedplain, $expectedhtml)
 {
     $this->resetAfterTest();
     $mime = Horde_Mime_Part::parseMessage($source);
     if ($plainpartid = $mime->findBody('plain')) {
         $messagedata = new stdClass();
         $messagedata->plain = $mime->getPart($plainpartid)->getContents();
         $messagedata->html = '';
         list($message, $format) = test_handler::remove_quoted_text($messagedata);
         list($message, $expectedplain) = preg_replace("#\r\n#", "\n", array($message, $expectedplain));
         // Normalise line endings on both strings.
         $this->assertEquals($expectedplain, $message);
         $this->assertEquals(FORMAT_PLAIN, $format);
     }
     if ($htmlpartid = $mime->findBody('html')) {
         $messagedata = new stdClass();
         $messagedata->plain = '';
         $messagedata->html = $mime->getPart($htmlpartid)->getContents();
         list($message, $format) = test_handler::remove_quoted_text($messagedata);
         // Normalise line endings on both strings.
         list($message, $expectedhtml) = preg_replace("#\r\n#", "\n", array($message, $expectedhtml));
         $this->assertEquals($expectedhtml, $message);
         $this->assertEquals(FORMAT_PLAIN, $format);
     }
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:28,代码来源:messageinbound_test.php

示例12: testInvite

 /**
  * Test creating a Horde_ActiveSync_Message_MeetingRequest from a MIME Email
  */
 public function testInvite()
 {
     $this->markTestIncomplete('Has issues on 32bit systems');
     $fixture = file_get_contents(__DIR__ . '/fixtures/invitation_one.eml');
     $mime = Horde_Mime_Part::parseMessage($fixture);
     $msg = new Horde_ActiveSync_Message_MeetingRequest();
     foreach ($mime->contentTypeMap() as $id => $type) {
         if ($type == 'text/calendar') {
             $vcal = new Horde_Icalendar();
             $vcal->parseVcalendar($mime->getPart($id)->getContents());
             $msg->fromvEvent($vcal);
             break;
         }
     }
     $stream = fopen('php://memory', 'wb+');
     $encoder = new Horde_ActiveSync_Wbxml_Encoder($stream);
     $msg->encodeStream($encoder);
     rewind($stream);
     $results = stream_get_contents($stream);
     fclose($stream);
     $stream = fopen(__DIR__ . '/fixtures/meeting_request_one.wbxml', 'r+');
     $expected = '';
     // Using file_get_contents or even fread mangles the binary data for some
     // reason.
     while ($line = fgets($stream)) {
         $expected .= $line;
     }
     fclose($stream);
     $this->assertEquals($expected, $results);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:33,代码来源:InviteTest.php

示例13: testHasiCalendar

 public function testHasiCalendar()
 {
     $fixture = file_get_contents(__DIR__ . '/fixtures/invitation_one.eml');
     $mime = new Horde_ActiveSync_Mime(Horde_Mime_Part::parseMessage($fixture));
     $this->assertEquals(true, $mime->hasAttachments());
     $this->assertEquals(false, $mime->isSigned());
     $this->assertEquals(true, (bool) $mime->hasiCalendar());
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:8,代码来源:MimeTest.php

示例14: isAttachment

 /**
  * Determines if a MIME type is an attachment.
  *
  * @param Horde_Mime_Part $part  The MIME part.
  */
 public static function isAttachment(Horde_Mime_Part $part)
 {
     $type = $part->getType();
     switch ($type) {
         case 'application/ms-tnef':
         case 'application/pgp-keys':
         case 'application/vnd.ms-tnef':
             return false;
     }
     if ($part->parent) {
         switch ($part->parent->getType()) {
             case 'multipart/encrypted':
                 switch ($type) {
                     case 'application/octet-stream':
                         return false;
                 }
                 break;
             case 'multipart/signed':
                 switch ($type) {
                     case 'application/pgp-signature':
                     case 'application/pkcs7-signature':
                     case 'application/x-pkcs7-signature':
                         return false;
                 }
                 break;
         }
     }
     switch ($part->getDisposition()) {
         case 'attachment':
             return true;
     }
     switch ($part->getPrimaryType()) {
         case 'application':
             if (strlen($part->getName())) {
                 return true;
             }
             break;
         case 'audio':
         case 'video':
             return true;
         case 'multipart':
             return false;
     }
     return false;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:50,代码来源:Attachment.php

示例15: _write

 /**
  */
 protected function _write($filename, Horde_Mime_Part $part)
 {
     global $browser;
     try {
         $this->_vfs->write($this->_vfspath, $this->_id, $filename, true);
     } catch (Horde_Vfs_Exception $e) {
         throw new IMP_Compose_Exception($e);
     }
     // Prevent 'jar:' attacks on Firefox.  See Ticket #5892.
     $type = $part->getType();
     if ($browser->isBrowser('mozilla') && in_array(Horde_String::lower($type), array('application/java-archive', 'application/x-jar'))) {
         $type = 'application/octet-stream';
     }
     $md = $this->getMetadata();
     $md->filename = $part->getName(true);
     $md->time = time();
     $md->type = $type;
     $this->saveMetadata($md);
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:21,代码来源:VfsLinked.php


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