From 4ef6faa2fb5a774bb29ef8cb1dc2e648a73ca626 Mon Sep 17 00:00:00 2001 From: discoverygnoye Date: Tue, 15 Nov 2011 11:41:49 -0400 Subject: [PATCH] COLORADO-1628 Fix the breadcrumb path calculation to remove blanks The current breadcrumb calculation takes the first tag in the DC datastream. The sorting order of the 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. --- ObjectHelper.inc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 70f73d4b..d1e73b8c 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -937,18 +937,22 @@ class ObjectHelper { or $parentObject) and $parentObject ) minus $content - 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); + } } }