Browse Source

Use Sparql query for breadcrumbs.

pull/126/head
Adam Vessey 13 years ago
parent
commit
c76891ff25
  1. 52
      ObjectHelper.inc

52
ObjectHelper.inc

@ -987,21 +987,33 @@ class ObjectHelper {
$breadcrumbs[] = l(t('Home'), '<front>'); $breadcrumbs[] = l(t('Home'), '<front>');
} }
else { else {
$query_string = 'select $parentObject $title $content from <#ri> $sparql_query_string = <<<EOQ
where ( PREFIX fedora-model: <info:fedora/fedora-system:def/model#>
<info:fedora/' . $pid . '> <fedora-model:label> $title PREFIX rels-ext: <info:fedora/fedora-system:def/relations-external#>
and $parentObject <fedora-model:hasModel> $content SELECT ?parentObject ?title ?content
and ( FROM <#ri>
<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject WHERE {
or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject ?this fedora-model:label ?title ;
or <info:fedora/' . $pid . '> <fedora-rels-ext:isPartOf> $parentObject ?relationship ?parentObject .
) ?parentObject fedora-model:state fedora-model:Active ;
and $parentObject <fedora-model:state> <info:fedora/fedora-system:def/model#Active> fedora-model:hasModel ?content .
) FILTER(
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> sameTerm(?this, <info:fedora/$pid>) &&
order by $title desc'; (
sameTerm(?relationship, rels-ext:isMemberOfCollection) ||
if (count($results = self::performItqlQuery($query_string)) > 0 && $level > 0) { sameTerm(?relationship, rels-ext:isMemberOf) ||
sameTerm(?relationship, rels-ext:isPartOf)
) &&
!sameTerm(?content, <info:fedora/fedora-system:FedoraObject-3.0>)
) .
}
ORDER BY DESC(?title)
EOQ;
$results = self::performSparqlQuery($sparql_query_string);
$next_pid = NULL;
if (count($results) > 0 && $level > 0) {
$parent = $results[0]['parentObject']; $parent = $results[0]['parentObject'];
$this_title = $results[0]['title']; $this_title = $results[0]['title'];
@ -1011,13 +1023,17 @@ class ObjectHelper {
$breadcrumbs[] = l($this_title, "fedora/repository/$pid"); $breadcrumbs[] = l($this_title, "fedora/repository/$pid");
$level--; $next_pid = $parent;
$this->getBreadcrumbs($parent, $breadcrumbs);
} }
else { else {
watchdog('fedora_repository', 'Error generating breadcrumbs for %pid. Verify there exists relationships back up to %root. (May also be due to a hierarchy deeper than %max_depth).', array('%pid' => $pid, '%root' => $root, '%max_depth' => $max_depth), WATCHDOG_WARNING); watchdog('fedora_repository', 'Error generating breadcrumbs for %pid. Verify there exists relationships back up to %root. (May also be due to a hierarchy deeper than %max_depth).', array('%pid' => $pid, '%root' => $root, '%max_depth' => $max_depth), WATCHDOG_WARNING);
$breadcrumbs[] = '...'; //Add an non-link, as we don't know how to get back to the root. $breadcrumbs[] = '...'; //Add an non-link, as we don't know how to get back to the root.
$this->getBreadcrumbs($root, $breadcrumbs); //And render the last two links and break (on the next pass). $next_pid = $root; //And cue the last two links to render and break recursion (on the next pass).
}
if ($next_pid !== NULL) {
$level--;
$this->getBreadcrumbs($next_pid, $breadcrumbs);
} }
} }
} }

Loading…
Cancel
Save