Browse Source

Themify datastream link creation.

pull/352/head
Adam Vessey 12 years ago
parent
commit
fa34498130
  1. 38
      includes/datastream.inc
  2. 16
      islandora.module
  3. 88
      theme/theme.inc

38
includes/datastream.inc

@ -84,9 +84,12 @@ function islandora_datastream_get_url(AbstractDatastream $datastream, $type = 'd
* The datastream to generated the url to. * The datastream to generated the url to.
*/ */
function islandora_datastream_get_delete_link(AbstractDatastream $datastream) { function islandora_datastream_get_delete_link(AbstractDatastream $datastream) {
$datastreams = module_invoke_all('islandora_undeletable_datastreams', $datastream->parent->models); $message = islandora_deprecated('7.x-1.2', 'Use the "islandora_datastream_delete_link" theme implementation.');
$can_delete = !in_array($datastream->id, $datastreams) && islandora_datastream_access(FEDORA_PURGE, $datastream); trigger_error($message, E_USER_DEPRECATED);
return $can_delete ? l(t('delete'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/delete") : '';
return theme('islandora_datastream_delete_link', array(
'datastream' => $datastream,
));
} }
/** /**
@ -96,9 +99,12 @@ function islandora_datastream_get_delete_link(AbstractDatastream $datastream) {
* The datastream to generated the url to. * The datastream to generated the url to.
*/ */
function islandora_datastream_edit_get_link(AbstractDatastream $datastream) { function islandora_datastream_edit_get_link(AbstractDatastream $datastream) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream); $message = islandora_deprecated('7.x-1.2', 'Use the "islandora_datastream_edit_link" theme implementation.');
$can_edit = count($edit_registry) > 0 && islandora_datastream_access(FEDORA_METADATA_EDIT, $datastream); trigger_error($message, E_USER_DEPRECATED);
return $can_edit ? l(t('edit'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/edit") : '';
return theme('islandora_datastream_edit_link', array(
'datastream' => $datastream,
));
} }
/** /**
@ -156,10 +162,12 @@ function islandora_edit_datastream_registry_render(array $edit_registry) {
* user is not allowed to see the given datastream. * user is not allowed to see the given datastream.
*/ */
function islandora_datastream_get_download_link(AbstractDatastream $datastream) { function islandora_datastream_get_download_link(AbstractDatastream $datastream) {
$label = t('download'); $message = islandora_deprecated('7.x-1.2', 'Use the "islandora_datastream_download_link" theme implementation.');
return islandora_datastream_access(FEDORA_VIEW_OBJECTS, $datastream) ? trigger_error($message, E_USER_DEPRECATED);
l($label, islandora_datastream_get_url($datastream, 'download')) :
''; return theme('islandora_datastream_download_link', array(
'datastream' => $datastream,
));
} }
/** /**
@ -173,8 +181,10 @@ function islandora_datastream_get_download_link(AbstractDatastream $datastream)
* datastream ID if the user is not allowed to see the given datastream. * datastream ID if the user is not allowed to see the given datastream.
*/ */
function islandora_datastream_get_view_link(AbstractDatastream $datastream) { function islandora_datastream_get_view_link(AbstractDatastream $datastream) {
$label = check_plain($datastream->id); $message = islandora_deprecated('7.x-1.2', 'Use the "islandora_datastream_view_link" theme implementation.');
return islandora_datastream_access(FEDORA_VIEW_OBJECTS, $datastream) ? trigger_error($message, E_USER_DEPRECATED);
l($label, islandora_datastream_get_url($datastream, 'view')) :
$label; return theme('islandora_datastream_view_link', array(
'datastream' => $datastream,
));
} }

16
islandora.module

@ -322,6 +322,22 @@ function islandora_theme() {
'template' => 'theme/islandora-objects-list', 'template' => 'theme/islandora-objects-list',
'variables' => array('objects' => NULL), 'variables' => array('objects' => NULL),
), ),
'islandora_datastream_edit_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL),
),
'islandora_datastream_delete_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL),
),
'islandora_datastream_view_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL),
),
'islandora_datastream_download_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL),
),
); );
} }

