Convert Excel column name correctly
[phpmyadmin/arisferyanto.git] / libraries / select_server.lib.php
blob80230419996cba82c39a83b107ec1fb8e07c79c6
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Code for displaying server selection written by nijel
6 * @version $Id$
7 * @package phpMyAdmin
8 */
10 /**
11 * display server selection in list or selectbox form, or option tags only
13 * @uses $GLOBALS['cfg']['DisplayServersList']
14 * @uses $GLOBALS['strServer']
15 * @uses $GLOBALS['cfg']['Servers']
16 * @uses $GLOBALS['strGo']
17 * @uses implode()
18 * @uses htmlspecialchars()
19 * @uses PMA_generate_common_hidden_inputs()
20 * @uses PMA_generate_common_url()
21 * @param boolean $not_only_options whether to include form tags or not
22 * @param boolean $ommit_fieldset whether to ommit fieldset tag or not
24 function PMA_select_server($not_only_options, $ommit_fieldset)
26 // Show as list?
27 if ($not_only_options) {
28 $list = $GLOBALS['cfg']['DisplayServersList'];
29 $not_only_options =! $list;
30 } else {
31 $list = false;
34 if ($not_only_options) {
35 echo '<form method="post" action="index.php" target="_parent">';
36 echo PMA_generate_common_hidden_inputs();
38 if (! $ommit_fieldset) {
39 echo '<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";
46 } elseif ($list) {
47 echo $GLOBALS['strServer'] . ':<br />';
48 echo '<ul id="list_server">';
51 foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
52 if (empty($server['host'])) {
53 continue;
56 if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
57 $selected = 1;
58 } else {
59 $selected = 0;
62 if (!empty($server['verbose'])) {
63 $label = $server['verbose'];
64 } else {
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'] . ')';
82 if ($list) {
83 echo '<li>';
84 if ($selected && !$ommit_fieldset) {
85 echo '<strong>' . htmlspecialchars($label) . '</strong>';
86 } else {
88 echo '<a class="item" href="index.php'
89 . PMA_generate_common_url(array('server' => $key))
90 . '" target="_top">' . htmlspecialchars($label) . '</a>';
92 echo '</li>';
93 } else {
94 echo '<option value="' . $key . '" '
95 . ($selected ? ' selected="selected"' : '') . '>'
96 . htmlspecialchars($label) . '</option>' . "\n";
98 } // end while
100 if ($not_only_options) {
101 echo '</select>';
102 // Show submit button if we have just one server (this happens with no default)
103 echo '<noscript>';
104 echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
105 echo '</noscript>';
106 if (! $ommit_fieldset) {
107 echo '</fieldset>';
109 echo '</form>';
110 } elseif ($list) {
111 echo '</ul>';