2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Code for displaying server selection written by nijel
10 * display server selection in list or selectbox form, or option tags only
13 * @globals $convcharset
14 * @uses $GLOBALS['cfg']['DisplayServersList']
15 * @uses $GLOBALS['strServer']
16 * @uses $GLOBALS['cfg']['Servers']
17 * @uses $GLOBALS['strGo']
19 * @uses htmlspecialchars()
20 * @param boolean $not_only_options whether to include form tags or not
21 * @param boolean $ommit_fieldset whether to ommit fieldset tag or not
23 function PMA_select_server($not_only_options, $ommit_fieldset)
25 global $lang, $convcharset;
28 if ($not_only_options) {
29 $list = $GLOBALS['cfg']['DisplayServersList'];
30 $not_only_options =! $list;
35 if ($not_only_options) {
36 echo '<form method="post" action="index.php" target="_parent">';
38 if (! $ommit_fieldset) {
41 echo '<label for="select_server">' . $GLOBALS['strServer'] . ':</label> ';
43 echo '<select name="server" id="select_server"'
44 . ' onchange="if (this.value != \'\') this.form.submit();">';
45 echo '<option value="">(' . $GLOBALS['strServers'] . ') ...</option>' . "\n";
47 echo $GLOBALS['strServer'] . ':<br />';
48 echo '<ul id="list_server">';
51 foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
52 if (empty($server['host'])) {
56 if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
62 if (!empty($server['verbose'])) {
63 $label = $server['verbose'];
65 $label = $server['host'];
66 if (!empty($server['port'])) {
67 $label .= ':' . $server['port'];
70 if (! empty($server['only_db'])) {
71 if (! is_array($server['only_db'])) {
72 $label .= ' - ' . $server['only_db'];
73 // try to avoid displaying a too wide selector
74 } elseif (count($server['only_db']) < 4) {
75 $label .= ' - ' . implode(', ', $server['only_db']);
78 if (!empty($server['user']) && $server['auth_type'] == 'config') {
79 $label .= ' (' . $server['user'] . ')';
84 if ($selected && !$ommit_fieldset) {
85 echo '<b>' . htmlspecialchars($label) . '</b>';
87 echo '<a class="item" href="index.php?server=' . $key . '&lang=' . $lang . '&convcharset=' . $convcharset . '" target="_top">' . htmlspecialchars($label) . '</a>';
91 echo ' <option value="' . $key . '" ' . ($selected ?
' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>' . "\n";
95 if ($not_only_options) {
98 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
99 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
101 // Show submit button if we have just one server (this happens with no default)
103 echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
105 if (! $ommit_fieldset) {