88
theme/theme.inc

@ -29,7 +29,9 @@ function islandora_preprocess_islandora_default_edit(array &$variables) {
$rows[] = array( $rows[] = array(
array( array(
'class' => 'datastream-id', 'class' => 'datastream-id',
'data' => islandora_datastream_get_view_link($ds), 'data' => theme('islandora_datastream_view_link', array(
'datastream' => $ds,
)),
), ),
array( array(
'class' => 'datastream-label', 'class' => 'datastream-label',
@ -49,15 +51,21 @@ function islandora_preprocess_islandora_default_edit(array &$variables) {
), ),
array( array(
'class' => 'datastream-download', 'class' => 'datastream-download',
'data' => islandora_datastream_get_download_link($ds), 'data' => theme('islandora_datastream_download_link', array(
'datastream' => $ds,
)),
), ),
array( array(
'class' => 'datstream-edit', 'class' => 'datstream-edit',
'data' => islandora_datastream_edit_get_link($ds), 'data' => theme('islandora_datastream_edit_link', array(
'datastream' => $ds,
)),
), ),
array( array(
'class' => 'datastream-delete', 'class' => 'datastream-delete',
'data' => islandora_datastream_get_delete_link($ds), 'data' => theme('islandora_datastream_delete_link', array(
'datastream' => $ds,
)),
), ),
); );
} }
@ -224,3 +232,75 @@ function islandora_preprocess_islandora_objects(array &$variables) {
$module_path = drupal_get_path('module', 'islandora'); $module_path = drupal_get_path('module', 'islandora');
drupal_add_css("$module_path/css/islandora.objects.css"); drupal_add_css("$module_path/css/islandora.objects.css");
} }
/**
* Renders a link to allow downloading of a datatream.
*
* @param array $vars
* An array containing:
* - datastream: An AbstractDatastream for which to generate a download link.
*/
function theme_islandora_datastream_download_link(array $vars) {
$datastream = $vars['datastream'];
module_load_include('inc', 'islandora', 'includes/utilities');
$label = t('download');
return islandora_datastream_access(FEDORA_VIEW_OBJECTS, $datastream) ?
l($label, islandora_datastream_get_url($datastream, 'download')) :
'';
}
/**
* Renders a link to allow viewing of a datatream.
*
* @param array $vars
* An array containing:
* - datastream: An AbstractDatastream for which to generate a view link.
*/
function theme_islandora_datastream_view_link(array $vars) {
$datastream = $vars['datastream'];
module_load_include('inc', 'islandora', 'includes/utilities');
$label = check_plain($datastream->label);
return islandora_datastream_access(FEDORA_VIEW_OBJECTS, $datastream) ?
l($label, islandora_datastream_get_url($datastream, 'view')) :
$label;
}
/**
* Renders a link to allow deleting of a datatream.
*
* @param array $vars
* An array containing:
* - datastream: An AbstractDatastream for which to generate a delete link.
*/
function theme_islandora_datastream_delete_link(array $vars) {
$datastream = $vars['datastream'];
$datastreams = module_invoke_all('islandora_undeletable_datastreams', $datastream->parent->models);
$can_delete = !in_array($datastream->id, $datastreams) && islandora_datastream_access(FEDORA_PURGE, $datastream);
return $can_delete ?
l(t('delete'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/delete") :
'';
}
/**
* Renders a link to allow editing of a datatream.
*
* @param array $vars
* An array containing:
* - datastream: An AbstractDatastream for which to generate a edit link.
*/
function theme_islandora_datastream_edit_link(array $vars) {
$datastream = $vars['datastream'];
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream);
$can_edit = count($edit_registry) > 0 && islandora_datastream_access(FEDORA_METADATA_EDIT, $datastream);
return $can_edit ?
l(t('edit'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/edit") :
'';
}

Loading…
Cancel
Save