Browse Source

Merge branch '7.x' of github.com:Islandora/islandora into 7.x-metadata-object-alter

Conflicts:
	islandora.api.php
	islandora.module
pull/611/head
Jordan Dukart 9 years ago
parent
commit
89507c5ce3
  1. 13
      includes/breadcrumb.inc
  2. 14
      islandora.api.php
  3. 12
      islandora.module

13
includes/breadcrumb.inc

@ -54,6 +54,8 @@ function islandora_get_breadcrumbs($object) {
* An array of links representing the breadcrumb trail, "root" first. * An array of links representing the breadcrumb trail, "root" first.
*/ */
function islandora_get_breadcrumbs_recursive($pid, FedoraRepository $repository, array &$context = NULL) { function islandora_get_breadcrumbs_recursive($pid, FedoraRepository $repository, array &$context = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
// Before executing the query, we have a base case of accessing the top-level // Before executing the query, we have a base case of accessing the top-level
// collection. // collection.
if ($context === NULL) { if ($context === NULL) {
@ -102,9 +104,13 @@ EOQ;
$filter_map = function ($filter) { $filter_map = function ($filter) {
return "FILTER($filter)"; return "FILTER($filter)";
}; };
$collection_predicate_filters = "sameTerm(?collection_predicate, <fedora-rels-ext:isPartOf>)"; $object = islandora_object_load($pid);
$collection_predicate_filters .= " || sameTerm(?collection_predicate, <fedora-rels-ext:isMemberOfCollection>) || sameTerm(?collection_predicate, <fedora-rels-ext:isMemberOf>)"; $breadcrumb_predicates = islandora_invoke_hook_list(ISLANDORA_BREADCRUMB_FILTER_PREDICATE_HOOK, $object->models, array($object));
$query_filters[] = $collection_predicate_filters; $same_term_map = function ($predicate) {
return "sameTerm(?collection_predicate, <$predicate>)";
};
$collection_predicate_filters = array_map($same_term_map, $breadcrumb_predicates);
$query_filters[] = implode(' || ', $collection_predicate_filters);
$query_order = "ORDER BY DESC(?label)"; $query_order = "ORDER BY DESC(?label)";
$query = format_string($query, array( $query = format_string($query, array(
'!optionals' => !empty($query_optionals) ? ('OPTIONAL {{' . implode('} UNION {', $query_optionals) . '}}') : '', '!optionals' => !empty($query_optionals) ? ('OPTIONAL {{' . implode('} UNION {', $query_optionals) . '}}') : '',
@ -114,7 +120,6 @@ EOQ;
$query = format_string($query, array( $query = format_string($query, array(
'!pid' => $pid, '!pid' => $pid,
)); ));
$results = $repository->ri->sparqlQuery($query, 'unlimited'); $results = $repository->ri->sparqlQuery($query, 'unlimited');
if (count($results) > 0 && $context['level'] > 0) { if (count($results) > 0 && $context['level'] > 0) {

14
islandora.api.php

@ -816,3 +816,17 @@ function hook_islandora_metadata_object_description_alter(AbstractObject &$objec
$this_other_object = islandora_object_load('awild:indirectionappears'); $this_other_object = islandora_object_load('awild:indirectionappears');
$object = $this_other_object; $object = $this_other_object;
} }
/**
* Defines predicates to be searched for when constructing breadcrumbs.
*
* @return array
* An array containing strings of predicates to be ORed together to be
* matched on in SPARQL.
*/
function hook_islandora_get_breadcrumb_query_predicates() {
return array(
'somepredicate',
'someotherpredicate',
);
}

12
islandora.module

@ -51,6 +51,7 @@ define('ISLANDORA_POST_PURGE_OBJECT_HOOK', 'islandora_post_purge_object');
define('ISLANDORA_UPDATE_RELATED_OBJECTS_PROPERTIES_HOOK', 'islandora_update_related_objects_properties'); define('ISLANDORA_UPDATE_RELATED_OBJECTS_PROPERTIES_HOOK', 'islandora_update_related_objects_properties');
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');
// @todo Add Documentation. // @todo Add Documentation.
define('ISLANDORA_OBJECT_INGESTED_HOOK', 'islandora_object_ingested'); define('ISLANDORA_OBJECT_INGESTED_HOOK', 'islandora_object_ingested');
@ -2188,3 +2189,14 @@ function islandora_schedule_cache_clear_for_batch() {
// iterations/operations of a single batch. // iterations/operations of a single batch.
$batch['islandora_cache_clear_scheduled'] = TRUE; $batch['islandora_cache_clear_scheduled'] = TRUE;
} }
/**
* Implements hook_islandora_get_breadcrumb_query_predicates().
*/
function islandora_islandora_get_breadcrumb_query_predicates(AbstractObject $object) {
return array(
'fedora-rels-ext:isPartOf',
'fedora-rels-ext:isMemberOfCollection',
'fedora-rels-ext:isMemberOf',
);
}

Loading…
Cancel
Save