You are here

function ctools_jump_menu_submit in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/jump-menu.inc \ctools_jump_menu_submit()

Submit handler for the jump menu.

This is normally only invoked upon submit without javascript enabled.

1 string reference to 'ctools_jump_menu_submit'
ctools_jump_menu in includes/jump-menu.inc
Generate a jump menu form.

File

includes/jump-menu.inc, line 118
Provides a simple "jump menu".

Code

function ctools_jump_menu_submit($form, &$form_state) {
  if ($form_state['values']['jump'] === '') {

    // We have nothing to do when the user has not selected any value.
    return;
  }

  // If the path we are redirecting to contains the string :: then treat the
  // the string after the double colon as the path to redirect to.
  // This allows duplicate paths to be used in jump menus for multiple options.
  $redirect_array = explode("::", $form_state['values']['jump']);
  if (isset($redirect_array[1]) && !empty($redirect_array[1])) {
    $redirect = $redirect_array[1];
  }
  else {
    $redirect = $form_state['values']['jump'];
  }

  // If the path we are redirecting to starts with the base path (for example,
  // "/somepath/node/1"), we need to strip the base path off before passing it
  // to $form_state['redirect'].
  $base_path = base_path();
  if (strpos($redirect, $base_path) === 0) {
    $redirect = substr($redirect, strlen($base_path));
  }

  // Parse the URL so that query strings and fragments are preserved in the
  // redirect.
  $redirect = drupal_parse_url($redirect);
  $redirect['path'] = urldecode($redirect['path']);
  $form_state['redirect'] = array(
    $redirect['path'],
    $redirect,
  );
}