home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / select_server.lib.php < prev    next >
Encoding:
PHP Script  |  2008-06-23  |  3.7 KB  |  114 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  * Code for displaying server selection written by nijel
  5.  *
  6.  * @version $Id: select_server.lib.php 10142 2007-03-20 10:32:13Z cybot_tm $
  7.  */
  8.  
  9. /**
  10.  * display server selection in list or selectbox form, or option tags only
  11.  *
  12.  * @globals $lang
  13.  * @globals $convcharset
  14.  * @uses    $GLOBALS['cfg']['DisplayServersList']
  15.  * @uses    $GLOBALS['strServer']
  16.  * @uses    $GLOBALS['cfg']['Servers']
  17.  * @uses    $GLOBALS['strGo']
  18.  * @uses    implode()
  19.  * @uses    htmlspecialchars()
  20.  * @param   boolean $not_only_options   whether to include form tags or not
  21.  * @param   boolean $ommit_fieldset     whether to ommit fieldset tag or not
  22.  */
  23. function PMA_select_server($not_only_options, $ommit_fieldset)
  24. {
  25.     global $lang, $convcharset;
  26.  
  27.     // Show as list?
  28.     if ($not_only_options) {
  29.         $list = $GLOBALS['cfg']['DisplayServersList'];
  30.         $not_only_options =! $list;
  31.     } else {
  32.         $list = false;
  33.     }
  34.  
  35.     if ($not_only_options) {
  36.         echo '<form method="post" action="index.php" target="_parent">';
  37.  
  38.         if (! $ommit_fieldset) {
  39.             echo '<fieldset>';
  40.         }
  41.         echo '<label for="select_server">' . $GLOBALS['strServer'] . ':</label> ';
  42.  
  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">';
  49.     }
  50.  
  51.     foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
  52.         if (empty($server['host'])) {
  53.             continue;
  54.         }
  55.  
  56.         if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
  57.             $selected = 1;
  58.         } else {
  59.             $selected = 0;
  60.         }
  61.  
  62.         if (!empty($server['verbose'])) {
  63.             $label = $server['verbose'];
  64.         } else {
  65.             $label = $server['host'];
  66.             if (!empty($server['port'])) {
  67.                 $label .= ':' . $server['port'];
  68.             }
  69.         }
  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']);
  76.             }
  77.         }
  78.         if (!empty($server['user']) && $server['auth_type'] == 'config') {
  79.             $label .= '  (' . $server['user'] . ')';
  80.         }
  81.  
  82.         if ($list) {
  83.             echo '<li>';
  84.             if ($selected && !$ommit_fieldset) {
  85.                 echo '<b>' . htmlspecialchars($label) . '</b>';
  86.             } else {
  87.                 echo '<a class="item" href="index.php?server=' . $key . '&lang=' . $lang . '&convcharset=' . $convcharset . '" target="_top">' . htmlspecialchars($label) . '</a>';
  88.             }
  89.             echo '</li>';
  90.         } else {
  91.             echo '            <option value="' . $key . '" ' . ($selected ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>' . "\n";
  92.         }
  93.     } // end while
  94.  
  95.     if ($not_only_options) {
  96.         echo '</select>';
  97.         ?>
  98.         <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  99.         <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
  100.         <?php
  101.         // Show submit button if we have just one server (this happens with no default)
  102.         echo '<noscript>';
  103.         echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
  104.         echo '</noscript>';
  105.         if (! $ommit_fieldset) {
  106.             echo '</fieldset>';
  107.         }
  108.         echo '</form>';
  109.     } elseif ($list) {
  110.         echo '</ul>';
  111.     }
  112. }
  113. ?>
  114.