1 ajax_test.module ajax_test_dialog_contents($page_mode = 'nojs', $is_modal = 0)

Menu callback: Returns the contents for dialogs opened by ajax_test_dialog().

File

core/modules/simpletest/tests/ajax_test.module, line 185
Helper module for Ajax framework tests.

Code

function ajax_test_dialog_contents($page_mode = 'nojs', $is_modal = 0) {
  // This is a regular render array; the keys do not have special meaning.
  $content = array(
    'content' => array(
      '#markup' => 'Example message',
    ),
    'cancel' => array(
      '#type' => 'link',
      '#title' => 'Cancel',
      '#href' => '',
      '#attributes' => array(
        // This is a special class to which JavaScript assigns dialog closing
        // behavior.
        'class' => array('dialog-cancel'),
      ),
    ),
  );

  if ($page_mode === 'ajax') {
    $commands = array(
      '#type' => 'ajax',
      '#commands' => array(),
    );
    $title = t('AJAX Dialog');
    $html = backdrop_render($content);
    if ($is_modal) {
      $commands['#commands'][] = ajax_command_open_modal_dialog($title, $html);
    }
    else {
      $selector = '#ajax-test-dialog-wrapper-1';
      $commands['#commands'][] = ajax_command_open_dialog($selector, $title, $html);
    }
    return $commands;
  }
  else {
    return $content;
  }
}