2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Code for displaying server selection
12 * Renders the server selection in list or selectbox form, or option tags only
14 * @param boolean $not_only_options whether to include form tags or not
15 * @param boolean $omit_fieldset whether to omit fieldset tag or not
19 function PMA_selectServer($not_only_options, $omit_fieldset)
24 if ($not_only_options) {
25 $list = $GLOBALS['cfg']['DisplayServersList'];
26 $not_only_options =! $list;
31 if ($not_only_options) {
32 $retval .= '<form method="post" action="'
33 . PMA\libraries\Util
::getScriptNameForOption(
34 $GLOBALS['cfg']['DefaultTabServer'], 'server'
36 . '" class="disableAjax">';
38 if (! $omit_fieldset) {
39 $retval .= '<fieldset>';
42 $retval .= '<input type="hidden" name="token" value="' . $_SESSION[" PMA_token "] . '" >';
43 $retval .= '<label for="select_server">'
44 . __('Current server:') . '</label> ';
46 $retval .= '<select name="server" id="select_server" class="autosubmit">';
47 $retval .= '<option value="">(' . __('Servers') . ') ...</option>' . "\n";
49 $retval .= __('Current server:') . '<br />';
50 $retval .= '<ul id="list_server">';
53 foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
54 if (empty($server['host'])) {
58 if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
63 if (!empty($server['verbose'])) {
64 $label = $server['verbose'];
66 $label = $server['host'];
67 if (!empty($server['port'])) {
68 $label .= ':' . $server['port'];
71 if (! empty($server['only_db'])) {
72 if (! is_array($server['only_db'])) {
73 $label .= ' - ' . $server['only_db'];
74 // try to avoid displaying a too wide selector
75 } elseif (count($server['only_db']) < 4) {
76 $label .= ' - ' . implode(', ', $server['only_db']);
79 if (!empty($server['user']) && $server['auth_type'] == 'config') {
80 $label .= ' (' . $server['user'] . ')';
86 $retval .= '<strong>' . htmlspecialchars($label) . '</strong>';
89 $retval .= '<a class="disableAjax item" href="'
90 . PMA\libraries\Util
::getScriptNameForOption(
91 $GLOBALS['cfg']['DefaultTabServer'], 'server'
93 . URL
::getCommon(array('server' => $key))
94 . '" >' . htmlspecialchars($label) . '</a>';
98 $retval .= '<option value="' . $key . '" '
99 . ($selected ?
' selected="selected"' : '') . '>'
100 . htmlspecialchars($label) . '</option>' . "\n";
104 if ($not_only_options) {
105 $retval .= '</select>';
106 if (! $omit_fieldset) {
107 $retval .= '</fieldset>';
109 $retval .= '</form>';