You are here

function ctools_context_get_context_from_arguments in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/context.inc \ctools_context_get_context_from_arguments()

Load the contexts for a given list of arguments.

Parameters

$arguments: The array of argument definitions.

&$contexts: The array of existing contexts. New contexts will be added to this array.

$args: The arguments to load.

Return value

FALSE if an argument wants to 404.

1 call to ctools_context_get_context_from_arguments()
ctools_context_handler_get_task_contexts in includes/context-task-handler.inc
Load the contexts for a task, using arguments.

File

includes/context.inc, line 803
Contains code related to the ctools system of 'context'.

Code

function ctools_context_get_context_from_arguments($arguments, &$contexts, $args) {
  foreach ($arguments as $argument) {

    // pull the argument off the list.
    $arg = array_shift($args);
    $id = ctools_context_id($argument, 'argument');

    // For % arguments embedded in the URL, our context is already loaded.
    // There is no need to go and load it again.
    if (empty($contexts[$id])) {
      if ($context = ctools_context_get_context_from_argument($argument, $arg)) {
        $contexts[$id] = $context;
      }
    }
    else {
      $context = $contexts[$id];
    }
    if ((empty($context) || empty($context->data)) && !empty($argument['default']) && $argument['default'] == '404') {
      return FALSE;
    }
  }
  return TRUE;
}