make use of new third 'class' parameter for PMA_showMessage()

This commit is contained in:
Sebastian Mendel
2007-10-09 12:16:10 +00:00
parent 534ac6fe1d
commit ec7a30f4fd
11 changed files with 48 additions and 36 deletions

View File

@@ -30,12 +30,15 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
$move = false; $move = false;
} }
$_msg_type = 'success';
if (!isset($newname) || !strlen($newname)) { if (!isset($newname) || !strlen($newname)) {
$message = $strDatabaseEmpty; $_message = $strDatabaseEmpty;
$_msg_type = 'error';
} else { } else {
$sql_query = ''; // in case target db exists $sql_query = ''; // in case target db exists
if ($move || if ($move ||
(isset($create_database_before_copying) && $create_database_before_copying)) { (isset($create_database_before_copying) && $create_database_before_copying)) {
/** /**
* @todo activate this with the correct version of MySQL * @todo activate this with the correct version of MySQL
* when they fix the problem when the db contains a VIEW * when they fix the problem when the db contains a VIEW
@@ -85,9 +88,6 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
// value of $what for this table only // value of $what for this table only
$this_what = $what; $this_what = $what;
if (!isset($tables_full[$each_table]['Engine'])) {
$tables_full[$each_table]['Engine'] = $tables_full[$each_table]['Type'];
}
// do not copy the data from a Merge table // do not copy the data from a Merge table
// note: on the calling FORM, 'data' means 'structure and data' // note: on the calling FORM, 'data' means 'structure and data'
if ($tables_full[$each_table]['Engine'] == 'MRG_MyISAM') { if ($tables_full[$each_table]['Engine'] == 'MRG_MyISAM') {
@@ -107,7 +107,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
unset($GLOBALS['sql_constraints_query']); unset($GLOBALS['sql_constraints_query']);
} }
} }
// $sql_query is filled by PMA_Table::moveCopy()
$sql_query = $back . $sql_query; $sql_query = $back . $sql_query;
} // end (foreach) } // end (foreach)
unset($each_table); unset($each_table);
@@ -154,10 +154,10 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
$sql_query .= "\n" . $local_query; $sql_query .= "\n" . $local_query;
PMA_DBI_query($local_query); PMA_DBI_query($local_query);
} }
$message = sprintf($strRenameDatabaseOK, htmlspecialchars($db), $_message = sprintf($strRenameDatabaseOK, htmlspecialchars($db),
htmlspecialchars($newname)); htmlspecialchars($newname));
} else { } else {
$message = sprintf($strCopyDatabaseOK, htmlspecialchars($db), $_message = sprintf($strCopyDatabaseOK, htmlspecialchars($db),
htmlspecialchars($newname)); htmlspecialchars($newname));
} }
$reload = true; $reload = true;
@@ -202,6 +202,11 @@ if (empty($is_info)) {
$sub_part = '_structure'; $sub_part = '_structure';
require './libraries/db_info.inc.php'; require './libraries/db_info.inc.php';
echo "\n"; echo "\n";
if (iseet($_message)) {
PMA_showMessage($_message, $sql_query, $_msg_type);
unset($_message, $_msg_type);
}
} }
$db_collation = PMA_getDbCollation($db); $db_collation = PMA_getDbCollation($db);

View File

@@ -50,8 +50,8 @@ if (!empty($sql_query)) {
// upload limit has been reached, let's assume the second possibility. // upload limit has been reached, let's assume the second possibility.
if ($_POST == array() && $_GET == array()) { if ($_POST == array() && $_GET == array()) {
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
$show_error_header = TRUE; PMA_showMessage(sprintf($strUploadLimit, '[a@./Documentation.html#faq1_16@_blank]', '[/a]'),
PMA_showMessage(sprintf($strUploadLimit, '[a@./Documentation.html#faq1_16@_blank]', '[/a]')); null, 'error');
require './libraries/footer.inc.php'; require './libraries/footer.inc.php';
} }

View File

@@ -35,9 +35,7 @@ $export_list = PMA_getPlugins('./libraries/export/', array('export_type' => $exp
/* Fail if we didn't find any plugin */ /* Fail if we didn't find any plugin */
if (empty($export_list)) { if (empty($export_list)) {
$GLOBALS['show_error_header'] = TRUE; PMA_showMessage($strCanNotLoadExportPlugins, null, 'error');
PMA_showMessage($strCanNotLoadExportPlugins);
unset($GLOBALS['show_error_header']);
require './libraries/footer.inc.php'; require './libraries/footer.inc.php';
} }
?> ?>

View File

@@ -16,9 +16,7 @@ $import_list = PMA_getPlugins('./libraries/import/', $import_type);
/* Fail if we didn't find any plugin */ /* Fail if we didn't find any plugin */
if (empty($import_list)) { if (empty($import_list)) {
$GLOBALS['show_error_header'] = TRUE; PMA_showMessage($strCanNotLoadImportPlugins, null, 'error');
PMA_showMessage($strCanNotLoadImportPlugins);
unset($GLOBALS['show_error_header']);
require './libraries/footer.inc.php'; require './libraries/footer.inc.php';
} }
?> ?>

View File

@@ -1868,7 +1868,13 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
$last_shown_rec = ($_SESSION['userconf']['max_rows'] == 'all' || $pos_next > $total) $last_shown_rec = ($_SESSION['userconf']['max_rows'] == 'all' || $pos_next > $total)
? $total - 1 ? $total - 1
: $pos_next - 1; : $pos_next - 1;
PMA_showMessage($GLOBALS['strShowingRecords'] . ' ' . $_SESSION['userconf']['pos'] . ' - ' . $last_shown_rec . ' (' . $pre_count . PMA_formatNumber($total, 0) . $after_count . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')'); PMA_showMessage($GLOBALS['strShowingRecords'] . ' '
. $_SESSION['userconf']['pos'] . ' - ' . $last_shown_rec
. ' (' . $pre_count . PMA_formatNumber($total, 0) . $after_count
. ' ' . $GLOBALS['strTotal'] . $selectstring . ', '
. sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')',
$sql_query,
'success');
if (PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) { if (PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) {
echo '<div class="notice">' . "\n"; echo '<div class="notice">' . "\n";
@@ -1876,7 +1882,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
echo '</div>' . "\n"; echo '</div>' . "\n";
} }
} elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
PMA_showMessage($GLOBALS['strSQLQuery']); PMA_showMessage($GLOBALS['strSuccess'], $sql_query, 'success');
} }
// 2.3 Displays the navigation bars // 2.3 Displays the navigation bars

View File

@@ -144,7 +144,7 @@ if (count($binary_logs) > 1) {
echo '</form>'; echo '</form>';
} }
PMA_showMessage($GLOBALS['strSuccess']); PMA_showMessage($GLOBALS['strSuccess'], null, 'success');
/** /**
* Displays the page * Displays the page

View File

@@ -49,7 +49,7 @@ echo '<h2>' . "\n"
$sql_query = 'SHOW' . (empty($full) ? '' : ' FULL') . ' PROCESSLIST'; $sql_query = 'SHOW' . (empty($full) ? '' : ' FULL') . ' PROCESSLIST';
$result = PMA_DBI_query($sql_query); $result = PMA_DBI_query($sql_query);
PMA_showMessage($GLOBALS['strSuccess']); PMA_showMessage($GLOBALS['strSuccess'], null, 'success');
/** /**

View File

@@ -572,10 +572,7 @@ else {
// Display previous update query (from tbl_replace) // Display previous update query (from tbl_replace)
if (isset($disp_query) && $cfg['ShowSQL'] == true) { if (isset($disp_query) && $cfg['ShowSQL'] == true) {
$tmp_sql_query = $GLOBALS['sql_query']; PMA_showMessage($disp_message, $disp_query, 'success');
$GLOBALS['sql_query'] = $disp_query;
PMA_showMessage($disp_message);
$GLOBALS['sql_query'] = $tmp_sql_query;
} }
if (isset($profiling_results)) { if (isset($profiling_results)) {

View File

@@ -43,23 +43,23 @@ PMA_DBI_select_db($GLOBALS['db']);
require './libraries/tbl_info.inc.php'; require './libraries/tbl_info.inc.php';
$reread_info = false; $reread_info = false;
$errors = array();
$table_alters = array(); $table_alters = array();
/** /**
* Updates table comment, type and options if required * Updates table comment, type and options if required
*/ */
if (isset($_REQUEST['submitoptions'])) { if (isset($_REQUEST['submitoptions'])) {
$message = ''; $_message = '';
if (isset($_REQUEST['new_name'])) { if (isset($_REQUEST['new_name'])) {
if ($pma_table->rename($_REQUEST['new_name'])) { if ($pma_table->rename($_REQUEST['new_name'])) {
$message .= $pma_table->getLastMessage(); $_message .= $pma_table->getLastMessage();
$GLOBALS['table'] = $pma_table->getName();; $result = true;
$GLOBALS['table'] = $pma_table->getName();
$reread_info = true; $reread_info = true;
$reload = true; $reload = true;
} else { } else {
$errors[] = $pma_table->getLastError(); $_message .= $pma_table->getLastError();
$message .= $pma_table->getLastError(); $result = false;
} }
} }
if (isset($_REQUEST['comment']) if (isset($_REQUEST['comment'])
@@ -108,7 +108,7 @@ if (isset($_REQUEST['submitoptions'])) {
if (count($table_alters) > 0) { if (count($table_alters) > 0) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']); $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
$sql_query .= "\r\n" . implode("\r\n", $table_alters); $sql_query .= "\r\n" . implode("\r\n", $table_alters);
$message .= PMA_DBI_query($sql_query) ? $strSuccess : $strError; $result .= PMA_DBI_query($sql_query) ? true : false;
$reread_info = true; $reread_info = true;
unset($table_alters); unset($table_alters);
} }
@@ -123,7 +123,7 @@ if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') { if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
$sql_query .= ' DESC'; $sql_query .= ' DESC';
} }
$message = PMA_DBI_query($sql_query) ? $strSuccess : $strError; $result = PMA_DBI_query($sql_query);
} // end if } // end if
@@ -138,6 +138,14 @@ unset($reread_info);
*/ */
require_once './libraries/tbl_links.inc.php'; require_once './libraries/tbl_links.inc.php';
if (isset($result)) {
if (empty($_message)) {
$_message = $result ? $strSuccess : $strError;
$_type = $result ? 'success' : 'error';
}
PMA_showMessage($_message, $sql_query, $_type);
}
$url_params['goto'] = 'tbl_operations.php'; $url_params['goto'] = 'tbl_operations.php';
$url_params['back'] = 'tbl_operations.php'; $url_params['back'] = 'tbl_operations.php';
@@ -501,7 +509,7 @@ if ($cfgRelation['relwork'] && $tbl_type != "INNODB") {
?> ?>
</ul> </ul>
<?php <?php
} // end if ($result) } // end if ($foreign)
} // end if (!empty($cfg['Server']['relation'])) } // end if (!empty($cfg['Server']['relation']))

View File

@@ -229,9 +229,9 @@ if (isset($_REQUEST['destination_innodb'])) {
} // end foreach } // end foreach
if (!empty($display_query)) { if (!empty($display_query)) {
if ($seen_error) { if ($seen_error) {
PMA_showMessage($strError); PMA_showMessage($strError, null, 'error');
} else { } else {
PMA_showMessage($strSuccess); PMA_showMessage($strSuccess, null, 'success');
} }
} }
} // end if isset($destination_innodb) } // end if isset($destination_innodb)

View File

@@ -108,7 +108,7 @@ if (isset($_REQUEST['nopass'])) {
// Displays the page // Displays the page
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
echo '<h1>' . $strChangePassword . '</h1>' . "\n\n"; echo '<h1>' . $strChangePassword . '</h1>' . "\n\n";
PMA_showMessage($strUpdateProfileMessage, $sql_query); PMA_showMessage($strUpdateProfileMessage, $sql_query, 'success');
?> ?>
<a href="index.php<?php echo PMA_generate_common_url($_url_params); ?>" target="_parent"> <a href="index.php<?php echo PMA_generate_common_url($_url_params); ?>" target="_parent">
<b><?php echo $strBack; ?></b></a> <b><?php echo $strBack; ?></b></a>