Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db_create.php28
-rw-r--r--db_operations.php15
-rw-r--r--db_tables_search.php3
-rw-r--r--db_tracking.php9
-rw-r--r--gis_data_editor.php8
-rw-r--r--import.php18
-rw-r--r--js/functions.js5
-rw-r--r--js/gis_data_editor.js9
-rw-r--r--js/sql.js10
-rw-r--r--js/tbl_zoom_plot_jqplot.js5
-rw-r--r--libraries/auth/cookie.auth.lib.php2
-rw-r--r--libraries/common.lib.php29
-rw-r--r--libraries/db_common.inc.php7
-rw-r--r--libraries/rte/rte_events.lib.php25
-rw-r--r--libraries/rte/rte_export.lib.php11
-rw-r--r--libraries/rte/rte_routines.lib.php66
-rw-r--r--libraries/rte/rte_triggers.lib.php33
-rw-r--r--navigation.php9
-rw-r--r--prefs_manage.php15
-rw-r--r--server_databases.php5
-rw-r--r--server_privileges.php17
-rw-r--r--sql.php46
-rw-r--r--tbl_addfield.php8
-rw-r--r--tbl_alter.php30
-rw-r--r--tbl_create.php37
-rw-r--r--tbl_indexes.php26
-rw-r--r--tbl_move_copy.php23
-rw-r--r--tbl_operations.php16
-rw-r--r--tbl_replace.php7
-rw-r--r--tbl_zoom_select.php25
-rw-r--r--test/libraries/common/PMA_ajaxResponse_test.php71
-rw-r--r--view_create.php18
32 files changed, 328 insertions, 308 deletions
diff --git a/db_create.php b/db_create.php
index c0618b1ca8..b04a793f84 100644
--- a/db_create.php
+++ b/db_create.php
@@ -61,12 +61,15 @@ if (! $result) {
$GLOBALS['table'] = '';
/**
- * If in an Ajax request, just display the message with {@link PMA_ajaxResponse}
+ * If in an Ajax request, just display the message with {@link PMA_Response}
*/
if ($GLOBALS['is_ajax_request'] == true) {
- PMA_ajaxResponse($message, false);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $message);
+ } else {
+ include_once 'main.php';
}
- include_once 'main.php';
} else {
$message = PMA_Message::success(__('Database %1$s has been created.'));
$message->addParam($new_db);
@@ -76,14 +79,6 @@ if (! $result) {
* If in an Ajax request, build the output and send it
*/
if ($GLOBALS['is_ajax_request'] == true) {
-
- /**
- * String containing the SQL Query formatted in pretty HTML
- * @global array $GLOBALS['extra_data']
- * @name $extra_data
- */
- $extra_data['sql_query'] = PMA_getMessage(null, $sql_query, 'success');
-
//Construct the html for the new database, so that it can be appended to
// the list of databases on server_databases.php
@@ -137,11 +132,12 @@ if (! $result) {
$new_db_string .= '</tr>';
- $extra_data['new_db_string'] = $new_db_string;
-
- PMA_ajaxResponse($message, true, $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $message);
+ $response->addJSON('new_db_string', $new_db_string);
+ $response->addJSON('sql_query', PMA_getMessage(null, $sql_query, 'success'));
+ } else {
+ include_once '' . $cfg['DefaultTabDatabase'];
}
-
- include_once '' . $cfg['DefaultTabDatabase'];
}
?>
diff --git a/db_operations.php b/db_operations.php
index 4e77fe8822..16f6191802 100644
--- a/db_operations.php
+++ b/db_operations.php
@@ -340,13 +340,16 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
/**
* Database has been successfully renamed/moved. If in an Ajax request,
- * generate the output with {@link PMA_ajaxResponse} and exit
+ * generate the output with {@link PMA_Response} and exit
*/
- if ( $GLOBALS['is_ajax_request'] == true) {
- $extra_data['newname'] = $newname;
- $extra_data['sql_query'] = PMA_getMessage(null, $sql_query);
- PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
- };
+ if ($GLOBALS['is_ajax_request'] == true) {
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($message->isSuccess());
+ $response->addJSON('message', $message);
+ $response->addJSON('newname', $newname);
+ $response->addJSON('sql_query', PMA_getMessage(null, $sql_query));
+ exit;
+ }
}
diff --git a/db_tables_search.php b/db_tables_search.php
index 6dbb1a4e8f..53542ca9c7 100644
--- a/db_tables_search.php
+++ b/db_tables_search.php
@@ -63,5 +63,6 @@ foreach ($tables_full as $key => $table) {
}
}
-PMA_ajaxResponse('', true, array('tables' => $tables_response));
+$response = PMA_Response::getInstance();
+$response->addJSON('tables', $tables_response);
?>
diff --git a/db_tracking.php b/db_tracking.php
index 91b33147a3..94e4fe4847 100644
--- a/db_tracking.php
+++ b/db_tracking.php
@@ -20,8 +20,8 @@ $scripts->addFile('db_structure.js');
*/
if ($GLOBALS['is_ajax_request'] != true) {
include 'libraries/db_common.inc.php';
+ $url_query .= '&amp;goto=tbl_tracking.php&amp;back=db_tracking.php';
}
-$url_query .= '&amp;goto=tbl_tracking.php&amp;back=db_tracking.php';
// Get the database structure
$sub_part = '_structure';
@@ -34,11 +34,12 @@ if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
/**
* If in an Ajax request, generate the success message and use
- * {@link PMA_ajaxResponse()} to send the output
+ * {@link PMA_Response()} to send the output
*/
if ($GLOBALS['is_ajax_request'] == true) {
- $message = PMA_Message::success();
- PMA_ajaxResponse($message, true);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', PMA_Message::success());
+ exit;
}
}
diff --git a/gis_data_editor.php b/gis_data_editor.php
index 83b59fe34a..9eb0e99744 100644
--- a/gis_data_editor.php
+++ b/gis_data_editor.php
@@ -62,7 +62,9 @@ if (isset($_REQUEST['generate']) && $_REQUEST['generate'] == true) {
'visualization' => $visualization,
'openLayers' => $open_layers,
);
- PMA_ajaxResponse(null, true, $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON($extra_data);
+ exit;
}
ob_start();
@@ -311,7 +313,7 @@ ob_start();
</form>
<?php
-$extra_data['gis_editor'] = ob_get_contents();
-PMA_ajaxResponse(null, ob_end_clean(), $extra_data);
+PMA_Response::getInstance()->addJSON('gis_editor', ob_get_contents());
+ob_end_clean();
?>
diff --git a/import.php b/import.php
index 1522c0d048..85dfaea5e1 100644
--- a/import.php
+++ b/import.php
@@ -221,10 +221,13 @@ if (! empty($id_bookmark)) {
case 1: // bookmarked query that have to be displayed
$import_text = PMA_Bookmark_get($db, $id_bookmark);
if ($GLOBALS['is_ajax_request'] == true) {
- $extra_data['sql_query'] = $import_text;
- $extra_data['action_bookmark'] = $action_bookmark;
$message = PMA_Message::success(__('Showing bookmark'));
- PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($message->isSuccess());
+ $response->addJSON('message', $message);
+ $response->addJSON('sql_query', $import_text);
+ $response->addJSON('action_bookmark', $action_bookmark);
+ exit;
} else {
$run_query = false;
}
@@ -234,9 +237,12 @@ if (! empty($id_bookmark)) {
PMA_Bookmark_delete($db, $id_bookmark);
if ($GLOBALS['is_ajax_request'] == true) {
$message = PMA_Message::success(__('The bookmark has been deleted.'));
- $extra_data['action_bookmark'] = $action_bookmark;
- $extra_data['id_bookmark'] = $id_bookmark;
- PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($message->isSuccess());
+ $response->addJSON('message', $message);
+ $response->addJSON('action_bookmark', $action_bookmark);
+ $response->addJSON('id_bookmark', $id_bookmark);
+ exit;
} else {
$run_query = false;
$error = true; // this is kind of hack to skip processing the query
diff --git a/js/functions.js b/js/functions.js
index a20a204e6b..c907328c1e 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -2417,10 +2417,7 @@ $(function() {
window.parent.frame_navigation.location.reload();
}
} else {
- var $temp_div = $("<div id='temp_div'></div>");
- $temp_div.html(data.error);
- var $error = $temp_div.find("code").addClass("error");
- PMA_ajaxShowMessage($error, false);
+ PMA_ajaxShowMessage(data.error, false);
}
}); // end $.post()
}
diff --git a/js/gis_data_editor.js b/js/gis_data_editor.js
index 477b3988a9..9cba83659d 100644
--- a/js/gis_data_editor.js
+++ b/js/gis_data_editor.js
@@ -142,7 +142,8 @@ function loadGISEditor(value, field, type, input_name, token) {
'type' : type,
'input_name' : input_name,
'get_gis_editor' : true,
- 'token' : token
+ 'token' : token,
+ 'ajax_request': true
}, function(data) {
if (data.success == true) {
$gis_editor.html(data.gis_editor);
@@ -190,7 +191,7 @@ function insertDataAndClose() {
var $form = $('form#gis_data_editor_form');
var input_name = $form.find("input[name='input_name']").val();
- $.post('gis_data_editor.php', $form.serialize() + "&generate=true", function(data) {
+ $.post('gis_data_editor.php', $form.serialize() + "&generate=true&ajax_request=true", function(data) {
if(data.success == true) {
$("input[name='" + input_name + "']").val(data.result);
} else {
@@ -226,7 +227,7 @@ $(function() {
*/
$('#gis_editor').find("input[type='text']").live('change', function() {
var $form = $('form#gis_data_editor_form');
- $.post('gis_data_editor.php', $form.serialize() + "&generate=true", function(data) {
+ $.post('gis_data_editor.php', $form.serialize() + "&generate=true&ajax_request=true", function(data) {
if(data.success == true) {
$('#gis_data_textarea').val(data.result);
$('#placeholder').empty().removeClass('hasSVG').html(data.visualization);
@@ -246,7 +247,7 @@ $(function() {
var $gis_editor = $("#gis_editor");
var $form = $('form#gis_data_editor_form');
- $.post('gis_data_editor.php', $form.serialize() + "&get_gis_editor=true", function(data) {
+ $.post('gis_data_editor.php', $form.serialize() + "&get_gis_editor=true&ajax_request=true", function(data) {
if(data.success == true) {
$gis_editor.html(data.gis_editor);
initGISEditorVisualization();
diff --git a/js/sql.js b/js/sql.js
index a31709effc..895e509386 100644
--- a/js/sql.js
+++ b/js/sql.js
@@ -227,11 +227,15 @@ $(function() {
$sqlqueryresults.show().trigger('makegrid');
$('#togglequerybox').show();
PMA_init_slider();
- if( $('#sqlqueryform input[name="retain_query_box"]').is(':checked') != true ) {
- if ($("#togglequerybox").siblings(":visible").length > 0) {
- $("#togglequerybox").trigger('click');
+
+ if (typeof data.action_bookmark == 'undefined') {
+ if( $('#sqlqueryform input[name="retain_query_box"]').is(':checked') != true ) {
+ if ($("#togglequerybox").siblings(":visible").length > 0) {
+ $("#togglequerybox").trigger('click');
+ }
}
}
+
// this happens if a USE command was typed
if (typeof data.reload != 'undefined') {
// Unbind the submit event before reloading. See bug #3295529
diff --git a/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js
index e7d60eeb8d..4c3b0706fa 100644
--- a/js/tbl_zoom_plot_jqplot.js
+++ b/js/tbl_zoom_plot_jqplot.js
@@ -12,10 +12,7 @@
** Display Help/Info
**/
function displayHelp() {
- var msgbox = PMA_ajaxShowMessage(PMA_messages['strDisplayHelp'], 10000);
- msgbox.click(function() {
- PMA_ajaxRemoveMessage(msgbox);
- });
+ PMA_ajaxShowMessage(PMA_messages['strDisplayHelp'], 10000);
}
/**
diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php
index 7eb487c014..c4f5d2fc35 100644
--- a/libraries/auth/cookie.auth.lib.php
+++ b/libraries/auth/cookie.auth.lib.php
@@ -136,7 +136,7 @@ function PMA_auth()
if (! empty($conn_error)) {
$response->addJSON('message', $conn_error);
} else {
- $response->addJSON('message', __('Session expired'));
+ $response->addJSON('message', PMA_Message::error(__('Your session has expired. Please login again.')));
}
exit;
}
diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index 08b0437c94..77bb491e4e 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -679,10 +679,13 @@ function PMA_mysqlDie(
/**
* If in an Ajax request
* - avoid displaying a Back link
- * - use PMA_ajaxResponse() to transmit the message and exit
+ * - use PMA_Response() to transmit the message and exit
*/
if ($GLOBALS['is_ajax_request'] == true) {
- PMA_ajaxResponse($error_msg, false);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $error_msg);
+ exit;
}
if (! empty($back_url)) {
if (strstr($back_url, '?')) {
@@ -3245,28 +3248,6 @@ function PMA_expandUserString($string, $escape = null, $updates = array())
}
/**
- * function that generates a json output for an ajax request and ends script
- * execution
- *
- * @param PMA_Message|string $message message string containing the
- * html of the message
- * @param bool $success success whether the ajax request
- * was successfull
- * @param array $extra_data extra data optional - any other data
- * as part of the json request
- *
- * @return void
- */
-function PMA_ajaxResponse($message, $success = true, $extra_data = array())
-{
- $response = PMA_Response::getInstance();
- $response->isSuccess($success);
- $response->addJSON('message', $message);
- $response->addJSON($extra_data);
- exit;
-}
-
-/**
* Display the form used to browse anywhere on the local server for a file to
* import
*
diff --git a/libraries/db_common.inc.php b/libraries/db_common.inc.php
index 7516a2dd20..75ae3a280d 100644
--- a/libraries/db_common.inc.php
+++ b/libraries/db_common.inc.php
@@ -72,8 +72,11 @@ if (isset($submitcollation) && !empty($db_collation)) {
* other pages, we might have to move this to a different location.
*/
if ( $GLOBALS['is_ajax_request'] == true) {
- PMA_ajaxResponse($message, $message->isSuccess());
- };
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($message->isSuccess());
+ $response->addJSON('message', $message);
+ exit;
+ }
}
/**
diff --git a/libraries/rte/rte_events.lib.php b/libraries/rte/rte_events.lib.php
index 55d7b9c02e..3c5832614e 100644
--- a/libraries/rte/rte_events.lib.php
+++ b/libraries/rte/rte_events.lib.php
@@ -148,21 +148,22 @@ function PMA_EVN_handleEditor()
$output = PMA_getMessage($message, $sql_query);
if ($GLOBALS['is_ajax_request']) {
- $extra_data = array();
+ $response = PMA_Response::getInstance();
if ($message->isSuccess()) {
$columns = "`EVENT_NAME`, `EVENT_TYPE`, `STATUS`";
$where = "EVENT_SCHEMA='" . PMA_sqlAddSlashes($db) . "' "
. "AND EVENT_NAME='" . PMA_sqlAddSlashes($_REQUEST['item_name']) . "'";
$query = "SELECT $columns FROM `INFORMATION_SCHEMA`.`EVENTS` WHERE $where;";
$event = PMA_DBI_fetch_single_row($query);
- $extra_data['name'] = htmlspecialchars(strtoupper($_REQUEST['item_name']));
- $extra_data['new_row'] = PMA_EVN_getRowForList($event);
- $extra_data['insert'] = ! empty($event);
- $response = $output;
+ $response->addJSON('name', htmlspecialchars(strtoupper($_REQUEST['item_name'])));
+ $response->addJSON('new_row', PMA_EVN_getRowForList($event));
+ $response->addJSON('insert', ! empty($event));
+ $response->addJSON('message', $output);
} else {
- $response = $message;
+ $response->isSuccess(false);
+ $response->addJSON('message', $message);
}
- PMA_ajaxResponse($response, $message->isSuccess(), $extra_data);
+ exit;
}
}
/**
@@ -200,8 +201,9 @@ function PMA_EVN_handleEditor()
// Show form
$editor = PMA_EVN_getEditorForm($mode, $operation, $item);
if ($GLOBALS['is_ajax_request']) {
- $extra_data = array('title' => $title);
- PMA_ajaxResponse($editor, true, $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $editor);
+ $response->addJSON('title', $title);
} else {
echo "\n\n<h2>$title</h2>\n\n$editor";
unset($_POST);
@@ -216,7 +218,10 @@ function PMA_EVN_handleEditor()
);
$message = PMA_message::error($message);
if ($GLOBALS['is_ajax_request']) {
- PMA_ajaxResponse($message, false);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $message);
+ exit;
} else {
$message->display();
}
diff --git a/libraries/rte/rte_export.lib.php b/libraries/rte/rte_export.lib.php
index 45adb0edea..47751fb4a3 100644
--- a/libraries/rte/rte_export.lib.php
+++ b/libraries/rte/rte_export.lib.php
@@ -26,8 +26,10 @@ function PMA_RTE_handleExport($item_name, $export_data)
. htmlspecialchars(trim($export_data)) . '</textarea>';
$title = sprintf(PMA_RTE_getWord('export'), $item_name);
if ($GLOBALS['is_ajax_request'] == true) {
- $extra_data = array('title' => $title);
- PMA_ajaxResponse($export_data, true, $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $export_data);
+ $response->addJSON('title', $title);
+ exit;
} else {
echo "<fieldset>\n"
. "<legend>$title</legend>\n"
@@ -40,7 +42,10 @@ function PMA_RTE_handleExport($item_name, $export_data)
. sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db);
$response = PMA_message::error($response);
if ($GLOBALS['is_ajax_request'] == true) {
- PMA_ajaxResponse($response, false);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $response);
+ exit;
} else {
$response->display();
}
diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php
index da85edd8ee..c5654635d6 100644
--- a/libraries/rte/rte_routines.lib.php
+++ b/libraries/rte/rte_routines.lib.php
@@ -301,21 +301,22 @@ function PMA_RTN_handleEditor()
$output = PMA_getMessage($message, $sql_query);
if ($GLOBALS['is_ajax_request']) {
- $extra_data = array();
+ $response = PMA_Response::getInstance();
if ($message->isSuccess()) {
$columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, `DTD_IDENTIFIER`, `ROUTINE_DEFINITION`";
$where = "ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "' "
. "AND ROUTINE_NAME='" . PMA_sqlAddSlashes($_REQUEST['item_name']) . "'"
. "AND ROUTINE_TYPE='" . PMA_sqlAddSlashes($_REQUEST['item_type']) . "'";
$routine = PMA_DBI_fetch_single_row("SELECT $columns FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE $where;");
- $extra_data['name'] = htmlspecialchars(strtoupper($_REQUEST['item_name']));
- $extra_data['new_row'] = PMA_RTN_getRowForList($routine);
- $extra_data['insert'] = ! empty($routine);
- $response = $output;
+ $response->addJSON('name', htmlspecialchars(strtoupper($_REQUEST['item_name'])));
+ $response->addJSON('new_row', PMA_RTN_getRowForList($routine));
+ $response->addJSON('insert', ! empty($routine));
+ $response->addJSON('message', $output);
} else {
- $response = $message;
+ $response->isSuccess(false);
+ $response->addJSON('message', $output);
}
- PMA_ajaxResponse($response, $message->isSuccess(), $extra_data);
+ exit;
}
}
@@ -359,13 +360,14 @@ function PMA_RTN_handleEditor()
// Show form
$editor = PMA_RTN_getEditorForm($mode, $operation, $routine);
if ($GLOBALS['is_ajax_request']) {
- $template = PMA_RTN_getParameterRow();
- $extra_data = array('title' => $title,
- 'param_template' => $template,
- 'type' => $routine['item_type']);
- PMA_ajaxResponse($editor, true, $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $editor);
+ $response->addJSON('title', $title);
+ $response->addJSON('param_template', PMA_RTN_getParameterRow());
+ $response->addJSON('type', $routine['item_type']);
+ } else {
+ echo "\n\n<h2>$title</h2>\n\n$editor";
}
- echo "\n\n<h2>$title</h2>\n\n$editor";
exit;
} else {
$message = __('Error in processing request') . ' : ';
@@ -376,7 +378,9 @@ function PMA_RTN_handleEditor()
);
$message = PMA_message::error($message);
if ($GLOBALS['is_ajax_request']) {
- PMA_ajaxResponse($message, false);
+ $response->isSuccess(false);
+ $response->addJSON('message', $message);
+ exit;
} else {
$message->display();
}
@@ -1267,12 +1271,11 @@ function PMA_RTN_handleExecute()
}
// Print/send output
if ($GLOBALS['is_ajax_request']) {
- $extra_data = array('dialog' => false);
- PMA_ajaxResponse(
- $message->getDisplay() . $output,
- $message->isSuccess(),
- $extra_data
- );
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($message->isSuccess());
+ $response->addJSON('message', $message->getDisplay() . $output);
+ $response->addJSON('dialog', false);
+ exit;
} else {
echo $message->getDisplay() . $output;
if ($message->isError()) {
@@ -1292,7 +1295,10 @@ function PMA_RTN_handleExecute()
);
$message = PMA_message::error($message);
if ($GLOBALS['is_ajax_request']) {
- PMA_ajaxResponse($message, $message->isSuccess());
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $message);
+ exit;
} else {
echo $message->getDisplay();
unset($_POST);
@@ -1306,18 +1312,18 @@ function PMA_RTN_handleExecute()
if ($routine !== false) {
$form = PMA_RTN_getExecuteForm($routine);
if ($GLOBALS['is_ajax_request'] == true) {
- $extra_data = array();
- $extra_data['dialog'] = true;
- $extra_data['title'] = __("Execute routine") . " ";
- $extra_data['title'] .= PMA_backquote(
+ $title = __("Execute routine") . " " . PMA_backquote(
htmlentities($_GET['item_name'], ENT_QUOTES)
);
- PMA_ajaxResponse($form, true, $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $form);
+ $response->addJSON('title', $title);
+ $response->addJSON('dialog', true);
} else {
echo "\n\n<h2>" . __("Execute routine") . "</h2>\n\n";
echo $form;
- exit;
}
+ exit;
} else if (($GLOBALS['is_ajax_request'] == true)) {
$message = __('Error in processing request') . ' : ';
$message .= sprintf(
@@ -1326,7 +1332,11 @@ function PMA_RTN_handleExecute()
htmlspecialchars(PMA_backquote($db))
);
$message = PMA_message::error($message);
- PMA_ajaxResponse($message, false);
+
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $message);
+ exit;
}
}
}
diff --git a/libraries/rte/rte_triggers.lib.php b/libraries/rte/rte_triggers.lib.php
index 25414eadd3..ba8d3f8b30 100644
--- a/libraries/rte/rte_triggers.lib.php
+++ b/libraries/rte/rte_triggers.lib.php
@@ -121,7 +121,7 @@ function PMA_TRI_handleEditor()
$output = PMA_getMessage($message, $sql_query);
if ($GLOBALS['is_ajax_request']) {
- $extra_data = array();
+ $response = PMA_Response::getInstance();
if ($message->isSuccess()) {
$items = PMA_DBI_get_triggers($db, $table, '');
$trigger = false;
@@ -130,19 +130,24 @@ function PMA_TRI_handleEditor()
$trigger = $value;
}
}
- $extra_data['insert'] = false;
+ $insert = false;
if (empty($table) || ($trigger !== false && $table == $trigger['table'])) {
- $extra_data['insert'] = true;
- $extra_data['new_row'] = PMA_TRI_getRowForList($trigger);
- $extra_data['name'] = htmlspecialchars(
- strtoupper($_REQUEST['item_name'])
+ $insert = true;
+ $response->addJSON('new_row', PMA_TRI_getRowForList($trigger));
+ $response->addJSON(
+ 'name',
+ htmlspecialchars(
+ strtoupper($_REQUEST['item_name'])
+ )
);
}
- $response = $output;
+ $response->addJSON('insert', $insert);
+ $response->addJSON('message', $output);
} else {
- $response = $message;
+ $response->addJSON('message', $message);
+ $response->isSuccess(false);
}
- PMA_ajaxResponse($response, $message->isSuccess(), $extra_data);
+ exit;
}
}
@@ -175,8 +180,9 @@ function PMA_TRI_handleEditor()
// Show form
$editor = PMA_TRI_getEditorForm($mode, $item);
if ($GLOBALS['is_ajax_request']) {
- $extra_data = array('title' => $title);
- PMA_ajaxResponse($editor, true, $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $editor);
+ $response->addJSON('title', $title);
} else {
echo "\n\n<h2>$title</h2>\n\n$editor";
unset($_POST);
@@ -191,7 +197,10 @@ function PMA_TRI_handleEditor()
);
$message = PMA_message::error($message);
if ($GLOBALS['is_ajax_request']) {
- PMA_ajaxResponse($message, false);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $message);
+ exit;
} else {
$message->display();
}
diff --git a/navigation.php b/navigation.php
index f92abf2883..17d649b6da 100644
--- a/navigation.php
+++ b/navigation.php
@@ -29,11 +29,12 @@ require_once 'libraries/RecentTable.class.php';
* Check if it is an ajax request to reload the recent tables list.
*/
if ($GLOBALS['is_ajax_request'] && $_REQUEST['recent_table']) {
- PMA_ajaxResponse(
- '',
- true,
- array('options' => PMA_RecentTable::getInstance()->getHtmlSelectOption())
+ $response = PMA_Response::getInstance();
+ $response->addJSON(
+ 'options',
+ PMA_RecentTable::getInstance()->getHtmlSelectOption()
);
+ exit;
}
// keep the offset of the db list in session before closing it
diff --git a/prefs_manage.php b/prefs_manage.php
index d18479dfe8..fac699bfec 100644
--- a/prefs_manage.php
+++ b/prefs_manage.php
@@ -28,18 +28,13 @@ if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') ==
PMA_downloadHeader($filename, 'application/json');
$settings = PMA_load_userprefs();
echo json_encode($settings['config_data']);
- return;
+ exit;
} else if (isset($_POST['submit_get_json'])) {
$settings = PMA_load_userprefs();
- PMA_ajaxResponse(
- '',
- true,
- array(
- 'prefs' => json_encode($settings['config_data']),
- 'mtime' => $settings['mtime']
- )
- );
- return;
+ $response = PMA_Response::getInstance();
+ $response->addJSON('prefs', json_encode($settings['config_data']));
+ $response->addJSON('mtime', $settings['mtime']);
+ exit;
} else if (isset($_POST['submit_import'])) {
// load from JSON file
$json = '';
diff --git a/server_databases.php b/server_databases.php
index f267fb9d7d..a15e2cd178 100644
--- a/server_databases.php
+++ b/server_databases.php
@@ -117,7 +117,10 @@ if ((isset($_REQUEST['drop_selected_dbs']) || isset($_REQUEST['query_type']))
}
}
if ($GLOBALS['is_ajax_request'] && $message instanceof PMA_Message) {
- PMA_ajaxResponse($message, $message->isSuccess());
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($message->isSuccess());
+ $response->addJSON('message', $message);
+ exit;
}
}
diff --git a/server_privileges.php b/server_privileges.php
index 0bf3955079..cb9cc59b7c 100644
--- a/server_privileges.php
+++ b/server_privileges.php
@@ -1643,7 +1643,11 @@ if ($GLOBALS['is_ajax_request'] && ! isset($_REQUEST['export']) && (! isset($_RE
}
if ($message instanceof PMA_Message) {
- PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($message->isSuccess());
+ $response->addJSON('message', $message);
+ $response->addJSON($extra_data);
+ exit;
}
}
@@ -1705,7 +1709,10 @@ if (isset($_REQUEST['export']) || (isset($_REQUEST['submit_mult']) && $_REQUEST[
$response .= '</textarea>';
unset($username, $hostname, $grants, $one_grant);
if ($GLOBALS['is_ajax_request']) {
- PMA_ajaxResponse($response, 1, array('title' => $title));
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $response);
+ $response->addJSON('title', $title);
+ exit;
} else {
echo "<h2>$title</h2>$response";
}
@@ -2568,9 +2575,11 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
. '</table></fieldset></form>' . "\n";
if ($GLOBALS['is_ajax_request'] == true) {
- $extra_data['user_form'] = $user_form;
$message = PMA_Message::success(__('User has been added.'));
- PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $message);
+ $response->addJSON('user_form', $user_form);
+ exit;
} else {
// Offer to create a new user for the current database
$user_form .= '<fieldset id="fieldset_add_user">' . "\n"
diff --git a/sql.php b/sql.php
index c20ed2bc7f..0a109a9b5a 100644
--- a/sql.php
+++ b/sql.php
@@ -146,8 +146,9 @@ if (isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_value
$dropdown = '<select>' . $dropdown . '</select>';
}
- $extra_data['dropdown'] = $dropdown;
- PMA_ajaxResponse(null, true, $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('dropdown', $dropdown);
+ exit;
}
/**
@@ -173,8 +174,9 @@ if (isset($_REQUEST['get_enum_values']) && $_REQUEST['get_enum_values'] == true)
$dropdown = '<select>' . $dropdown . '</select>';
- $extra_data['dropdown'] = $dropdown;
- PMA_ajaxResponse(null, true, $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('dropdown', $dropdown);
+ exit;
}
/**
@@ -201,8 +203,9 @@ if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) {
$select_size = (sizeof($values) > 10) ? 10 : sizeof($values);
$select = '<select multiple="multiple" size="' . $select_size . '">' . $select . '</select>';
- $extra_data['select'] = $select;
- PMA_ajaxResponse(null, true, $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('select', $select);
+ exit;
}
/**
@@ -220,7 +223,10 @@ if (isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) {
$_REQUEST['table_create_time']
);
if (gettype($retval) != 'boolean') {
- PMA_ajaxResponse($retval->getString(), false);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $retval->getString());
+ exit;
}
}
@@ -232,11 +238,16 @@ if (isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) {
$_REQUEST['table_create_time']
);
if (gettype($retval) != 'boolean') {
- PMA_ajaxResponse($retval->getString(), false);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $retval->getString());
+ exit;
}
}
- PMA_ajaxResponse(null, ($retval == true));
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($retval == true);
+ exit;
}
// Default to browse if no query set and we have table
@@ -572,7 +583,10 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) {
$message = PMA_Message::rawError($error);
if ($GLOBALS['is_ajax_request'] == true) {
- PMA_ajaxResponse($message, false);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $message);
+ exit;
}
/**
@@ -820,7 +834,11 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
$extra_data['reload'] = 1;
$extra_data['db'] = $GLOBALS['db'];
}
- PMA_ajaxResponse($message, $message->isSuccess(), (isset($extra_data) ? $extra_data : array()));
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($message->isSuccess());
+ $response->addJSON('message', $message);
+ $response->addJSON(isset($extra_data) ? $extra_data : array());
+ exit;
}
if ($is_gotofile) {
@@ -863,9 +881,9 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
// value of a transformed field, show it here and exit
if ($GLOBALS['grid_edit'] == true && $GLOBALS['cfg']['AjaxEnable']) {
$row = PMA_DBI_fetch_row($result);
- $extra_data = array();
- $extra_data['value'] = $row[0];
- PMA_ajaxResponse(null, true, $extra_data);
+ $response = PMA_Response::getInstance();
+ $response->addJSON('value', $row[0]);
+ exit;
}
if (isset($_REQUEST['ajax_request']) && isset($_REQUEST['table_maintenance'])) {
diff --git a/tbl_addfield.php b/tbl_addfield.php
index e0cf74dda1..efde25c048 100644
--- a/tbl_addfield.php
+++ b/tbl_addfield.php
@@ -188,9 +188,11 @@ if (isset($_REQUEST['do_save_data'])) {
$message = PMA_Message::success(__('Table %1$s has been altered successfully'));
$message->addParam($table);
- if ( $GLOBALS['is_ajax_request'] == true) {
- $extra_data['sql_query'] = PMA_getMessage(null, $sql_query);
- PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
+ if ($GLOBALS['is_ajax_request'] == true) {
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $message);
+ $response->addJSON('sql_query', PMA_getMessage(null, $sql_query));
+ exit;
}
$active_page = 'tbl_structure.php';
diff --git a/tbl_alter.php b/tbl_alter.php
index 8c41860fa0..b7e1d74b91 100644
--- a/tbl_alter.php
+++ b/tbl_alter.php
@@ -113,8 +113,10 @@ if (isset($_REQUEST['move_columns'])
// insert moved column
array_splice($column_names, $i, 0, $column);
}
+ $response = PMA_Response::getInstance();
if (empty($changes)) { // should never happen
- PMA_ajaxResponse('', true);
+ $response->isSuccess(false);
+ exit;
}
$move_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ';
$move_query .= implode(', ', $changes);
@@ -122,15 +124,16 @@ if (isset($_REQUEST['move_columns'])
$result = PMA_DBI_try_query($move_query);
$tmp_error = PMA_DBI_getError();
if ($tmp_error) {
- PMA_ajaxResponse(PMA_Message::error($tmp_error), false);
+ $response->isSuccess(false);
+ $response->addJSON('message', PMA_Message::error($tmp_error));
+ } else {
+ $message = PMA_Message::success(
+ __('The columns have been moved successfully.')
+ );
+ $response->addJSON('message', $message);
+ $response->addJSON('columns', $column_names);
}
- PMA_ajaxResponse(
- PMA_Message::success(__('The columns have been moved successfully.')),
- true,
- array(
- 'columns' => $column_names
- )
- );
+ exit;
}
/**
@@ -249,9 +252,12 @@ if (isset($_REQUEST['do_save_data'])) {
}
}
- if ( $_REQUEST['ajax_request'] == true) {
- $extra_data['sql_query'] = PMA_getMessage(null, $sql_query);
- PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
+ if ($_REQUEST['ajax_request'] == true) {
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($message->isSuccess());
+ $response->addJSON('message', $message);
+ $response->addJSON('sql_query', PMA_getMessage(null, $sql_query));
+ exit;
}
$active_page = 'tbl_structure.php';
diff --git a/tbl_create.php b/tbl_create.php
index 43832a887f..78f687129e 100644
--- a/tbl_create.php
+++ b/tbl_create.php
@@ -320,29 +320,31 @@ if (isset($_REQUEST['do_save_data'])) {
$new_table_string .= '</tr>' . "\n";
- $extra_data['new_table_string'] = $new_table_string;
-
- PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
- }
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $message);
+ $response->addJSON('new_table_string', $new_table_string);
+ } else {
- $display_query = $sql_query;
- $sql_query = '';
+ $display_query = $sql_query;
+ $sql_query = '';
- // read table info on this newly created table, in case
- // the next page is Structure
- $reread_info = true;
- include 'libraries/tbl_info.inc.php';
+ // read table info on this newly created table, in case
+ // the next page is Structure
+ $reread_info = true;
+ include 'libraries/tbl_info.inc.php';
- // do not switch to sql.php - as there is no row to be displayed on a new table
- if ($cfg['DefaultTabTable'] === 'sql.php') {
- include 'tbl_structure.php';
- } else {
- include '' . $cfg['DefaultTabTable'];
+ // do not switch to sql.php - as there is no row to be displayed on a new table
+ if ($cfg['DefaultTabTable'] === 'sql.php') {
+ include 'tbl_structure.php';
+ } else {
+ include '' . $cfg['DefaultTabTable'];
+ }
}
- exit;
} else {
if ($GLOBALS['is_ajax_request'] == true) {
- PMA_ajaxResponse(PMA_DBI_getError(), false);
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', PMA_DBI_getError());
} else {
PMA_mysqlDie('', '', '', $err_url, false);
// An error happened while inserting/updating a table definition.
@@ -352,6 +354,7 @@ if (isset($_REQUEST['do_save_data'])) {
$regenerate = true;
}
}
+ exit;
} // end do create table
/**
diff --git a/tbl_indexes.php b/tbl_indexes.php
index dc07c9c925..5b1462585f 100644
--- a/tbl_indexes.php
+++ b/tbl_indexes.php
@@ -105,21 +105,25 @@ if (isset($_REQUEST['do_save_data'])) {
'Table %1$s has been altered successfully'));
$message->addParam($table);
- if ( $GLOBALS['is_ajax_request'] == true) {
- $extra_data['index_table'] = PMA_Index::getView($table, $db);
- $extra_data['sql_query'] = PMA_getMessage(null, $sql_query);
- PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
+ if ($GLOBALS['is_ajax_request'] == true) {
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $message);
+ $response->addJSON('index_table', PMA_Index::getView($table, $db));
+ $response->addJSON('sql_query', PMA_getMessage(null, $sql_query));
+ } else {
+ $active_page = 'tbl_structure.php';
+ include 'tbl_structure.php';
}
-
- $active_page = 'tbl_structure.php';
- include 'tbl_structure.php';
exit;
} else {
- if ( $GLOBALS['is_ajax_request'] == true) {
- $extra_data['error'] = $error;
- PMA_ajaxResponse($error, false);
+ if ($GLOBALS['is_ajax_request'] == true) {
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $error);
+ exit;
+ } else {
+ $error->display();
}
- $error->display();
}
} // end builds the new index
diff --git a/tbl_move_copy.php b/tbl_move_copy.php
index 6779754a59..c9a6d3aad4 100644
--- a/tbl_move_copy.php
+++ b/tbl_move_copy.php
@@ -64,16 +64,9 @@ if (PMA_isValid($_REQUEST['new_name'])) {
/* Check: Work on new table or on old table? */
if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) {
- $db = $_REQUEST['target_db'];
- $table = $_REQUEST['new_name'];
+ $db = $_REQUEST['target_db'];
+ $table = $_REQUEST['new_name'];
}
-
- if ( $_REQUEST['ajax_request'] == true) {
- $extra_data['sql_query'] = PMA_getMessage(null, $sql_query);
- $extra_data['db'] = $GLOBALS['db'];
- PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
- }
-
$reload = 1;
}
} else {
@@ -84,6 +77,18 @@ if (PMA_isValid($_REQUEST['new_name'])) {
$result = false;
}
+if ($GLOBALS['is_ajax_request'] == true) {
+ $response = PMA_Response::getInstance();
+ $response->addJSON('message', $message);
+ if ($message->isSuccess()) {
+ $response->addJSON('db', $GLOBALS['db']);
+ $response->addJSON('sql_query', PMA_getMessage(null, $sql_query));
+ } else {
+ $response->isSuccess(false);
+ }
+ exit;
+}
+
/**
* Back to the calling script
*/
diff --git a/tbl_operations.php b/tbl_operations.php
index 3d44a7e684..e2d1e25319 100644
--- a/tbl_operations.php
+++ b/tbl_operations.php
@@ -231,17 +231,23 @@ if (isset($result) && empty($message_to_show)) {
$_message = $result ? $message = PMA_Message::success(__('Your SQL query has been executed successfully')) : PMA_Message::error(__('Error'));
// $result should exist, regardless of $_message
$_type = $result ? 'success' : 'error';
- if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
- $extra_data['sql_query'] = PMA_getMessage(null, $sql_query);
- PMA_ajaxResponse($_message, $_message->isSuccess(), $extra_data);
+ if ($GLOBALS['ajax_request'] == true) {
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($_message->isSuccess());
+ $response->addJSON('message', $_message);
+ $response->addJSON('sql_query', PMA_getMessage(null, $sql_query));
+ exit;
}
}
if (! empty($warning_messages)) {
$_message = new PMA_Message;
$_message->addMessages($warning_messages);
$_message->isError(true);
- if ( $_REQUEST['ajax_request'] == true) {
- PMA_ajaxResponse($_message, false);
+ if ($GLOBALS['ajax_request'] == true) {
+ $response = PMA_Response::getInstance();
+ $response->isSuccess(false);
+ $response->addJSON('message', $_message);
+ exit;
}
unset($warning_messages);
}
diff --git a/tbl_replace.php b/tbl_replace.php
index 2f75331b06..f74281dd69 100644
--- a/tbl_replace.php
+++ b/tbl_replace.php
@@ -421,7 +421,12 @@ if ($GLOBALS['is_ajax_request'] == true) {
/**Get the total row count of the table*/
$extra_data['row_count'] = PMA_Table::countRecords($_REQUEST['db'], $_REQUEST['table']);
$extra_data['sql_query'] = PMA_getMessage($message, $GLOBALS['display_query']);
- PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
+
+ $response = PMA_Response::getInstance();
+ $response->isSuccess($message->isSuccess());
+ $response->addJSON('message', $message);
+ $response->addJSON($extra_data);
+ exit;
}
if (isset($return_to_sql_query)) {
diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php
index cdb37b5b38..0ff020be97 100644
--- a/tbl_zoom_select.php
+++ b/tbl_zoom_select.php
@@ -72,7 +72,8 @@ if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) {
}
$extra_data['row_info'] = $row;
}
- PMA_ajaxResponse(null, true, $extra_data);
+ PMA_Response::getInstance()->addJSON($extra_data);
+ exit;
}
/**
@@ -82,14 +83,14 @@ if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) {
*/
if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) {
- $extra_data = array();
+ $response = PMA_Response::getInstance();
$field = $_REQUEST['field'];
if ($field == 'pma_null') {
- $extra_data['field_type'] = '';
- $extra_data['field_collation'] = '';
- $extra_data['field_operators'] = '';
- $extra_data['field_value'] = '';
- PMA_ajaxResponse(null, true, $extra_data);
+ $response->addJSON('field_type', '');
+ $response->addJSON('field_collation', '');
+ $response->addJSON('field_operators', '');
+ $response->addJSON('field_value', '');
+ exit;
}
// Gets the list and number of fields
list($columnNames, $columnTypes, $columnCollations, $columnNullFlags)
@@ -100,11 +101,11 @@ if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true)
$db, $table, $columnNames, $columnTypes, $columnCollations,
$columnNullFlags, $foreigners, $_REQUEST['it'], $key
);
- $extra_data['field_type'] = $properties['type'];
- $extra_data['field_collation'] = $properties['collation'];
- $extra_data['field_operators'] = $properties['func'];
- $extra_data['field_value'] = $properties['value'];
- PMA_ajaxResponse(null, true, $extra_data);
+ $response->addJSON('field_type', $properties['type']);
+ $response->addJSON('field_collation', $properties['collation']);
+ $response->addJSON('field_operators', $properties['func']);
+ $response->addJSON('field_value', $properties['value']);
+ exit;
}
$titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
diff --git a/test/libraries/common/PMA_ajaxResponse_test.php b/test/libraries/common/PMA_ajaxResponse_test.php
deleted file mode 100644
index 916f15b2b4..0000000000
--- a/test/libraries/common/PMA_ajaxResponse_test.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-/* vim: set expandtab sw=4 ts=4 sts=4: */
-/**
- * Test for PMA_ajaxResponse from common.lib.php
- *
- * @package PhpMyAdmin-test
- * @group common.lib-tests
- */
-
-/*
- * Include to test.
- */
-require_once 'libraries/common.lib.php';
-require_once 'libraries/Message.class.php';
-
-class PMA_ajaxResponse_test extends PHPUnit_Framework_TestCase
-{
- function testAjaxResponseText()
- {
- $message = 'text';
-
- $this->expectOutputString('{"success":true,"message":"' . $message . '"}');
- PMA_ajaxResponse($message);
- }
-
- function testAjaxResponseTextWithExtra()
- {
- $message = 'text';
- $exra = array('str_val' => 'te\x/t"1', 'int_val' => 10);
-
- $this->expectOutputString('{"success":true,"message":"' . $message . '","str_val":"te\\\\x\/t\"1","int_val":10}');
- PMA_ajaxResponse($message, true, $exra);
- }
-
- function testAjaxResponseTextError()
- {
- $message = 'error_text';
-
- $this->expectOutputString('{"success":false,"error":"' . $message . '"}');
- PMA_ajaxResponse($message, false);
- }
-
- function testAjaxResponseMessage()
- {
- $message = new PMA_Message("Message Text", 1);
-
- $this->expectOutputString('{"success":true,"message":"<div class=\"success\">Message Text<\/div>"}');
- PMA_ajaxResponse($message);
- }
-
- function testAjaxResponseMessageWithExtra()
- {
-
- $message = new PMA_Message("Message Text", 1);
- $exra = array('str_val' => 'te\x/t"1', 'int_val' => 10);
-
- $this->expectOutputString('{"success":true,"message":"<div class=\"success\">Message Text<\/div>","str_val":"te\\\\x\/t\"1","int_val":10}');
- PMA_ajaxResponse($message, true, $exra);
- }
-
- function testAjaxResponseMessageError()
- {
-
- $message = new PMA_Message("Error Message Text", 1);
-
- // TODO: class for output div should be "error"
- $this->expectOutputString('{"success":false,"error":"<div class=\"success\">Error Message Text<\/div>"}');
- PMA_ajaxResponse($message, false);
- }
-
-} \ No newline at end of file
diff --git a/view_create.php b/view_create.php
index b0cf55764b..10ccfbc9d1 100644
--- a/view_create.php
+++ b/view_create.php
@@ -66,15 +66,27 @@ if (isset($_REQUEST['createview'])) {
if ($GLOBALS['is_ajax_request'] != true) {
$message = PMA_Message::success();
include './' . $cfg['DefaultTabDatabase'];
- exit();
} else {
- PMA_ajaxResponse(PMA_getMessage(PMA_Message::success(), $sql_query), 1);
+ $response = PMA_Response::getInstance();
+ $response->addJSON(
+ 'message',
+ PMA_getMessage(PMA_Message::success(), $sql_query)
+ );
}
+ exit;
} else {
if ($GLOBALS['is_ajax_request'] != true) {
$message = PMA_Message::rawError(PMA_DBI_getError());
} else {
- PMA_ajaxResponse(PMA_Message::error("<i>$sql_query</i><br /><br />" . PMA_DBI_getError()), 0);
+ $response = PMA_Response::getInstance();
+ $response->addJSON(
+ 'message',
+ PMA_Message::error(
+ "<i>$sql_query</i><br /><br />" . PMA_DBI_getError()
+ )
+ );
+ $response->isSuccess(false);
+ exit;
}
}
}