Browse Source

Updating extestion and mime detection on download to use drupals file_g=default_mimetype_mapping() funcitons.

pull/543/head
MorganDawe 10 years ago
parent
commit
2b2c5c8601
  1. 4
      includes/datastream.inc
  2. 9
      includes/utilities.inc

4
includes/datastream.inc

@ -30,6 +30,7 @@ function islandora_download_datastream(AbstractDatastream $datastream) {
* The version of the datastream to display * The version of the datastream to display
*/ */
function islandora_view_datastream(AbstractDatastream $datastream, $download = FALSE, $version = NULL) { function islandora_view_datastream(AbstractDatastream $datastream, $download = FALSE, $version = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
// XXX: Certain features of the Devel module rely on the use of "shutdown // XXX: Certain features of the Devel module rely on the use of "shutdown
// handlers", such as query logging... The problem is that they might blindly // handlers", such as query logging... The problem is that they might blindly
// add additional output which will break things if what is actually being // add additional output which will break things if what is actually being
@ -45,7 +46,6 @@ function islandora_view_datastream(AbstractDatastream $datastream, $download = F
return drupal_not_found(); return drupal_not_found();
} }
} }
header('Content-type: ' . $datastream->mimetype); header('Content-type: ' . $datastream->mimetype);
if ($datastream->controlGroup == 'M' || $datastream->controlGroup == 'X') { if ($datastream->controlGroup == 'M' || $datastream->controlGroup == 'X') {
header('Content-length: ' . $datastream->size); header('Content-length: ' . $datastream->size);
@ -53,7 +53,7 @@ function islandora_view_datastream(AbstractDatastream $datastream, $download = F
if ($download) { if ($download) {
// Browsers will not append all extensions. // Browsers will not append all extensions.
$mime_detect = new MimeDetect(); $mime_detect = new MimeDetect();
$extension = '.' . $mime_detect->getExtension($datastream->mimetype); $extension = '.' . islandora_get_extension_for_mimetype($datastream->mimetype);//$mime_detect->getExtension($datastream->mimetype);
// Prevent adding on a duplicate extension. // Prevent adding on a duplicate extension.
$label = $datastream->label; $label = $datastream->label;
$extension_length = strlen($extension); $extension_length = strlen($extension);

9
includes/utilities.inc

@ -46,6 +46,15 @@ function islandora_convert_bytes_to_human_readable($bytes, $precision = 2) {
} }
} }
function islandora_get_extension_for_mimetype($mimetype) {
module_load_include('inc', 'file', 'file.mimetypes.inc');
dsm($mimetype, "mimetype");
$mimetype_mapping = file_default_mimetype_mapping();
$extenstion_index = array_search($mimetype, $mimetype_mapping['mimetypes']);
$extenstion = array_search($extenstion_index, $mimetype_mapping['extensions']);
dsm($extenstion, "extenstion");
return $extenstion;
}
/** /**
* Add a file as managed if is not already. * Add a file as managed if is not already.
* *

Loading…
Cancel
Save