Browse Source

Merge branch '7.x-ingest' of git://github.com/nigelgbanks/islandora into 7.x-ingest

pull/203/head
jonathangreen 12 years ago
parent
commit
391fa9e8f6
  1. 72
      includes/datastream.inc
  2. 17
      includes/globals.inc
  3. 2
      includes/ingest.form.inc
  4. 4
      islandora.api.php
  5. 6
      islandora.module
  6. 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) { function islandora_datastream_get_delete_link(FedoraDatastream $datastream) {
$datastreams = module_invoke_all('islandora_undeletable_datastreams', $datastream->parent->models); $datastreams = module_invoke_all('islandora_undeletable_datastreams', $datastream->parent->models);
if (in_array($datastream->id, $datastreams)) { $can_delete = !in_array($datastream->id, $datastreams);
return ''; 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) { * Gets the edit link.
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $ds_id); *
if (count($edit_registry) > 0 && user_access(FEDORA_METADATA_EDIT)) { * @param FedoraDatastream $datastream
return l(t('edit'), 'islandora/object/' . $object->id . '/datastream/' . $ds_id . '/edit'); * The datastream to generated the url to.
} */
else { function islandora_datastream_edit_get_link(FedoraDatastream $datastream) {
return ''; $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); $edit_count = count($edit_registry);
switch ($edit_count) {
if ($edit_count == 0) { case 0:
// No edit implementations. // No edit implementations.
drupal_set_message(t('There are no edit methods specified for this datastream.')); drupal_set_message(t('There are no edit methods specified for this datastream.'));
drupal_goto('islandora/object/' . $object->id . '/manage/datastreams'); drupal_goto("islandora/object/{$object->id}/manage/datastreams");
} break;
elseif ($edit_count == 1) { case 1:
// One registry implementation, go there // One registry implementation, go there
drupal_goto($edit_registry[0]['url']); drupal_goto($edit_registry[0]['url']);
} break;
else { default:
// Multiple edit routes registered // Multiple edit routes registered
return islandora_edit_datastream_registry_render($edit_registry); return islandora_edit_datastream_registry_render($edit_registry);
} }
} }
// @TODO: theme / preprocess /**
function islandora_edit_datastream_registry_render($edit_registry) { * Displays links to all the edit datastream registry items.
$output = array( *
* @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', '#type' => 'markup',
'#markup' => '', '#markup' => $markup,
); );
foreach ($edit_registry AS $edit_route) {
$output['#markup'] .= l($edit_route['name'], $edit_route['url']) . '<br/>';
}
return $output;
} }

17
includes/globals.inc

@ -321,8 +321,23 @@ function islandora_get_missing_datastreams_requirements(FedoraObject $object) {
* object. * object.
*/ */
function islandora_get_datastreams_requirements(FedoraObject $object) { function islandora_get_datastreams_requirements(FedoraObject $object) {
return islandora_get_datastreams_requirements_from_models($object->models);
}
/**
* Get the list of which datastreams are valid in the given set of models.
*
* @param array $models
* An array of content models PIDs from which to parse the DS-COMPOSITE-MODEL
* stream.
*
* @return array
* An associative array of associative arrays, merged from calls to
* islandora_get_datastreams_requirements_from_content_model().
*/
function islandora_get_datastreams_requirements_from_models(array $models) {
$dsids = array(); $dsids = array();
foreach ($object->models as $model) { foreach ($models as $model) {
$model = islandora_get_object_by_id($model); $model = islandora_get_object_by_id($model);
$dsids += islandora_get_datastreams_requirements_from_content_model($model); $dsids += islandora_get_datastreams_requirements_from_content_model($model);
} }

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) { foreach (islandora_build_hook_list(ISLANDORA_INGEST_STEP_HOOK, $models) as $hook) {
$steps = array_merge($steps, module_invoke_all($hook, $configuration)); $steps = array_merge($steps, module_invoke_all($hook, $configuration));
} }
// Remove NULL values.
$steps = array_filter($steps);
usort($steps, 'drupal_sort_weight'); usort($steps, 'drupal_sort_weight');
return $steps; return $steps;
} }

4
islandora.api.php

@ -235,6 +235,10 @@ function hook_islandora_undeletable_datastreams(array $models) {}
* - form_id: The form building function to call to get the form structure * - form_id: The form building function to call to get the form structure
* for this step. * for this step.
* - args: An array of arguments to pass to the form building function. * - args: An array of arguments to pass to the form building function.
* And may optionally include both:
* - module: A module from which we want to load an include.
* - file: A file to include (relative to the module's path, including the
* file's extension).
*/ */
function hook_islandora_ingest_steps(array $configuration) { function hook_islandora_ingest_steps(array $configuration) {
return array( return array(

6
islandora.module

@ -155,7 +155,7 @@ function islandora_menu() {
$items['islandora/object/%islandora_object/datastream/%islandora_datastream'] = array( $items['islandora/object/%islandora_object/datastream/%islandora_datastream'] = array(
'title' => 'View datastream', 'title' => 'View datastream',
'page callback' => 'islandora_view_datastream', 'page callback' => 'islandora_view_datastream',
'page arguments' => array(4), 'page arguments' => array(4, FALSE),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc', 'file' => 'includes/datastream.inc',
'access callback' => 'islandora_object_datastream_access_callback', 'access callback' => 'islandora_object_datastream_access_callback',
@ -176,10 +176,10 @@ function islandora_menu() {
'access arguments' => array(FEDORA_VIEW, 2, 4), 'access arguments' => array(FEDORA_VIEW, 2, 4),
'load arguments' => array('%map'), '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', 'title' => 'Edit datastream',
'page callback' => 'islandora_edit_datastream', 'page callback' => 'islandora_edit_datastream',
'page arguments' => array(2, 4), 'page arguments' => array(4),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc', 'file' => 'includes/datastream.inc',
'access callback' => 'islandora_object_datastream_access_callback', '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-mime', 'data' => $ds->mimeType),
array('class' => 'datastream-size', 'data' => islandora_datastream_get_human_readable_size($ds)), 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' => '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)), array('class' => 'datastream-delete', 'data' => islandora_datastream_get_delete_link($ds)),
); );
} }

Loading…
Cancel
Save