1 layout.admin.inc layout_ajax_form_save_title_dialog($form, $form_state)

AJAX handler that updates the title.

Return value

array: AJAX commands to update the page.

File

core/modules/layout/layout.admin.inc, line 3216
Admin page callbacks for the Layout module.

Code

function layout_ajax_form_save_title_dialog($form, $form_state) {
  $layout = $form_state['layout'];

  $commands = array();
  $commands[] = ajax_command_close_modal_dialog();

  // If errors occurred in the dialog, show messages and re-display.
  if (form_get_errors()) {
    $html = '';
    $html .= theme('status_messages');
    $html .= backdrop_render($form);
    $title = isset($form['#title']) ? $form['#title'] : backdrop_get_title();
    $commands[] = ajax_command_open_modal_dialog($title, $html, array('dialogClass' => 'layout-dialog'));
  }
  else {
    // Rebuild the title area description.
    $description = '<span class="description">' . layout_get_title_description($layout) . '</span>';
    $commands[] = ajax_command_replace("#layout-editor-title .description", $description);

    // Clear out previous messages.
    if ($message = layout_locked_message($layout, 'layout')) {
      backdrop_set_message($message, 'warning');
    }
    elseif ($message = layout_locked_message($menu_item, 'menu_item')) {
      backdrop_set_message($message, 'warning');
    }
    $commands[] = ajax_command_remove('#messages');
    $commands[] = ajax_command_html('#layout-messages', theme('status_messages'));
  }

  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}