示例#1
0
文件: mime.php 项目: bermi/akelos
 static function getMimeType($acceptables)
 {
     // we group by 'quality'
     $grouped_acceptables = array();
     foreach ($acceptables as $acceptable) {
         $grouped_acceptables[$acceptable['q']][] = $acceptable['type'];
     }
     foreach ($grouped_acceptables as $q => $array_with_acceptables_of_same_quality) {
         foreach (AkMimeType::getRegistered() as $mime_type => $our_mime_type) {
             foreach ($array_with_acceptables_of_same_quality as $acceptable) {
                 if ($mime_type == $acceptable) {
                     return $our_mime_type;
                 }
             }
         }
     }
     return AkMimeType::lookupMimeType('default');
 }
示例#2
0
文件: request.php 项目: bermi/akelos
 public function lookupMimeType($mime_type)
 {
     $mime_types = AkMimeType::getRegistered();
     if (!isset($mime_types[$mime_type])) {
         throw new NotAcceptableException('Invalid content type. Please register new content types in your config/ using AkMimeType::register("application/vnd.ms-excel", "xls")');
     }
     return $mime_types[$mime_type];
 }