make use of PMA_Message

This commit is contained in:
Sebastian Mendel
2007-10-16 12:14:19 +00:00
parent 86acb749a4
commit 107fc46ad9
14 changed files with 103 additions and 91 deletions

View File

@@ -35,14 +35,18 @@ $sql_query .= ';';
$result = PMA_DBI_try_query($sql_query); $result = PMA_DBI_try_query($sql_query);
if (! $result) { if (! $result) {
$message = PMA_DBI_getError(); $message = PMA_Message::rawError(PMA_DBI_getError());
// avoid displaying the not-created db name in header or navi panel // avoid displaying the not-created db name in header or navi panel
$GLOBALS['db'] = ''; $GLOBALS['db'] = '';
$GLOBALS['table'] = ''; $GLOBALS['table'] = '';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
require_once './main.php'; require_once './main.php';
} else { } else {
$message = $strDatabase . ' ' . htmlspecialchars($db) . ' ' . $strHasBeenCreated; $message = PMA_Message::success();
$message->setMessage($strDatabase . ' ' . htmlspecialchars($db) . ' ' . $strHasBeenCreated);
//$message = PMA_Message::success('strDatabaseHasBeenCreated');
//$message->addParam($db);
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
require_once './' . $cfg['DefaultTabDatabase']; require_once './' . $cfg['DefaultTabDatabase'];
} }

View File

