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 * @param boolean $not_only_options whether to include form tags or not
13 * @param boolean $ommit_fieldset whether to ommit fieldset tag or not
15 function PMA_select_server($not_only_options, $ommit_fieldset)
18 if ($not_only_options) {
19 $list = $GLOBALS['cfg']['DisplayServersList'];
20 $not_only_options =! $list;
25 if ($not_only_options) {
26 echo '<form method="post" action="index.php" target="_parent">';
27 echo PMA_generate_common_hidden_inputs();
29 if (! $ommit_fieldset) {
32 echo '<label for="select_server">' . __('Current Server') . ':</label> ';
34 echo '<select name="server" id="select_server" class="autosubmit">';
35 echo '<option value="">(' . __('Servers') . ') ...</option>' . "\n";
37 echo __('Current Server') . ':<br />';
38 echo '<ul id="list_server">';
41 foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
42 if (empty($server['host'])) {
46 if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
51 if (!empty($server['verbose'])) {
52 $label = $server['verbose'];
54 $label = $server['host'];
55 if (!empty($server['port'])) {
56 $label .= ':' . $server['port'];
59 if (! empty($server['only_db'])) {
60 if (! is_array($server['only_db'])) {
61 $label .= ' - ' . $server['only_db'];
62 // try to avoid displaying a too wide selector
63 } elseif (count($server['only_db']) < 4) {
64 $label .= ' - ' . implode(', ', $server['only_db']);
67 if (!empty($server['user']) && $server['auth_type'] == 'config') {
68 $label .= ' (' . $server['user'] . ')';
74 echo '<strong>' . htmlspecialchars($label) . '</strong>';
77 echo '<a class="item" href="index.php'
78 . PMA_generate_common_url(array('server' => $key))
79 . '" target="_top">' . htmlspecialchars($label) . '</a>';
83 echo '<option value="' . $key . '" '
84 . ($selected ?
' selected="selected"' : '') . '>'
85 . htmlspecialchars($label) . '</option>' . "\n";
89 if ($not_only_options) {
91 // Show submit button if we have just one server (this happens with no default)
93 echo '<input type="submit" value="' . __('Go') . '" />';
95 if (! $ommit_fieldset) {