Browse Source

ISLANDORA-1748 -- add hook_islandora_datastream_filename_alter(). (#706)

* ISLANDORA-1748 -- add hook_datastream_filename_alter().

Co-authored-by: Diego Pino Navarro <DiegoPino@users.noreply.github.com>
pull/711/head
Pat Dunlavey 7 years ago committed by Rosemary Le Faive
parent
commit
d8b8b4f6dc
  1. 4
      includes/datastream.inc
  2. 21
      islandora.api.php

4
includes/datastream.inc

@ -63,6 +63,10 @@ function islandora_view_datastream(AbstractDatastream $datastream, $download = F
if ($duplicate_extension_position === FALSE) {
$filename .= $extension;
}
// Allow other modules to modify or replace the filename.
drupal_alter('islandora_datastream_filename', $filename, $datastream);
header("Content-Disposition: attachment; filename=\"$filename\"");
}

21
islandora.api.php

@ -945,3 +945,24 @@ function callback_islandora_breadcrumbs_backends(AbstractObject $object) {
// Do something to get an array of breadcrumb links for $object, root first.
return array($root_link, $collection_link, $object_link);
}
/**
* Permit modules to alter the filename of a downloaded datastream.
*
* @param string $filename
* The filename being created.
*
* @param AbstractDatastream $datastream
* The datastream object being downloaded.
*/
function hook_islandora_datastream_filename_alter(&$filename, AbstractDatastream $datastream) {
// Example taken from islandora_datastream_filenamer.
$pattern = variable_get('islandora_ds_download_filename_pattern', FALSE);
if ($pattern) {
$filename = token_replace($pattern,
array('datastream' => $datastream),
array('clear' => TRUE)
);
}
}

Loading…
Cancel
Save