function view::_build_arguments

3.x view.inc view::_build_arguments()
2.x view.inc view::_build_arguments()

Build all the arguments.

2 calls to view::_build_arguments()
view::build in includes/view.inc
Build the query for the view.
view::build_title in includes/view.inc
Force the view to build a title.

File

includes/view.inc, line 480
view.inc Provides the view object type and associated methods.

Class

view
An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.

Code

function _build_arguments() {
  // Initially, we want to build sorts and fields. This can change, though,
  // if we get a summary view.
  if (empty($this->argument)) {
    return TRUE;
  }

  // build arguments.
  $position = -1;

  // Create a title for use in the breadcrumb trail.
  $title = $this->display_handler->get_option('title');

  $this->build_info['breadcrumb'] = array();
  $breadcrumb_args = array();
  $substitutions = array();

  $status = TRUE;

  // Iterate through each argument and process.
  foreach ($this->argument as $id => $arg) {
    $position++;
    $argument = &$this->argument[$id];

    if ($argument->broken()) {
      continue;
    }

    $argument->set_relationship();

    $arg = isset($this->args[$position]) ? $this->args[$position] : NULL;
    $argument->position = $position;

    if (isset($arg) || $argument->has_default_argument()) {
      if (!isset($arg)) {
        $arg = $argument->get_default_argument();
        // make sure default args get put back.
        if (isset($arg)) {
          $this->args[$position] = $arg;
        }
      }

      // Set the argument, which will also validate that the argument can be set.
      if (!$argument->set_argument($arg)) {
        $status = $argument->validate_fail($arg);
        break;
      }

      if ($argument->is_wildcard()) {
        $arg_title = $argument->wildcard_title();
      }
      else {
        $arg_title = $argument->get_title();
        $argument->query();
      }

      // Add this argument's substitution
      $substitutions['%' . ($position + 1)] = $arg_title;

      // Since we're really generating the breadcrumb for the item above us,
      // check the default action of this argument.
      if ($this->display_handler->uses_breadcrumb() && $argument->uses_breadcrumb()) {
        $path = $this->get_url($breadcrumb_args);
        if (strpos($path, '%') === FALSE) {
          $breadcrumb = !empty($argument->options['breadcrumb']) ? $argument->options['breadcrumb'] : $title;
          $this->build_info['breadcrumb'][$path] = str_replace(array_keys($substitutions), $substitutions, $breadcrumb);
        }
      }

      // Allow the argument to muck with this breadcrumb.
      $argument->set_breadcrumb($this->build_info['breadcrumb']);

      // Test to see if we should use this argument's title
      if (!empty($argument->options['title'])) {
        $title = $argument->options['title'];
      }

      $breadcrumb_args[] = $arg;
    }
    else {
      // determine default condition and handle.
      $status = $argument->default_action();
      break;
    }

    // Be safe with references and loops:
    unset($argument);
  }

  // set the title in the build info.
  if (!empty($title)) {
    $this->build_info['title'] = str_replace(array_keys($substitutions), $substitutions, $title);
  }

  // Store the arguments for later use.
  $this->build_info['substitutions'] = $substitutions;

  return $status;
}