Horde_Mime_Part::findBody PHP Method

findBody() public method

"Body" data is the first text part under this part.
public findBody ( string $subtype = null ) : mixed
$subtype string Specifically search for this subtype.
return mixed The MIME ID of the main body part, or null if a body part is not found.
    public function findBody($subtype = null)
    {
        $this->buildMimeIds();
        foreach ($this->partIterator() as $val) {
            $id = $val->getMimeId();
            if ($val->getPrimaryType() == 'text' && (intval($id) === 1 || !$this->getMimeId()) && (is_null($subtype) || $val->getSubType() == $subtype) && $val->getDisposition() !== 'attachment') {
                return $id;
            }
        }
        return null;
    }

Usage Example

Example #1
0
 protected function _isAttachment($part)
 {
     if ($part->getDisposition() == 'attachment') {
         return true;
     }
     $id = $part->getMimeId();
     $mime_type = $part->getType();
     switch ($mime_type) {
         case 'text/plain':
             if (!($this->_part->findBody('plain') == $id)) {
                 return true;
             }
             return false;
         case 'text/html':
             if (!($this->_part->findBody('html') == $id)) {
                 return true;
             }
             return false;
         case 'application/pkcs7-signature':
         case 'application/x-pkcs7-signature':
             return false;
     }
     list($ptype, ) = explode('/', $mime_type, 2);
     switch ($ptype) {
         case 'message':
             return in_array($mime_type, array('message/rfc822', 'message/disposition-notification'));
         case 'multipart':
             return false;
         default:
             return true;
     }
 }
All Usage Examples Of Horde_Mime_Part::findBody