You are here

function dialog_test_dialog_contents in Dialog 7.2

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

3 calls to dialog_test_dialog_contents()
AJAXDialogTest::testDialog in ./dialog.test
Test sending non-JS and AJAX requests to open and manipulate modals.
dialog_test_dialog_form_callback_modal in tests/dialog_test.module
AJAX callback handler for dialog_test_dialog_form().
dialog_test_dialog_form_callback_nonmodal in tests/dialog_test.module
AJAX callback handler for dialog_test_dialog_form().
1 string reference to 'dialog_test_dialog_contents'
dialog_test_menu in tests/dialog_test.module
Implements hook_menu().

File

tests/dialog_test.module, line 144
A dummy module for testing dialog related hooks.

Code

function dialog_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 = drupal_render($content);
    if ($is_modal) {
      $commands['#commands'][] = dialog_command_open_modal_dialog($title, $html);
    }
    else {
      $selector = '#ajax-test-dialog-wrapper-1';
      $commands['#commands'][] = dialog_command_open_dialog($selector, $title, $html);
    }
    return $commands;
  }
  else {
    return $content;
  }
}