Functionalised server selection and use it in cookie auth (RFE #1362727).

This commit is contained in:
Michal Čihař
2005-11-23 15:03:57 +00:00
parent 8fc4a4ce05
commit 8996ff60a1
5 changed files with 45 additions and 58 deletions

View File

@@ -38,6 +38,10 @@ $Source$
information.
* libraries/display_select_lang.lib.php,
libraries/auth/cookie.auth.lib.php: Use fieldset for language selection.
* main.php, libraries/left_header.inc.php,
libraries/select_server.lib.php, libraries/auth/cookie.auth.lib.php:
Functionalised server selection and use it in cookie auth (RFE
#1362727).
2005-11-22 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* added test/theme.php: for testing themes

View File

@@ -201,40 +201,8 @@ echo sprintf( $GLOBALS['strWelcome'],
?>
>
<?php
echo "\n";
// Displays the MySQL servers choice
foreach ($cfg['Servers'] AS $key => $val) {
if (!empty($val['host'])) {
echo ' <option value="' . $key . '"';
if (!empty($server) && ($server == $key)) {
echo ' selected="selected"';
}
echo '>';
if ($val['verbose'] != '') {
echo htmlspecialchars($val['verbose']);
} else {
echo htmlspecialchars($val['host']);
if (!empty($val['port'])) {
echo ':' . $val['port'];
}
// loic1: skip this because it's not a so good idea to
// display sockets used to everybody
// if (!empty($val['socket']) && PMA_PHP_INT_VERSION >= 30010) {
// echo ':' . $val['socket'];
// }
}
// loic1: if 'only_db' is an array and there is more than one
// value, displaying such informations may not be a so
// good idea
if (!empty($val['only_db'])) {
echo ' - ' . (is_array($val['only_db']) ? implode(', ', $val['only_db']) : $val['only_db']);
}
if (!empty($val['user']) && ($val['auth_type'] == 'basic')) {
echo ' (' . $val['user'] . ')';
}
echo '&nbsp;</option>' . "\n";
} // end if (!empty($val['host']))
} // end while
require_once('./libraries/select_server.lib.php');
PMA_select_server(FALSE, FALSE);
?>
</select>
</div>

View File

@@ -80,8 +80,11 @@ if ($GLOBALS['cfg']['MainPageIconic']) {
}
echo '</div>' . "\n";
if ( $GLOBALS['cfg']['LeftDisplayServers'] ) {
$show_server_left = TRUE;
/**
* Displays the MySQL servers choice form
*/
if ( $GLOBALS['cfg']['LeftDisplayServers'] && count($cfg['Servers']) > 1 ) {
include('./libraries/select_server.lib.php');
PMA_select_server(TRUE, TRUE);
} // end if LeftDisplayServers
?>

View File

@@ -4,21 +4,31 @@
* $Id$
*/
if (count($cfg['Servers']) > 1) {
if ($show_server_left) {
echo '<div class="heada">' . $strServer . ':</div>';
function PMA_select_server($form, $left) {
global $cfg, $lang, $convcharset;
// Show as list?
$list = $cfg['DisplayServersList'];
if (!$form) {
$list = FALSE;
}
if ($form) {
if ($left) {
echo '<div class="heada">' . $GLOBALS['strServer']. ':</div>';
} else {
?>
<fieldset>
<legend><?php echo $strServerChoice; ?></legend>
<legend><?php echo $GLOBALS['strServerChoice']; ?></legend>
<?php
}
if (!$cfg['DisplayServersList']) {
if (!$list) {
?>
<form method="post" action="index.php" target="_parent">
<select name="server" onchange="this.form.submit();">
<?php
}
}
foreach ($cfg['Servers'] AS $key => $val) {
if (!empty($val['host'])) {
$selected = 0;
@@ -43,8 +53,8 @@ if (count($cfg['Servers']) > 1) {
$label .= ' (' . $val['user'] . ')';
}
if ($cfg['DisplayServersList']){
if ($selected && !$show_server_left) {
if ($list){
if ($selected && !$left) {
echo '&raquo; <b>' . htmlspecialchars($label) . '</b><br />';
}else{
echo '&raquo; <a class="item" href="index.php?server=' . $key . '&amp;lang=' . $lang . '&amp;convcharset=' . $convcharset . '" target="_top">' . htmlspecialchars($label) . '</a><br />';
@@ -56,18 +66,19 @@ if (count($cfg['Servers']) > 1) {
} // end if (!empty($val['host']))
} // end while
if ( ! $cfg['DisplayServersList'] ) {
if ($form) {
if ( ! $list ) {
?>
</select>
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
<noscript>
<input type="submit" value="<?php echo $strGo; ?>" />
<input type="submit" value="<?php echo $GLOBALS['strGo']; ?>" />
</noscript>
</form>
<?php
}
if (!$show_server_left) {
if (!$left) {
?>
</fieldset>
<?php
@@ -75,4 +86,5 @@ if (count($cfg['Servers']) > 1) {
echo '<hr />';
}
}
}
?>

View File

@@ -126,9 +126,9 @@ if (($server > 0) && isset($mode) && ($mode == 'reload')) {
/**
* Displays the MySQL servers choice form
*/
if (!$cfg['LeftDisplayServers']) {
$show_server_left = FALSE;
if (!$cfg['LeftDisplayServers'] && count($cfg['Servers']) > 1) {
include('./libraries/select_server.lib.php');
PMA_select_server(TRUE, FALSE);
}
// nested table needed