2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * the navigation frame - displays server, db and table selection tree
10 * Gets a core script and starts output buffering work
12 require_once './libraries/common.inc.php';
15 * finish and cleanup navigation.php script execution, only to be used in navigation.php
19 function PMA_exitNavigationFrame()
21 echo '</body></html>';
25 require_once './libraries/common.lib.php';
26 require_once './libraries/RecentTable.class.php';
29 * Check if it is an ajax request to reload the recent tables list.
31 if ($GLOBALS['is_ajax_request'] && $_REQUEST['recent_table']) {
32 PMA_ajaxResponse('', true, array('options' => PMA_RecentTable
::getInstance()->getHtmlSelectOption()) );
35 // keep the offset of the db list in session before closing it
36 if (! isset($_SESSION['tmp_user_values']['navi_limit_offset'])) {
37 $_SESSION['tmp_user_values']['navi_limit_offset'] = 0;
39 if (! isset($_SESSION['tmp_user_values']['table_limit_offset']) ||
$_SESSION['tmp_user_values']['table_limit_offset_db'] != $db) {
40 $_SESSION['tmp_user_values']['table_limit_offset'] = 0;
41 $_SESSION['tmp_user_values']['table_limit_offset_db'] = $db;
43 if (isset($_REQUEST['pos'])) {
44 if (isset($_REQUEST['tpos'])) {
45 $_SESSION['tmp_user_values']['table_limit_offset'] = (int) $_REQUEST['pos'];
48 $_SESSION['tmp_user_values']['navi_limit_offset'] = (int) $_REQUEST['pos'];
51 $pos = $_SESSION['tmp_user_values']['navi_limit_offset'];
52 $tpos = $_SESSION['tmp_user_values']['table_limit_offset'];
53 // free the session file, for the other frames to be loaded
54 // but only if debugging is not enabled
55 if (empty($_SESSION['debug'])) {
56 session_write_close();
60 * the output compression library
62 require_once './libraries/ob.lib.php';
67 * selects the database if there is only one on current server
69 if ($GLOBALS['server'] && ! strlen($GLOBALS['db'])) {
70 $GLOBALS['db'] = $GLOBALS['pma']->databases
->getSingleItem();
73 $db_start = $GLOBALS['db'];
76 * the relation settings
78 $cfgRelation = PMA_getRelationsParam();
81 * For re-usability, moved http-headers to a seperate file.
82 * It can now be included by libraries/header.inc.php, querywindow.php.
84 require_once './libraries/header_http.inc.php';
89 // xml declaration moves IE into quirks mode, making much trouble with CSS
90 /* echo '<?xml version="1.0" encoding="utf-8"?>'; */
92 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
93 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
94 <html xmlns
="http://www.w3.org/1999/xhtml"
95 xml
:lang
="<?php echo $available_languages[$lang][1]; ?>"
96 lang
="<?php echo $available_languages[$lang][1]; ?>"
97 dir
="<?php echo $GLOBALS['text_dir']; ?>">
100 <link rel
="icon" href
="./favicon.ico" type
="image/x-icon" />
101 <link rel
="shortcut icon" href
="./favicon.ico" type
="image/x-icon" />
102 <title
>phpMyAdmin
</title
>
103 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
104 <base target
="frame_content" />
105 <link rel
="stylesheet" type
="text/css"
106 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=left&nocache=<?php echo $GLOBALS['PMA_Config']->getThemeUniqueValue(); ?>" />
108 echo PMA_includeJS('jquery/jquery-1.6.1.js');
109 echo PMA_includeJS('jquery/jquery-ui-1.8.custom.js');
110 echo PMA_includeJS('navigation.js');
111 echo PMA_includeJS('functions.js');
112 echo PMA_includeJS('messages.php');
114 <script type
="text/javascript">
116 // INIT PMA_setFrameSize
118 var onLoadHandler
= window
.onload
;
119 var resizeHandler
= window
.onresize
;
120 window
.document
.onresize
= resizeHandler
;
121 window
.onload
= function() {
122 if (onloadCnt
== 0) {
123 if (typeof(onLoadHandler
) == "function") {
126 if (typeof(PMA_setFrameSize
) != 'undefined' && typeof(PMA_setFrameSize
) == 'function') {
132 window
.onresize
= function() {
133 if (typeof(resizeHandler
) == "function") {
136 if (typeof(PMA_saveFrameSize
) != 'undefined' && typeof(PMA_saveFrameSize
) == 'function') {
144 * remove horizontal scroll bar bug in IE 6 by forcing a vertical scroll bar
148 <style type
="text/css">
158 <body id
="body_leftFrame">
160 require './libraries/navigation_header.inc.php';
162 // display recently used tables
163 if ($GLOBALS['cfg']['LeftRecentTable'] > 0) {
164 echo '<div id="recentTableList">' . "\n"
165 .'<form method="post" action="index.php" target="_parent">' . "\n"
166 .PMA_generate_common_hidden_inputs() . "\n"
167 .PMA_RecentTable
::getInstance()->getHtmlSelect()
169 .'<input type="submit" name="Go" value="' . __('Go') . '" />' . "\n"
170 .'</noscript>' . "\n"
175 if (! $GLOBALS['server']) {
176 // no server selected
177 PMA_exitNavigationFrame();
178 } elseif (! count($GLOBALS['pma']->databases
)) {
179 // no database available, so we break here
180 echo '<p>' . __('No databases') . '</p>';
181 PMA_exitNavigationFrame();
182 } elseif ($GLOBALS['cfg']['LeftFrameLight'] && count($GLOBALS['pma']->databases
) > 1) {
183 $list = $cfg['DisplayDatabasesList'];
184 if ($list === 'auto') {
185 if (empty($GLOBALS['db'])) {
192 // more than one database available and LeftFrameLight is true
193 // display db selectbox
195 // Light mode -> beginning of the select combo for databases
196 // Note: When javascript is active, the frameset will be changed from
197 // within navigation.php. With no JS (<noscript>) the whole frameset will
198 // be rebuilt with the new target frame.
201 <div id
="databaseList">
202 <form method
="post" action
="index.php" target
="_parent" id
="left">
204 echo PMA_generate_common_hidden_inputs() . "\n";
205 echo $GLOBALS['pma']->databases
->getHtmlSelectGrouped(true, $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
206 echo '<noscript>' . "\n"
207 .'<input type="submit" name="Go" value="' . __('Go') . '" />' . "\n"
208 .'</noscript>' . "\n"
212 echo $GLOBALS['pma']->databases
->getHtmlListGrouped(true, $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
214 $_url_params = array('pos' => $pos);
215 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
219 <div id
="left_tableList">
221 // Don't display expansible/collapsible database info if:
222 // 1. $GLOBALS['server'] == 0 (no server selected)
223 // This is the case when there are multiple servers and
224 // '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome
225 // screen to appear with no database info displayed.
226 // 2. there is only one database available (ie either only one database exists
227 // or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
228 // In this case, the database should not be collapsible/expandable
230 $img_plus = '<img class="icon ic_b_plus" id="el%dImg" src="themes/dot.gif"'
232 $img_minus = '<img class="icon ic_b_minus" id="el%dImg" src="themes/dot.gif"'
235 $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
236 .' href="navigation.php?%s" target="_self">';
238 $element_counter = 0;
241 if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
242 $table_list = PMA_getTableList($GLOBALS['db'], null, $tpos, $cfg['MaxTableList']);
243 $table_count = PMA_getTableCount($GLOBALS['db']);
245 // show selected databasename as link to DefaultTabDatabase-page
246 // with table count in ()
247 $common_url_query = PMA_generate_common_url($GLOBALS['db']);
251 if ($GLOBALS['cfg']['ShowTooltip']
252 && $GLOBALS['cfgRelation']['commwork']) {
253 $_db_tooltip = PMA_getDbComment($GLOBALS['db']);
255 $db_tooltip = $_db_tooltip;
259 $disp_name = $GLOBALS['db'];
260 if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
261 $disp_name = $db_tooltip;
262 $disp_name_cut = $db_tooltip;
263 $db_tooltip = $GLOBALS['db'];
266 if ($table_count >= $GLOBALS['cfg']['LeftDisplayTableFilterMinimum']) {
268 <span id
="NavFilter">
269 <span id
="clear_fast_filter" title
="<?php echo __('Clear'); ?>">X
</span
>
270 <input type
="text" name
="fast_filter" id
="fast_filter" title
="<?php echo __('Filter'); ?>" value
="<?php echo __('filter tables by name'); ?>" />
276 * This helps reducing the navi panel size; in the right panel,
277 * user can find a navigator to page thru all tables.
280 if (! empty($table_list)) {
281 // upper table list paginator
282 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
283 $_url_params = array(
286 'db' => $GLOBALS['db']
288 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
290 PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
291 // lower table list paginator
292 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
293 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
296 echo __('No tables found in database.');
299 if ($db != 'information_schema') {
301 $GLOBALS['cfg']['AjaxEnable'] ?
$class="ajax" : '';
302 echo '<ul id="newtable"><li><a target="frame_content" href="tbl_create.php' . PMA_generate_common_url(array('db' => $GLOBALS['db'])) . '" class="'.$class .'" >'
303 .'<img class="icon ic_b_snewtbl" src="themes/dot.gif" id="icon_newtable" alt="' . _pgettext('short form', 'Create table') . '" />'
304 . _pgettext('short form', 'Create table') . '</a></li></ul>';
306 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
307 /* No need to tell user to select database if we're showing complete list */
309 echo '<p>' . __('Please select a database') . '</p>';
312 echo '<div id="databaseList">' . "\n";
313 $_url_params = array('pos' => $pos);
314 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
315 echo '</div>' . "\n";
317 $common_url_query = PMA_generate_common_url();
318 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']);
322 * displays collapsable db list
324 * @global integer $element_counter
325 * @global string $img_minus
326 * @global string $img_plus
327 * @global string $href_left
328 * @global string $db_start
329 * @global string $common_url_query
330 * @param array $ext_dblist extended db list
331 * @param integer $offset
332 * @param integer $count
334 function PMA_displayDbList($ext_dblist, $offset, $count) {
335 global $element_counter, $img_minus, $img_plus, $href_left,
336 $db_start, $common_url_query;
338 // get table list, for all databases
339 // doing this in one step takes advantage of a single query with information_schema!
340 $tables_full = PMA_DBI_get_tables_full($GLOBALS['pma']->databases
->getLimitedItems($offset, $count));
343 echo '<ul id="leftdatabaselist">';
344 $close_db_group = false;
345 foreach ($ext_dblist as $group => $db_group) {
346 if (count($GLOBALS['pma']->databases
) > 1) {
347 if ($close_db_group) {
351 $close_db_group = false;
353 if (count($db_group) > 1) {
354 $close_db_group = true;
355 $url_dbgroup = '&dbgroup=' . urlencode($group);
356 $common_url_query = PMA_generate_common_url() . $url_dbgroup;
358 echo '<li class="dbgroup">';
359 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
360 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
361 // display + only if this db(group) is not preselected
362 printf($href_left, $element_counter, PMA_generate_common_url());
363 printf($img_minus, $element_counter);
365 printf($href_left, $element_counter, $common_url_query);
366 printf($img_plus, $element_counter);
368 echo '</a> ' . $group . "\n";
369 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
370 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
371 echo '<ul id="subel' . $element_counter . '">' . "\n";
373 echo '<ul id="subel' . $element_counter . '"'
374 .' style="display: none">' . "\n";
378 foreach ($db_group as $db) {
379 $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup;
382 // Displays the database name
385 if (count($GLOBALS['pma']->databases
) > 1) {
386 // only with more than one db we need collapse ...
387 if ($db_start != $db['name'] ||
$db['num_tables'] < 1) {
388 // display + only if this db is not preselected
389 // or table count is 0
390 printf($href_left, $element_counter, $common_url_query);
391 printf($img_plus, $element_counter);
393 printf($href_left, $element_counter,
394 PMA_generate_common_url() . $url_dbgroup);
395 printf($img_minus, $element_counter);
399 // ... and we need to refresh both frames on db selection
402 id
="<?php echo htmlspecialchars($db['name']); ?>"
403 href
="index.php?<?php echo $common_url_query; ?>"
405 title
="<?php echo htmlspecialchars($db['comment']); ?>"
407 if (! toggle('<?php echo $element_counter; ?>', true))
408 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
409 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
410 . '?' . $common_url_query; ?>', 'main');
413 // Might be unset if CountTables directive is false
414 if (isset($db['num_tables'])) {
415 if ($GLOBALS['text_dir'] === 'rtl') {
416 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
419 echo htmlspecialchars($db['disp_name']);
420 if (isset($db['num_tables'])) {
421 if ($GLOBALS['text_dir'] === 'ltr') {
422 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
429 // with only 1 db available we dont need to refresh navi frame
430 // on db selection, only phpmain
432 <a href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
433 . '?' . $common_url_query; ?>"
434 id
="<?php echo htmlspecialchars($db['name']); ?>"
435 title
="<?php echo htmlspecialchars($db['comment']); ?>">
437 if (isset($db['num_tables'])) {
438 if ($GLOBALS['text_dir'] === 'rtl') {
439 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
442 echo htmlspecialchars($db['disp_name']);
443 if (isset($db['num_tables'])) {
444 if ($GLOBALS['text_dir'] === 'ltr') {
445 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
452 if (($GLOBALS['cfg']['Server']['CountTables'] === false) ||
$db['num_tables']) {
453 if (isset($tables_full[$db['name']])) {
454 $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
455 } elseif (isset($tables_full[strtolower($db['name'])])) {
456 // on windows with lower_case_table_names = 1
458 // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
459 // but information_schema.TABLES gives `test`
461 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
462 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
464 $tables = PMA_getTableList($db['name']);
467 (bool) (count($GLOBALS['pma']->databases
) === 1 ||
$db_start == $db['name']);
468 PMA_displayTableList($tables, $child_visible, '', $db['name']);
469 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
470 // no tables and LeftFrameLight:
471 // display message no tables in selected db
472 echo '<p>' . __('Please select a database') . '</p>' . "\n";
476 } // end foreach group
478 if ($close_db_group) {
482 $close_db_group = false;
489 * display unordered list of tables
490 * calls itself recursively if table in given list
493 * @global integer the element counter
494 * @global string html code for '-' image
495 * @global string html code for '+' image
496 * @global string html code for self link
497 * @param array $tables array of tables/tablegroups
498 * @param boolean $visible whether the list is visible or not
499 * @param string $tab_group_full full tab group name
500 * @param string $table_db db of this table
502 function PMA_displayTableList($tables, $visible = false,
503 $tab_group_full = '', $table_db = '')
505 if (! is_array($tables) ||
count($tables) === 0) {
509 global $element_counter, $img_minus, $img_plus, $href_left;
510 $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
513 echo '<ul id="subel' . $element_counter . '">';
515 echo '<ul id="subel' . $element_counter . '" style="display: none">';
517 foreach ($tables as $group => $table) {
518 // only allow grouping if the group has more than 1 table
519 if (isset($table['is' . $sep . 'group']) && $table['tab' . $sep . 'count'] > 1) {
520 $common_url_query = $GLOBALS['common_url_query']
521 . '&tbl_group=' . urlencode($tab_group_full . $group);
526 && ((isset($_REQUEST['tbl_group'])
527 && (strpos($_REQUEST['tbl_group'], $group) === 0
528 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
529 ||
strpos($GLOBALS['table'], $group) === 0)) {
530 printf($href_left, $element_counter,
531 $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full);
532 printf($img_minus, $element_counter);
534 printf($href_left, $element_counter, $common_url_query);
535 printf($img_plus, $element_counter);
539 <a href
="index.php?<?php echo $common_url_query; ?>"
542 if (! toggle('<?php echo $element_counter; ?>', true))
543 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
544 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
545 . '?' . $common_url_query; ?>', 'main');
548 if ($GLOBALS['text_dir'] === 'rtl') {
549 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
551 echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
552 if ($GLOBALS['text_dir'] === 'ltr') {
553 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
559 unset($table['is' . $sep . 'group']);
560 unset($table['tab' . $sep . 'group']);
561 unset($table['tab' . $sep . 'count']);
564 ((isset($_REQUEST['tbl_group'])
565 && (strpos($_REQUEST['tbl_group'], $group) === 0
566 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
567 ||
strpos($GLOBALS['table'], $group) === 0)) {
568 PMA_displayTableList($table, true,
569 $tab_group_full . $group, $table_db);
571 PMA_displayTableList($table, false, '', $table_db);
574 } elseif (is_array($table)) {
575 // the table was not grouped because it is the only one with its prefix
576 while (isset($table['is' . $sep . 'group'])) {
577 // get the array with the actual table information
578 foreach ($table as $value) {
579 if (is_array($value)) {
584 $link_title = PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']);
585 // quick access icon next to each table name
587 echo '<a class="tableicon" title="'
588 . htmlspecialchars($link_title)
589 . ': ' . htmlspecialchars($table['Comment'])
590 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"'
591 .' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
592 .' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
593 . $GLOBALS['common_url_query']
594 .'&table=' . urlencode($table['Name'])
595 .'&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable']
597 .'<img src="themes/dot.gif"';
598 if ('VIEW' === strtoupper($table['Comment'])) {
599 echo ' class="icon ic_s_views"';
601 echo ' class="icon ic_b_sbrowse"';
603 echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
604 .' alt="' . htmlspecialchars($link_title) . '" /></a>' . "\n";
606 // link for the table name itself
607 $href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
608 .$GLOBALS['common_url_query'] . '&table='
609 .urlencode($table['Name']) . '&pos=0';
610 echo '<a href="' . $href
611 . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment']
612 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows')) . ')"'
613 .' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
614 // preserve spaces in table name
615 . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
622 echo '</div>' . "\n";
624 PMA_exitNavigationFrame();