1 ajax.inc ajax_deliver_dialog($page_callback_result)

Delivers the content of a page as a dialog.

Related topics

File

core/includes/ajax.inc, line 531
Functions for use with Backdrop's Ajax framework.

Code

function ajax_deliver_dialog($page_callback_result) {
  if (isset($page_callback_result['#title'])) {
    $title = $page_callback_result['#title'];
  }
  else {
    $title = backdrop_get_title();
  }
  $html = backdrop_render($page_callback_result);

  $dialog_options = isset($_POST['dialogOptions']) ? $_POST['dialogOptions'] : array('modal' => TRUE);
  if (isset($dialog_options['target'])) {
    $selector = $dialog_options['target'];
  }
  else {
    $selector = '#backdrop-modal';
    $dialog_options['modal'] = TRUE;
  }

  // Convert string values to booleans.
  foreach ($dialog_options as $key => $value) {
    if ($value === 'true') {
      $dialog_options[$key] = TRUE;
    }
    elseif ($value === 'false') {
      $dialog_options[$key] = FALSE;
    }
  }

  $commands = array();
  $commands[] = ajax_command_open_dialog($selector, $title, $html, $dialog_options);
  $return = array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
  ajax_deliver($return);
}