2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * the navigation frame - displays server, db and table selection tree
8 * @uses $GLOBALS['pma']->databases
9 * @uses $GLOBALS['server']
10 * @uses $GLOBALS['db']
11 * @uses $GLOBALS['table']
12 * @uses $GLOBALS['available_languages']
13 * @uses $GLOBALS['lang']
14 * @uses $GLOBALS['text_dir']
15 * @uses $GLOBALS['charset']
16 * @uses $GLOBALS['pmaThemeImage']
17 * @uses $GLOBALS['strNoDatabases']
18 * @uses $GLOBALS['strDatabase']
19 * @uses $GLOBALS['strGo']
20 * @uses $GLOBALS['strSelectADb']
21 * @uses $GLOBALS['strNoTablesFound']
22 * @uses $GLOBALS['cfg']['LeftFrameLight']
23 * @uses $GLOBALS['cfg']['ShowTooltip']
24 * @uses $GLOBALS['cfg']['ShowTooltipAliasDB']
25 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
26 * @uses $GLOBALS['cfgRelation']['commwork']) {
27 * @uses PMA_List_Database::getSingleItem()
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_getDbComment();
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, only to be used in navigation.php
53 * @uses $GLOBALS['controllink'] to close it
54 * @uses $GLOBALS['userlink'] to close it
57 function PMA_exitNavigationFrame()
59 echo '</body></html>';
63 // keep the offset of the db list in session before closing it
64 if (! isset($_SESSION['userconf']['navi_limit_offset'])) {
65 $_SESSION['userconf']['navi_limit_offset'] = 0;
67 if (! isset($_SESSION['userconf']['table_limit_offset']) ||
$_SESSION['userconf']['table_limit_offset_db'] != $db) {
68 $_SESSION['userconf']['table_limit_offset'] = 0;
69 $_SESSION['userconf']['table_limit_offset_db'] = $db;
71 if (isset($_REQUEST['pos'])) {
72 if (isset($_REQUEST['tpos'])) {
73 $_SESSION['userconf']['table_limit_offset'] = (int) $_REQUEST['pos'];
76 $_SESSION['userconf']['navi_limit_offset'] = (int) $_REQUEST['pos'];
79 $pos = $_SESSION['userconf']['navi_limit_offset'];
80 $tpos = $_SESSION['userconf']['table_limit_offset'];
81 // free the session file, for the other frames to be loaded
82 // but only if debugging is not enabled
83 if (empty($_SESSION['debug'])) {
84 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']->databases
->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';
118 // xml declaration moves IE into quirks mode, making much trouble with CSS
119 /* echo '<?xml version="1.0" encoding="' . $GLOBALS['charset'] . '"?>'; */
121 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
122 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
123 <html xmlns
="http://www.w3.org/1999/xhtml"
124 xml
:lang
="<?php echo $available_languages[$lang][2]; ?>"
125 lang
="<?php echo $available_languages[$lang][2]; ?>"
126 dir
="<?php echo $GLOBALS['text_dir']; ?>">
129 <link rel
="icon" href
="./favicon.ico" type
="image/x-icon" />
130 <link rel
="shortcut icon" href
="./favicon.ico" type
="image/x-icon" />
131 <title
>phpMyAdmin
</title
>
132 <meta http
-equiv
="Content-Type"
133 content
="text/html; charset=<?php echo $GLOBALS['charset']; ?>" />
134 <base target
="frame_content" />
135 <link rel
="stylesheet" type
="text/css"
136 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=left&nocache=<?php echo $_SESSION['PMA_Config']->getThemeUniqueValue(); ?>" />
137 <script type
="text/javascript" src
="js/navigation.js"></script
>
138 <script type
="text/javascript" src
="js/functions.js"></script
>
139 <script type
="text/javascript">
141 var image_minus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_minus.png';
142 var image_plus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_plus.png';
144 // INIT PMA_setFrameSize
146 var onLoadHandler
= window
.onload
;
147 var resizeHandler
= window
.onresize
;
148 window
.document
.onresize
= resizeHandler
;
149 window
.onload
= function() {
150 if (onloadCnt
== 0) {
151 if (typeof(onLoadHandler
) == "function") {
154 if (typeof(PMA_setFrameSize
) != 'undefined' && typeof(PMA_setFrameSize
) == 'function') {
160 window
.onresize
= function() {
161 if (typeof(resizeHandler
) == "function") {
164 if (typeof(PMA_saveFrameSize
) != 'undefined' && typeof(PMA_saveFrameSize
) == 'function') {
172 * remove horizontal scroll bar bug in IE 6 by forcing a vertical scroll bar
176 <style type
="text/css">
186 <body id
="body_leftFrame">
188 require './libraries/navigation_header.inc.php';
189 if (! $GLOBALS['server']) {
190 // no server selected
191 PMA_exitNavigationFrame();
192 } elseif (! count($GLOBALS['pma']->databases
)) {
193 // no database available, so we break here
194 echo '<p>' . $GLOBALS['strNoDatabases'] . '</p>';
195 PMA_exitNavigationFrame();
196 } elseif ($GLOBALS['cfg']['LeftFrameLight'] && count($GLOBALS['pma']->databases
) > 1) {
197 $list = $cfg['DisplayDatabasesList'];
198 if ($list === 'auto') {
199 if (empty($GLOBALS['db'])) {
206 // more than one database available and LeftFrameLight is true
207 // display db selectbox
209 // Light mode -> beginning of the select combo for databases
210 // Note: When javascript is active, the frameset will be changed from
211 // within navigation.php. With no JS (<noscript>) the whole frameset will
212 // be rebuilt with the new target frame.
215 <div id
="databaseList">
216 <form method
="post" action
="index.php" target
="_parent" id
="left">
217 <label
for="lightm_db"><?php
echo $GLOBALS['strDatabase']; ?
></label
>
219 echo PMA_generate_common_hidden_inputs() . "\n";
220 echo $GLOBALS['pma']->databases
->getHtmlSelectGrouped(true, $_SESSION['userconf']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
221 echo '<noscript>' . "\n"
222 .'<input type="submit" name="Go" value="' . $GLOBALS['strGo'] . '" />' . "\n"
223 .'</noscript>' . "\n"
227 echo '<div id="databaseList">' . "\n";
229 echo $GLOBALS['pma']->databases
->getHtmlListGrouped(true, $_SESSION['userconf']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
231 $_url_params = array('pos' => $pos);
232 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
234 echo '</div>' . "\n";
239 <div id
="left_tableList">
241 // Don't display expansible/collapsible database info if:
242 // 1. $GLOBALS['server'] == 0 (no server selected)
243 // This is the case when there are multiple servers and
244 // '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome
245 // screen to appear with no database info displayed.
246 // 2. there is only one database available (ie either only one database exists
247 // or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
248 // In this case, the database should not be collapsible/expandable
250 $img_plus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_plus.png"'
251 .' width="9" height="9" alt="+" />';
252 $img_minus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_minus.png"'
253 .' width="9" height="9" alt="-" />';
255 $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
256 .' href="navigation.php?%s" target="_self">';
258 $element_counter = 0;
261 if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
262 $table_list = PMA_getTableList($GLOBALS['db']);
263 $table_count = count($table_list);
265 // show selected databasename as link to DefaultTabDatabase-page
266 // with table count in ()
267 $common_url_query = PMA_generate_common_url($GLOBALS['db']);
271 if ($GLOBALS['cfg']['ShowTooltip']
272 && $GLOBALS['cfgRelation']['commwork']) {
273 $_db_tooltip = PMA_getDbComment($GLOBALS['db']);
275 $db_tooltip = $_db_tooltip;
279 $disp_name = $GLOBALS['db'];
280 if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
281 $disp_name = $db_tooltip;
282 $disp_name_cut = $db_tooltip;
283 $db_tooltip = $GLOBALS['db'];
288 href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?>"
289 title
="<?php echo htmlspecialchars($db_tooltip); ?>" >
291 if ($GLOBALS['text_dir'] === 'rtl') {
292 echo ' <bdo dir="ltr">(' . $table_count . ')</bdo> ';
294 echo '<span class="navi_dbName">' . htmlspecialchars($disp_name) . '</span>';
295 if ($GLOBALS['text_dir'] === 'ltr') {
296 echo ' <bdo dir="ltr">(' . $table_count . ')</bdo> ';
301 * This helps reducing the navi panel size; in the right panel,
302 * user can find a navigator to page thru all tables.
305 $table_list = array_slice($table_list, $tpos, $cfg['MaxTableList']);
306 if (! empty($table_list)) {
307 // upper table list paginator
308 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
309 $_url_params = array(
312 'db' => $GLOBALS['db']
314 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
316 PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
317 // lower table list paginator
318 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
319 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
322 echo $GLOBALS['strNoTablesFound'];
325 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
326 echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
328 echo '<div id="databaseList">' . "\n";
329 $_url_params = array('pos' => $pos);
330 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
331 echo '</div>' . "\n";
333 $common_url_query = PMA_generate_common_url();
334 PMA_displayDbList($GLOBALS['pma']->databases
->getGroupedDetails($_SESSION['userconf']['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']), $_SESSION['userconf']['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']);
338 * displays collapsable db list
340 * @uses $_REQUEST['dbgroup']
341 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
342 * @uses $GLOBALS['strSelectADb']
346 * @uses htmlspecialchars()
347 * @uses PMA_generate_common_url()
348 * @uses PMA_getTableList()
349 * @uses PMA_displayTableList()
350 * @global integer $element_counter
351 * @global string $img_minus
352 * @global string $img_plus
353 * @global string $href_left
354 * @global string $db_start
355 * @global string $common_url_query
356 * @param array $ext_dblist extended db list
357 * @param integer $offset
358 * @param integer $count
360 function PMA_displayDbList($ext_dblist, $offset, $count) {
361 global $element_counter, $img_minus, $img_plus, $href_left,
362 $db_start, $common_url_query;
364 // get table list, for all databases
365 // doing this in one step takes advantage of a single query with information_schema!
366 $tables_full = PMA_DBI_get_tables_full($GLOBALS['pma']->databases
->getLimitedItems($offset, $count));
369 echo '<ul id="leftdatabaselist">';
370 $close_db_group = false;
371 foreach ($ext_dblist as $group => $db_group) {
372 if (count($GLOBALS['pma']->databases
) > 1) {
373 if ($close_db_group) {
377 $close_db_group = false;
379 if (count($db_group) > 1) {
380 $close_db_group = true;
381 $url_dbgroup = '&dbgroup=' . urlencode($group);
382 $common_url_query = PMA_generate_common_url() . $url_dbgroup;
384 echo '<li class="dbgroup">';
385 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
386 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
387 // display + only if this db(group) is not preselected
388 printf($href_left, $element_counter, PMA_generate_common_url());
389 printf($img_minus, $element_counter);
391 printf($href_left, $element_counter, $common_url_query);
392 printf($img_plus, $element_counter);
394 echo '</a> ' . $group . "\n";
395 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
396 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
397 echo '<ul id="subel' . $element_counter . '">' . "\n";
399 echo '<ul id="subel' . $element_counter . '"'
400 .' style="display: none">' . "\n";
404 foreach ($db_group as $db) {
405 $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup;
408 // Displays the database name
411 if (count($GLOBALS['pma']->databases
) > 1) {
412 // only with more than one db we need collapse ...
413 if ($db_start != $db['name'] ||
$db['num_tables'] < 1) {
414 // display + only if this db is not preselected
415 // or table count is 0
416 printf($href_left, $element_counter, $common_url_query);
417 printf($img_plus, $element_counter);
419 printf($href_left, $element_counter,
420 PMA_generate_common_url() . $url_dbgroup);
421 printf($img_minus, $element_counter);
425 // ... and we need to refresh both frames on db selection
428 id
="<?php echo htmlspecialchars($db['name']); ?>"
429 href
="index.php?<?php echo $common_url_query; ?>"
431 title
="<?php echo htmlspecialchars($db['comment']); ?>"
433 if (! toggle('<?php echo $element_counter; ?>', true))
434 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
435 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
436 . '?' . $common_url_query; ?>', 'main');
439 if ($GLOBALS['text_dir'] === 'rtl') {
440 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
442 echo htmlspecialchars($db['disp_name']);
443 if ($GLOBALS['text_dir'] === 'ltr') {
444 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
450 // with only 1 db available we dont need to refresh left frame
451 // on db selection, only phpmain
453 <a href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
454 . '?' . $common_url_query; ?>"
455 id
="<?php echo htmlspecialchars($db['name']); ?>"
456 title
="<?php echo htmlspecialchars($db['comment']); ?>">
458 if ($GLOBALS['text_dir'] === 'rtl') {
459 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
461 echo htmlspecialchars($db['disp_name']);
462 if ($GLOBALS['text_dir'] === 'ltr') {
463 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
469 if ($db['num_tables']) {
470 if (isset($tables_full[$db['name']])) {
471 $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
472 } elseif (isset($tables_full[strtolower($db['name'])])) {
473 // on windows with lower_case_table_names = 1
475 // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
476 // but information_schema.TABLES gives `test`
478 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
479 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
481 $tables = PMA_getTableList($db['name']);
484 (bool) (count($GLOBALS['pma']->databases
) === 1 ||
$db_start == $db['name']);
485 PMA_displayTableList($tables, $child_visible, '', $db['name']);
486 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
487 // no tables and LeftFrameLight:
488 // display message no tables in selected db
489 echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
493 } // end foreach group
495 if ($close_db_group) {
499 $close_db_group = false;
506 * display unordered list of tables
507 * calls itself recursively if table in given list
515 * @uses htmlspecialchars()
518 * @uses PMA_displayTableList()
519 * @uses $_REQUEST['tbl_group']
520 * @uses $GLOBALS['common_url_query']
521 * @uses $GLOBALS['table']
522 * @uses $GLOBALS['pmaThemeImage']
523 * @uses $GLOBALS['cfg']['LeftFrameTableSeparator']
524 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
525 * @uses $GLOBALS['cfg']['DefaultTabTable']
526 * @uses $GLOBALS['strRows']
527 * @uses $GLOBALS['strBrowse']
528 * @global integer the element counter
529 * @global string html code for '-' image
530 * @global string html code for '+' image
531 * @global string html code for self link
532 * @param array $tables array of tables/tablegroups
533 * @param boolean $visible whether the list is visible or not
534 * @param string $tab_group_full full tab group name
535 * @param string $table_db db of this table
537 function PMA_displayTableList($tables, $visible = false,
538 $tab_group_full = '', $table_db = '')
540 if (! is_array($tables) ||
count($tables) === 0) {
544 global $element_counter, $img_minus, $img_plus, $href_left;
545 $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
548 echo '<ul id="subel' . $element_counter . '">';
550 echo '<ul id="subel' . $element_counter . '" style="display: none">';
552 foreach ($tables as $group => $table) {
553 if (isset($table['is' . $sep . 'group'])) {
554 $common_url_query = $GLOBALS['common_url_query']
555 . '&tbl_group=' . urlencode($tab_group_full . $group);
560 && ((isset($_REQUEST['tbl_group'])
561 && (strpos($_REQUEST['tbl_group'], $group) === 0
562 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
563 ||
strpos($GLOBALS['table'], $group) === 0)) {
564 printf($href_left, $element_counter,
565 $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full);
566 printf($img_minus, $element_counter);
568 printf($href_left, $element_counter, $common_url_query);
569 printf($img_plus, $element_counter);
573 <a href
="index.php?<?php echo $common_url_query; ?>"
576 if (! toggle('<?php echo $element_counter; ?>', true))
577 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
578 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
579 . '?' . $common_url_query; ?>', 'main');
582 if ($GLOBALS['text_dir'] === 'rtl') {
583 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
585 echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
586 if ($GLOBALS['text_dir'] === 'ltr') {
587 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
593 unset($table['is' . $sep . 'group']);
594 unset($table['tab' . $sep . 'group']);
595 unset($table['tab' . $sep . 'count']);
598 ((isset($_REQUEST['tbl_group'])
599 && (strpos($_REQUEST['tbl_group'], $group) === 0
600 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
601 ||
strpos($GLOBALS['table'], $group) === 0)) {
602 PMA_displayTableList($table, true,
603 $tab_group_full . $group, $table_db);
605 PMA_displayTableList($table, false, '', $table_db);
608 } elseif (is_array($table)) {
609 $link_title = PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']);
610 // quick access icon next to each table name
613 . htmlspecialchars($link_title)
614 . ': ' . htmlspecialchars($table['Comment'])
615 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')"'
616 .' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
617 .' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
618 . $GLOBALS['common_url_query']
619 .'&table=' . urlencode($table['Name'])
620 .'&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable']
622 .'<img class="icon"';
623 if ('VIEW' === strtoupper($table['Comment'])) {
624 echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"';
626 echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"';
628 echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
629 .' width="10" height="10" alt="' . htmlspecialchars($link_title) . '" /></a>' . "\n";
631 // link for the table name itself
632 $href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
633 .$GLOBALS['common_url_query'] . '&table='
634 .urlencode($table['Name']) . '&pos=0';
635 echo '<a href="' . $href
636 . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment']
637 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows']) . ')"'
638 .' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
639 // preserve spaces in table name
640 . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
647 echo '</div>' . "\n";
649 PMA_exitNavigationFrame();