Translation update done using Pootle.
[phpmyadmin.git] / libraries / select_server.lib.php
blob9bf1df11cc187399f0f10dc833f0a557c6fe4953
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Code for displaying server selection
6 * @package PhpMyAdmin
7 */
9 /**
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)
17 // Show as list?
18 if ($not_only_options) {
19 $list = $GLOBALS['cfg']['DisplayServersList'];
20 $not_only_options =! $list;
21 } else {
22 $list = false;
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) {
30 echo '<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";
36 } elseif ($list) {
37 echo __('Current Server') . ':<br />';
38 echo '<ul id="list_server">';
41 foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
42 if (empty($server['host'])) {
43 continue;
46 if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
47 $selected = 1;
48 } else {
49 $selected = 0;
51 if (!empty($server['verbose'])) {
52 $label = $server['verbose'];
53 } else {
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'] . ')';
71 if ($list) {
72 echo '<li>';
73 if ($selected) {
74 echo '<strong>' . htmlspecialchars($label) . '</strong>';
75 } else {
77 echo '<a class="item" href="index.php'
78 . PMA_generate_common_url(array('server' => $key))
79 . '" target="_top">' . htmlspecialchars($label) . '</a>';
81 echo '</li>';
82 } else {
83 echo '<option value="' . $key . '" '
84 . ($selected ? ' selected="selected"' : '') . '>'
85 . htmlspecialchars($label) . '</option>' . "\n";
87 } // end while
89 if ($not_only_options) {
90 echo '</select>';
91 // Show submit button if we have just one server (this happens with no default)
92 echo '<noscript>';
93 echo '<input type="submit" value="' . __('Go') . '" />';
94 echo '</noscript>';
95 if (! $ommit_fieldset) {
96 echo '</fieldset>';
98 echo '</form>';
99 } elseif ($list) {
100 echo '</ul>';