Browse Source

Updated islandora to include datastream history page

pull/374/head
jonathangreen 12 years ago
parent
commit
13967dd4a5
  1. 2
      includes/add_datastream.form.inc
  2. 42
      includes/datastream.versions.inc
  3. 22
      islandora.module
  4. 146
      theme/theme.inc

2
includes/add_datastream.form.inc

@ -62,7 +62,7 @@ function islandora_add_datastream_form(array $form, array &$form_state, Abstract
'#element_validate' => array('islandora_add_datastream_form_field_does_not_contain_a_forward_slash'), '#element_validate' => array('islandora_add_datastream_form_field_does_not_contain_a_forward_slash'),
), ),
'file' => array( 'file' => array(
'#type' => 'managed_file', '#type' => 'file',
'#required' => TRUE, '#required' => TRUE,
'#title' => t('Upload Document'), '#title' => t('Upload Document'),
'#size' => 48, '#size' => 48,

42
includes/datastream.versions.inc

@ -0,0 +1,42 @@
<?php
function islandora_datastream_versions_table ($datastream) {
module_load_include('inc', 'islandora', 'includes/datastream');
module_load_include('inc', 'islandora', 'includes/utilities');
drupal_set_title("$datastream->id Previous Versions");
$header = array();
$header[] = array ('data' => 'Created Date');
$header[] = array('data' => t('Size'));
$header[] = array('data' => t('Label'));
$header[] = array('data' => t('Mime type'));
$rows = array();
foreach ($datastream as $version => $datastream_version) {
$row = array();
$row[] = array(
'class' => 'datastream-date',
'data' => theme('islandora_datastream_view_link', array(
'datastream' => $datastream,
'label' => $datastream_version->createdDate->format(DATE_RFC850),
'version' => $version,
)),
);
$row[] = array(
'class' => 'datastream-size',
'data' => islandora_datastream_get_human_readable_size($datastream_version),
);
$row[] = array(
'class' => 'datastream-label',
'data' => $datastream_version->label,
);
$row[] = array(
'class' => 'datastream-mime',
'data' => $datastream_version->mimeType,
);
$rows[] = $row;
}
return theme('table', array('header' => $header, 'rows' => $rows));
}

22
islandora.module

@ -33,6 +33,7 @@ define('FEDORA_ADD_DS', 'add fedora datastreams');
define('FEDORA_INGEST', 'ingest fedora objects'); define('FEDORA_INGEST', 'ingest fedora objects');
define('FEDORA_PURGE', 'delete fedora objects and datastreams'); define('FEDORA_PURGE', 'delete fedora objects and datastreams');
define('FEDORA_MANAGE_PROPERTIES', 'manage object properties'); define('FEDORA_MANAGE_PROPERTIES', 'manage object properties');
define('ISLANDORA_VIEW_DATASTREAM_HISTORY', 'view old datastream versions');
// Hooks. // Hooks.
define('ISLANDORA_VIEW_HOOK', 'islandora_view_object'); define('ISLANDORA_VIEW_HOOK', 'islandora_view_object');
@ -233,6 +234,16 @@ function islandora_menu() {
'access arguments' => array(FEDORA_PURGE, 4), 'access arguments' => array(FEDORA_PURGE, 4),
'load arguments' => array(2), 'load arguments' => array(2),
); );
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/versions'] = array(
'title' => 'Datastream Versions',
'page arguments' => array(4),
'page callback' => 'islandora_datastream_versions_table',
'file' => 'includes/datastream.versions.inc',
'type' => MENU_CALLBACK,
'access callback' => 'islandora_datastream_access',
'access arguments' => array(ISLANDORA_VIEW_DATASTREAM_HISTORY, 4),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/print'] = array( $items['islandora/object/%islandora_object/print'] = array(
'title' => 'Print Object', 'title' => 'Print Object',
'page callback' => 'islandora_print_object', 'page callback' => 'islandora_print_object',
@ -270,6 +281,7 @@ function islandora_admin_paths() {
$paths['islandora/object/*/manage*'] = TRUE; $paths['islandora/object/*/manage*'] = TRUE;
$paths['islandora/object/*/delete'] = TRUE; $paths['islandora/object/*/delete'] = TRUE;
$paths['islandora/object/*/datastream/*/edit'] = TRUE; $paths['islandora/object/*/datastream/*/edit'] = TRUE;
$paths['islandora/object/*/datastream/*/versions'] = TRUE;
return $paths; return $paths;
} }
@ -333,12 +345,16 @@ function islandora_theme() {
), ),
'islandora_datastream_view_link' => array( 'islandora_datastream_view_link' => array(
'file' => 'theme/theme.inc', 'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL), 'variables' => array('datastream' => NULL, 'version' => NULL, 'label' => NULL),
), ),
'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),
), ),
'islandora_datastream_version_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL),
),
); );
} }
@ -371,6 +387,10 @@ function islandora_permission() {
'title' => t('Manage object properties'), 'title' => t('Manage object properties'),
'description' => t('Modify object labels, owner IDs, and states.'), 'description' => t('Modify object labels, owner IDs, and states.'),
), ),
ISLANDORA_VIEW_DATASTREAM_HISTORY => array(
'title' => t('View datastream history'),
'description' => t('View all previous versions of a datastream.'),
),
); );
} }

