Browse Source

Added a drupal alter to allow for other modules to modify the datastream edit registry after it has been built.

pull/637/head
Matthew Perry 9 years ago
parent
commit
0ae1a25b73
  1. 9
      includes/datastream.inc
  2. 25
      islandora.api.php
  3. 1
      islandora.module

9
includes/datastream.inc

@ -295,6 +295,12 @@ function islandora_datastream_get_url(AbstractDatastream $datastream, $type = 'd
*/ */
function islandora_edit_datastream(AbstractDatastream $datastream) { function islandora_edit_datastream(AbstractDatastream $datastream) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream); $edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream);
$context = array(
'datastream_parent' => $datastream->parent,
'datastream' => $datastream,
'original_edit_registry' => $edit_registry,
);
drupal_alter(ISLANDORA_EDIT_DATASTREAM_MODIFY_REGISTRY_HOOK, $edit_registry, $context);
$edit_count = count($edit_registry); $edit_count = count($edit_registry);
switch ($edit_count) { switch ($edit_count) {
case 0: case 0:
@ -305,7 +311,8 @@ function islandora_edit_datastream(AbstractDatastream $datastream) {
case 1: case 1:
// One registry implementation, go there. // One registry implementation, go there.
drupal_goto($edit_registry[0]['url']); $edit_registry = reset($edit_registry);
drupal_goto($edit_registry['url']);
break; break;
default: default:

25
islandora.api.php

@ -849,3 +849,28 @@ function hook_islandora_get_breadcrumb_query_predicates() {
'someotherpredicate', 'someotherpredicate',
); );
} }
/**
* Use alter hook to modify registry paths before the paths are rendered.
*
* @param array $edit_registry
* The array of registry paths.
* @param array $context
* An associative array containing:
* - datastream_parent: The datastream parent.
* - datastream: The datastream being edited.
* - original_edit_registry: The original edit_registry prior to any
* modifications.
*/
function hook_islandora_edit_datastream_modify_registry_alter(&$edit_registry, $context) {
// Example: Remove xml form builder edit registry.
if (isset($edit_registry['xml_form_builder_edit_form_registry'])) {
unset($edit_registry['xml_form_builder_edit_form_registry']);
}
// Add custom form to replace the removed form builder edit_form.
$edit_registry['somemodule_custom_form'] = array(
'name' => t('Somemodule Custom Form'),
'url' => "islandora/custom_form/{$context['datastream_parent']->id}/{$context['datastream']->id}",
'weight' => 1,
);
}

1
islandora.module

@ -52,6 +52,7 @@ define('ISLANDORA_UPDATE_RELATED_OBJECTS_PROPERTIES_HOOK', 'islandora_update_rel
define('ISLANDORA_METADATA_OBJECT_ALTER', 'islandora_metadata_object'); define('ISLANDORA_METADATA_OBJECT_ALTER', 'islandora_metadata_object');
define('ISLANDORA_METADATA_OBJECT_DESCRIPTION_ALTER', 'islandora_metadata_object_description'); define('ISLANDORA_METADATA_OBJECT_DESCRIPTION_ALTER', 'islandora_metadata_object_description');
define('ISLANDORA_BREADCRUMB_FILTER_PREDICATE_HOOK', 'islandora_get_breadcrumb_query_predicates'); define('ISLANDORA_BREADCRUMB_FILTER_PREDICATE_HOOK', 'islandora_get_breadcrumb_query_predicates');
define('ISLANDORA_EDIT_DATASTREAM_MODIFY_REGISTRY_HOOK', 'islandora_edit_datastream_modify_registry');
// @todo Add Documentation. // @todo Add Documentation.
define('ISLANDORA_OBJECT_INGESTED_HOOK', 'islandora_object_ingested'); define('ISLANDORA_OBJECT_INGESTED_HOOK', 'islandora_object_ingested');

Loading…
Cancel
Save