Browse Source

islandora_objects object array alter

pull/614/head
qadan 9 years ago
parent
commit
47bf1523c3
  1. 28
      islandora.api.php
  2. 1
      islandora.module
  3. 10
      theme/theme.inc

28
islandora.api.php

@ -830,3 +830,31 @@ function hook_islandora_get_breadcrumb_query_predicates() {
'someotherpredicate',
);
}
/**
* Allows for the alteration of object arrays for the islandora_objects theme.
*
* The islandora_objects theme is used to render a view for multiple objects on
* a page, such as when viewing the objects in a collection. This hook is called
* on each object that is added to the islandora_objects array.
*
* Each object array contains the following:
*
* 'label' - the object label.
* 'class' - the class to add to the object's div on the page.
* 'link' - a link to the object, passed through l().
* 'thumb' - a link to the object as a thumbnail, passed through l().
* 'description' - the object description.
*
* @param array $object_array
* The object array to be added.
* @param array $object_info
* An associative array containing two keys: 'pid' for the object's PID, and
* 'object', which either contains the loaded object that the $object_array
* was generated from, or FALSE if it was unable to be loaded.
*/
function hook_islandora_objects_object_results_alter(&$object_array, $object_info) {
if (!$object_info['object']) {
$object_array['description'] = t('The object could not be loaded.');
}
}

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_DESCRIPTION_ALTER', 'islandora_metadata_object_description');
define('ISLANDORA_BREADCRUMB_FILTER_PREDICATE_HOOK', 'islandora_get_breadcrumb_query_predicates');
define('ISLANDORA_OBJECTS_DISPLAY_HOOK', 'islandora_objects_object_results');
// @todo Add Documentation.
define('ISLANDORA_OBJECT_INGESTED_HOOK', 'islandora_object_ingested');

10
theme/theme.inc

@ -283,7 +283,7 @@ function islandora_objects_object_mapper($object_id) {
$description = $dc['dc:description']['value'];
}
}
return array(
$return = array(
'label' => $o->label,
'class' => drupal_strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $o->id)),
'link' => l($o->label, $url, $link_options),
@ -293,7 +293,7 @@ function islandora_objects_object_mapper($object_id) {
}
else {
$link_options = array('html' => TRUE, 'attributes' => array('title' => t('(Unknown)')));
return array(
$return = array(
'label' => t('(Unknown)'),
'class' => drupal_strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $object_id)),
'link' => l(t('(Unknown)'), $url, $link_options),
@ -301,6 +301,12 @@ function islandora_objects_object_mapper($object_id) {
'description' => '',
);
}
$object_info = array(
'pid' => $object_id,
'object' => $o,
);
drupal_alter(ISLANDORA_OBJECTS_DISPLAY_HOOK, $return, $object_info);
return $return;
}
/**

Loading…
Cancel
Save