146
theme/theme.inc

@ -15,59 +15,71 @@ function islandora_preprocess_islandora_default_edit(array &$variables) {
$variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id; $variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id;
module_load_include('inc', 'islandora', 'includes/datastream'); module_load_include('inc', 'islandora', 'includes/datastream');
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$header = array( $header = array();
array('data' => t('ID')), $header[] = array('data' => t('ID'));
array('data' => t('Label')), $header[] = array('data' => t('Label'));
array('data' => t('Type')), $header[] = array('data' => t('Type'));
array('data' => t('Mime type')), $header[] = array('data' => t('Mime type'));
array('data' => t('Size')), $header[] = array('data' => t('Size'));
array('data' => t('Operations'), 'colspan' => '3'), if (user_access(ISLANDORA_VIEW_DATASTREAM_HISTORY)) {
); $header[] = array('data' => t('Versions'));
}
$header[] = array('data' => t('Operations'), 'colspan' => '3');
$table_attributes = array('class' => array('manage-datastreams')); $table_attributes = array('class' => array('manage-datastreams'));
$rows = array(); $rows = array();
foreach ($islandora_object as $ds) { foreach ($islandora_object as $ds) {
$rows[] = array( $row = array();
array( $row[] = array(
'class' => 'datastream-id', 'class' => 'datastream-id',
'data' => theme('islandora_datastream_view_link', array( 'data' => theme('islandora_datastream_view_link', array(
'datastream' => $ds, 'datastream' => $ds,
)), )),
), );
array( $row[] = array(
'class' => 'datastream-label', 'class' => 'datastream-label',
'data' => $ds->label, 'data' => $ds->label,
), );
array( $row[] = array(
'class' => 'datastream-control', 'class' => 'datastream-control',
'data' => islandora_control_group_to_human_readable($ds->controlGroup), 'data' => islandora_control_group_to_human_readable($ds->controlGroup),
), );
array( $row[] = array(
'class' => 'datastream-mime', 'class' => 'datastream-mime',
'data' => $ds->mimeType, 'data' => $ds->mimeType,
), );
array( $row[] = array(
'class' => 'datastream-size', 'class' => 'datastream-size',
'data' => islandora_datastream_get_human_readable_size($ds), 'data' => islandora_datastream_get_human_readable_size($ds),
), );
array( if (user_access(ISLANDORA_VIEW_DATASTREAM_HISTORY)) {
'class' => 'datastream-download', $row[] = array(
'data' => theme('islandora_datastream_download_link', array( 'class' => 'datastream-versions',
'datastream' => $ds, 'data' => theme('islandora_datastream_version_link', array(
)),
),
array(
'class' => 'datstream-edit',
'data' => theme('islandora_datastream_edit_link', array(
'datastream' => $ds,
)),
),
array(
'class' => 'datastream-delete',
'data' => theme('islandora_datastream_delete_link', array(
'datastream' => $ds, 'datastream' => $ds,
)), )),
), );
}
$row[] = array(
'class' => 'datastream-download',
'data' => theme('islandora_datastream_download_link', array(
'datastream' => $ds,
)),
); );
$row[] = array(
'class' => 'datstream-edit',
'data' => theme('islandora_datastream_edit_link', array(
'datastream' => $ds,
)),
);
$row[] = array(
'class' => 'datastream-delete',
'data' => theme('islandora_datastream_delete_link', array(
'datastream' => $ds,
)),
);
$rows[] = $row;
} }
$caption = $islandora_object->label . ' - ' . $islandora_object->id; $caption = $islandora_object->label . ' - ' . $islandora_object->id;
$table = array( $table = array(
@ -261,10 +273,28 @@ function theme_islandora_datastream_view_link(array $vars) {
$datastream = $vars['datastream']; $datastream = $vars['datastream'];
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$label = check_plain($datastream->id); if($vars['label'] === NULL) {
return islandora_datastream_access(FEDORA_VIEW_OBJECTS, $datastream) ? $label = check_plain($datastream->id);
l($label, islandora_datastream_get_url($datastream, 'view')) : }
$label; else {
$label = check_plain($vars['label']);
}
if($vars['version'] === NULL) {
$perm = FEDORA_VIEW_OBJECTS;
$query = array();
}
else {
$perm = ISLANDORA_VIEW_DATASTREAM_HISTORY;
$query = array('version' => $vars['version']);
}
if (islandora_datastream_access($perm, $datastream)) {
return l($label, islandora_datastream_get_url($datastream, 'view'), array('query' => $query));
}
else {
return $label;
}
} }
/** /**
@ -304,3 +334,17 @@ function theme_islandora_datastream_edit_link(array $vars) {
l(t('edit'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/edit") : l(t('edit'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/edit") :
''; '';
} }
function theme_islandora_datastream_version_link(array $vars) {
$datastream = $vars['datastream'];
module_load_include('inc', 'islandora', 'includes/utilities');
$see_history = islandora_datastream_access(ISLANDORA_VIEW_DATASTREAM_HISTORY, $datastream);
if($see_history) {
return l(count($datastream), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/versions");
}
else {
return '';
}
}
Loading…
Cancel
Save