getParts() public méthode

Get a list of all MIME subparts.
public getParts ( ) : array
Résultat array An array of the Horde_Mime_Part subparts.
Exemple #1
0
 /**
  * Converts armored input into a Horde_Mime_Part object.
  *
  * @param mixed $input  Armored input.
  * @param array $opts   Additional options:
  *   - charset: (string) Charset of the armored input.
  *
  * @return mixed  Either null if no PGP data was found, or a
  *                Horde_Mime_Part object.
  */
 public function armorToPart($input, array $opts = array())
 {
     $opts = array_merge(array('charset' => 'UTF-8'), $opts);
     $armor = Horde_Pgp_Armor::create($input);
     $new_part = new Horde_Mime_Part();
     $new_part->setType('multipart/mixed');
     foreach ($armor as $val) {
         switch (get_class($val)) {
             case 'Horde_Pgp_Element_Text':
                 $part = new Horde_Mime_Part();
                 $part->setType('text/plain');
                 $part->setCharset($opts['charset']);
                 $part->setContents($val->message[0]->data);
                 $new_part[] = $part;
                 break;
             case 'Horde_Pgp_Element_PrivateKey':
             case 'Horde_Pgp_Element_PublicKey':
                 $part = new Horde_Mime_Part();
                 $part->setType('application/pgp-keys');
                 $part->setContents(strval($val));
                 $new_part[] = $part;
                 break;
             case 'Horde_Pgp_Element_Message':
                 // TODO: Message can also be text or signature
                 $part = $this->_encryptBase($val);
                 $part->setMetadata(self::PGP_ARMOR, true);
                 $part['2']->setMetadata(self::PGP_CHARSET, isset($val->headers['Charset']) ? $val->headers['Charset'] : 'UTF-8');
                 $new_part[] = $part;
                 break;
             case 'Horde_Pgp_Element_SignedMessage':
                 $part = $this->_signPart($val->text, $val->signature);
                 $new_part[] = $part;
                 break;
         }
     }
     return count($new_part->getParts()) ? $new_part : null;
 }
Exemple #2
0
 /**
  * @param \Horde_Mime_Part $part
  * @param int $partNo
  */
 private function handleMultiPartMessage($part, $partNo)
 {
     $i = 1;
     foreach ($part->getParts() as $p) {
         $this->getPart($p, "{$partNo}.{$i}");
         $i++;
     }
 }
Exemple #3
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);
     }
 }
Exemple #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 to the
  *                                        tree, including its sub-parts.
  * @param string $parent                  The parent part's MIME id.
  */
 protected function _addTreeNodes($tree, $part, $parent = null)
 {
     $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' => $parent, 'label' => sprintf('%s (%s) %s %s', $summary['description'], $summary['size'], $summary['download'], $summary['strip']), 'params' => array('class' => 'partsTreeDiv', 'icon' => $summary['icon'])));
     foreach ($part->getParts() as $part) {
         $this->_addTreeNodes($tree, $part, $mimeid);
     }
 }