Horde_Mime_Part::getName PHP Method

getName() public method

Get the name of this part.
public getName ( boolean $default = false ) : string
$default boolean If the name parameter doesn't exist, should we use the default name from the description parameter?
return string The name of the part.
    public function getName($default = false)
    {
        if (!($name = $this->getDispositionParameter('filename')) && !($name = $this->getContentTypeParameter('name')) && $default) {
            $name = preg_replace('|\\W|', '_', $this->getDescription(false));
        }
        return $name;
    }

Usage Example

Example #1
0
 /**
  * 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;
 }
All Usage Examples Of Horde_Mime_Part::getName