Browse Source

COLORADO-1628 Fix the breadcrumb path calculation to remove blanks

The current breadcrumb calculation takes the first <dc:title> tag in the DC
datastream.  The sorting order of the <dc:title> tags (in the case of more than
one tag) has empty tags appearing as the first items to be selected by the
query.  This fix alters the query to change the sort order to make empty tags
the last items to be selected and thus, if a non-empty tag exists it will be
selected as the name of the breadcrumb.

There is also a problem with the breadcrumb query processing that will attempt
to process failed queries.  The test for failure was incorrect and allowed some
failed queries to be treated as successes.  This resulted in recursively
calling the breadcrumb processing an additional 10 times and failing each time.
This resulted in 10 '>' symbols instead of an error message.  This fix tests
for falure and puts up an error message in the breadcrumb trail.

The breadcrumb calculation should be rewritten to be more robust.
pull/60/head
discoverygnoye 13 years ago
parent
commit
4ef6faa2fb
  1. 14
      ObjectHelper.inc

14
ObjectHelper.inc

@ -937,18 +937,22 @@ class ObjectHelper {
or <info:fedora/' . $pid . '> <fedora-rels-ext:isPartOf> $parentObject)
and $parentObject <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by $title';
order by $title desc';
$query_string = htmlentities(urlencode($query_string));
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=TRUE&format=CSV&limit=1&offset=0&lang=itql&stream=on&query=" . $query_string;
$result = preg_split('/[\r\n]+/', do_curl($url));
array_shift($result); // throw away first line
$matches = str_getcsv(join("\n", $result));
if ($matches !== FALSE) {
if (count($matches) >= 2) {
$parent = preg_replace('/^info:fedora\//', '', $matches[0]);
if (0 == strlen($matches[1])) {
$matches[1] = "Unlabeled Object";
}
$breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid);
if ($parent == variable_get('fedora_repository_pid', 'islandora:root')) {
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
@ -958,6 +962,10 @@ class ObjectHelper {
$this->getBreadcrumbs($parent, $breadcrumbs, $level - 1);
}
}
else {
$breadcrumbs[] = l("Path Calculation Error", 'fedora/repository/' . $pid);
}
}
}

Loading…
Cancel
Save