3 // vim: expandtab sw=4 ts=4 sts=4:
6 * Library for extracting information about the available storage engines
9 $GLOBALS['mysql_storage_engines'] = array();
11 if (PMA_MYSQL_INT_VERSION
>= 40102) {
13 * For MySQL >= 4.1.2, the job is easy...
15 $res = PMA_DBI_query('SHOW STORAGE ENGINES');
16 while ($row = PMA_DBI_fetch_assoc($res)) {
17 $GLOBALS['mysql_storage_engines'][strtolower($row['Engine'])] = $row;
19 PMA_DBI_free_result($res);
23 * Emulating SHOW STORAGE ENGINES...
25 $GLOBALS['mysql_storage_engines'] = array(
28 'Support' => 'DEFAULT'
43 $known_engines = array(
44 'archive' => 'ARCHIVE',
51 $res = PMA_DBI_query('SHOW VARIABLES LIKE \'have\\_%\';');
52 while ($row = PMA_DBI_fetch_row($res)) {
53 $current = substr($row[0], 5);
54 if (!empty($known_engines[$current])) {
55 $GLOBALS['mysql_storage_engines'][$current] = array(
56 'Engine' => $known_engines[$current],
61 PMA_DBI_free_result($res);
62 unset($known_engines, $res, $row);
66 * Function for generating the storage engine selection
69 * @uses $GLOBALS['mysql_storage_engines']
70 * @param string $name The name of the select form element
71 * @param string $id The ID of the form field
72 * @param boolean $offerUnavailableEngines
73 * Should unavailable storage engines be offered?
74 * @param string $selected The selected engine
75 * @param int $indent The indentation level
76 * @return string html selectbox
78 function PMA_generateEnginesDropdown($name = 'engine', $id = null,
79 $offerUnavailableEngines = false, $selected = null, $indent = 0)
81 $selected = strtolower($selected);
82 $spaces = str_repeat( ' ', $indent );
83 $output = $spaces . '<select name="' . $name . '"'
84 . (empty($id) ?
'' : ' id="' . $id . '"') . '>' . "\n";
86 foreach ($GLOBALS['mysql_storage_engines'] as $key => $details) {
87 if (!$offerUnavailableEngines
88 && ($details['Support'] == 'NO' ||
$details['Support'] == 'DISABLED')) {
91 $output .= $spaces . ' <option value="' . htmlspecialchars($key). '"'
92 . (empty($details['Comment'])
93 ?
'' : ' title="' . htmlspecialchars($details['Comment']) . '"')
94 . ($key == $selected ||
(empty($selected) && $details['Support'] == 'DEFAULT')
95 ?
' selected="selected"' : '') . '>' . "\n"
96 . $spaces . ' ' . htmlspecialchars($details['Engine']) . "\n"
97 . $spaces . ' </option>' . "\n";
99 $output .= $spaces . '</select>' . "\n";
106 define('PMA_ENGINE_SUPPORT_NO', 0);
107 define('PMA_ENGINE_SUPPORT_DISABLED', 1);
108 define('PMA_ENGINE_SUPPORT_YES', 2);
109 define('PMA_ENGINE_SUPPORT_DEFAULT', 3);
112 * Abstract Storage Engine Class
114 class PMA_StorageEngine
117 * @var string engine name
119 var $engine = 'dummy';
122 * @var string engine title/description
124 var $title = 'PMA Dummy Engine Class';
127 * @var string engine lang description
129 var $comment = 'If you read this text inside phpMyAdmin, something went wrong...';
132 * @var integer engine supported by current server
134 var $support = PMA_ENGINE_SUPPORT_NO
;
137 * public static final PMA_StorageEngine getEngine()
139 * Loads the corresponding engine plugin, if available.
141 * @uses str_replace()
142 * @uses file_exists()
143 * @uses PMA_StorageEngine
144 * @param string $engine The engine ID
145 * @return object The engine plugin
147 function getEngine($engine)
149 $engine = str_replace('/', '', str_replace('.', '', $engine));
150 if (file_exists('./libraries/engines/' . $engine . '.lib.php')
151 && include_once('./libraries/engines/' . $engine . '.lib.php')) {
152 $class_name = 'PMA_StorageEngine_' . $engine;
153 $engine_object = new $class_name($engine);
155 $engine_object = new PMA_StorageEngine($engine);
157 return $engine_object;
163 * @uses $GLOBALS['mysql_storage_engines']
164 * @uses PMA_ENGINE_SUPPORT_DEFAULT
165 * @uses PMA_ENGINE_SUPPORT_YES
166 * @uses PMA_ENGINE_SUPPORT_DISABLED
167 * @uses PMA_ENGINE_SUPPORT_NO
168 * @uses $this->engine
170 * @uses $this->comment
171 * @uses $this->support
172 * @param string $engine The engine ID
174 function __construct($engine)
176 if (!empty($GLOBALS['mysql_storage_engines'][$engine])) {
177 $this->engine
= $engine;
178 $this->title
= $GLOBALS['mysql_storage_engines'][$engine]['Engine'];
180 (isset($GLOBALS['mysql_storage_engines'][$engine]['Comment'])
181 ?
$GLOBALS['mysql_storage_engines'][$engine]['Comment']
183 switch ($GLOBALS['mysql_storage_engines'][$engine]['Support']) {
185 $this->support
= PMA_ENGINE_SUPPORT_DEFAULT
;
188 $this->support
= PMA_ENGINE_SUPPORT_YES
;
191 $this->support
= PMA_ENGINE_SUPPORT_DISABLED
;
195 $this->support
= PMA_ENGINE_SUPPORT_NO
;
201 * old PHP 4 style constructor
203 * @see PMA_StorageEngine::__construct()
204 * @uses PMA_StorageEngine::__construct()
205 * @param string $engine engine name
207 function PMA_StorageEngine($engine)
209 $this->__construct($engine);
213 * public String getTitle()
215 * Reveals the engine's title
217 * @return string The title
225 * public String getComment()
227 * Fetches the server's comment about this engine
228 * @uses $this->comment
229 * @return string The comment
231 function getComment()
233 return $this->comment
;
237 * public String getSupportInformationMessage()
239 * @uses $GLOBALS['strDefaultEngine']
240 * @uses $GLOBALS['strEngineAvailable']
241 * @uses $GLOBALS['strEngineDisabled']
242 * @uses $GLOBALS['strEngineUnsupported']
243 * @uses $GLOBALS['strEngineUnsupported']
244 * @uses PMA_ENGINE_SUPPORT_DEFAULT
245 * @uses PMA_ENGINE_SUPPORT_YES
246 * @uses PMA_ENGINE_SUPPORT_DISABLED
247 * @uses PMA_ENGINE_SUPPORT_NO
248 * @uses $this->support
251 * @return string The localized message.
253 function getSupportInformationMessage()
255 switch ($this->support
) {
256 case PMA_ENGINE_SUPPORT_DEFAULT
:
257 $message = $GLOBALS['strDefaultEngine'];
259 case PMA_ENGINE_SUPPORT_YES
:
260 $message = $GLOBALS['strEngineAvailable'];
262 case PMA_ENGINE_SUPPORT_DISABLED
:
263 $message = $GLOBALS['strEngineDisabled'];
265 case PMA_ENGINE_SUPPORT_NO
:
267 $message = $GLOBALS['strEngineUnsupported'];
269 return sprintf($message, htmlspecialchars($this->title
));
273 * public string[][] getVariables()
275 * Generates a list of MySQL variables that provide information about this
276 * engine. This function should be overridden when extending this class
277 * for a particular engine.
280 * @return Array The list of variables.
282 function getVariables()
288 * returns string with filename for the MySQL helppage
289 * about this storage engne
291 * @return string mysql helppage filename
293 function getMysqlHelpPage()
295 return $this->engine
. '-storage-engine';
299 * public string getVariablesLikePattern()
302 * @return string SQL query LIKE pattern
304 function getVariablesLikePattern()
310 * public String[] getInfoPages()
312 * Returns a list of available information pages with labels
315 * @return array The list
317 function getInfoPages()
323 * public String getPage()
325 * Generates the requested information page
328 * @param string $id The page ID
330 * @return string The page
331 * boolean or false on error.
333 function getPage($id)