Browse Source

Merge remote-tracking branch 'upstream/7.x-ingest' into 7.x-ingest

pull/203/head
Adam Vessey 12 years ago
parent
commit
30b8830d33
  1. 72
      includes/datastream.inc
  2. 2
      includes/ingest.form.inc
  3. 6
      islandora.module
  4. 2
      theme/islandora.theme.inc

72
includes/datastream.inc

@ -85,52 +85,60 @@ function islandora_datastream_get_url(FedoraDatastream $datastream, $type = 'dow
*/
function islandora_datastream_get_delete_link(FedoraDatastream $datastream) {
$datastreams = module_invoke_all('islandora_undeletable_datastreams', $datastream->parent->models);
if (in_array($datastream->id, $datastreams)) {
return '';
$can_delete = !in_array($datastream->id, $datastreams);
return $can_delete ? l(t('delete'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/delete") : '';
}
else {
return l(t('delete'), 'islandora/object/' . $datastream->parent->id . '/datastream/' . $datastream->id . '/delete');
}
}
function islandora_datastream_edit_get_link($object, $ds_id) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $ds_id);
if (count($edit_registry) > 0 && user_access(FEDORA_METADATA_EDIT)) {
return l(t('edit'), 'islandora/object/' . $object->id . '/datastream/' . $ds_id . '/edit');
}
else {
return '';
}
/**
* Gets the edit link.
*
* @param FedoraDatastream $datastream
* The datastream to generated the url to.
*/
function islandora_datastream_edit_get_link(FedoraDatastream $datastream) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream);
$can_edit = count($edit_registry) > 0 && user_access(FEDORA_METADATA_EDIT);
return $can_edit ? l(t('edit'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/edit") : '';
}
function islandora_edit_datastream($object, $ds_id) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $ds_id);
/**
* Display the edit datastream page.
*
* @param FedoraDatastream $datastream
* The datastream to edit.
*/
function islandora_edit_datastream(FedoraDatastream $datastream) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream);
$edit_count = count($edit_registry);
if ($edit_count == 0) {
switch ($edit_count) {
case 0:
// No edit implementations.
drupal_set_message(t('There are no edit methods specified for this datastream.'));
drupal_goto('islandora/object/' . $object->id . '/manage/datastreams');
}
elseif ($edit_count == 1) {
drupal_goto("islandora/object/{$object->id}/manage/datastreams");
break;
case 1:
// One registry implementation, go there
drupal_goto($edit_registry[0]['url']);
}
else {
break;
default:
// Multiple edit routes registered
return islandora_edit_datastream_registry_render($edit_registry);
}
}
// @TODO: theme / preprocess
function islandora_edit_datastream_registry_render($edit_registry) {
$output = array(
/**
* Displays links to all the edit datastream registry items.
*
* @param array $edit_registry
* A list of 'islandora_edit_datastream_registry' values.
*/
function islandora_edit_datastream_registry_render(array $edit_registry) {
$markup = '';
foreach ($edit_registry as $edit_route) {
$markup .= l($edit_route['name'], $edit_route['url']) . '<br/>';
}
return array(
'#type' => 'markup',
'#markup' => '',
'#markup' => $markup,
);
foreach ($edit_registry AS $edit_route) {
$output['#markup'] .= l($edit_route['name'], $edit_route['url']) . '<br/>';
}
return $output;
}

2
includes/ingest.form.inc

@ -420,6 +420,8 @@ function islandora_ingest_get_steps(array $configuration) {
foreach (islandora_build_hook_list(ISLANDORA_INGEST_STEP_HOOK, $models) as $hook) {
$steps = array_merge($steps, module_invoke_all($hook, $configuration));
}
// Remove NULL values.
$steps = array_filter($steps);
usort($steps, 'drupal_sort_weight');
return $steps;
}

6
islandora.module

@ -155,7 +155,7 @@ function islandora_menu() {
$items['islandora/object/%islandora_object/datastream/%islandora_datastream'] = array(
'title' => 'View datastream',
'page callback' => 'islandora_view_datastream',
'page arguments' => array(4),
'page arguments' => array(4, FALSE),
'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc',
'access callback' => 'islandora_object_datastream_access_callback',
@ -176,10 +176,10 @@ function islandora_menu() {
'access arguments' => array(FEDORA_VIEW, 2, 4),
'load arguments' => array('%map'),
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastreams/edit'] = array(
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/edit'] = array(
'title' => 'Edit datastream',
'page callback' => 'islandora_edit_datastream',
'page arguments' => array(2, 4),
'page arguments' => array(4),
'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc',
'access callback' => 'islandora_object_datastream_access_callback',

2
theme/islandora.theme.inc

@ -38,7 +38,7 @@ function islandora_preprocess_islandora_default_edit(&$variables) {
array('class' => 'datastream-mime', 'data' => $ds->mimeType),
array('class' => 'datastream-size', 'data' => islandora_datastream_get_human_readable_size($ds)),
array('class' => 'datastream-download', 'data' => l(t('download'), islandora_datastream_get_url($ds, 'download'))),
array('class' => 'datstream-edit', 'data' => islandora_datastream_edit_get_link($islandora_object, $ds->id)),
array('class' => 'datstream-edit', 'data' => islandora_datastream_edit_get_link($ds)),
array('class' => 'datastream-delete', 'data' => islandora_datastream_get_delete_link($ds)),
);
}

Loading…
Cancel
Save