From c52034cccf2e39ab40cc9651e26c176c1fb26fee Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Wed, 3 Jun 2015 15:37:21 -0300 Subject: [PATCH] Still flip, but comment and handle the XML case. --- includes/mimetype.utils.inc | 6 +++++- islandora.module | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/mimetype.utils.inc b/includes/mimetype.utils.inc index deb7f13b..62c1824e 100644 --- a/includes/mimetype.utils.inc +++ b/includes/mimetype.utils.inc @@ -22,7 +22,11 @@ function islandora_get_extension_for_mimetype($mimetype) { $mimetype_mapping = file_mimetype_mapping(); $extension_index = array_search($mimetype, $mimetype_mapping['mimetypes']); 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'. diff --git a/islandora.module b/islandora.module index 2dec1fd9..10d6060f 100644 --- a/islandora.module +++ b/islandora.module @@ -1662,6 +1662,12 @@ function islandora_file_mimetype_mapping_alter(&$mapping) { end($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; } /**