Browse Source

Merge pull request #611 from jordandukart/7.x-metadata-object-alter

Allow modules to modify which object is being loaded.
pull/612/head
Matthew Perry 9 years ago
parent
commit
2bb02b31c8
  1. 4
      includes/metadata.inc
  2. 22
      islandora.api.php
  3. 2
      islandora.module

4
includes/metadata.inc

@ -20,6 +20,8 @@ function islandora_retrieve_metadata_markup(AbstractObject $object, $print = FAL
$viewer = variable_get('islandora_metadata_display', 'dublin_core');
$markup = '';
if (isset($viewers[$viewer]['metadata callback'])) {
$hooks = islandora_build_hook_list(ISLANDORA_METADATA_OBJECT_ALTER, $object->models);
drupal_alter($hooks, $object);
$markup = call_user_func($viewers[$viewer]['metadata callback'], $object, $print);
// The callback doesn't have any markup provided for this particular object,
// default back to the dublin_core display.
@ -44,6 +46,8 @@ function islandora_retrieve_description_markup(AbstractObject $object) {
$viewer = variable_get('islandora_metadata_display', 'dublin_core');
$markup = '';
if (isset($viewers[$viewer]['description callback'])) {
$hooks = islandora_build_hook_list(ISLANDORA_METADATA_OBJECT_DESCRIPTION_ALTER, $object->models);
drupal_alter($hooks, $object);
$markup = call_user_func($viewers[$viewer]['description callback'], $object);
// The callback doesn't have any markup provided for this particular object,
// default back to the dublin_core display.

22
islandora.api.php

@ -795,6 +795,28 @@ function hook_islandora_metadata_display_info() {
);
}
/**
* Allows modifications to the object whose metadata is being rendered.
*
* @param AbstractObject $object
* An AbstractObject representing an object within Fedora.
*/
function hook_islandora_metadata_object_alter(AbstractObject &$object) {
$this_other_object = islandora_object_load('awild:indirectionappears');
$object = $this_other_object;
}
/**
* Allows modifications to the object whose metadata is being rendered.
*
* @param AbstractObject $object
* An AbstractObject representing an object within Fedora.
*/
function hook_islandora_metadata_object_description_alter(AbstractObject &$object) {
$this_other_object = islandora_object_load('awild:indirectionappears');
$object = $this_other_object;
}
/**
* Defines predicates to be searched for when constructing breadcrumbs.
*

2
islandora.module

@ -49,6 +49,8 @@ define('ISLANDORA_POST_INGEST_HOOK', 'islandora_ingest_post_ingest');
define('ISLANDORA_PRE_PURGE_OBJECT_HOOK', 'islandora_pre_purge_object');
define('ISLANDORA_POST_PURGE_OBJECT_HOOK', 'islandora_post_purge_object');
define('ISLANDORA_UPDATE_RELATED_OBJECTS_PROPERTIES_HOOK', 'islandora_update_related_objects_properties');
define('ISLANDORA_METADATA_OBJECT_ALTER', 'islandora_metadata_object');
define('ISLANDORA_METADATA_OBJECT_DESCRIPTION_ALTER', 'islandora_metadata_object_description');
define('ISLANDORA_BREADCRUMB_FILTER_PREDICATE_HOOK', 'islandora_get_breadcrumb_query_predicates');
// @todo Add Documentation.

Loading…
Cancel
Save