1 views_ui.admin.inc views_ui_add_form_to_stack($key, &$view, $display_id, $args, $top = FALSE, $rebuild_keys = FALSE)

Add another form to the stack; clicking 'apply' will go to this form rather than closing the ajax popup.

File

core/modules/views_ui/views_ui.admin.inc, line 2842
Admin page callbacks for the Views UI module.

Code

function views_ui_add_form_to_stack($key, &$view, $display_id, $args, $top = FALSE, $rebuild_keys = FALSE) {
  if (empty($view->stack)) {
    $view->stack = array();
  }

  $stack = array(views_ui_build_identifier($key, $view, $display_id, $args), $key, &$view, $display_id, $args);
  // If we're being asked to add this form to the bottom of the stack, no
  // special logic is required. Our work is equally easy if we were asked to add
  // to the top of the stack, but there's nothing in it yet.
  if (!$top || empty($view->stack)) {
    $view->stack[] = $stack;
  }
  // If we're adding to the top of an existing stack, we have to maintain the
  // existing integer keys, so they can be used for the "2 of 3" progress
  // indicator (which will now read "2 of 4").
  else {
    $keys = array_keys($view->stack);
    $first = current($keys);
    $last = end($keys);
    for ($i = $last; $i >= $first; $i--) {
      if (!isset($view->stack[$i])) {
        continue;
      }
      // Move form number $i to the next position in the stack.
      $view->stack[$i + 1] = $view->stack[$i];
      unset($view->stack[$i]);
    }
    // Now that the previously $first slot is free, move the new form into it.
    $view->stack[$first] = $stack;
    ksort($view->stack);

    // Start the keys from 0 again, if requested.
    if ($rebuild_keys) {
      $view->stack = array_values($view->stack);
    }
  }
}