id, $object->repository); array_pop($breadcrumbs); return $breadcrumbs; } /** * Builds an array of drupal links for use in breadcrumbs. * * @todo Make fully recursive... * * @param string $pid * The object id whose parent will be fetched for the next link. * @param FedoraRepository $repository * The fedora repository. * @param array $context * An associative array of context for internal use when recursing. Currently * only used to track a single value: * - level: The number of child-parent relationships to follow. Defaults to * 10. * * @return array * An array of links representing the breadcrumb trail, "root" first. */ function islandora_get_breadcrumbs_recursive($pid, FedoraRepository $repository, array &$context = NULL) { // Before executing the query, we have a base case of accessing the top-level // collection. if ($context === NULL) { $context['level'] = 10; } $root = variable_get('islandora_repository_pid', 'islandora:root'); if ($pid == $root) { $title = 'Islandora Repository'; $trail = menu_get_active_trail(); foreach ($trail as $key => $item) { if ($item['link_path'] == 'islandora') { $title = $item['link_title']; break; } } return array( l(t('Home'), ''), l($title, 'islandora'), ); } else { $query_string = 'select $parentObject $title $content from <#ri> where ( $title and $parentObject $content and ( $parentObject or $parentObject or $parentObject ) and $parentObject ) minus $content minus $parentObject order by $title desc'; $results = $repository->ri->itqlQuery($query_string); if (count($results) > 0 && $context['level'] > 0) { $parent = $results[0]['parentObject']['value']; $this_title = $results[0]['title']['value']; if (empty($this_title)) { $this_title = t('-'); } $context['level']--; return array_merge( islandora_get_breadcrumbs_recursive($parent, $repository, $context), array( l($this_title, "islandora/object/$pid"), ) ); } else { // Add an non-link, as we don't know how to get back to the root, and // render the last two links and break (on the next pass). return array_merge( islandora_get_breadcrumbs_recursive($root, $repository, $context), array( '...', ) ); } } }