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']->databases
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['cfg']['LeftFrameLight']
17 * @uses $GLOBALS['cfg']['ShowTooltip']
18 * @uses $GLOBALS['cfg']['ShowTooltipAliasDB']
19 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
20 * @uses $GLOBALS['cfgRelation']['commwork']) {
21 * @uses PMA_List_Database::getSingleItem()
22 * @uses PMA_List_Database::getHtmlSelectGrouped()
23 * @uses PMA_List_Database::getGroupedDetails()
24 * @uses PMA_generate_common_url()
25 * @uses PMA_generate_common_hidden_inputs()
26 * @uses PMA_getDbComment();
27 * @uses PMA_getTableCount()
28 * @uses PMA_getTableList()
29 * @uses PMA_getRelationsParam()
30 * @uses PMA_outBufferPre()
32 * @uses session_write_close()
35 * @uses htmlspecialchars()
39 * Gets a core script and starts output buffering work
41 require_once './libraries/common.inc.php';
44 * finish and cleanup navigation.php script execution, only to be used in navigation.php
46 * @uses $GLOBALS['controllink'] to close it
47 * @uses $GLOBALS['userlink'] to close it
50 function PMA_exitNavigationFrame()
52 $params = array('uniqid' => uniqid());
53 if (!empty($GLOBALS['db'])) {
54 $params['db'] = $GLOBALS['db'];
56 echo '</body></html>';
60 // keep the offset of the db list in session before closing it
61 if (! isset($_SESSION['tmp_user_values']['navi_limit_offset'])) {
62 $_SESSION['tmp_user_values']['navi_limit_offset'] = 0;
64 if (! isset($_SESSION['tmp_user_values']['table_limit_offset']) ||
$_SESSION['tmp_user_values']['table_limit_offset_db'] != $db) {
65 $_SESSION['tmp_user_values']['table_limit_offset'] = 0;
66 $_SESSION['tmp_user_values']['table_limit_offset_db'] = $db;
68 if (isset($_REQUEST['pos'])) {
69 if (isset($_REQUEST['tpos'])) {
70 $_SESSION['tmp_user_values']['table_limit_offset'] = (int) $_REQUEST['pos'];
73 $_SESSION['tmp_user_values']['navi_limit_offset'] = (int) $_REQUEST['pos'];
76 $pos = $_SESSION['tmp_user_values']['navi_limit_offset'];
77 $tpos = $_SESSION['tmp_user_values']['table_limit_offset'];
78 // free the session file, for the other frames to be loaded
79 // but only if debugging is not enabled
80 if (empty($_SESSION['debug'])) {
81 session_write_close();
85 * the output compression library
87 require_once './libraries/ob.lib.php';
92 * selects the database if there is only one on current server
94 if ($GLOBALS['server'] && ! strlen($GLOBALS['db'])) {
95 $GLOBALS['db'] = $GLOBALS['pma']->databases
->getSingleItem();
98 $db_start = $GLOBALS['db'];
101 * the relation settings
103 $cfgRelation = PMA_getRelationsParam();
106 * For re-usability, moved http-headers to a seperate file.
107 * It can now be included by libraries/header.inc.php, querywindow.php.
109 require_once './libraries/header_http.inc.php';
114 // xml declaration moves IE into quirks mode, making much trouble with CSS
115 /* echo '<?xml version="1.0" encoding="' . $GLOBALS['charset'] . '"?>'; */
117 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
118 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
119 <html xmlns
="http://www.w3.org/1999/xhtml"
120 xml
:lang
="<?php echo $available_languages[$lang][1]; ?>"
121 lang
="<?php echo $available_languages[$lang][1]; ?>"
122 dir
="<?php echo $GLOBALS['text_dir']; ?>">
125 <link rel
="icon" href
="./favicon.ico" type
="image/x-icon" />
126 <link rel
="shortcut icon" href
="./favicon.ico" type
="image/x-icon" />
127 <title
>phpMyAdmin
</title
>
128 <meta http
-equiv
="Content-Type"
129 content
="text/html; charset=<?php echo $GLOBALS['charset']; ?>" />
130 <base target
="frame_content" />
131 <link rel
="stylesheet" type
="text/css"
132 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=left&nocache=<?php echo $GLOBALS['PMA_Config']->getThemeUniqueValue(); ?>" />
133 <script src
="./js/jquery/jquery-1.4.2.js" type
="text/javascript"></script
>
134 <script type
="text/javascript" src
="js/navigation.js"></script
>
135 <script type
="text/javascript" src
="js/functions.js"></script
>
136 <script type
="text/javascript">
138 var image_minus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_minus.png';
139 var image_plus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_plus.png';
141 // INIT PMA_setFrameSize
143 var onLoadHandler
= window
.onload
;
144 var resizeHandler
= window
.onresize
;
145 window
.document
.onresize
= resizeHandler
;
146 window
.onload
= function() {
147 if (onloadCnt
== 0) {
148 if (typeof(onLoadHandler
) == "function") {
151 if (typeof(PMA_setFrameSize
) != 'undefined' && typeof(PMA_setFrameSize
) == 'function') {
157 window
.onresize
= function() {
158 if (typeof(resizeHandler
) == "function") {
161 if (typeof(PMA_saveFrameSize
) != 'undefined' && typeof(PMA_saveFrameSize
) == 'function') {
169 * remove horizontal scroll bar bug in IE 6 by forcing a vertical scroll bar
173 <style type
="text/css">
183 <body id
="body_leftFrame">
185 require './libraries/navigation_header.inc.php';
186 if (! $GLOBALS['server']) {
187 // no server selected
188 PMA_exitNavigationFrame();
189 } elseif (! count($GLOBALS['pma']->databases
)) {
190 // no database available, so we break here
191 echo '<p>' . __('No databases') . '</p>';
192 PMA_exitNavigationFrame();
193 } elseif ($GLOBALS['cfg']['LeftFrameLight'] && count($GLOBALS['pma']->databases
) > 1) {
194 $list = $cfg['DisplayDatabasesList'];
195 if ($list === 'auto') {
196 if (empty($GLOBALS['db'])) {
203 // more than one database available and LeftFrameLight is true
204 // display db selectbox
206 // Light mode -> beginning of the select combo for databases
207 // Note: When javascript is active, the frameset will be changed from
208 // within navigation.php. With no JS (<noscript>) the whole frameset will
209 // be rebuilt with the new target frame.
212 <div id
="databaseList">
213 <form method
="post" action
="index.php" target
="_parent" id
="left">
215 echo PMA_generate_common_hidden_inputs() . "\n";
216 echo $GLOBALS['pma']->databases
->getHtmlSelectGrouped(true, $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
217 echo '<noscript>' . "\n"
218 .'<input type="submit" name="Go" value="' . __('Go') . '" />' . "\n"
219 .'</noscript>' . "\n"
223 echo $GLOBALS['pma']->databases
->getHtmlListGrouped(true, $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
225 $_url_params = array('pos' => $pos);
226 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
230 <div id
="left_tableList">
232 // Don't display expansible/collapsible database info if:
233 // 1. $GLOBALS['server'] == 0 (no server selected)
234 // This is the case when there are multiple servers and
235 // '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome
236 // screen to appear with no database info displayed.
237 // 2. there is only one database available (ie either only one database exists
238 // or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
239 // In this case, the database should not be collapsible/expandable
241 $img_plus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_plus.png"'
242 .' width="9" height="9" alt="+" />';
243 $img_minus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_minus.png"'
244 .' width="9" height="9" alt="-" />';
246 $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
247 .' href="navigation.php?%s" target="_self">';
249 $element_counter = 0;
252 if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
253 $table_list = PMA_getTableList($GLOBALS['db']);
254 $table_count = count($table_list);
256 // show selected databasename as link to DefaultTabDatabase-page
257 // with table count in ()
258 $common_url_query = PMA_generate_common_url($GLOBALS['db']);
262 if ($GLOBALS['cfg']['ShowTooltip']
263 && $GLOBALS['cfgRelation']['commwork']) {
264 $_db_tooltip = PMA_getDbComment($GLOBALS['db']);
266 $db_tooltip = $_db_tooltip;
270 $disp_name = $GLOBALS['db'];
271 if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
272 $disp_name = $db_tooltip;
273 $disp_name_cut = $db_tooltip;
274 $db_tooltip = $GLOBALS['db'];
277 if ($table_count >= $GLOBALS['cfg']['LeftDisplayTableFilterMinimum']) {
279 <span id
="NavFilter">
280 <span id
="clear_fast_filter" title
="<?php echo __('Clear'); ?>">X
</span
>
281 <input type
="text" name
="fast_filter" id
="fast_filter" title
="<?php echo __('Filter'); ?>" value
="<?php echo __('filter tables by name'); ?>" />
287 * This helps reducing the navi panel size; in the right panel,
288 * user can find a navigator to page thru all tables.
291 $table_list = array_slice($table_list, $tpos, $cfg['MaxTableList']);
292 if (! empty($table_list)) {
293 // upper table list paginator
294 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
295 $_url_params = array(
298 'db' => $GLOBALS['db']
300 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
302 PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
303 // lower table list paginator
304 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
305 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
308 echo __('No tables found in database.');
311 echo '<ul id="newtable"><li><a target="frame_content" href="tbl_create.php' . PMA_generate_common_url(array('db' => $GLOBALS['db'])) . '">'
312 .'<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_snewtbl.png" id="icon_newtable" width="10" height="10" alt="' . _pgettext('short form', 'Create table') . '" />'
313 . _pgettext('short form', 'Create table') . '</a></li></ul>';
314 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
315 echo '<p>' . __('Please select a database') . '</p>';
317 echo '<div id="databaseList">' . "\n";
318 $_url_params = array('pos' => $pos);
319 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
320 echo '</div>' . "\n";
322 $common_url_query = PMA_generate_common_url();
323 PMA_displayDbList($GLOBALS['pma']->databases
->getGroupedDetails($_SESSION['tmp_user_values']['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']), $_SESSION['tmp_user_values']['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']);
327 * displays collapsable db list
329 * @uses $_REQUEST['dbgroup']
330 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
334 * @uses htmlspecialchars()
335 * @uses PMA_generate_common_url()
336 * @uses PMA_getTableList()
337 * @uses PMA_displayTableList()
338 * @global integer $element_counter
339 * @global string $img_minus
340 * @global string $img_plus
341 * @global string $href_left
342 * @global string $db_start
343 * @global string $common_url_query
344 * @param array $ext_dblist extended db list
345 * @param integer $offset
346 * @param integer $count
348 function PMA_displayDbList($ext_dblist, $offset, $count) {
349 global $element_counter, $img_minus, $img_plus, $href_left,
350 $db_start, $common_url_query;
352 // get table list, for all databases
353 // doing this in one step takes advantage of a single query with information_schema!
354 $tables_full = PMA_DBI_get_tables_full($GLOBALS['pma']->databases
->getLimitedItems($offset, $count));
357 echo '<ul id="leftdatabaselist">';
358 $close_db_group = false;
359 foreach ($ext_dblist as $group => $db_group) {
360 if (count($GLOBALS['pma']->databases
) > 1) {
361 if ($close_db_group) {
365 $close_db_group = false;
367 if (count($db_group) > 1) {
368 $close_db_group = true;
369 $url_dbgroup = '&dbgroup=' . urlencode($group);
370 $common_url_query = PMA_generate_common_url() . $url_dbgroup;
372 echo '<li class="dbgroup">';
373 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
374 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
375 // display + only if this db(group) is not preselected
376 printf($href_left, $element_counter, PMA_generate_common_url());
377 printf($img_minus, $element_counter);
379 printf($href_left, $element_counter, $common_url_query);
380 printf($img_plus, $element_counter);
382 echo '</a> ' . $group . "\n";
383 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
384 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
385 echo '<ul id="subel' . $element_counter . '">' . "\n";
387 echo '<ul id="subel' . $element_counter . '"'
388 .' style="display: none">' . "\n";
392 foreach ($db_group as $db) {
393 $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup;
396 // Displays the database name
399 if (count($GLOBALS['pma']->databases
) > 1) {
400 // only with more than one db we need collapse ...
401 if ($db_start != $db['name'] ||
$db['num_tables'] < 1) {
402 // display + only if this db is not preselected
403 // or table count is 0
404 printf($href_left, $element_counter, $common_url_query);
405 printf($img_plus, $element_counter);
407 printf($href_left, $element_counter,
408 PMA_generate_common_url() . $url_dbgroup);
409 printf($img_minus, $element_counter);
413 // ... and we need to refresh both frames on db selection
416 id
="<?php echo htmlspecialchars($db['name']); ?>"
417 href
="index.php?<?php echo $common_url_query; ?>"
419 title
="<?php echo htmlspecialchars($db['comment']); ?>"
421 if (! toggle('<?php echo $element_counter; ?>', true))
422 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
423 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
424 . '?' . $common_url_query; ?>', 'main');
427 if ($GLOBALS['text_dir'] === 'rtl') {
428 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
430 echo htmlspecialchars($db['disp_name']);
431 if ($GLOBALS['text_dir'] === 'ltr') {
432 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
438 // with only 1 db available we dont need to refresh left frame
439 // on db selection, only phpmain
441 <a href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
442 . '?' . $common_url_query; ?>"
443 id
="<?php echo htmlspecialchars($db['name']); ?>"
444 title
="<?php echo htmlspecialchars($db['comment']); ?>">
446 if ($GLOBALS['text_dir'] === 'rtl') {
447 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
449 echo htmlspecialchars($db['disp_name']);
450 if ($GLOBALS['text_dir'] === 'ltr') {
451 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
457 if ($db['num_tables']) {
458 if (isset($tables_full[$db['name']])) {
459 $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
460 } elseif (isset($tables_full[strtolower($db['name'])])) {
461 // on windows with lower_case_table_names = 1
463 // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
464 // but information_schema.TABLES gives `test`
466 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
467 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
469 $tables = PMA_getTableList($db['name']);
472 (bool) (count($GLOBALS['pma']->databases
) === 1 ||
$db_start == $db['name']);
473 PMA_displayTableList($tables, $child_visible, '', $db['name']);
474 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
475 // no tables and LeftFrameLight:
476 // display message no tables in selected db
477 echo '<p>' . __('Please select a database') . '</p>' . "\n";
481 } // end foreach group
483 if ($close_db_group) {
487 $close_db_group = false;
494 * display unordered list of tables
495 * calls itself recursively if table in given list
503 * @uses htmlspecialchars()
506 * @uses PMA_displayTableList()
507 * @uses $_REQUEST['tbl_group']
508 * @uses $GLOBALS['common_url_query']
509 * @uses $GLOBALS['table']
510 * @uses $GLOBALS['pmaThemeImage']
511 * @uses $GLOBALS['cfg']['LeftFrameTableSeparator']
512 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
513 * @uses $GLOBALS['cfg']['DefaultTabTable']
514 * @global integer the element counter
515 * @global string html code for '-' image
516 * @global string html code for '+' image
517 * @global string html code for self link
518 * @param array $tables array of tables/tablegroups
519 * @param boolean $visible whether the list is visible or not
520 * @param string $tab_group_full full tab group name
521 * @param string $table_db db of this table
523 function PMA_displayTableList($tables, $visible = false,
524 $tab_group_full = '', $table_db = '')
526 if (! is_array($tables) ||
count($tables) === 0) {
530 global $element_counter, $img_minus, $img_plus, $href_left;
531 $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
534 echo '<ul id="subel' . $element_counter . '">';
536 echo '<ul id="subel' . $element_counter . '" style="display: none">';
538 foreach ($tables as $group => $table) {
539 // only allow grouping if the group has more than 1 table
540 if (isset($table['is' . $sep . 'group']) && $table['tab' . $sep . 'count'] > 1) {
541 $common_url_query = $GLOBALS['common_url_query']
542 . '&tbl_group=' . urlencode($tab_group_full . $group);
547 && ((isset($_REQUEST['tbl_group'])
548 && (strpos($_REQUEST['tbl_group'], $group) === 0
549 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
550 ||
strpos($GLOBALS['table'], $group) === 0)) {
551 printf($href_left, $element_counter,
552 $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full);
553 printf($img_minus, $element_counter);
555 printf($href_left, $element_counter, $common_url_query);
556 printf($img_plus, $element_counter);
560 <a href
="index.php?<?php echo $common_url_query; ?>"
563 if (! toggle('<?php echo $element_counter; ?>', true))
564 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
565 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
566 . '?' . $common_url_query; ?>', 'main');
569 if ($GLOBALS['text_dir'] === 'rtl') {
570 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
572 echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
573 if ($GLOBALS['text_dir'] === 'ltr') {
574 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
580 unset($table['is' . $sep . 'group']);
581 unset($table['tab' . $sep . 'group']);
582 unset($table['tab' . $sep . 'count']);
585 ((isset($_REQUEST['tbl_group'])
586 && (strpos($_REQUEST['tbl_group'], $group) === 0
587 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
588 ||
strpos($GLOBALS['table'], $group) === 0)) {
589 PMA_displayTableList($table, true,
590 $tab_group_full . $group, $table_db);
592 PMA_displayTableList($table, false, '', $table_db);
595 } elseif (is_array($table)) {
596 // the table was not grouped because it is the only one with its prefix
597 while (isset($table['is' . $sep . 'group'])) {
598 // get the array with the actual table information
599 foreach ($table as $value) {
600 if(is_array($value)) {
605 $link_title = PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']);
606 // quick access icon next to each table name
608 echo '<a class="tableicon" title="'
609 . htmlspecialchars($link_title)
610 . ': ' . htmlspecialchars($table['Comment'])
611 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"'
612 .' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
613 .' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
614 . $GLOBALS['common_url_query']
615 .'&table=' . urlencode($table['Name'])
616 .'&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable']
618 .'<img class="icon"';
619 if ('VIEW' === strtoupper($table['Comment'])) {
620 echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"';
622 echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"';
624 echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
625 .' width="10" height="10" alt="' . htmlspecialchars($link_title) . '" /></a>' . "\n";
627 // link for the table name itself
628 $href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
629 .$GLOBALS['common_url_query'] . '&table='
630 .urlencode($table['Name']) . '&pos=0';
631 echo '<a href="' . $href
632 . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment']
633 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows')) . ')"'
634 .' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
635 // preserve spaces in table name
636 . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
643 echo '</div>' . "\n";
645 PMA_exitNavigationFrame();