id, $breadcrumbs, $object->repository); if (isset($breadcrumbs[0])) { // Remove the actual object. unset($breadcrumbs[0]); } $breadcrumbs = array_reverse($breadcrumbs); return $breadcrumbs; } /** * Builds an array of drupal links for use in breadcrumbs. * * @todo Make fully recursive... * * @todo Could use some clean up, can't be called multiple times safely due to * the use of static variables. * * @param string $pid * THe object id whose parent will be fetched for the next link. * @param array $breadcrumbs * The list of existing bread-crumb links in reverse order. * @param FedoraRepository $repository * The fedora repository. */ function islandora_get_breadcrumbs_recursive($pid, array &$breadcrumbs, FedoraRepository $repository) { // Before executing the query, we hve a base case of accessing the // top-level collection static $max_level = 10; static $level = -1; if (count($breadcrumbs) === 0) { $level = $max_level; } $root = variable_get('islandora_repository_pid', 'islandora:root'); if ($pid == $root) { $breadcrumbs[] = l(menu_get_active_title(), 'islandora'); $breadcrumbs[] = l(t('Home'), ''); } 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 desc'; $results = $repository->ri->itqlQuery($query_string); if (count($results) > 0 && $level > 0) { $parent = $results[0]['parentObject']['value']; $this_title = $results[0]['title']['value']; if (empty($this_title)) { $this_title = t('-'); } $breadcrumbs[] = l($this_title, "islandora/object/$pid"); $level--; islandora_get_breadcrumbs_recursive($parent, $breadcrumbs, $repository); } else { // Add an non-link, as we don't know how to get back to the root. $breadcrumbs[] = '...'; // And render the last two links and break (on the next pass). islandora_get_breadcrumbs_recursive($root, $breadcrumbs, $repository); } } }