Browse Source

Add optional label text to datastream download links

pull/727/head
dheles 5 years ago
parent
commit
0044efd753
No known key found for this signature in database
GPG Key ID: CAD908D45D48894F
  1. 5
      islandora.module
  2. 7
      theme/theme.inc

5
islandora.module

@ -537,7 +537,10 @@ function islandora_theme() {
), ),
'islandora_datastream_download_link' => array( 'islandora_datastream_download_link' => array(
'file' => 'theme/theme.inc', 'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL), 'variables' => array(
'datastream' => NULL,
'label' => NULL,
),
), ),
'islandora_datastream_version_link' => array( 'islandora_datastream_version_link' => array(
'file' => 'theme/theme.inc', 'file' => 'theme/theme.inc',

7
theme/theme.inc

@ -404,6 +404,7 @@ function template_process_islandora_objects_subset(&$variables) {
* @param array $vars * @param array $vars
* An array containing: * An array containing:
* - datastream: An AbstractDatastream for which to generate a download link. * - datastream: An AbstractDatastream for which to generate a download link.
* - label: (Optional) The label for the link.
* *
* @return string * @return string
* Markup containing the download url if the user has access, empty otherwise. * Markup containing the download url if the user has access, empty otherwise.
@ -412,7 +413,13 @@ function theme_islandora_datastream_download_link(array $vars) {
$datastream = $vars['datastream']; $datastream = $vars['datastream'];
module_load_include('inc', 'islandora', 'includes/datastream'); module_load_include('inc', 'islandora', 'includes/datastream');
if ($vars['label'] === NULL) {
$label = t('download'); $label = t('download');
}
else {
$label = check_plain($vars['label']);
}
return islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $datastream) ? return islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $datastream) ?
l($label, islandora_datastream_get_url($datastream, 'download')) : l($label, islandora_datastream_get_url($datastream, 'download')) :
''; '';

Loading…
Cancel
Save