Documentation TYPO3 par Ameos

storage_engines.lib.php

00001 <?php
00002 /* $Id: storage_engines.lib.php,v 2.5 2005/05/11 09:00:33 lem9 Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00009 $GLOBALS['mysql_storage_engines'] = array();
00010 
00011 if (PMA_MYSQL_INT_VERSION >= 40102) {
00015     $res = PMA_DBI_query('SHOW STORAGE ENGINES');
00016     while ($row = PMA_DBI_fetch_assoc($res)) {
00017         $GLOBALS['mysql_storage_engines'][strtolower($row['Engine'])] = $row;
00018     }
00019     PMA_DBI_free_result($res);
00020     unset($res, $row);
00021 } else {
00025     $GLOBALS['mysql_storage_engines'] = array(
00026         'myisam' => array(
00027             'Engine'  => 'MyISAM',
00028             'Support' => 'DEFAULT'
00029         ),
00030         'merge' => array(
00031             'Engine'  => 'MERGE',
00032             'Support' => 'YES'
00033         ),
00034         'heap' => array(
00035             'Engine'  => 'HEAP',
00036             'Support' => 'YES'
00037         ),
00038         'memory' => array(
00039             'Engine'  => 'MEMORY',
00040             'Support' => 'YES'
00041         )
00042     );
00043     $known_engines = array(
00044         'archive' => 'ARCHIVE',
00045         'bdb'     => 'BDB',
00046         'csv'     => 'CSV',
00047         'innodb'  => 'InnoDB',
00048         'isam'    => 'ISAM',
00049         'gemini'  => 'Gemini'
00050     );
00051     $res = PMA_DBI_query('SHOW VARIABLES LIKE \'have\\_%\';');
00052     while ($row = PMA_DBI_fetch_row($res)) {
00053         $current = substr($row[0], 5);
00054         if (!empty($known_engines[$current])) {
00055             $GLOBALS['mysql_storage_engines'][$current] = array(
00056                 'Engine'  => $known_engines[$current],
00057                 'Support' => $row[1]
00058             );
00059         }
00060     }
00061     PMA_DBI_free_result($res);
00062     unset($known_engines, $res, $row);
00063 }
00064 
00080 function PMA_generateEnginesDropdown($name = 'engine', $id = NULL, $offerUnavailableEngines = FALSE, $selected = NULL, $indent = 0) {
00081     global $mysql_storage_engines;
00082     $selected = strtolower($selected);
00083     $spaces = '';
00084     for ($i = 0; $i < $indent; $i++) $spaces .= '    ';
00085     $output  = $spaces . '<select name="' . $name . '"' . (empty($id) ? '' : ' id="' . $id . '"') . '>' . "\n";
00086     foreach ($mysql_storage_engines as $key => $details) {
00087         if (!$offerUnavailableEngines && ($details['Support'] == 'NO' || $details['Support'] == 'DISABLED')) {
00088             continue;
00089         }
00090         $output .= $spaces . '    <option value="' . htmlspecialchars($key). '"'
00091                  . (empty($details['Comment']) ? '' : ' title="' . htmlspecialchars($details['Comment']) . '"')
00092                  . ($key == $selected || (empty($selected) && $details['Support'] == 'DEFAULT') ? ' selected="selected"' : '') . '>' . "\n"
00093                  . $spaces . '        ' . htmlspecialchars($details['Engine']) . "\n"
00094                  . $spaces . '    </option>' . "\n";
00095     }
00096     $output .= $spaces . '</select>' . "\n";
00097     return $output;
00098 }
00099 
00103 define('PMA_ENGINE_SUPPORT_NO', 0);
00104 define('PMA_ENGINE_SUPPORT_DISABLED', 1);
00105 define('PMA_ENGINE_SUPPORT_YES', 2);
00106 define('PMA_ENGINE_SUPPORT_DEFAULT', 3);
00107 class PMA_StorageEngine {
00108     var $engine  = 'dummy';
00109     var $title   = 'PMA Dummy Engine Class';
00110     var $comment = 'If you read this text inside phpMyAdmin, something went wrong...';
00111     var $support = PMA_ENGINE_SUPPORT_NO;
00112 
00122     function getEngine ($engine) {
00123         $engine = str_replace('/', '', str_replace('.', '', $engine));
00124         if (file_exists('./libraries/engines/' . $engine . '.lib.php') && include_once('./libraries/engines/' . $engine . '.lib.php')) {
00125             $class_name = 'PMA_StorageEngine_' . $engine;
00126             $engine_object = new $class_name($engine);
00127         } else {
00128             $engine_object = new PMA_StorageEngine($engine);
00129         }
00130         return $engine_object;
00131     }
00132 
00138     function PMA_StorageEngine ($engine) {
00139         global $mysql_storage_engines;
00140 
00141         if (!empty($mysql_storage_engines[$engine])) {
00142             $this->engine  = $engine;
00143             $this->title   = $mysql_storage_engines[$engine]['Engine'];
00144             $this->comment = (isset($mysql_storage_engines[$engine]['Comment']) ? $mysql_storage_engines[$engine]['Comment'] : '');
00145             switch ($mysql_storage_engines[$engine]['Support']) {
00146                 case 'DEFAULT':
00147                     $this->support = PMA_ENGINE_SUPPORT_DEFAULT;
00148                     break;
00149                 case 'YES':
00150                     $this->support = PMA_ENGINE_SUPPORT_YES;
00151                     break;
00152                 case 'DISABLED':
00153                     $this->support = PMA_ENGINE_SUPPORT_DISABLED;
00154                     break;
00155                 case 'NO':
00156                 default:
00157                     $this->support = PMA_ENGINE_SUPPORT_NO;
00158             }
00159         }
00160     }
00161 
00169     function getTitle () {
00170         return $this->title;
00171     }
00172 
00180     function getComment () {
00181         return $this->comment;
00182     }
00183 
00189     function getSupportInformationMessage () {
00190         switch ($this->support) {
00191             case PMA_ENGINE_SUPPORT_DEFAULT:
00192                 $message = $GLOBALS['strDefaultEngine'];
00193                 break;
00194             case PMA_ENGINE_SUPPORT_YES:
00195                 $message = $GLOBALS['strEngineAvailable'];
00196                 break;
00197             case PMA_ENGINE_SUPPORT_DISABLED:
00198                 $message = $GLOBALS['strEngineUnsupported'];
00199                 break;
00200             case PMA_ENGINE_SUPPORT_NO:
00201             default:
00202                 $message = $GLOBALS['strEngineUnavailable'];
00203         }
00204         return sprintf($message, htmlspecialchars($this->title));
00205     }
00206 
00216     function getVariables () {
00217         return array();
00218     }
00219 
00223     function getVariablesLikePattern () {
00224         return FALSE;
00225     }
00226 
00234     function getInfoPages () {
00235         return array();
00236     }
00237 
00248     function getPage($id) {
00249         return FALSE;
00250     }
00251 }
00252 
00253 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6