From ac0b34cb39360449df8622fe1a47aeb0d194ce96 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Tue, 26 Apr 2011 19:48:39 -0300 Subject: [PATCH] ISLANDORA-249 getBreadcrumbs didn't properly deal with the case of top level objects. --- ObjectHelper.inc | 55 +++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 6bc4d8a9..1b503deb 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -850,34 +850,37 @@ class ObjectHelper { module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); // Before executing the query, we hve a base case of accessing the top-level collection global $base_url; - $query_string = 'select $parentObject $title $content from <#ri> - where ( $title - and $parentObject $content - and ( $parentObject - or $parentObject - or $parentObject) - and $parentObject ) - minus $content - order by $title'; - $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) { - $parent = preg_replace('/^info:fedora\//','',$matches[0]); - - $breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid); - if ($parent == variable_get('fedora_repository_pid', 'islandora:top')) { + if ($pid == variable_get('fedora_repository_pid', 'islandora:top')){ $breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); $breadcrumbs[] = l(t('Home'), $base_url); - - - } elseif ($level > 0) { - $this->getBreadcrumbs($parent, $breadcrumbs, $level - 1); + } else { + $query_string = 'select $parentObject $title $content from <#ri> + where ( $title + and $parentObject $content + and ( $parentObject + or $parentObject + or $parentObject) + and $parentObject ) + minus $content + order by $title'; + $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) { + $parent = preg_replace('/^info:fedora\//','',$matches[0]); + + $breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid); + if ($parent == variable_get('fedora_repository_pid', 'islandora:top')) { + $breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); + $breadcrumbs[] = l(t('Home'), $base_url); + } elseif ($level > 0) { + $this->getBreadcrumbs($parent, $breadcrumbs, $level - 1); + } } } }