2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * the navigation frame - displays server, db and table selection tree
7 * @uses $GLOBALS['PMA_List_Database']
8 * @uses $GLOBALS['server']
10 * @uses $GLOBALS['table']
11 * @uses $GLOBALS['available_languages']
12 * @uses $GLOBALS['lang']
13 * @uses $GLOBALS['text_dir']
14 * @uses $GLOBALS['charset']
15 * @uses $GLOBALS['pmaThemeImage']
16 * @uses $GLOBALS['strNoDatabases']
17 * @uses $GLOBALS['strDatabase']
18 * @uses $GLOBALS['strGo']
19 * @uses $GLOBALS['strSelectADb']
20 * @uses $GLOBALS['strNoTablesFound']
21 * @uses $GLOBALS['cfg']['LeftFrameLight']
22 * @uses $GLOBALS['cfg']['ShowTooltip']
23 * @uses $GLOBALS['cfg']['ShowTooltipAliasDB']
24 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
25 * @uses $GLOBALS['cfgRelation']['commwork']) {
26 * @uses PMA_List_Database::getSingleItem()
27 * @uses PMA_List_Database::count()
28 * @uses PMA_List_Database::getHtmlSelectGrouped()
29 * @uses PMA_List_Database::getGroupedDetails()
30 * @uses PMA_generate_common_url()
31 * @uses PMA_generate_common_hidden_inputs()
32 * @uses PMA_getComments();
33 * @uses PMA_getTableCount()
34 * @uses PMA_getTableList()
35 * @uses PMA_getRelationsParam()
36 * @uses PMA_outBufferPre()
37 * @uses session_write_close()
39 * @uses session_write_close()
42 * @uses htmlspecialchars()
46 * Gets a core script and starts output buffering work
48 require_once './libraries/common.inc.php';
51 * finish and cleanup navigation.php script execution
53 * @uses $GLOBALS['controllink'] to close it
54 * @uses $GLOBALS['userlink'] to close it
55 * @uses PMA_DBI_close()
56 * @access private only to be used in navigation.php
58 function PMA_exitNavigationFrame()
60 echo '</body></html>';
63 * Close MySQL connections
65 if (isset($GLOBALS['controllink']) && $GLOBALS['controllink']) {
66 @PMA_DBI_close
($GLOBALS['controllink']);
68 if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) {
69 @PMA_DBI_close
($GLOBALS['userlink']);
75 // keep the offset of the db list in session before closing it
76 if (! isset($_SESSION['navi_limit_offset'])) {
77 $_SESSION['navi_limit_offset'] = 0;
79 if (isset($_REQUEST['pos'])) {
80 $_SESSION['navi_limit_offset'] = (int) $_REQUEST['pos'];
82 $pos = $_SESSION['navi_limit_offset'];
84 // free the session file, for the other frames to be loaded
85 session_write_close();
88 * the output compression library
90 require_once './libraries/ob.lib.php';
95 * selects the database if there is only one on current server
97 if ($GLOBALS['server'] && ! strlen($GLOBALS['db'])) {
98 $GLOBALS['db'] = $GLOBALS['PMA_List_Database']->getSingleItem();
101 $db_start = $GLOBALS['db'];
104 * the relation library
106 require_once './libraries/relation.lib.php';
107 $cfgRelation = PMA_getRelationsParam();
110 * garvin: For re-usability, moved http-headers to a seperate file.
111 * It can now be included by libraries/header.inc.php, querywindow.php.
113 require_once './libraries/header_http.inc.php';
115 if (! isset($_SESSION['navi_limit_offset'])) {
116 $_SESSION['navi_limit_offset'] = 0;
118 if (isset($_REQUEST['pos'])) {
119 $_SESSION['navi_limit_offset'] = (int) $_REQUEST['pos'];
121 $pos = $_SESSION['navi_limit_offset'];
126 // xml declaration moves IE into quirks mode, making much trouble with CSS
127 /* echo '<?xml version="1.0" encoding="' . $GLOBALS['charset'] . '"?>'; */
129 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
130 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
131 <html xmlns
="http://www.w3.org/1999/xhtml"
132 xml
:lang
="<?php echo $available_languages[$lang][2]; ?>"
133 lang
="<?php echo $available_languages[$lang][2]; ?>"
134 dir
="<?php echo $GLOBALS['text_dir']; ?>">
137 <link rel
="icon" href
="./favicon.ico" type
="image/x-icon" />
138 <link rel
="shortcut icon" href
="./favicon.ico" type
="image/x-icon" />
139 <title
>phpMyAdmin
</title
>
140 <meta http
-equiv
="Content-Type"
141 content
="text/html; charset=<?php echo $GLOBALS['charset']; ?>" />
142 <base target
="frame_content" />
143 <link rel
="stylesheet" type
="text/css"
144 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=left&nocache=<?php echo $_SESSION['PMA_Config']->getMtime(); ?>" />
145 <script type
="text/javascript" src
="js/navigation.js"></script
>
146 <script type
="text/javascript" src
="js/functions.js"></script
>
147 <script type
="text/javascript">
149 var image_minus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_minus.png';
150 var image_plus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_plus.png';
155 * remove horizontal scroll bar bug in IE 6 by forcing a vertical scroll bar
159 <style type
="text/css">
169 <body id
="body_leftFrame" onload
="PMA_setFrameSize();" onresize
="PMA_saveFrameSize();">
171 require './libraries/navigation_header.inc.php';
172 if (! $GLOBALS['server']) {
173 // no server selected
174 PMA_exitNavigationFrame();
175 } elseif (! $GLOBALS['PMA_List_Database']->count()) {
176 // no database available, so we break here
177 echo '<p>' . $GLOBALS['strNoDatabases'] . '</p>';
178 PMA_exitNavigationFrame();
179 } elseif ($GLOBALS['cfg']['LeftFrameLight'] && $GLOBALS['PMA_List_Database']->count() > 1) {
180 $list = $cfg['DisplayDatabasesList'];
181 if ($list === 'auto') {
182 if (empty($GLOBALS['db'])) {
189 // more than one database available and LeftFrameLight is true
190 // display db selectbox
192 // Light mode -> beginning of the select combo for databases
193 // Note: When javascript is active, the frameset will be changed from
194 // within navigation.php. With no JS (<noscript>) the whole frameset will
195 // be rebuilt with the new target frame.
198 <div id
="databaseList">
199 <form method
="post" action
="index.php" target
="_parent" id
="left">
200 <label
for="lightm_db"><?php
echo $GLOBALS['strDatabase']; ?
></label
>
202 echo PMA_generate_common_hidden_inputs() . "\n";
203 echo $GLOBALS['PMA_List_Database']->getHtmlSelectGrouped(true, $_SESSION['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
204 echo '<noscript>' . "\n"
205 .'<input type="submit" name="Go" value="' . $GLOBALS['strGo'] . '" />' . "\n"
206 .'</noscript>' . "\n"
210 echo '<div id="databaseList">' . "\n";
212 echo $GLOBALS['PMA_List_Database']->getHtmlListGrouped(true, $_SESSION['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
214 $_url_params = array('pos' => $pos);
215 PMA_listNavigator($GLOBALS['PMA_List_Database']->count(), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
217 echo '</div>' . "\n";
222 <div id
="left_tableList">
224 // Don't display expansible/collapsible database info if:
225 // 1. $GLOBALS['server'] == 0 (no server selected)
226 // This is the case when there are multiple servers and
227 // '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome
228 // screen to appear with no database info displayed.
229 // 2. there is only one database available (ie either only one database exists
230 // or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
231 // In this case, the database should not be collapsible/expandable
233 $img_plus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_plus.png"'
234 .' width="9" height="9" alt="+" />';
235 $img_minus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_minus.png"'
236 .' width="9" height="9" alt="-" />';
238 $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
239 .' href="navigation.php?%s" target="_self">';
241 $element_counter = 0;
243 if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
244 // show selected databasename as link to DefaultTabDatabase-page
245 // with table count in ()
246 $common_url_query = PMA_generate_common_url($GLOBALS['db']);
250 if ($GLOBALS['cfg']['ShowTooltip']
251 && $GLOBALS['cfgRelation']['commwork']) {
252 $_db_tooltip = PMA_getComments($GLOBALS['db']);
253 if (is_array($_db_tooltip)) {
254 $db_tooltip = implode(' ', $_db_tooltip);
258 $disp_name = $GLOBALS['db'];
259 if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
260 $disp_name = $db_tooltip;
261 $disp_name_cut = $db_tooltip;
262 $db_tooltip = $GLOBALS['db'];
267 href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?>"
268 title
="<?php echo htmlspecialchars($db_tooltip); ?>" >
270 if ($GLOBALS['text_dir'] === 'rtl') {
271 echo ' <bdo dir="ltr">(' . PMA_getTableCount($GLOBALS['db']) . ')</bdo> ';
273 echo '<span class="navi_dbName">' . htmlspecialchars($disp_name) . '</span>';
274 if ($GLOBALS['text_dir'] === 'ltr') {
275 echo ' <bdo dir="ltr">(' . PMA_getTableCount($GLOBALS['db']) . ')</bdo> ';
280 * This helps reducing the navi panel size; in the right panel,
281 * user can find a navigator to page thru all tables.
283 * @todo instead of the 0 parameter, keep track of the
284 * offset in the list of tables ($_SESSION['navi_table_limit_offset'])
285 * and use PMA_listNavigator(); do not just check pos in REQUEST
286 * but add another hidden param to see if it's the pos of databases
287 * or the pos of tables.
289 $table_list = PMA_getTableList($GLOBALS['db'], null, 0, $cfg['MaxTableList']);
290 if (! empty($table_list)) {
291 PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
292 // hint user that the table list is larger, until the todo is done
293 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && PMA_getTableCount($GLOBALS['db']) > $GLOBALS['cfg']['MaxTableList']) {
294 echo ' ( 1 .. ', $GLOBALS['cfg']['MaxTableList'], ' / ', PMA_getTableCount($GLOBALS['db']), ' )';
297 echo $GLOBALS['strNoTablesFound'];
300 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
301 echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
303 echo '<div id="databaseList">' . "\n";
304 $_url_params = array('pos' => $pos);
305 PMA_listNavigator($GLOBALS['PMA_List_Database']->count(), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
306 echo '</div>' . "\n";
308 $common_url_query = PMA_generate_common_url();
309 PMA_displayDbList($GLOBALS['PMA_List_Database']->getGroupedDetails($_SESSION['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']), $_SESSION['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']);
313 * displays collapsable db list
315 * @uses $_REQUEST['dbgroup']
316 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
317 * @uses $GLOBALS['strSelectADb']
321 * @uses htmlspecialchars()
322 * @uses PMA_generate_common_url()
323 * @uses PMA_getTableList()
324 * @uses PMA_displayTableList()
325 * @global $element_counter
330 * @global $common_url_query
331 * @param array $ext_dblist extended db list
332 * @param integer $offset
333 * @param integer $count
335 function PMA_displayDbList($ext_dblist, $offset, $count) {
336 global $element_counter, $img_minus, $img_plus, $href_left,
337 $db_start, $common_url_query;
339 // get table list, for all databases
340 // doing this in one step takes advantage of a single query with information_schema!
341 $tables_full = PMA_DBI_get_tables_full($GLOBALS['PMA_List_Database']->getLimitedItems($offset, $count));
344 echo '<ul id="leftdatabaselist">';
345 $close_db_group = false;
346 foreach ($ext_dblist as $group => $db_group) {
347 if ($GLOBALS['PMA_List_Database']->count() > 1) {
348 if ($close_db_group) {
352 $close_db_group = false;
354 if (count($db_group) > 1) {
355 $close_db_group = true;
356 $url_dbgroup = '&dbgroup=' . urlencode($group);
357 $common_url_query = PMA_generate_common_url() . $url_dbgroup;
359 echo '<li class="dbgroup">';
360 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
361 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
362 // display + only if this db(group) is not preselected
363 printf($href_left, $element_counter, PMA_generate_common_url());
364 printf($img_minus, $element_counter);
366 printf($href_left, $element_counter, $common_url_query);
367 printf($img_plus, $element_counter);
369 echo '</a> ' . $group . "\n";
370 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
371 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
372 echo '<ul id="subel' . $element_counter . '">' . "\n";
374 echo '<ul id="subel' . $element_counter . '"'
375 .' style="display: none">' . "\n";
379 foreach ($db_group as $db) {
380 $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup;
383 // Displays the database name
386 if ($GLOBALS['PMA_List_Database']->count() > 1) {
387 // only with more than one db we need collapse ...
388 if ($db_start != $db['name'] ||
$db['num_tables'] < 1) {
389 // display + only if this db is not preselected
390 // or table count is 0
391 printf($href_left, $element_counter, $common_url_query);
392 printf($img_plus, $element_counter);
394 printf($href_left, $element_counter,
395 PMA_generate_common_url() . $url_dbgroup);
396 printf($img_minus, $element_counter);
400 // ... and we need to refresh both frames on db selection
403 id
="<?php echo htmlspecialchars($db['name']); ?>"
404 href
="index.php?<?php echo $common_url_query; ?>"
406 title
="<?php echo htmlspecialchars($db['comment']); ?>"
408 if (! toggle('<?php echo $element_counter; ?>', true))
409 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
410 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
411 . '?' . $common_url_query; ?>', 'main');
414 if ($GLOBALS['text_dir'] === 'rtl') {
415 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
417 echo htmlspecialchars($db['disp_name']);
418 if ($GLOBALS['text_dir'] === 'ltr') {
419 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
425 // with only 1 db available we dont need to refresh left frame
426 // on db selection, only phpmain
428 <a href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
429 . '?' . $common_url_query; ?>"
430 id
="<?php echo htmlspecialchars($db['name']); ?>"
431 title
="<?php echo htmlspecialchars($db['comment']); ?>">
433 if ($GLOBALS['text_dir'] === 'rtl') {
434 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
436 echo htmlspecialchars($db['disp_name']);
437 if ($GLOBALS['text_dir'] === 'ltr') {
438 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
444 if ($db['num_tables']) {
445 if (isset($tables_full[$db['name']])) {
446 $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
447 } elseif (isset($tables_full[strtolower($db['name'])])) {
448 // on windows with lower_case_table_names = 1
450 // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
451 // but information_schema.TABLES gives `test`
453 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
454 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
456 $tables = PMA_getTableList($db['name']);
459 (bool) ($GLOBALS['PMA_List_Database']->count() === 1 ||
$db_start == $db['name']);
460 PMA_displayTableList($tables, $child_visible, '', $db['name']);
461 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
462 // no tables and LeftFrameLight:
463 // display message no tables in selected db
464 echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
468 } // end foreach group
470 if ($close_db_group) {
474 $close_db_group = false;
481 * display unordered list of tables
482 * calls itself recursively if table in given list
490 * @uses htmlspecialchars()
493 * @uses PMA_displayTableList()
494 * @uses $_REQUEST['tbl_group']
495 * @uses $GLOBALS['common_url_query']
496 * @uses $GLOBALS['table']
497 * @uses $GLOBALS['pmaThemeImage']
498 * @uses $GLOBALS['cfg']['LeftFrameTableSeparator']
499 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
500 * @uses $GLOBALS['cfg']['DefaultTabTable']
501 * @uses $GLOBALS['strRows']
502 * @uses $GLOBALS['strBrowse']
503 * @global integer the element counter
504 * @global string html code for '-' image
505 * @global string html code for '+' image
506 * @global string html code for self link
507 * @param array $tables array of tables/tablegroups
508 * @param boolean $visible wether the list is visible or not
509 * @param string $tab_group_full full tab group name
510 * @param string $table_db db of this table
512 function PMA_displayTableList($tables, $visible = false,
513 $tab_group_full = '', $table_db = '')
515 if (! is_array($tables) ||
count($tables) === 0) {
519 global $element_counter, $img_minus, $img_plus, $href_left;
520 $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
523 echo '<ul id="subel' . $element_counter . '">';
525 echo '<ul id="subel' . $element_counter . '" style="display: none">';
527 foreach ($tables as $group => $table) {
528 if (isset($table['is' . $sep . 'group'])) {
529 $common_url_query = $GLOBALS['common_url_query']
530 . '&tbl_group=' . urlencode($tab_group_full . $group);
535 && ((isset($_REQUEST['tbl_group'])
536 && (strpos($_REQUEST['tbl_group'], $group) === 0
537 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
538 ||
strpos($GLOBALS['table'], $group) === 0)) {
539 printf($href_left, $element_counter,
540 $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full);
541 printf($img_minus, $element_counter);
543 printf($href_left, $element_counter, $common_url_query);
544 printf($img_plus, $element_counter);
548 <a href
="index.php?<?php echo $common_url_query; ?>"
551 if (! toggle('<?php echo $element_counter; ?>', true))
552 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
553 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
554 . '?' . $common_url_query; ?>', 'main');
557 if ($GLOBALS['text_dir'] === 'rtl') {
558 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
560 echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
561 if ($GLOBALS['text_dir'] === 'ltr') {
562 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
568 unset($table['is' . $sep . 'group']);
569 unset($table['tab' . $sep . 'group']);
570 unset($table['tab' . $sep . 'count']);
573 ((isset($_REQUEST['tbl_group'])
574 && (strpos($_REQUEST['tbl_group'], $group) === 0
575 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
576 ||
strpos($GLOBALS['table'], $group) === 0)) {
577 PMA_displayTableList($table, true,
578 $tab_group_full . $group, $table_db);
580 PMA_displayTableList($table, false, '', $table_db);
583 } elseif (is_array($table)) {
584 $href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
585 .$GLOBALS['common_url_query'] . '&table='
586 .urlencode($table['Name']);
588 echo '<a title="' . $GLOBALS['strBrowse'] . ': '
589 . htmlspecialchars($table['Comment'])
590 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')"'
591 .' id="browse_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
592 .' href="sql.php?' . $GLOBALS['common_url_query']
593 .'&table=' . urlencode($table['Name'])
594 .'&goto=' . $GLOBALS['cfg']['DefaultTabTable']
596 .'<img class="icon"';
597 if ('VIEW' === strtoupper($table['Comment'])) {
598 echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"';
600 echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"';
602 echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
603 .' width="10" height="10" alt="' . $GLOBALS['strBrowse'] . '" /></a>' . "\n"
604 .'<a href="' . $href . '" title="' . htmlspecialchars($table['Comment']
605 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows']) . ')"'
606 .' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
607 // preserve spaces in table name
608 . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
615 echo '</div>' . "\n";
617 PMA_exitNavigationFrame();