|
|
@ -53,8 +53,16 @@ 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 = '.' . $mime_detect->getExtension($datastream->mimetype); |
|
|
|
$filename = $datastream->label . '.' . $extension; |
|
|
|
|
|
|
|
|
|
|
|
// Prevent adding on a duplicate extension. |
|
|
|
|
|
|
|
$extension_length = strlen($extension); |
|
|
|
|
|
|
|
$duplicate_extension_position = strripos($datastream->label, $extension, -$extension_length); |
|
|
|
|
|
|
|
$filename = $datastream->label; |
|
|
|
|
|
|
|
if ($duplicate_extension_position === FALSE) { |
|
|
|
|
|
|
|
$filename .= $extension; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
header("Content-Disposition: attachment; filename=\"$filename\""); |
|
|
|
header("Content-Disposition: attachment; filename=\"$filename\""); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|