From a3dd431bdbfa14744655dd03f3d89694fecfe536 Mon Sep 17 00:00:00 2001 From: ninadsp Date: Sun, 27 Jun 2010 23:03:20 +0530 Subject: [PATCH] Modified PMA_showMessage so that it can show the sql query even in an ajax request, by using output buffering. Added a function to handle the output buffer for the ajax request. Fixed a typo in PMA_ajaxResponse --- libraries/common.lib.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 2ef52f692..77fa606fb 100755 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1021,6 +1021,9 @@ if (!$jsonly) */ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view = false) { + if( $GLOBALS['is_ajax_request'] == true) { + ob_start("PMA_ajaxOutputBufferHandler"); + } global $cfg; if (null === $sql_query) { @@ -1285,6 +1288,12 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view echo ''; } echo '
' . "\n"; + + if( $GLOBALS['is_ajax_request'] == true) { + $buffer_contents = ob_get_contents(); + ob_end_clean(); + return $buffer_contents; + } } // end of the 'PMA_showMessage()' function /** @@ -2881,7 +2890,7 @@ function PMA_ajaxResponse($message, $success = true, $extra_data = array()) } else { $response['success'] = false; - $response['error'] = $message; + $response['error'] = $message->getDisplay(); } if( count($extra_data) > 0 ) { @@ -2894,4 +2903,10 @@ function PMA_ajaxResponse($message, $success = true, $extra_data = array()) echo json_encode($response); exit; } -?> + +function PMA_ajaxOutputBufferHandler($output_buffer) { + $response = array(); + $response['message'] = $output_buffer; + return json_encode($response); +} +?> \ No newline at end of file