Browse Source

Moved building the edit registry to an includes function and changed teh context index.

pull/637/head
Matthew Perry 9 years ago
parent
commit
42f322930c
  1. 10
      includes/datastream.inc
  2. 22
      includes/utilities.inc
  3. 2
      islandora.api.php
  4. 3
      theme/theme.inc

10
includes/datastream.inc

@ -294,13 +294,9 @@ function islandora_datastream_get_url(AbstractDatastream $datastream, $type = 'd
* The datastream to edit.
*/
function islandora_edit_datastream(AbstractDatastream $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);
module_load_include('inc', 'islandora', 'includes/utilities');
$edit_registry = islandora_build_datastream_edit_registry($datastream->parent, $datastream);
$edit_count = count($edit_registry);
switch ($edit_count) {
case 0:

22
includes/utilities.inc

@ -946,3 +946,25 @@ function islandora_deployed_on_windows() {
}
return FALSE;
}
/**
* Build the edit registry for a given datastream.
*
* @param AbstractObject $object
* The object being edited.
* @param AbstractDatastream $datastream
* The datastream being edited.
*
* @return array
* The built edit registry array.
*/
function islandora_build_datastream_edit_registry($object, $datastream) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $datastream);
$context = array(
'object' => $object,
'datastream' => $datastream,
'original_edit_registry' => $edit_registry,
);
drupal_alter(ISLANDORA_EDIT_DATASTREAM_MODIFY_REGISTRY_HOOK, $edit_registry, $context);
return $edit_registry;
}

2
islandora.api.php

@ -870,7 +870,7 @@ function hook_islandora_edit_datastream_modify_registry_alter(&$edit_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}",
'url' => "islandora/custom_form/{$context['object']->id}/{$context['datastream']->id}",
'weight' => 1,
);
}

3
theme/theme.inc

@ -533,8 +533,9 @@ function theme_islandora_datastream_revert_link(array $vars) {
*/
function theme_islandora_datastream_edit_link(array $vars) {
$datastream = $vars['datastream'];
module_load_include('inc', 'islandora', 'includes/utilities');
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $datastream->parent, $datastream);
$edit_registry = islandora_build_datastream_edit_registry($datastream->parent, $datastream);
$can_edit = count($edit_registry) > 0 && islandora_datastream_access(ISLANDORA_METADATA_EDIT, $datastream);

Loading…
Cancel
Save