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 var image_minus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_minus.png';
117 var image_plus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_plus.png';
119 // INIT PMA_setFrameSize
121 var onLoadHandler
= window
.onload
;
122 var resizeHandler
= window
.onresize
;
123 window
.document
.onresize
= resizeHandler
;
124 window
.onload
= function() {
125 if (onloadCnt
== 0) {
126 if (typeof(onLoadHandler
) == "function") {
129 if (typeof(PMA_setFrameSize
) != 'undefined' && typeof(PMA_setFrameSize
) == 'function') {
135 window
.onresize
= function() {
136 if (typeof(resizeHandler
) == "function") {
139 if (typeof(PMA_saveFrameSize
) != 'undefined' && typeof(PMA_saveFrameSize
) == 'function') {
147 * remove horizontal scroll bar bug in IE 6 by forcing a vertical scroll bar
151 <style type
="text/css">
161 <body id
="body_leftFrame">
163 require './libraries/navigation_header.inc.php';
165 // display recently used tables
166 if ($GLOBALS['cfg']['LeftRecentTable'] > 0) {
167 echo '<div id="recentTableList">' . "\n"
168 .'<form method="post" action="index.php" target="_parent">' . "\n"
169 .PMA_generate_common_hidden_inputs() . "\n"
170 .PMA_RecentTable
::getInstance()->getHtmlSelect()
172 .'<input type="submit" name="Go" value="' . __('Go') . '" />' . "\n"
173 .'</noscript>' . "\n"
178 if (! $GLOBALS['server']) {
179 // no server selected
180 PMA_exitNavigationFrame();
181 } elseif (! count($GLOBALS['pma']->databases
)) {
182 // no database available, so we break here
183 echo '<p>' . __('No databases') . '</p>';
184 PMA_exitNavigationFrame();
185 } elseif ($GLOBALS['cfg']['LeftFrameLight'] && count($GLOBALS['pma']->databases
) > 1) {
186 $list = $cfg['DisplayDatabasesList'];
187 if ($list === 'auto') {
188 if (empty($GLOBALS['db'])) {
195 // more than one database available and LeftFrameLight is true
196 // display db selectbox
198 // Light mode -> beginning of the select combo for databases
199 // Note: When javascript is active, the frameset will be changed from
200 // within navigation.php. With no JS (<noscript>) the whole frameset will
201 // be rebuilt with the new target frame.
204 <div id
="databaseList">
205 <form method
="post" action
="index.php" target
="_parent" id
="left">
207 echo PMA_generate_common_hidden_inputs() . "\n";
208 echo $GLOBALS['pma']->databases
->getHtmlSelectGrouped(true, $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
209 echo '<noscript>' . "\n"
210 .'<input type="submit" name="Go" value="' . __('Go') . '" />' . "\n"
211 .'</noscript>' . "\n"
215 echo $GLOBALS['pma']->databases
->getHtmlListGrouped(true, $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
217 $_url_params = array('pos' => $pos);
218 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
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"'
235 $img_minus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_minus.png"'
238 $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
239 .' href="navigation.php?%s" target="_self">';
241 $element_counter = 0;
244 if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
245 $table_list = PMA_getTableList($GLOBALS['db'], null, $tpos, $cfg['MaxTableList']);
246 $table_count = PMA_getTableCount($GLOBALS['db']);
248 // show selected databasename as link to DefaultTabDatabase-page
249 // with table count in ()
250 $common_url_query = PMA_generate_common_url($GLOBALS['db']);
254 if ($GLOBALS['cfg']['ShowTooltip']
255 && $GLOBALS['cfgRelation']['commwork']) {
256 $_db_tooltip = PMA_getDbComment($GLOBALS['db']);
258 $db_tooltip = $_db_tooltip;
262 $disp_name = $GLOBALS['db'];
263 if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
264 $disp_name = $db_tooltip;
265 $disp_name_cut = $db_tooltip;
266 $db_tooltip = $GLOBALS['db'];
269 if ($table_count >= $GLOBALS['cfg']['LeftDisplayTableFilterMinimum']) {
271 <span id
="NavFilter">
272 <span id
="clear_fast_filter" title
="<?php echo __('Clear'); ?>">X
</span
>
273 <input type
="text" name
="fast_filter" id
="fast_filter" title
="<?php echo __('Filter'); ?>" value
="<?php echo __('filter tables by name'); ?>" />
279 * This helps reducing the navi panel size; in the right panel,
280 * user can find a navigator to page thru all tables.
283 if (! empty($table_list)) {
284 // upper table list paginator
285 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
286 $_url_params = array(
289 'db' => $GLOBALS['db']
291 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
293 PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
294 // lower table list paginator
295 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
296 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
299 echo __('No tables found in database.');
302 if ($db != 'information_schema') {
304 $GLOBALS['cfg']['AjaxEnable'] ?
$class="ajax" : '';
305 echo '<ul id="newtable"><li><a target="frame_content" href="tbl_create.php' . PMA_generate_common_url(array('db' => $GLOBALS['db'])) . '" class="'.$class .'" >'
306 .'<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_snewtbl.png" id="icon_newtable" alt="' . _pgettext('short form', 'Create table') . '" />'
307 . _pgettext('short form', 'Create table') . '</a></li></ul>';
309 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
310 /* No need to tell user to select database if we're showing complete list */
312 echo '<p>' . __('Please select a database') . '</p>';
315 echo '<div id="databaseList">' . "\n";
316 $_url_params = array('pos' => $pos);
317 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
318 echo '</div>' . "\n";
320 $common_url_query = PMA_generate_common_url();
321 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']);
325 * displays collapsable db list
327 * @global integer $element_counter
328 * @global string $img_minus
329 * @global string $img_plus
330 * @global string $href_left
331 * @global string $db_start
332 * @global string $common_url_query
333 * @param array $ext_dblist extended db list
334 * @param integer $offset
335 * @param integer $count
337 function PMA_displayDbList($ext_dblist, $offset, $count) {
338 global $element_counter, $img_minus, $img_plus, $href_left,
339 $db_start, $common_url_query;
341 // get table list, for all databases
342 // doing this in one step takes advantage of a single query with information_schema!
343 $tables_full = PMA_DBI_get_tables_full($GLOBALS['pma']->databases
->getLimitedItems($offset, $count));
346 echo '<ul id="leftdatabaselist">';
347 $close_db_group = false;
348 foreach ($ext_dblist as $group => $db_group) {
349 if (count($GLOBALS['pma']->databases
) > 1) {
350 if ($close_db_group) {
354 $close_db_group = false;
356 if (count($db_group) > 1) {
357 $close_db_group = true;
358 $url_dbgroup = '&dbgroup=' . urlencode($group);
359 $common_url_query = PMA_generate_common_url() . $url_dbgroup;
361 echo '<li class="dbgroup">';
362 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
363 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
364 // display + only if this db(group) is not preselected
365 printf($href_left, $element_counter, PMA_generate_common_url());
366 printf($img_minus, $element_counter);
368 printf($href_left, $element_counter, $common_url_query);
369 printf($img_plus, $element_counter);
371 echo '</a> ' . $group . "\n";
372 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
373 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
374 echo '<ul id="subel' . $element_counter . '">' . "\n";
376 echo '<ul id="subel' . $element_counter . '"'
377 .' style="display: none">' . "\n";
381 foreach ($db_group as $db) {
382 $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup;
385 // Displays the database name
388 if (count($GLOBALS['pma']->databases
) > 1) {
389 // only with more than one db we need collapse ...
390 if ($db_start != $db['name'] ||
$db['num_tables'] < 1) {
391 // display + only if this db is not preselected
392 // or table count is 0
393 printf($href_left, $element_counter, $common_url_query);
394 printf($img_plus, $element_counter);
396 printf($href_left, $element_counter,
397 PMA_generate_common_url() . $url_dbgroup);
398 printf($img_minus, $element_counter);
402 // ... and we need to refresh both frames on db selection
405 id
="<?php echo htmlspecialchars($db['name']); ?>"
406 href
="index.php?<?php echo $common_url_query; ?>"
408 title
="<?php echo htmlspecialchars($db['comment']); ?>"
410 if (! toggle('<?php echo $element_counter; ?>', true))
411 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
412 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
413 . '?' . $common_url_query; ?>', 'main');
416 // Might be unset if CountTables directive is false
417 if (isset($db['num_tables'])) {
418 if ($GLOBALS['text_dir'] === 'rtl') {
419 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
422 echo htmlspecialchars($db['disp_name']);
423 if (isset($db['num_tables'])) {
424 if ($GLOBALS['text_dir'] === 'ltr') {
425 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
432 // with only 1 db available we dont need to refresh navi frame
433 // on db selection, only phpmain
435 <a href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
436 . '?' . $common_url_query; ?>"
437 id
="<?php echo htmlspecialchars($db['name']); ?>"
438 title
="<?php echo htmlspecialchars($db['comment']); ?>">
440 if (isset($db['num_tables'])) {
441 if ($GLOBALS['text_dir'] === 'rtl') {
442 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
445 echo htmlspecialchars($db['disp_name']);
446 if (isset($db['num_tables'])) {
447 if ($GLOBALS['text_dir'] === 'ltr') {
448 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
455 if (($GLOBALS['cfg']['Server']['CountTables'] === false) ||
$db['num_tables']) {
456 if (isset($tables_full[$db['name']])) {
457 $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
458 } elseif (isset($tables_full[strtolower($db['name'])])) {
459 // on windows with lower_case_table_names = 1
461 // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
462 // but information_schema.TABLES gives `test`
464 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
465 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
467 $tables = PMA_getTableList($db['name']);
470 (bool) (count($GLOBALS['pma']->databases
) === 1 ||
$db_start == $db['name']);
471 PMA_displayTableList($tables, $child_visible, '', $db['name']);
472 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
473 // no tables and LeftFrameLight:
474 // display message no tables in selected db
475 echo '<p>' . __('Please select a database') . '</p>' . "\n";
479 } // end foreach group
481 if ($close_db_group) {
485 $close_db_group = false;
492 * display unordered list of tables
493 * calls itself recursively if table in given list
496 * @global integer the element counter
497 * @global string html code for '-' image
498 * @global string html code for '+' image
499 * @global string html code for self link
500 * @param array $tables array of tables/tablegroups
501 * @param boolean $visible whether the list is visible or not
502 * @param string $tab_group_full full tab group name
503 * @param string $table_db db of this table
505 function PMA_displayTableList($tables, $visible = false,
506 $tab_group_full = '', $table_db = '')
508 if (! is_array($tables) ||
count($tables) === 0) {
512 global $element_counter, $img_minus, $img_plus, $href_left;
513 $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
516 echo '<ul id="subel' . $element_counter . '">';
518 echo '<ul id="subel' . $element_counter . '" style="display: none">';
520 foreach ($tables as $group => $table) {
521 // only allow grouping if the group has more than 1 table
522 if (isset($table['is' . $sep . 'group']) && $table['tab' . $sep . 'count'] > 1) {
523 $common_url_query = $GLOBALS['common_url_query']
524 . '&tbl_group=' . urlencode($tab_group_full . $group);
529 && ((isset($_REQUEST['tbl_group'])
530 && (strpos($_REQUEST['tbl_group'], $group) === 0
531 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
532 ||
strpos($GLOBALS['table'], $group) === 0)) {
533 printf($href_left, $element_counter,
534 $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full);
535 printf($img_minus, $element_counter);
537 printf($href_left, $element_counter, $common_url_query);
538 printf($img_plus, $element_counter);
542 <a href
="index.php?<?php echo $common_url_query; ?>"
545 if (! toggle('<?php echo $element_counter; ?>', true))
546 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
547 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
548 . '?' . $common_url_query; ?>', 'main');
551 if ($GLOBALS['text_dir'] === 'rtl') {
552 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
554 echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
555 if ($GLOBALS['text_dir'] === 'ltr') {
556 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
562 unset($table['is' . $sep . 'group']);
563 unset($table['tab' . $sep . 'group']);
564 unset($table['tab' . $sep . 'count']);
567 ((isset($_REQUEST['tbl_group'])
568 && (strpos($_REQUEST['tbl_group'], $group) === 0
569 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
570 ||
strpos($GLOBALS['table'], $group) === 0)) {
571 PMA_displayTableList($table, true,
572 $tab_group_full . $group, $table_db);
574 PMA_displayTableList($table, false, '', $table_db);
577 } elseif (is_array($table)) {
578 // the table was not grouped because it is the only one with its prefix
579 while (isset($table['is' . $sep . 'group'])) {
580 // get the array with the actual table information
581 foreach ($table as $value) {
582 if(is_array($value)) {
587 $link_title = PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']);
588 // quick access icon next to each table name
590 echo '<a class="tableicon" title="'
591 . htmlspecialchars($link_title)
592 . ': ' . htmlspecialchars($table['Comment'])
593 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"'
594 .' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
595 .' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
596 . $GLOBALS['common_url_query']
597 .'&table=' . urlencode($table['Name'])
598 .'&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable']
600 .'<img class="icon"';
601 if ('VIEW' === strtoupper($table['Comment'])) {
602 echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"';
604 echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"';
606 echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
607 .' alt="' . htmlspecialchars($link_title) . '" /></a>' . "\n";
609 // link for the table name itself
610 $href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
611 .$GLOBALS['common_url_query'] . '&table='
612 .urlencode($table['Name']) . '&pos=0';
613 echo '<a href="' . $href
614 . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment']
615 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows')) . ')"'
616 .' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
617 // preserve spaces in table name
618 . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
625 echo '</div>' . "\n";
627 PMA_exitNavigationFrame();