3 * Code for displaying server selection written by nijel
8 * display server selection in list or selectbox form, or option tags only
11 * @globals $convcharset
12 * @uses $GLOBALS['cfg']['DisplayServersList']
13 * @uses $GLOBALS['strServer']
14 * @uses $GLOBALS['cfg']['Servers']
15 * @uses $GLOBALS['strGo']
17 * @uses htmlspecialchars()
18 * @param boolean $not_only_options whether to include form tags or not
19 * @param boolean $ommit_fieldset whether to ommit fieldset tag or not
21 function PMA_select_server($not_only_options, $ommit_fieldset)
23 global $lang, $convcharset;
26 if ($not_only_options) {
27 $list = $GLOBALS['cfg']['DisplayServersList'];
28 $not_only_options =! $list;
33 if ($not_only_options) {
34 echo '<form method="post" action="index.php" target="_parent">';
36 if (! $ommit_fieldset) {
39 echo '<label for="select_server">' . $GLOBALS['strServer'] . ':</label> ';
41 echo '<select name="server" id="select_server"'
42 . ' onchange="if (this.value != \'\') this.form.submit();">';
43 echo '<option value="">(' . $GLOBALS['strServers'] . ') ...</option>' . "\n";
45 echo $GLOBALS['strServer'] . ':<br />';
46 echo '<ul id="list_server">';
49 foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
50 if (empty($server['host'])) {
54 if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
60 if (!empty($server['verbose'])) {
61 $label = $server['verbose'];
63 $label = $server['host'];
64 if (!empty($server['port'])) {
65 $label .= ':' . $server['port'];
68 // loic1: if 'only_db' is an array and there is more than one
69 // value, displaying such informations may not be a so good
71 if (!empty($server['only_db'])) {
73 * @todo this can become a really big/long/wide selectbox ...
75 $label .= ' - ' . (is_array($server['only_db']) ?
implode(', ', $server['only_db']) : $server['only_db']);
77 if (!empty($server['user']) && $server['auth_type'] == 'config') {
78 $label .= ' (' . $server['user'] . ')';
83 if ($selected && !$ommit_fieldset) {
84 echo '<b>' . htmlspecialchars($label) . '</b>';
86 echo '<a class="item" href="index.php?server=' . $key . '&lang=' . $lang . '&convcharset=' . $convcharset . '" target="_top">' . htmlspecialchars($label) . '</a>';
90 echo ' <option value="' . $key . '" ' . ($selected ?
' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>' . "\n";
94 if ($not_only_options) {
97 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
98 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
100 // Show submit button if we have just one server (this happens with no default)
102 echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
104 if (! $ommit_fieldset) {