fix problem not remembering selected server

This commit is contained in:
Sebastian Mendel
2005-10-19 07:58:50 +00:00
parent c2c7e8b6b0
commit e58627459a
5 changed files with 94 additions and 22 deletions

View File

@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
$Id$
$Source$
2005-10-18 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* footer.inc.php, index.php, server_databases.php, libraries/querywindow.js:
fix problem not remembering selected server
2005-10-18 Michal Čihař <michal@cihar.com>
* libraries/relation.lib.php: Do not set database if not needed.
* libraries/common.lib.php: Use common infrastructure for getting tables.

View File

@@ -15,7 +15,6 @@ require_once('./libraries/relation.lib.php'); // for PMA_setHistory()
// If query window is wanted and open, update with latest selected db/table.
if ( $cfg['QueryFrame'] && $cfg['QueryFrameJS'] ) {
?>
<script type="text/javascript">
//<![CDATA[
@@ -24,7 +23,7 @@ if ( $cfg['QueryFrame'] && $cfg['QueryFrameJS'] ) {
$table = isset( $table ) ? $table : '';
?>
// sets selection in left frame quick db selectbox to current db
window.parent.setTable( '<?php echo $db; ?>', '<?php echo $table; ?>' );
window.parent.setAll( '<?php echo $lang; ?>', '<?php echo $collation_connection; ?>', '<?php echo $server; ?>', '<?php echo $db; ?>', '<?php echo $table; ?>' );
<?php
}
?>

View File

@@ -141,6 +141,9 @@ header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
var safari_browser = <?php echo PMA_USR_BROWSER_AGENT != 'SAFARI' ? 'true' : 'false' ?>;
var querywindow_height = <?php echo $GLOBALS['cfg']['QueryWindowHeight']; ?>;
var querywindow_width = <?php echo $GLOBALS['cfg']['QueryWindowWidth']; ?>;
var collation_connection = '<?php echo $GLOBALS['collation_connection']; ?>';
var lang = '<?php echo $GLOBALS['lang']; ?>';
var server = '<?php echo $GLOBALS['server']; ?>';
var table = '<?php echo $GLOBALS['table']; ?>';
var db = '<?php echo $GLOBALS['db']; ?>';
var pma_absolute_uri = '<?php echo $GLOBALS['cfg']['PmaAbsoluteUri']; ?>';

View File

@@ -1,22 +1,81 @@
var querywindow = '';
// sets current selected table (called from footer.inc.php)
function setTable( new_db, new_table ) {
//alert('setTable');
if ( new_db != db || new_table != table ) {
// table or db has changed
/**
* sets current selected server, table and db (called from footer.inc.php)
*/
function setDb( new_db ) {
//alert('setDb(' + new_db + ')');
if ( new_db != db ) {
// db has changed
//alert( new_db + '(' + new_db.length + ') : ' + db );
db = new_db;
if ( window.frames[0].document.getElementById( db ) == null ) {
// db is unknown, reload complete left frame
refreshLeft();
//alert( new_table + '(' + new_table.length + ') : ' + table );
if ( window.frames[0].document.getElementById( new_db ) == null
&& window.frames[0].document.getElementById( new_db + '.' + new_table ) == null ) {
// table or db is unknown, reload complete left frame
goTo('left.php?&db=' + new_db + '&table=' + new_table);
}
// TODO: add code to expand db in lightview mode
// refresh querywindow
refreshQuerywindow();
}
}
function refreshMain( url ) {
if ( ! url ) {
if ( db ) {
url = opendb_url;
} else {
url = 'main.php';
}
}
goTo( url + '?&server=' + server +
'&db=' + db +
'&table=' + table +
'&lang=' + lang +
'&collation_connection=' + collation_connection,
'main' );
}
function refreshLeft() {
goTo('left.php?&server=' + server +
'&db=' + db +
'&table=' + table +
'&lang=' + lang +
'&collation_connection=' + collation_connection
);
}
/**
* sets current selected server, table and db (called from footer.inc.php)
*/
function setAll( new_lang, new_collation_connection, new_server, new_db, new_table ) {
//alert('setAll( ' + new_lang + ', ' + new_collation_connection + ', ' + new_server + ', ' + new_db + ', ' + new_table + ' )');
if ( new_server != server || new_lang != lang
|| new_collation_connection != collation_connection ) {
// something important has changed
server = new_server;
db = new_db;
table = new_table;
collation_connection = new_collation_connection;
lang = new_lang;
refreshLeft();
}
else if ( new_db != db || new_table != table ) {
// save new db and table
db = new_db;
table = new_table;
if ( window.frames[0].document.getElementById( db ) == null
&& window.frames[0].document.getElementById( db + '.' + table ) == null ) {
// table or db is unknown, reload complete left frame
refreshLeft();
}
// TODO: add code to expand db in lightview mode
// refresh querywindow
refreshQuerywindow();
}
@@ -90,6 +149,13 @@ function refreshQuerywindow( url ) {
}
}
/**
* opens new url in target frame, with default beeing left frame
* valid is 'main' and 'querywindow' all others leads to 'left'
*
* @param string targeturl new url to load
* @param string target frame where to load the new url
*/
function goTo( targeturl, target ) {
//alert('goto');
if ( target == 'main' ) {
@@ -119,10 +185,10 @@ function goTo( targeturl, target ) {
}
// opens selected db in main frame
function openDb( db ) {
//alert('opendb');
goTo( opendb_url + '?' + common_query + '&db=' + db,
window.parent.frames[1] );
function openDb( new_db ) {
//alert('opendb(' + new_db + ')');
setDb( new_db );
refreshMain( opendb_url );
return true;
}

View File

@@ -252,7 +252,7 @@ if (count($statistics) > 0) {
}
if ($is_superuser) {
echo ' <td class="tool">' . "\n"
. ' <a onclick="window.parent.setTable(\'' . urlencode($current['db_name']) . '\');" href="./server_privileges.php?' . $url_query . '&amp;checkprivs=' . urlencode($current['db_name']) . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['db_name'])) . '">'. "\n"
. ' <a onclick="window.parent.setDb(\'' . urlencode($current['db_name']) . '\');" href="./server_privileges.php?' . $url_query . '&amp;checkprivs=' . urlencode($current['db_name']) . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['db_name'])) . '">'. "\n"
. ' ' .($cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' .$strCheckPrivs . '" /> ' : $strCheckPrivs ). "\n"
. ' </a>' . "\n"
. ' </td>' . "\n";