3 // vim: expandtab sw=4 ts=4 sts=4:
5 * the navigation frame - displays server, db and table selection tree
9 * Gets a core script and starts output buffering work
11 require_once './libraries/common.lib.php';
13 // free the session file, for the other frames to be loaded
14 session_write_close();
16 require_once './libraries/ob.lib.php';
17 if ($GLOBALS['cfg']['OBGzip']) {
18 $ob_mode = PMA_outBufferModeGet();
20 PMA_outBufferPre($ob_mode);
24 require_once './libraries/bookmark.lib.php';
25 require_once './libraries/relation.lib.php';
26 $cfgRelation = PMA_getRelationsParam();
29 * Get the list and number of available databases.
30 * Skipped if no server selected: in this case no database should be displayed
31 * before the user choose among available ones at the welcome screen.
34 // this function is defined in "common.lib.php"
35 // it defines $num_dbs and $dblist
36 PMA_availableDatabases();
38 if ((! isset($db) ||
! strlen($db)) && count($dblist) === 1) {
40 $db = current($dblist);
46 $db = isset($db) ?
$db : '';
47 $table = isset($table) ?
$table : '';
51 // garvin: For re-usability, moved http-headers
52 // to a seperate file. It can now be included by libraries/header.inc.php,
55 require_once './libraries/header_http.inc.php';
60 // xml declaration moves IE into quirks mode, making much trouble with CSS
61 /* echo '<?xml version="1.0" encoding="' . $GLOBALS['charset'] . '"?>'; */
63 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
64 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
65 <html xmlns
="http://www.w3.org/1999/xhtml"
66 xml
:lang
="<?php echo $available_languages[$lang][2]; ?>"
67 lang
="<?php echo $available_languages[$lang][2]; ?>"
68 dir
="<?php echo $text_dir; ?>">
71 <link rel
="icon" href
="./favicon.ico" type
="image/x-icon" />
72 <link rel
="shortcut icon" href
="./favicon.ico" type
="image/x-icon" />
73 <title
>phpMyAdmin
</title
>
74 <meta http
-equiv
="Content-Type"
75 content
="text/html; charset=<?php echo $charset; ?>" />
76 <base target
="frame_content" />
77 <link rel
="stylesheet" type
="text/css"
78 href
="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=left" />
79 <script type
="text/javascript" language
="javascript">
81 function toggle(id
, only_open
) {
82 var el
= document
.getElementById('subel' + id
);
87 var img
= document
.getElementById('el' + id +
'Img');
89 if (el
.style
.display
== 'none' || only_open
) {
90 el
.style
.display
= '';
92 img
.src
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_minus.png';
96 el
.style
.display
= 'none';
98 img
.src
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_plus.png';
108 * remove horizontal scroll bar bug in IE by forcing a vertical scroll bar
112 <style type
="text/css">
122 <body id
="body_leftFrame">
124 require './libraries/left_header.inc.php';
126 if ($num_dbs === 0) {
127 // no database available, so we break here
128 echo '<p>' . $strNoDatabases . '</p></body></html>';
131 * Close MySql connections
133 if (isset($controllink) && $controllink) {
134 @PMA_DBI_close
($controllink);
136 if (isset($userlink) && $userlink) {
137 @PMA_DBI_close
($userlink);
141 * Sends bufferized data
143 if ($GLOBALS['cfg']['OBGzip'] && isset($ob_mode) && $ob_mode) {
144 PMA_outBufferPost($ob_mode);
147 } elseif ($GLOBALS['cfg']['LeftFrameLight'] && $num_dbs > 1) {
148 // more than one database available and LeftFrameLight is true
149 // display db selectbox
151 // Light mode -> beginning of the select combo for databases
152 // Note: When javascript is active, the frameset will be changed from
153 // within left.php. With no JS (<noscript>) the whole frameset will
154 // be rebuilt with the new target frame.
157 <div id
="databaseList">
158 <form method
="post" action
="index.php" target
="_parent" id
="left">
159 <label
for="lightm_db"><?php
echo $strDatabase; ?
></label
>
161 echo PMA_generate_common_hidden_inputs() . "\n";
162 echo PMA_getHtmlSelectDb($db) . "\n";
163 echo '<noscript>' . "\n"
164 .'<input type="submit" name="Go" value="' . $strGo . '" />' . "\n"
165 .'</noscript>' . "\n"
171 <div id
="left_tableList">
173 // Don't display expansible/collapsible database info if:
174 // 1. $server == 0 (no server selected)
175 // This is the case when there are multiple servers and
176 // '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome
177 // screen to appear with no database info displayed.
178 // 2. there is only one database available (ie either only one database exists
179 // or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
180 // In this case, the database should not be collapsible/expandable
182 $img_plus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_plus.png"'
183 .' width="9" height="9" alt="+" />';
184 $img_minus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_minus.png"'
185 .' width="9" height="9" alt="-" />';
187 $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
188 .' href="left.php?%s" target="_self">';
190 $element_counter = 0;
192 if ($GLOBALS['cfg']['LeftFrameLight'] && isset($db) && strlen($db)) {
193 // show selected databasename as link to DefaultTabDatabase-page
194 // with table count in ()
195 $common_url_query = PMA_generate_common_url($db);
198 if ($GLOBALS['cfg']['ShowTooltip']
199 && $GLOBALS['cfgRelation']['commwork']) {
200 $_db_tooltip = PMA_getComments($db);
201 if (is_array($_db_tooltip)) {
202 $db_tooltip = implode(' ', $_db_tooltip);
207 if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
208 $disp_name = $db_tooltip;
209 $disp_name_cut = $db_tooltip;
215 href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?>"
216 title
="<?php echo htmlspecialchars($db_tooltip); ?>" >
218 if ($GLOBALS['text_dir'] === 'rtl') {
219 echo ' <bdo dir="ltr">(' . PMA_getTableCount($db) . ')</bdo> ';
221 echo htmlspecialchars($disp_name);
222 if ($GLOBALS['text_dir'] === 'ltr') {
223 echo ' <bdo dir="ltr">(' . PMA_getTableCount($db) . ')</bdo> ';
227 $table_list = PMA_getTableList($db);
228 if (count($table_list) > 0) {
229 PMA_displayTableList($table_list, true, '', $db);
231 echo $strNoTablesFound;
234 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
235 echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
237 $common_url_query = PMA_generate_common_url();
238 PMA_displayDbList(PMA_getDbList());
242 * displays collapsable db list
244 * @uses $_REQUEST['dbgroup']
245 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
246 * @uses $GLOBALS['strSelectADb']
250 * @uses htmlspecialchars()
251 * @uses PMA_generate_common_url()
252 * @uses PMA_getTableList()
253 * @uses PMA_displayTableList()
254 * @global $element_counter
260 * @global $common_url_query
261 * @param array $ext_dblist extended db list
263 function PMA_displayDbList($ext_dblist) {
264 global $element_counter, $img_minus, $img_plus, $href_left, $num_dbs,
265 $db_start, $common_url_query;
267 // get table list, for all databases
268 // doing this in one step takes advantage of a single query with information_schema!
269 $tables_full = PMA_DBI_get_tables_full($GLOBALS['dblist']);
272 echo '<ul id="leftdatabaselist">';
273 $close_db_group = false;
274 foreach ($ext_dblist as $group => $db_group) {
276 if ($close_db_group) {
280 $close_db_group = false;
282 if (count($db_group) > 1) {
283 $close_db_group = true;
284 $url_dbgroup = '&dbgroup=' . urlencode($group);
285 $common_url_query = PMA_generate_common_url() . $url_dbgroup;
287 echo '<li class="dbgroup">';
288 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
289 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
290 // display + only if this db(group) is not preselected
291 printf($href_left, $element_counter, PMA_generate_common_url());
292 printf($img_minus, $element_counter);
294 printf($href_left, $element_counter, $common_url_query);
295 printf($img_plus, $element_counter);
297 echo '</a> ' . $group . "\n";
298 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
299 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
300 echo '<ul id="subel' . $element_counter . '">' . "\n";
302 echo '<ul id="subel' . $element_counter . '"'
303 .' style="display: none">' . "\n";
307 foreach ($db_group as $db) {
308 $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup;
311 // Displays the database name
315 // only with more than one db we need collapse ...
316 if ($db_start != $db['name'] ||
$db['num_tables'] < 1) {
317 // display + only if this db is not preselected
318 // or table count is 0
319 printf($href_left, $element_counter, $common_url_query);
320 printf($img_plus, $element_counter);
322 printf($href_left, $element_counter,
323 PMA_generate_common_url() . $url_dbgroup);
324 printf($img_minus, $element_counter);
328 // ... and we need to refresh both frames on db selection
331 id
="<?php echo htmlspecialchars($db['name']); ?>"
332 href
="index.php?<?php echo $common_url_query; ?>"
334 title
="<?php echo htmlspecialchars($db['comment']); ?>"
336 if (! toggle('<?php echo $element_counter; ?>', true))
337 window.parent.goTo('./left.php?<?php echo $common_url_query; ?>');
338 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
339 . '?' . $common_url_query; ?>', 'main');
342 if ($GLOBALS['text_dir'] === 'rtl') {
343 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
345 echo htmlspecialchars($db['disp_name']);
346 if ($GLOBALS['text_dir'] === 'ltr') {
347 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
353 // with only 1 db available we dont need to refresh left frame
354 // on db selection, only phpmain
356 <a href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
357 . '?' . $common_url_query; ?>"
358 id
="<?php echo htmlspecialchars($db['name']); ?>"
359 title
="<?php echo htmlspecialchars($db['comment']); ?>">
361 if ($GLOBALS['text_dir'] === 'rtl') {
362 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
364 echo htmlspecialchars($db['disp_name']);
365 if ($GLOBALS['text_dir'] === 'ltr') {
366 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
372 if ($db['num_tables']) {
373 if (isset($tables_full[$db['name']])) {
374 $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
375 } elseif (isset($tables_full[strtolower($db['name'])])) {
376 // on windows with lower_case_table_names = 1
378 // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
379 // but information_schema.TABLES gives `test`
381 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
382 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
384 $tables = PMA_getTableList($db['name']);
387 (bool) ($num_dbs === 1 ||
$db_start == $db['name']);
388 PMA_displayTableList($tables, $child_visible, '', $db['name']);
389 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
390 // no tables and LeftFrameLight:
391 // display message no tables in selected db
392 echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
396 } // end foreach group
398 if ($close_db_group) {
402 $close_db_group = false;
409 * display unordered list of tables
410 * calls itself recursively if table in given list
418 * @uses htmlspecialchars()
421 * @uses PMA_displayTableList()
422 * @uses $_REQUEST['tbl_group']
423 * @uses $GLOBALS['common_url_query']
424 * @uses $GLOBALS['table']
425 * @uses $GLOBALS['pmaThemeImage']
426 * @uses $GLOBALS['cfg']['LeftFrameTableSeparator']
427 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
428 * @uses $GLOBALS['cfg']['DefaultTabTable']
429 * @uses $GLOBALS['strRows']
430 * @uses $GLOBALS['strBrowse']
431 * @global $element_counter
435 * @param array $tables array of tables/tablegroups
436 * @param boolean $visible wether the list is visible or not
437 * @param string $tab_group_full full tab group name
438 * @param string $table_db db of this table
440 function PMA_displayTableList($tables, $visible = false,
441 $tab_group_full = '', $table_db = '')
443 if (! is_array($tables) ||
count($tables) === 0) {
447 global $element_counter, $img_minus, $img_plus, $href_left;
448 $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
451 echo '<ul id="subel' . $element_counter . '">';
453 echo '<ul id="subel' . $element_counter . '" style="display: none">';
455 foreach ($tables as $group => $table) {
456 if (isset($table['is' . $sep . 'group'])) {
457 $common_url_query = $GLOBALS['common_url_query']
458 . '&tbl_group=' . urlencode($tab_group_full . $group);
463 ((isset($_REQUEST['tbl_group'])
464 && (strpos($_REQUEST['tbl_group'], $group) === 0
465 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
467 (isset($GLOBALS['table'])
468 && strpos($GLOBALS['table'], $group) === 0))) {
469 printf($href_left, $element_counter,
470 $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full);
471 printf($img_minus, $element_counter);
473 printf($href_left, $element_counter, $common_url_query);
474 printf($img_plus, $element_counter);
478 <a href
="index.php?<?php echo $common_url_query; ?>"
481 if (! toggle('<?php echo $element_counter; ?>', true))
482 window.parent.goTo('./left.php?<?php echo $common_url_query; ?>');
483 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
484 . '?' . $common_url_query; ?>', 'main');
487 if ($GLOBALS['text_dir'] === 'rtl') {
488 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
490 echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
491 if ($GLOBALS['text_dir'] === 'ltr') {
492 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
498 unset($table['is' . $sep . 'group']);
499 unset($table['tab' . $sep . 'group']);
500 unset($table['tab' . $sep . 'count']);
503 ((isset($_REQUEST['tbl_group'])
504 && (strpos($_REQUEST['tbl_group'], $group) === 0
505 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
507 (isset($GLOBALS['table'])
508 && strpos($GLOBALS['table'], $group) === 0))) {
509 PMA_displayTableList($table, true,
510 $tab_group_full . $group, $table_db);
512 PMA_displayTableList($table, false, '', $table_db);
515 } elseif (is_array($table)) {
516 $href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
517 .$GLOBALS['common_url_query'] . '&table='
518 .urlencode($table['Name']);
520 echo '<a title="' . $GLOBALS['strBrowse'] . ': '
521 . htmlspecialchars($table['Comment'])
522 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')"'
523 .' id="browse_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
524 .' href="sql.php?' . $GLOBALS['common_url_query']
525 .'&table=' . urlencode($table['Name'])
526 .'&goto=' . $GLOBALS['cfg']['DefaultTabTable']
528 .'<img class="icon"';
529 if ('VIEW' === strtoupper($table['Comment'])) {
530 echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"';
532 echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"';
534 echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
535 .' width="10" height="10" alt="' . $GLOBALS['strBrowse'] . '" /></a>' . "\n"
536 .'<a href="' . $href . '" title="' . $table['Comment']
537 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')"'
538 .' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
539 . htmlspecialchars($table['disp_name']) . '</a>';
551 * Close MySql connections
553 if (isset($controllink) && $controllink) {
554 @PMA_DBI_close
($controllink);
556 if (isset($userlink) && $userlink) {
557 @PMA_DBI_close
($userlink);
561 * Sends bufferized data
563 if ($GLOBALS['cfg']['OBGzip'] && isset($ob_mode) && $ob_mode) {
564 PMA_outBufferPost($ob_mode);