diff --git a/includes/datastream.inc b/includes/datastream.inc
index d643b984..46435449 100644
--- a/includes/datastream.inc
+++ b/includes/datastream.inc
@@ -425,4 +425,56 @@ function islandora_datastream_get_url($ds, $type = 'download') {
else {
return "islandora/object/{$ds->parent->id}/datastream/{$ds->id}/$type";
}
+}
+
+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 '';
+ }
+}
+
+function islandora_edit_datastream($object_id, $ds_id) {
+ global $user;
+ try {
+ module_load_include('inc', 'islandora', 'RestConnection');
+ $restConnection = new RestConnection($user);
+ $object = new FedoraObject($object_id, $restConnection->repository);
+
+ $edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $ds_id);
+ $edit_count = count($edit_registry);
+
+ if ($edit_count == 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) {
+ // One registry implementation, go there
+ drupal_goto($edit_registry[0]['url']);
+ }
+ else {
+ // Multiple edit routes registered
+ return islandora_edit_datastream_registry_render($edit_registry);
+ }
+ } catch (Exception $e) {
+ drupal_set_message(t('Error getting Islandora edit method for %s ', array('%s' => $object_id)), 'error');
+ return;
+ }
+
+}
+
+//@TODO: theme / preprocess
+function islandora_edit_datastream_registry_render($edit_registry) {
+ $output = array(
+ '#type' => 'markup',
+ '#markup' => '',
+ );
+ foreach ($edit_registry AS $edit_route) {
+ $output['#markup'] .= l($edit_route['name'], $edit_route['url']) . '
';
+ }
+ return $output;
}
\ No newline at end of file
diff --git a/includes/ingest-menu.inc b/includes/ingest-menu.inc
index a27892b0..b2e795a2 100644
--- a/includes/ingest-menu.inc
+++ b/includes/ingest-menu.inc
@@ -22,7 +22,7 @@ function islandora_ingest_callback($collection_pid) {
}
elseif ($registry_count == 1) {
// One registry implementation, go there
- drupal_goto($ingest_registry[0]['url'] . "/$collection_pid");
+ drupal_goto($ingest_registry[0]['url']);
}
else {
// Multiple ingest routes registered
@@ -37,7 +37,7 @@ function islandora_ingest_registry_render($ingest_registry) {
'#markup' => '',
);
foreach ($ingest_registry AS $ingest_route) {
- $output['#markup'] .= l($ingest_route['name'], $ingest_route['url']. "/$collection_pid") . '
';
+ $output['#markup'] .= l($ingest_route['name'], $ingest_route['url']) . '
';
}
return $output;
}
\ No newline at end of file
diff --git a/islandora.module b/islandora.module
index 3e1dabe3..e86787c7 100644
--- a/islandora.module
+++ b/islandora.module
@@ -210,6 +210,7 @@ function islandora_menu() {
'page callback' => 'islandora_edit_datastream',
'page arguments' => array(2, 4),
'type' => MENU_CALLBACK,
+ 'file' => 'includes/datastream.inc',
'access arguments' => array(FEDORA_METADATA_EDIT),
);
@@ -672,7 +673,7 @@ function islandora_preprocess_islandora_default_edit(&$variables) {
array('data' => t('Type')),
array('data' => t('Mime type')),
array('data' => t('Size')),
- array('data' => t('Operations'), 'colspan' => '2'),
+ array('data' => t('Operations'), 'colspan' => '3'),
//array('data' => t('Delete')),
);
$table_attributes = array('class' => array('manage-datastreams'));
@@ -685,6 +686,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' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')),
);
}