2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Code for displaying server selection
10 * display server selection in list or selectbox form, or option tags only
12 * @uses $GLOBALS['cfg']['DisplayServersList']
13 * @uses $GLOBALS['cfg']['Servers']
15 * @uses htmlspecialchars()
16 * @uses PMA_generate_common_hidden_inputs()
17 * @uses PMA_generate_common_url()
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)
24 if ($not_only_options) {
25 $list = $GLOBALS['cfg']['DisplayServersList'];
26 $not_only_options =! $list;
31 if ($not_only_options) {
32 echo '<form method="post" action="index.php" target="_parent">';
33 echo PMA_generate_common_hidden_inputs();
35 if (! $ommit_fieldset) {
38 echo '<label for="select_server">' . __('Current Server') . ':</label> ';
40 echo '<select name="server" id="select_server"'
41 . ' onchange="if (this.value != \'\') this.form.submit();">';
42 echo '<option value="">(' . __('Servers') . ') ...</option>' . "\n";
44 echo __('Current Server') . ':<br />';
45 echo '<ul id="list_server">';
48 foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
49 if (empty($server['host'])) {
53 if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
58 if (!empty($server['verbose'])) {
59 $label = $server['verbose'];
61 $label = $server['host'];
62 if (!empty($server['port'])) {
63 $label .= ':' . $server['port'];
66 if (! empty($server['only_db'])) {
67 if (! is_array($server['only_db'])) {
68 $label .= ' - ' . $server['only_db'];
69 // try to avoid displaying a too wide selector
70 } elseif (count($server['only_db']) < 4) {
71 $label .= ' - ' . implode(', ', $server['only_db']);
74 if (!empty($server['user']) && $server['auth_type'] == 'config') {
75 $label .= ' (' . $server['user'] . ')';
81 echo '<strong>' . htmlspecialchars($label) . '</strong>';
84 echo '<a class="item" href="index.php'
85 . PMA_generate_common_url(array('server' => $key))
86 . '" target="_top">' . htmlspecialchars($label) . '</a>';
90 echo '<option value="' . $key . '" '
91 . ($selected ?
' selected="selected"' : '') . '>'
92 . htmlspecialchars($label) . '</option>' . "\n";
96 if ($not_only_options) {
98 // Show submit button if we have just one server (this happens with no default)
100 echo '<input type="submit" value="' . __('Go') . '" />';
102 if (! $ommit_fieldset) {