getBytes() public method

Determine the size of this MIME part and its child members.
public getBytes ( boolean $approx = false ) : integer
$approx boolean If true, determines an approximate size for parts consisting of base64 encoded data.
return integer Size of the part, in bytes.
Exemplo n.º 1
0
 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());
 }
Exemplo n.º 2
0
 /**
  * Build an appropriate attachment object from the given mime part.
  *
  * @param integer $id                  The mime id for the part
  * @param Horde_Mime_Part  $mime_part  The mime part.
  * @param float $version               The EAS version.
  *
  * @return Horde_ActiveSync_Message_AirSyncBaseAttachment |
  *         Horde_ActiveSync_Message_Attachment
  */
 protected function _buildEasAttachmentFromMime($id, Horde_Mime_Part $mime_part, $version)
 {
     if ($version > Horde_ActiveSync::VERSION_TWOFIVE) {
         $atc = Horde_ActiveSync::messageFactory('AirSyncBaseAttachment');
         $atc->contentid = $mime_part->getContentId();
         $atc->isinline = $mime_part->getDisposition() == 'inline';
     } else {
         $atc = Horde_ActiveSync::messageFactory('Attachment');
         $atc->attoid = $mime_part->getContentId();
     }
     $atc->attsize = intval($mime_part->getBytes(true));
     $atc->attname = $this->_mbox . ':' . $this->uid . ':' . $id;
     $atc->displayname = Horde_String::convertCharset($this->getPartName($mime_part, true), $this->basePart->getHeaderCharset(), 'UTF-8', true);
     $atc->attmethod = in_array($mime_part->getType(), array('message/rfc822', 'message/disposition-notification')) ? Horde_ActiveSync_Message_AirSyncBaseAttachment::ATT_TYPE_EMBEDDED : Horde_ActiveSync_Message_AirSyncBaseAttachment::ATT_TYPE_NORMAL;
     return $atc;
 }
Exemplo n.º 3
0
 public function testSettingBytes()
 {
     $part = new Horde_Mime_Part();
     $part->setBytes(10);
     $part->setTransferEncoding('base64');
     $this->assertEquals(10, $part->getBytes());
     $this->assertEquals(7, $part->getBytes(true));
     $part2 = new Horde_Mime_Part();
     $part2->setBytes(10);
     $part2->setTransferEncoding('base64');
     $part2->setContents('TestTes', array('encoding' => '7bit'));
     $this->assertEquals(7, $part2->getBytes());
     $this->assertEquals(7, $part2->getBytes(true));
 }