Exemplo n.º 1
0
 /**
  * Return default MIME-type for the specified extension.
  *
  * @param string $type MIME-type
  *
  * @return string A file extension without leading period.
  */
 function getExtension($type)
 {
     include_once 'MIME/Type.php';
     // Strip parameters and comments.
     $type = MIME_Type::getMedia($type) . '/' . MIME_Type::getSubType($type);
     $extension = array_search($type, $this->extensionToType);
     if ($extension === false) {
         return PEAR::raiseError("Sorry, couldn't determine extension.");
     }
     return $extension;
 }
Exemplo n.º 2
0
 /**
  * Is this a vendor MIME type?
  *
  * @note   Vendor types are denoted with a leading 'vnd. in the subtype.
  * @param  string  $type MIME type to check
  * @return boolean true if $type is a vendor type, false otherwise
  * @static
  */
 function isVendor($type)
 {
     if (substr(MIME_Type::getSubType($type), 0, 4) == 'vnd.') {
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  *
  */
 public function testGetSubType()
 {
     $this->assertEquals('plain', MIME_Type::getSubType('text/plain'));
     $this->assertEquals('ogg', MIME_Type::getSubType('application/ogg'));
     $this->assertEquals('*', MIME_Type::getSubType('*/*'));
     $this->assertEquals('plain', MIME_Type::getSubType('text/plain;a=b'));
 }