@@ -58,7 +58,7 @@ if (empty($_REQUEST['asfile'])) {
// Does export require to be into file? // Does export require to be into file?
if (isset($export_list[$type]['force_file']) && ! $asfile) { if (isset($export_list[$type]['force_file']) && ! $asfile) {
$message = new PMA_Message('strExportMustBeFile', PMA_Message::ERROR); $message = PMA_Message::error('strExportMustBeFile');
$GLOBALS['js_include'][] = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
if ($export_type == 'server') { if ($export_type == 'server') {
@@ -300,16 +300,16 @@ if ($save_on_server) {
$save_filename = PMA_userDir($cfg['SaveDir']) . preg_replace('@[/\\\\]@', '_', $filename); $save_filename = PMA_userDir($cfg['SaveDir']) . preg_replace('@[/\\\\]@', '_', $filename);
unset($message); unset($message);
if (file_exists($save_filename) && empty($onserverover)) { if (file_exists($save_filename) && empty($onserverover)) {
$message = new PMA_Message('strFileAlreadyExists', PMA_Message::ERROR, $save_filename); $message = PMA_Message::error('strFileAlreadyExists');
$GLOBALS['show_error_header'] = true; $message->addParam($save_filename);
} else { } else {
if (is_file($save_filename) && !is_writable($save_filename)) { if (is_file($save_filename) && !is_writable($save_filename)) {
$message = new PMA_Message('strNoPermission', PMA_Message::ERROR, $save_filename); $message = PMA_Message::error('strNoPermission');
$GLOBALS['show_error_header'] = true; $message->addParam($save_filename);
} else { } else {
if (!$file_handle = @fopen($save_filename, 'w')) { if (!$file_handle = @fopen($save_filename, 'w')) {
$message = new PMA_Message('strNoPermission', PMA_Message::ERROR, $save_filename); $message = PMA_Message::error('strNoPermission');
$GLOBALS['show_error_header'] = true; $message->addParam($save_filename);
} }
} }
} }
@@ -360,7 +360,7 @@ if (!$save_on_server) {
if ($export_type == 'database') { if ($export_type == 'database') {
$num_tables = count($tables); $num_tables = count($tables);
if ($num_tables == 0) { if ($num_tables == 0) {
$message = new PMA_Message('strNoTablesFound', PMA_Message::ERROR); $message = PMA_Message::error('strNoTablesFound');
$GLOBALS['js_include'][] = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
$active_page = 'db_export.php'; $active_page = 'db_export.php';

View File

@@ -251,8 +251,7 @@ if ($import_file != 'none' && !$error) {
// Handle file compression // Handle file compression
$compression = PMA_detectCompression($import_file); $compression = PMA_detectCompression($import_file);
if ($compression === FALSE) { if ($compression === FALSE) {
$message = $strFileCouldNotBeRead; $message = PMA_Message::error('strFileCouldNotBeRead');
$show_error_header = TRUE;
$error = TRUE; $error = TRUE;
} else { } else {
switch ($compression) { switch ($compression) {
@@ -260,8 +259,8 @@ if ($import_file != 'none' && !$error) {
if ($cfg['BZipDump'] && @function_exists('bzopen')) { if ($cfg['BZipDump'] && @function_exists('bzopen')) {
$import_handle = @bzopen($import_file, 'r'); $import_handle = @bzopen($import_file, 'r');
} else { } else {
$message = sprintf($strUnsupportedCompressionDetected, $compression); $message = PMA_Message::error('strUnsupportedCompressionDetected');
$show_error_header = TRUE; $message->addParam($compression);
$error = TRUE; $error = TRUE;
} }
break; break;
@@ -269,8 +268,8 @@ if ($import_file != 'none' && !$error) {
if ($cfg['GZipDump'] && @function_exists('gzopen')) { if ($cfg['GZipDump'] && @function_exists('gzopen')) {
$import_handle = @gzopen($import_file, 'r'); $import_handle = @gzopen($import_file, 'r');
} else { } else {
$message = sprintf($strUnsupportedCompressionDetected, $compression); $message = PMA_Message::error('strUnsupportedCompressionDetected');
$show_error_header = TRUE; $message->addParam($compression);
$error = TRUE; $error = TRUE;
} }
break; break;
@@ -280,12 +279,10 @@ if ($import_file != 'none' && !$error) {
$import_handle = new SimpleUnzip(); $import_handle = new SimpleUnzip();
$import_handle->ReadFile($import_file); $import_handle->ReadFile($import_file);
if ($import_handle->Count() == 0) { if ($import_handle->Count() == 0) {
$message = $strNoFilesFoundInZip; $message = PMA_Message::error('strNoFilesFoundInZip');
$show_error_header = TRUE;
$error = TRUE; $error = TRUE;
} elseif ($import_handle->GetError(0) != 0) { } elseif ($import_handle->GetError(0) != 0) {
$message = $strErrorInZipFile . ' ' . $import_handle->GetErrorMsg(0); $message = PMA_Message::rawError($strErrorInZipFile . ' ' . $import_handle->GetErrorMsg(0));
$show_error_header = TRUE;
$error = TRUE; $error = TRUE;
} else { } else {
$import_text = $import_handle->GetData(0); $import_text = $import_handle->GetData(0);
@@ -293,8 +290,8 @@ if ($import_file != 'none' && !$error) {
// We don't need to store it further // We don't need to store it further
$import_handle = ''; $import_handle = '';
} else { } else {
$message = sprintf($strUnsupportedCompressionDetected, $compression); $message = PMA_Message::error('strUnsupportedCompressionDetected');
$show_error_header = TRUE; $message->addParam($compression);
$error = TRUE; $error = TRUE;
} }
break; break;
@@ -302,21 +299,19 @@ if ($import_file != 'none' && !$error) {
$import_handle = @fopen($import_file, 'r'); $import_handle = @fopen($import_file, 'r');
break; break;
default: default:
$message = sprintf($strUnsupportedCompressionDetected, $compression); $message = PMA_Message::error('strUnsupportedCompressionDetected');
$show_error_header = TRUE; $message->addParam($compression);
$error = TRUE; $error = TRUE;
break; break;
} }
} }
if (!$error && $import_handle === FALSE) { if (!$error && $import_handle === FALSE) {
$message = $strFileCouldNotBeRead; $message = PMA_Message::error('strFileCouldNotBeRead');
$show_error_header = TRUE;
$error = TRUE; $error = TRUE;
} }
} elseif (!$error) { } elseif (!$error) {
if (!isset($import_text) || empty($import_text)) { if (!isset($import_text) || empty($import_text)) {
$message = $strNoDataReceived; $message = PMA_Message::error('strNoDataReceived');
$show_error_header = TRUE;
$error = TRUE; $error = TRUE;
} }
} }
@@ -349,8 +344,7 @@ if (!$error) {
// Check for file existance // Check for file existance
if (!file_exists('./libraries/import/' . $format . '.php')) { if (!file_exists('./libraries/import/' . $format . '.php')) {
$error = TRUE; $error = TRUE;
$message = $strCanNotLoadImportPlugins; $message = PMA_Message::error('strCanNotLoadImportPlugins');
$show_error_header = TRUE;
} else { } else {
// Do the real import // Do the real import
$plugin_param = $import_type; $plugin_param = $import_type;
@@ -371,26 +365,27 @@ if ($reset_charset) {
// Show correct message // Show correct message
if (!empty($id_bookmark) && $action_bookmark == 2) { if (!empty($id_bookmark) && $action_bookmark == 2) {
$message = $strBookmarkDeleted; $message = PMA_Message::success('strBookmarkDeleted');
$display_query = $import_text; $display_query = $import_text;
$error = FALSE; // unset error marker, it was used just to skip processing $error = FALSE; // unset error marker, it was used just to skip processing
} elseif (!empty($id_bookmark) && $action_bookmark == 1) { } elseif (!empty($id_bookmark) && $action_bookmark == 1) {
$message = $strShowingBookmark; $message = PMA_Message::notice('strShowingBookmark');
} elseif ($bookmark_created) { } elseif ($bookmark_created) {
$special_message = '[br]' . sprintf($strBookmarkCreated, htmlspecialchars($bkm_label)); $special_message = '[br]' . sprintf($strBookmarkCreated, htmlspecialchars($bkm_label));
} elseif ($finished && !$error) { } elseif ($finished && !$error) {
if ($import_type == 'query') { if ($import_type == 'query') {
$message = $strSuccess; $message = PMA_Message::success();
} else { } else {
$message = sprintf($strImportSuccessfullyFinished, $executed_queries); $message = PMA_Message::success('strImportSuccessfullyFinished');
$message->addParam($executed_queries);
} }
} }
// Did we hit timeout? Tell it user. // Did we hit timeout? Tell it user.
if ($timeout_passed) { if ($timeout_passed) {
$message = $strTimeoutPassed; $message = PMA_Message::error('strTimeoutPassed');
if ($offset == 0 || (isset($original_skip) && $original_skip == $offset)) { if ($offset == 0 || (isset($original_skip) && $original_skip == $offset)) {
$message .= ' ' . $strTimeoutNothingParsed; $message->addString('strTimeoutNothingParsed');
} }
} }

View File

@@ -47,7 +47,7 @@ if (isset($_REQUEST['drop_selected_dbs_x'])) {
if ((isset($_REQUEST['drop_selected_dbs']) || isset($_REQUEST['query_type'])) if ((isset($_REQUEST['drop_selected_dbs']) || isset($_REQUEST['query_type']))
&& ($is_superuser || $cfg['AllowUserDropDatabase'])) { && ($is_superuser || $cfg['AllowUserDropDatabase'])) {
if (! isset($_REQUEST['selected_dbs']) && ! isset($_REQUEST['query_type'])) { if (! isset($_REQUEST['selected_dbs']) && ! isset($_REQUEST['query_type'])) {
$message = $strNoDatabasesSelected; $message = PMA_Message::error('strNoDatabasesSelected');
} else { } else {
$action = 'server_databases.php'; $action = 'server_databases.php';
$submit_mult = 'drop_db' ; $submit_mult = 'drop_db' ;
@@ -58,7 +58,7 @@ if ((isset($_REQUEST['drop_selected_dbs']) || isset($_REQUEST['query_type']))
require './libraries/mult_submits.inc.php'; require './libraries/mult_submits.inc.php';
unset($action, $submit_mult, $err_url, $selected_db); unset($action, $submit_mult, $err_url, $selected_db);
if (empty($message)) { if (empty($message)) {
$message = new PMA_Message('strDatabasesDropped'); $message = PMA_Message::success('strDatabasesDropped');
if ($mult_btn == $strYes) { if ($mult_btn == $strYes) {
$message->addParam(count($selected)); $message->addParam(count($selected));
} else { } else {

View File

@@ -70,8 +70,7 @@ if (!$is_superuser) {
. PMA_getIcon('b_usrlist.png') . PMA_getIcon('b_usrlist.png')
. $GLOBALS['strPrivileges'] . "\n" . $GLOBALS['strPrivileges'] . "\n"
. '</h2>' . "\n"; . '</h2>' . "\n";
$message = new PMA_Message('strNoPrivileges', PMA_Message::ERROR); PMA_Message::error('strNoPrivileges')->display();
$message->display();
require_once './libraries/footer.inc.php'; require_once './libraries/footer.inc.php';
} }
@@ -815,7 +814,7 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
. " WHERE `User` = '" . PMA_sqlAddslashes($username) . "'" . " WHERE `User` = '" . PMA_sqlAddslashes($username) . "'"
. " AND `Host` = '" . PMA_sqlAddslashes($hostname) . "';"; . " AND `Host` = '" . PMA_sqlAddslashes($hostname) . "';";
if (PMA_DBI_fetch_value($sql) == 1) { if (PMA_DBI_fetch_value($sql) == 1) {
$message = new PMA_Message('strUserAlreadyExists', PMA_Message::ERROR); $message = PMA_Message::error('strUserAlreadyExists');
$message->addParam('[i]\'' . $username . '\'@\'' . $hostname . '\'[/i]'); $message->addParam('[i]\'' . $username . '\'@\'' . $hostname . '\'[/i]');
$_REQUEST['adduser'] = true; $_REQUEST['adduser'] = true;
} else { } else {
@@ -1200,7 +1199,7 @@ if (isset($_REQUEST['delete']) || (isset($_REQUEST['change_copy']) && $_REQUEST[
} }
if (empty($_REQUEST['change_copy'])) { if (empty($_REQUEST['change_copy'])) {
if (empty($queries)) { if (empty($queries)) {
$message = new PMA_Message('strDeleteNoUsersSelected', PMA_Message::ERROR); $message = PMA_Message::error('strDeleteNoUsersSelected');
} else { } else {
if ($_REQUEST['mode'] == 3) { if ($_REQUEST['mode'] == 3) {
$queries[] = '# ' . $GLOBALS['strReloadingThePrivileges'] . ' ...'; $queries[] = '# ' . $GLOBALS['strReloadingThePrivileges'] . ' ...';
@@ -1216,8 +1215,7 @@ if (isset($_REQUEST['delete']) || (isset($_REQUEST['change_copy']) && $_REQUEST[
} }
$sql_query = join("\n", $queries); $sql_query = join("\n", $queries);
if (! empty($drop_user_error)) { if (! empty($drop_user_error)) {
$message = PMA_Message::error(); $message = PMA_Message::rawError($drop_user_error);
$message->setMessage($drop_user_error);
} else { } else {
$message = PMA_Message::success('strUsersDeleted'); $message = PMA_Message::success('strUsersDeleted');
} }
@@ -1243,7 +1241,7 @@ if (isset($_REQUEST['change_copy'])) {
} }
$tmp_count++; $tmp_count++;
} }
$message = new PMA_Message('strSuccess', PMA_Message::SUCCESS); $message = PMA_Message::success();
$sql_query = join("\n", $queries); $sql_query = join("\n", $queries);
} }
@@ -1254,7 +1252,7 @@ if (isset($_REQUEST['change_copy'])) {
if (isset($_REQUEST['flush_privileges'])) { if (isset($_REQUEST['flush_privileges'])) {
$sql_query = 'FLUSH PRIVILEGES;'; $sql_query = 'FLUSH PRIVILEGES;';
PMA_DBI_query($sql_query); PMA_DBI_query($sql_query);
$message = new PMA_Message('strPrivilegesReloaded', PMA_Message::SUCCESS); $message = PMA_Message::success('strPrivilegesReloaded');
} }

View File

@@ -21,10 +21,11 @@ require_once './libraries/server_common.inc.php';
*/ */
if (!empty($kill)) { if (!empty($kill)) {
if (PMA_DBI_try_query('KILL ' . $kill . ';')) { if (PMA_DBI_try_query('KILL ' . $kill . ';')) {
$message = sprintf($strThreadSuccessfullyKilled, $kill); $message = PMA_Message::success('strThreadSuccessfullyKilled');
} else { } else {
$message = sprintf($strCouldNotKill, $kill); $message = PMA_Message::error('strCouldNotKill');
} }
$message->addParam($kill);
} }

36
sql.php
View File

@@ -311,7 +311,7 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
$table = ''; $table = '';
} }
$active_page = $goto; $active_page = $goto;
$message = PMA_Message::raw($error, PMA_Message::ERROR); $message = PMA_Message::rawError($error);
require './' . PMA_securePath($goto); require './' . PMA_securePath($goto);
} else { } else {
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
@@ -464,21 +464,27 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
// No rows returned -> move back to the calling page // No rows returned -> move back to the calling page
if ($num_rows < 1 || $is_affected) { if ($num_rows < 1 || $is_affected) {
if ($is_delete) { if ($is_delete) {
$message = $strDeletedRows . '&nbsp;' . $num_rows; $message = PMA_Message::success('strDeletedRows');
$message->addMessage($num_rows);
} elseif ($is_insert) { } elseif ($is_insert) {
if ($is_replace) { if ($is_replace) {
/* For replace we get DELETED + INSERTED row count, so we have to call it affected */ /* For replace we get DELETED + INSERTED row count, so we have to call it affected */
$message = $strAffectedRows . '&nbsp;' . $num_rows; $message = PMA_Message::success('strAffectedRows');
$message->addMessage($num_rows);
} else { } else {
$message = $strInsertedRows . '&nbsp;' . $num_rows; $message = PMA_Message::success('strInsertedRows');
$message->addMessage($num_rows);
} }
$insert_id = PMA_DBI_insert_id(); $insert_id = PMA_DBI_insert_id();
if ($insert_id != 0) { if ($insert_id != 0) {
// insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this // insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this
$message .= '[br]'.$strInsertedRowId . '&nbsp;' . ($insert_id + $num_rows - 1); $message->addMessage('[br]');
$message->addString('strInsertedRowId');
$message->addMessage($insert_id + $num_rows - 1);
} }
} elseif ($is_affected) { } elseif ($is_affected) {
$message = $strAffectedRows . '&nbsp;' . $num_rows; $message = PMA_Message::success('strAffectedRows');
$message->addMessage($num_rows);
// Ok, here is an explanation for the !$is_select. // Ok, here is an explanation for the !$is_select.
// The form generated by sql_query_form.lib.php // The form generated by sql_query_form.lib.php
@@ -489,19 +495,25 @@ if ($num_rows < 1 || $is_affected) {
// the form should not have priority over // the form should not have priority over
// errors like $strEmptyResultSet // errors like $strEmptyResultSet
} elseif (!empty($zero_rows) && !$is_select) { } elseif (!empty($zero_rows) && !$is_select) {
$message = $zero_rows; $message = PMA_Message::rawSuccess($zero_rows);
} elseif (!empty($GLOBALS['show_as_php'])) { } elseif (!empty($GLOBALS['show_as_php'])) {
$message = $strShowingPhp; $message = PMA_Message::success('strShowingPhp');
} elseif (isset($GLOBALS['show_as_php'])) { } elseif (isset($GLOBALS['show_as_php'])) {
/* User disable showing as PHP, query is only displayed */ /* User disable showing as PHP, query is only displayed */
$message = $strShowingSQL; $message = PMA_Message::notice('strShowingSQL');
} elseif (!empty($GLOBALS['validatequery'])) { } elseif (!empty($GLOBALS['validatequery'])) {
$message = $strValidateSQL; $message = PMA_Message::notice('strValidateSQL');
} else { } else {
$message = $strEmptyResultSet; $message = PMA_Message::success('strEmptyResultSet');
} }
$message .= ' ' . (isset($GLOBALS['querytime']) ? '(' . sprintf($strQueryTime, $GLOBALS['querytime']) . ')' : ''); if (isset($GLOBALS['querytime'])) {
$_querytime = PMA_Message::notice('strQueryTime');
$_querytime->addParam($GLOBALS['querytime']);
$message->addMessage('(');
$message->addMessage($_querytime);
$message->addMessage(')');
}
if ($is_gotofile) { if ($is_gotofile) {
$goto = PMA_securePath($goto); $goto = PMA_securePath($goto);

View File

@@ -180,7 +180,8 @@ if (isset($submit_num_fields)) {
// Go back to the structure sub-page // Go back to the structure sub-page
$sql_query = $sql_query_cpy; $sql_query = $sql_query_cpy;
unset($sql_query_cpy); unset($sql_query_cpy);
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered; $message = PMA_Message::success('strTableAlteredSuccessfully');
$message->addParam($table);
$active_page = 'tbl_structure.php'; $active_page = 'tbl_structure.php';
require './tbl_structure.php'; require './tbl_structure.php';
} else { } else {

View File

@@ -217,9 +217,12 @@ if (isset($_REQUEST['do_save_data'])) {
} }
} }
$message = $strTable . ' ' //$message = PMA_Message::success('strTableCreatedSuccessfully');
. htmlspecialchars(PMA_backquote($db) . '.' . PMA_backquote($table)) //$message->addParam(PMA_backquote($db) . '.' . PMA_backquote($table));
. ' ' . $strHasBeenCreated; $message = PMA_Message::success('strTable');
$message->addMessage(htmlspecialchars(PMA_backquote($db) . '.' . PMA_backquote($table)));
$message->addString('strHasBeenCreated');
$display_query = $sql_query; $display_query = $sql_query;
$sql_query = ''; $sql_query = '';

View File

@@ -108,7 +108,7 @@ if (! empty($sql_query)) {
} }
} }
} }
$message = $GLOBALS['strSuccess']; $message = PMA_Message::success();
} }
/** /**

View File

@@ -176,9 +176,9 @@ if (!defined('PMA_IDX_INCLUDED')
$sql_query .= $index_fields . ')'; $sql_query .= $index_fields . ')';
} }
$result = PMA_DBI_query($sql_query); $result = PMA_DBI_query($sql_query);
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' $message = PMA_Message::success('strTableAlteredSuccessfully');
. $strHasBeenAltered; $message->addParam($table);
$active_page = 'tbl_structure.php'; $active_page = 'tbl_structure.php';
require './tbl_structure.php'; require './tbl_structure.php';

View File

@@ -49,9 +49,9 @@ if (PMA_isValid($_REQUEST['new_name'])) {
$message = PMA_Message::success('strCopyTableOK'); $message = PMA_Message::success('strCopyTableOK');
} }
$old = PMA_backquote($db) . '.' . PMA_backquote($table); $old = PMA_backquote($db) . '.' . PMA_backquote($table);
$message->addParam(htmlspecialchars($old)); $message->addParam($old);
$new = PMA_backquote($_REQUEST['target_db']) . '.' . PMA_backquote($_REQUEST['new_name']); $new = PMA_backquote($_REQUEST['target_db']) . '.' . PMA_backquote($_REQUEST['new_name']);
$message->addParam(htmlspecialchars($new)); $message->addParam($new);
/* Check: Work on new table or on old table? */ /* Check: Work on new table or on old table? */
if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) { if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) {

View File

@@ -150,7 +150,6 @@ if (isset($_REQUEST['primary_key'])) {
} }
$query = array(); $query = array();
$message = new PMA_Message();
$value_sets = array(); $value_sets = array();
$func_no_param = array( $func_no_param = array(
'NOW', 'NOW',
@@ -274,15 +273,12 @@ if ($is_insert && count($value_sets) > 0) {
unset($query_fields, $value_sets); unset($query_fields, $value_sets);
$message->setString('strInsertedRows'); $message = PMA_Message::success('strInsertedRows');
$message->isSuccess(true);
} elseif (! empty($query)) { } elseif (! empty($query)) {
$message->setString('strAffectedRows'); $message = PMA_Message::success('strAffectedRows');
$message->isSuccess(true);
} else { } else {
// No change -> move back to the calling script // No change -> move back to the calling script
$message->setString('strNoModification'); $message = PMA_Message::success('strNoModification');
$message->isSuccess(true);
$GLOBALS['js_include'][] = 'functions.js'; $GLOBALS['js_include'][] = 'functions.js';
$active_page = $goto_include; $active_page = $goto_include;
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
@@ -301,9 +297,9 @@ if (! empty($GLOBALS['sql_query'])) {
} }
$GLOBALS['sql_query'] = implode('; ', $query) . ';'; $GLOBALS['sql_query'] = implode('; ', $query) . ';';
$total_affected_rows = 0; $total_affected_rows = 0;
$last_message = ''; $last_messages = array();
$warning_message = ''; $warning_messages = array();
$error_message = ''; $error_messages = array();
foreach ($query as $single_query) { foreach ($query as $single_query) {
if ($GLOBALS['cfg']['IgnoreMultiSubmitErrors']) { if ($GLOBALS['cfg']['IgnoreMultiSubmitErrors']) {
@@ -313,7 +309,7 @@ foreach ($query as $single_query) {
} }
if (! $result) { if (! $result) {
$error_message .= '<br />' . PMA_DBI_getError(); $error_messages[] = PMA_DBI_getError();
} else { } else {
if (@PMA_DBI_affected_rows()) { if (@PMA_DBI_affected_rows()) {
$total_affected_rows += @PMA_DBI_affected_rows(); $total_affected_rows += @PMA_DBI_affected_rows();
@@ -327,13 +323,15 @@ foreach ($query as $single_query) {
if ($total_affected_rows > 0) { if ($total_affected_rows > 0) {
$insert_id = $insert_id + $total_affected_rows - 1; $insert_id = $insert_id + $total_affected_rows - 1;
} }
$last_message .= '<br />' . $GLOBALS['strInsertedRowId'] . '&nbsp;' . $insert_id; $last_message = PMA_Message::notice('strInsertedRowId');
$last_message->addParam($insert_id);
$last_messages[] = $last_message;
} }
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
} // end if } // end if
foreach (PMA_DBI_get_warnings() as $warning) { foreach (PMA_DBI_get_warnings() as $warning) {
$warning_message .= '<br />' . $warning['Level'] . ': #' . $warning['Code'] $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
. ' ' . $warning['Message']; . ' ' . $warning['Message'];
} }
@@ -341,21 +339,22 @@ foreach ($query as $single_query) {
} }
unset($single_query, $query); unset($single_query, $query);
$message->append(' ' . $total_affected_rows . $last_message); $message->addMessage($total_affected_rows);
$message->addMessages($last_messages, '<br />');
if (! empty($warning_message)) { if (! empty($warning_messages)) {
/** /**
* @todo use a <div class="warning"> in PMA_showMessage() for this part of * @todo use a <div class="warning"> in PMA_showMessage() for this part of
* the message * the message
*/ */
$message->append($warning_message); $message->addMessages($warning_messages, '<br />');
$message->isWarning(true); $message->isWarning(true);
} }
if (! empty($error_message)) { if (! empty($error_messages)) {
$message->append($error_message); $message->addMessages($error_messages);
$message->isError(true); $message->isError(true);
} }
unset($error_message, $warning_message, $total_affected_rows, $last_message); unset($error_messages, $warning_messages, $total_affected_rows, $last_messages, $last_message);
if (isset($return_to_sql_query)) { if (isset($return_to_sql_query)) {
$disp_query = $GLOBALS['sql_query']; $disp_query = $GLOBALS['sql_query'];

View File

@@ -75,8 +75,7 @@ if (isset($_REQUEST['createview'])) {
require './' . $cfg['DefaultTabDatabase']; require './' . $cfg['DefaultTabDatabase'];
exit(); exit();
} else { } else {
$message = PMA_Message::error(); $message = PMA_Message::rawError(PMA_DBI_getError());
$message->setMessage(PMA_DBI_getError());
} }
} }