Browse Source

Merge pull request #727 from dheles/7.x-ISLANDORA-2480

Add optional label text to datastream download links
8.x0
Diego Pino Navarro 5 years ago committed by GitHub
parent
commit
52010c8ad3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      islandora.module
  2. 9
      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',

9
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');
$label = t('download'); if ($vars['label'] === NULL) {
$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