You are here

public function Solr_Base_Query::get_breadcrumb in Apache Solr Search 6.2

Same name and namespace in other branches
  1. 5.2 Solr_Base_Query.php \Solr_Base_Query::get_breadcrumb()
  2. 5 Solr_Base_Query.php \Solr_Base_Query::get_breadcrumb()
  3. 6 Solr_Base_Query.php \Solr_Base_Query::get_breadcrumb()

Build additional breadcrumb elements relative to $base.

File

./Solr_Base_Query.php, line 370

Class

Solr_Base_Query

Code

public function get_breadcrumb($base = NULL) {
  $breadcrumb = array();
  $progressive_crumb = array();
  if (!isset($base)) {
    $base = $this
      ->get_path();
  }
  $search_keys = $this
    ->get_query_basic();
  if ($search_keys) {
    $breadcrumb[] = l($search_keys, $base);
  }
  foreach ($this->fields as $field) {
    $name = $field['#name'];

    // Look for a field alias.
    if (isset($this->field_map[$name])) {
      $field['#name'] = $this->field_map[$name];
    }
    $progressive_crumb[] = $this
      ->make_filter($field);
    $options = array(
      'query' => 'filters=' . rawurlencode(implode(' ', $progressive_crumb)),
    );
    $breadcrumb_name = 'apachesolr_breadcrumb_' . $name;

    // Modules utilize this alter to consolidate several fields into one
    // theme function. This is how CCK breadcrumbs are handled.
    drupal_alter('apachesolr_theme_breadcrumb', $breadcrumb_name);
    if ($themed = theme($breadcrumb_name, $field)) {
      $breadcrumb[] = l($themed, $base, $options);
    }
    else {
      $breadcrumb[] = l($field['#value'], $base, $options);
    }
  }
  if (!empty($breadcrumb)) {

    // The last breadcrumb is the current page, so it shouldn't be a link.
    $last = count($breadcrumb) - 1;
    $breadcrumb[$last] = strip_tags($breadcrumb[$last]);
  }
  return $breadcrumb;
}