/** * Return the descriptive part label, making sure it is not empty. * * @param Horde_Mime_Part $part The MIME Part object. * @param boolean $use_descrip Use description? If false, uses name. * * @return string The part label (non-empty). */ public function getPartName(Horde_Mime_Part $part, $use_descrip = false) { $name = $use_descrip ? $part->getDescription(true) : $part->getName(true); if ($name) { return $name; } switch ($ptype = $part->getPrimaryType()) { case 'multipart': if ($part->getSubType() == 'related' && ($view_id = $part->getMetaData('viewable_part')) && ($viewable = $this->getMimePart($view_id, array('nocontents' => true)))) { return $this->getPartName($viewable, $use_descrip); } /* Fall-through. */ /* Fall-through. */ case 'application': case 'model': $ptype = $part->getSubType(); break; } switch ($ptype) { case 'audio': return _("Audio"); case 'image': return _("Image"); case 'message': case '': case Horde_Mime_Part::UNKNOWN: return _("Message"); case 'multipart': return _("Multipart"); case 'text': return _("Text"); case 'video': return _("Video"); default: // Attempt to translate this type, if possible. Odds are that // it won't appear in the dictionary though. return _(Horde_String::ucfirst($ptype)); } }