Browse Source

Still flip, but comment and handle the XML case.

pull/608/head
Jordan Dukart 9 years ago
parent
commit
c52034cccf
  1. 6
      includes/mimetype.utils.inc
  2. 6
      islandora.module

6
includes/mimetype.utils.inc

@ -22,7 +22,11 @@ function islandora_get_extension_for_mimetype($mimetype) {
$mimetype_mapping = file_mimetype_mapping(); $mimetype_mapping = file_mimetype_mapping();
$extension_index = array_search($mimetype, $mimetype_mapping['mimetypes']); $extension_index = array_search($mimetype, $mimetype_mapping['mimetypes']);
if ($extension_index !== FALSE) { if ($extension_index !== FALSE) {
$extension = array_search($extension_index, $mimetype_mapping['extensions']); // Reversing such that any altered values take precedence over the default
// mappings. As such we need to handle the case of application/xml mapping
// to .xml.
$mime_array_flipped = array_reverse($mimetype_mapping['extensions']);
$extension = array_search($extension_index, $mime_array_flipped);
} }
// We can only have one mapping in drupal for 'xml'. // We can only have one mapping in drupal for 'xml'.

6
islandora.module

@ -1662,6 +1662,12 @@ function islandora_file_mimetype_mapping_alter(&$mapping) {
end($mapping['mimetypes']); end($mapping['mimetypes']);
$mapping['extensions'][$ext] = key($mapping['mimetypes']); $mapping['extensions'][$ext] = key($mapping['mimetypes']);
} }
// Get the current XML mapping and unset it so it comes last when we do our
// reverse when getting mimetypes from extensions for use in downloads.
// @see islandora_get_extension_for_mimetype.
$xml_int = $mapping['extensions']['xml'];
unset($mapping['extensions']['xml']);
$mapping['extensions']['xml'] = $xml_int;
} }
/** /**

Loading…
Cancel
Save