1 view.inc | view::_build_arguments() |
Build all the arguments.
File
- core/
modules/ views/ includes/ view.inc, line 811 - Provides the view object type and associated methods.
Class
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;
}
// remember that this argument was computed, not passed on the URL.
$argument->is_default = TRUE;
}
// 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;
}