You are here

function jquery_ajax_load_delivery_callback in jQuery AJAX Load 7

Returns only content part of page for Delivery Callback function.

1 string reference to 'jquery_ajax_load_delivery_callback'
jquery_ajax_load_menu in ./jquery_ajax_load.module
Implementation of hook_menu().

File

./jquery_ajax_load.module, line 118
Basic Module file.

Code

function jquery_ajax_load_delivery_callback($page_callback_result) {
  if (isset($page_callback_result) && is_null(drupal_get_http_header('Content-Type'))) {
    drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
  }

  // Send appropriate HTTP-Header for browsers and search engines.
  global $language;
  drupal_add_http_header('Content-Language', $language->language);

  // Menu status constants are integers; page content is a string or array.
  if (is_int($page_callback_result)) {

    // @todo: Break these up into separate functions?
    switch ($page_callback_result) {
      case MENU_NOT_FOUND:
        drupal_add_http_header('Status', '404 Not Found');
        print t("Page not found");
        break;
      case MENU_ACCESS_DENIED:
        drupal_add_http_header('Status', '403 Forbidden');
        print t("Access denied");
        break;
      case MENU_SITE_OFFLINE:
        print t('Site under maintenance');
        break;
      default:
        print t('Unknown error');
        break;
    }
  }
  elseif (isset($page_callback_result)) {
    $content = is_string($page_callback_result) ? $page_callback_result : drupal_render($page_callback_result);
    $html = '<html><head><title></title>';
    if (variable_get('jquery_ajax_load_css', TRUE)) {
      $html .= drupal_get_css();
    }
    if (variable_get('jquery_ajax_load_js', TRUE)) {
      $html .= drupal_get_js();
    }
    $html .= '</head><body class="jquery-ajax-load">' . $content . '</body></html>';
    print $html;
    drupal_page_footer();
  }
}