getMimeId() public method

Returns the MIME ID of this part.
public getMimeId ( ) : string
return string The MIME ID.
Esempio n. 1
0
 /**
  * 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');
     }
     $ids = array_keys($mime_part->contentTypeMap());
     $related_id = $mime_part->getMimeId();
     $id = null;
     /* Build a list of parts -> CIDs. */
     foreach ($ids as $val) {
         if (strcmp($related_id, $val) !== 0 && ($cid = $mime_part->getPart($val)->getContentId())) {
             $this->_cids[$val] = $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]). */
     $start = $mime_part->getContentTypeParameter('start');
     if (!empty($start)) {
         $id = $this->cidSearch($start);
     }
     if (empty($id)) {
         reset($ids);
         $id = next($ids);
     }
     $this->_start = $id;
 }
Esempio n. 2
0
 /**
  * Adds a MIME Viewer action to the status text.
  *
  * @param string $action  Action ID.
  * @param string $text    Action description.
  * @param array $attr     Additional attributes.
  */
 public function addMimeAction($action, $text, array $attr = array())
 {
     $attr['mimevieweraction'] = $action;
     if (!is_null($this->_part)) {
         $attr['mimeviewerid'] = $this->_part->getMimeId();
     }
     $url = new Horde_Url('#');
     $this->addText($url->link($attr) . $text . '</a>');
 }
Esempio n. 3
0
 /**
  * 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);
 }
Esempio n. 4
0
 /**
  * Adds MIME parts to the tree instance.
  *
  * @param Horde_Tree_Renderer_Base tree   A tree instance.
  * @param Horde_Mime_Part $part           The MIME part to add.
  */
 protected function _addTreeNodes($tree, $part)
 {
     $mimeid = $part->getMimeId();
     $summary_mask = self::SUMMARY_ICON_RAW | self::SUMMARY_DESCRIP_LINK | self::SUMMARY_SIZE | self::SUMMARY_DOWNLOAD;
     if ($GLOBALS['prefs']->getValue('strip_attachments')) {
         $summary_mask += self::SUMMARY_STRIP;
     }
     $summary = $this->getSummary($mimeid, $summary_mask);
     $tree->addNode(array('id' => $mimeid, 'parent' => is_null($part->parent) ? null : $part->parent->getMimeId(), 'label' => sprintf('%s (%s) %s %s', $summary['description'], $summary['size'], $summary['download'], $summary['strip']), 'params' => array('class' => 'partsTreeDiv', 'icon' => $summary['icon'])));
 }
Esempio n. 5
0
 /**
  *
  * @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);
     }
 }
Esempio n. 6
0
File: Base.php Progetto: horde/horde
 /**
  * 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));
 }