You are here

function apachesolr_views_query::get_path in Apache Solr Views 6

return the search path

File

./apachesolr_views_query.inc, line 610

Class

apachesolr_views_query
Class for handling a view that gets its data not from the database, but from a Solr server.

Code

function get_path($new_keys = NULL) {
  if (isset($new_keys)) {
    $this
      ->set_query($new_keys);
  }
  $wildcard_count = 0;

  // this is used to remove the some/path/argument/all/all paths
  if (empty($this->_view_arguments)) {
    return $this->_base_path;
  }
  foreach ($this->_view_arguments as $field => $argument) {

    // because some arguments arn't standard base arguments we need to do things differently
    // so that the facet blocks behave. So any argument thats not part of a facet block
    // we have its value copied into the path
    // arguments that are a facet block argument will be processed differently
    $path_part = $this
      ->part_of_facet_block($argument) ? $this
      ->argument_part($field) : $argument->argument;
    if (!empty($path_part)) {
      $path_parts[$argument->position + 1] = $path_part;
      $wildcard_count = 0;
    }
    else {
      $path_parts[$argument->position + 1] = $argument->options['wildcard'];
      $wildcard_count++;
    }
  }
  $arguments = explode('/', $this->_base_path);
  $path = '';
  foreach ($arguments as $arg) {
    if ($arg == '%') {
      $part = array_shift($path_parts);
    }
    else {
      $part = $arg;
    }
    $path .= "/{$part}";
  }
  if (count($path_parts) && $wildcard_count != count($path_parts)) {
    $path .= "/" . implode('/', array_slice($path_parts, 0, count($path_parts) - $wildcard_count));
  }
  $path = substr($path, 1);
  if (trim($path) == trim(variable_get('site_frontpage', 'node'))) {
    return '<front>';
  }
  return $path;
}