[ Index ]
 

Code source de phpMyAdmin 2.10.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/libraries/ -> select_server.lib.php (source)

   1  <?php
   2  /*
   3   * Code for displaying server selection written by nijel
   4   * $Id: select_server.lib.php 9438 2006-09-21 14:28:46Z cybot_tm $
   5   */
   6  
   7  /**
   8   * display server selection in list or selectbox form, or option tags only
   9   *
  10   * @globals $lang
  11   * @globals $convcharset
  12   * @uses    $GLOBALS['cfg']['DisplayServersList']
  13   * @uses    $GLOBALS['strServer']
  14   * @uses    $GLOBALS['cfg']['Servers']
  15   * @uses    $GLOBALS['strGo']
  16   * @uses    implode()
  17   * @uses    htmlspecialchars()
  18   * @param   boolean $not_only_options   whether to include form tags or not
  19   * @param   boolean $ommit_fieldset     whether to ommit fieldset tag or not
  20   */
  21  function PMA_select_server($not_only_options, $ommit_fieldset)
  22  {
  23      global $lang, $convcharset;
  24  
  25      // Show as list?
  26      if ($not_only_options) {
  27          $list = $GLOBALS['cfg']['DisplayServersList'];
  28          $not_only_options =! $list;
  29      } else {
  30          $list = false;
  31      }
  32  
  33      if ($not_only_options) {
  34          echo '<form method="post" action="index.php" target="_parent">';
  35  
  36          if (! $ommit_fieldset) {
  37              echo '<fieldset>';
  38          }
  39          echo '<label for="select_server">' . $GLOBALS['strServer'] . ':</label> ';
  40  
  41          echo '<select name="server" id="select_server"'
  42              . ' onchange="if (this.value != \'\') this.form.submit();">';
  43          echo '<option value="">(' . $GLOBALS['strServers'] . ') ...</option>' . "\n";
  44      } elseif ($list) {
  45          echo $GLOBALS['strServer'] . ':<br />';
  46          echo '<ul id="list_server">';
  47      }
  48  
  49      foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
  50          if (empty($server['host'])) {
  51              continue;
  52          }
  53  
  54          if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
  55              $selected = 1;
  56          } else {
  57              $selected = 0;
  58          }
  59  
  60          if (!empty($server['verbose'])) {
  61              $label = $server['verbose'];
  62          } else {
  63              $label = $server['host'];
  64              if (!empty($server['port'])) {
  65                  $label .= ':' . $server['port'];
  66              }
  67          }
  68          // loic1: if 'only_db' is an array and there is more than one
  69          //        value, displaying such informations may not be a so good
  70          //        idea
  71          if (!empty($server['only_db'])) {
  72              /**
  73               * @todo this can become a really big/long/wide selectbox ...
  74               */
  75              $label .= ' - ' . (is_array($server['only_db']) ? implode(', ', $server['only_db']) : $server['only_db']);
  76          }
  77          if (!empty($server['user']) && $server['auth_type'] == 'config') {
  78              $label .= '  (' . $server['user'] . ')';
  79          }
  80  
  81          if ($list) {
  82              echo '<li>';
  83              if ($selected && !$ommit_fieldset) {
  84                  echo '<b>' . htmlspecialchars($label) . '</b>';
  85              } else {
  86                  echo '<a class="item" href="index.php?server=' . $key . '&amp;lang=' . $lang . '&amp;convcharset=' . $convcharset . '" target="_top">' . htmlspecialchars($label) . '</a>';
  87              }
  88              echo '</li>';
  89          } else {
  90              echo '            <option value="' . $key . '" ' . ($selected ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>' . "\n";
  91          }
  92      } // end while
  93  
  94      if ($not_only_options) {
  95          echo '</select>';
  96          ?>
  97          <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  98          <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
  99          <?php
 100          // Show submit button if we have just one server (this happens with no default)
 101          echo '<noscript>';
 102          echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
 103          echo '</noscript>';
 104          if (! $ommit_fieldset) {
 105              echo '</fieldset>';
 106          }
 107          echo '</form>';
 108      } elseif ($list) {
 109          echo '</ul>';
 110      }
 111  }
 112  ?>


Généré le : Mon Nov 26 15:18:20 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics