From 5ab3a60612ebf397406636503a59d6926ee63fff Mon Sep 17 00:00:00 2001 From: ninadsp Date: Wed, 26 May 2010 11:38:58 +0530 Subject: [PATCH] Header and Footr output is suppressed if it is an Ajax request --- libraries/footer.inc.php | 6 + libraries/header.inc.php | 277 ++++++++++++++++++++------------------- 2 files changed, 147 insertions(+), 136 deletions(-) diff --git a/libraries/footer.inc.php b/libraries/footer.inc.php index 2a3cb28f2..d094b2185 100755 --- a/libraries/footer.inc.php +++ b/libraries/footer.inc.php @@ -225,10 +225,16 @@ if (! empty($GLOBALS['cfg']['DBG']['php']) */ } +/** + * If we are in an AJAX request, we do not need to generate the closing tags for + * body and html. + */ +if (! $GLOBALS['is_ajax_request']) { ?> - - - - + require_once './libraries/header_http.inc.php'; + require_once './libraries/header_meta_style.inc.php'; + require_once './libraries/header_scripts.inc.php'; + ?> + + + + - - + display(); - } - - if (!defined('PMA_DISPLAY_HEADING')) { - define('PMA_DISPLAY_HEADING', 1); - } - - /** - * Display heading if needed. Design can be set in css file. - */ - - if (PMA_DISPLAY_HEADING && $GLOBALS['server'] > 0) { - $server_info = (!empty($GLOBALS['cfg']['Server']['verbose']) - ? $GLOBALS['cfg']['Server']['verbose'] - : $GLOBALS['cfg']['Server']['host'] . (empty($GLOBALS['cfg']['Server']['port']) - ? '' - : ':' . $GLOBALS['cfg']['Server']['port'] - ) - ); - $item = ''; - if ($GLOBALS['cfg']['NavigationBarIconic']) { - $separator = ' -' . "\n"; - $item .= ' ' . "\n"; - } else { - $separator = ' - ' . "\n"; + // Include possible custom headers + if (file_exists(CUSTOM_HEADER_FILE)) { + require CUSTOM_HEADER_FILE; } - if ($GLOBALS['cfg']['NavigationBarIconic'] !== true) { - $item .= '%4$s: '; + + // message of "Cookies required" displayed for auth_type http or config + // note: here, the decoration won't work because without cookies, + // our standard CSS is not operational + if (empty($_COOKIE)) { + PMA_Message::notice(__('Cookies must be enabled past this point.'))->display(); } - $item .= '%3$s' . "\n"; - echo '
' . "\n"; - printf($item, - $GLOBALS['cfg']['DefaultTabServer'], - PMA_generate_common_url(), - htmlspecialchars($server_info), - __('Server'), - 's_host.png'); + if (!defined('PMA_DISPLAY_HEADING')) { + define('PMA_DISPLAY_HEADING', 1); + } - if (strlen($GLOBALS['db'])) { + /** + * Display heading if needed. Design can be set in css file. + */ - echo $separator; - printf($item, - $GLOBALS['cfg']['DefaultTabDatabase'], - PMA_generate_common_url($GLOBALS['db']), - htmlspecialchars($GLOBALS['db']), - __('Database'), - 's_db.png'); - - if (isset($GLOBALS['action']) && $GLOBALS['action'] == 'tbl_create.php') { - /* We're creating a new table */ - echo $separator; - printf($item, - $action, - PMA_generate_common_url($GLOBALS['db']), - __('New table'), - '', - 's_tbl.png'); - } elseif (strlen($GLOBALS['table'])) { - require_once './libraries/tbl_info.inc.php'; - - echo $separator; - printf($item, - $GLOBALS['cfg']['DefaultTabTable'], - PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']), - str_replace(' ', ' ', htmlspecialchars($GLOBALS['table'])), - (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? __('View') : __('Table')), - (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? 'b_views' : 's_tbl') . '.png'); - - /** - * Displays table comment - * @uses $show_comment from libraries/tbl_info.inc.php - * @uses $GLOBALS['avoid_show_comment'] from tbl_relation.php - */ - if (!empty($show_comment) && !isset($GLOBALS['avoid_show_comment'])) { - if (strstr($show_comment, '; InnoDB free')) { - $show_comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment); - } - echo '' - .'"' . htmlspecialchars($show_comment) - .'"' . "\n"; - } // end if + if (PMA_DISPLAY_HEADING && $GLOBALS['server'] > 0) { + $server_info = (!empty($GLOBALS['cfg']['Server']['verbose']) + ? $GLOBALS['cfg']['Server']['verbose'] + : $GLOBALS['cfg']['Server']['host'] . (empty($GLOBALS['cfg']['Server']['port']) + ? '' + : ':' . $GLOBALS['cfg']['Server']['port'] + ) + ); + $item = ''; + if ($GLOBALS['cfg']['NavigationBarIconic']) { + $separator = ' -' . "\n"; + $item .= ' ' . "\n"; } else { - // no table selected, display database comment if present - /** - * Settings for relations stuff - */ - require_once './libraries/relation.lib.php'; - $cfgRelation = PMA_getRelationsParam(); + $separator = ' - ' . "\n"; + } + + if ($GLOBALS['cfg']['NavigationBarIconic'] !== true) { + $item .= '%4$s: '; + } + $item .= '%3$s' . "\n"; + + echo '
' . "\n"; + printf($item, + $GLOBALS['cfg']['DefaultTabServer'], + PMA_generate_common_url(), + htmlspecialchars($server_info), + __('Server'), + 's_host.png'); + + if (strlen($GLOBALS['db'])) { + + echo $separator; + printf($item, + $GLOBALS['cfg']['DefaultTabDatabase'], + PMA_generate_common_url($GLOBALS['db']), + htmlspecialchars($GLOBALS['db']), + __('Database'), + 's_db.png'); + + if (isset($GLOBALS['action']) && $GLOBALS['action'] == 'tbl_create.php') { + /* We're creating a new table */ + echo $separator; + printf($item, + $action, + PMA_generate_common_url($GLOBALS['db']), + __('New table'), + '', + 's_tbl.png'); + } elseif (strlen($GLOBALS['table'])) { + require_once './libraries/tbl_info.inc.php'; + + echo $separator; + printf($item, + $GLOBALS['cfg']['DefaultTabTable'], + PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']), + str_replace(' ', ' ', htmlspecialchars($GLOBALS['table'])), + (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? __('View') : __('Table')), + (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? 'b_views' : 's_tbl') . '.png'); - // Get additional information about tables for tooltip is done - // in libraries/db_info.inc.php only once - if ($cfgRelation['commwork']) { - $comment = PMA_getDbComment($GLOBALS['db']); /** * Displays table comment + * @uses $show_comment from libraries/tbl_info.inc.php + * @uses $GLOBALS['avoid_show_comment'] from tbl_relation.php */ - if (! empty($comment)) { - echo '"' - . htmlspecialchars($comment) - . '"' . "\n"; + if (!empty($show_comment) && !isset($GLOBALS['avoid_show_comment'])) { + if (strstr($show_comment, '; InnoDB free')) { + $show_comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment); + } + echo '' + .'"' . htmlspecialchars($show_comment) + .'"' . "\n"; } // end if + } else { + // no table selected, display database comment if present + /** + * Settings for relations stuff + */ + require_once './libraries/relation.lib.php'; + $cfgRelation = PMA_getRelationsParam(); + + // Get additional information about tables for tooltip is done + // in libraries/db_info.inc.php only once + if ($cfgRelation['commwork']) { + $comment = PMA_getDbComment($GLOBALS['db']); + /** + * Displays table comment + */ + if (! empty($comment)) { + echo '"' + . htmlspecialchars($comment) + . '"' . "\n"; + } // end if + } } } - } - echo '
'; + echo '
'; + } + /** + * Sets a variable to remember headers have been sent + */ + $GLOBALS['is_header_sent'] = true; } - /** - * Sets a variable to remember headers have been sent - */ - $GLOBALS['is_header_sent'] = true; -} +} //end if(!$GLOBALS['is_ajax_request']) ?>