function 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 831
Class
- view
- An object to contain all of the data to generate a view.
Code
public 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 = NULL;
if (isset($this->args[$position]) && $this->args[$position] !== '') {
$arg = $this->args[$position];
}
$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_exception()) {
$arg_title = $argument->exception_title();
}
else {
$arg_title = $argument->get_title();
$argument->query($this->display_handler
->use_group_by());
}
// Add this argument's substitution.
$substitutions['%' . ($position + 1)] = $arg_title;
$substitutions['!' . ($position + 1)] = strip_tags(decode_entities($arg));
// 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) {
if (!empty($argument->options['breadcrumb_enable']) && !empty($argument->options['breadcrumb'])) {
$breadcrumb = $argument->options['breadcrumb'];
}
else {
$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_enable']) && !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'] = $title;
}
// Store the arguments for later use.
$this->build_info['substitutions'] = $substitutions;
return $status;
}