function ajax_deliver_dialog in Dialog 7.2
Delivers the content of a page as a dialog.
Parameters
$page_callback_result: The result of a page callback. Can be one of:
- NULL: to indicate no content.
- An integer menu status constant: to indicate an error condition.
- A string of HTML content.
- A renderable array of content.
Return value
An Ajax commands array that can be passed to ajax_render().
1 string reference to 'ajax_deliver_dialog'
- dialog_page_delivery_callback_alter in ./
dialog.module - Implements hook_page_delivery_callback_alter().
File
- ./
dialog.module, line 281 - Provides an API for opening content in a dialog.
Code
function ajax_deliver_dialog($page_callback_result) {
if (!isset($page_callback_result)) {
// Simply delivering an empty commands array is sufficient. This results
// in the Ajax request being completed, but nothing being done to the page.
}
else {
$title = drupal_get_title();
$html = $page_callback_result;
if (is_int($page_callback_result)) {
switch ($page_callback_result) {
case MENU_NOT_FOUND:
$title = t('Page not found');
$html = t('The requested page could not be found.');
break;
case MENU_ACCESS_DENIED:
$title = t('Access denied');
$html = t('You are not authorized to access this page.');
break;
case MENU_SITE_OFFLINE:
$title = t('Site under maintenance');
$html = filter_xss_admin(variable_get('maintenance_mode_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array(
'@site' => variable_get('site_name', 'Drupal'),
))));
break;
}
}
elseif (is_array($page_callback_result)) {
$html = drupal_render($page_callback_result);
if (isset($page_callback_result['#title'])) {
$title = $page_callback_result['#title'];
}
}
$dialog_options = isset($_POST['dialogOptions']) ? $_POST['dialogOptions'] : array(
'modal' => TRUE,
);
if (isset($dialog_options['target'])) {
$selector = $dialog_options['target'];
}
else {
$selector = '#drupal-modal';
$dialog_options['modal'] = TRUE;
}
$commands[] = dialog_command_open_dialog($selector, $title, $html, $dialog_options);
$return = array(
'#type' => 'ajax',
'#commands' => $commands,
);
ajax_deliver($return);
}
}