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'];
47 $_SESSION['tmp_user_values']['navi_limit_offset'] = (int) $_REQUEST['pos'];
50 $pos = $_SESSION['tmp_user_values']['navi_limit_offset'];
51 $tpos = $_SESSION['tmp_user_values']['table_limit_offset'];
52 // free the session file, for the other frames to be loaded
53 // but only if debugging is not enabled
54 if (empty($_SESSION['debug'])) {
55 session_write_close();
59 * the output compression library
61 require_once './libraries/ob.lib.php';
66 * selects the database if there is only one on current server
68 if ($GLOBALS['server'] && ! strlen($GLOBALS['db'])) {
69 $GLOBALS['db'] = $GLOBALS['pma']->databases
->getSingleItem();
72 $db_start = $GLOBALS['db'];
75 * the relation settings
77 $cfgRelation = PMA_getRelationsParam();
80 * For re-usability, moved http-headers to a seperate file.
81 * It can now be included by libraries/header.inc.php, querywindow.php.
83 require_once './libraries/header_http.inc.php';
88 // xml declaration moves IE into quirks mode, making much trouble with CSS
89 /* echo '<?xml version="1.0" encoding="utf-8"?>'; */
91 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
92 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
93 <html xmlns
="http://www.w3.org/1999/xhtml"
94 xml
:lang
="<?php echo $available_languages[$lang][1]; ?>"
95 lang
="<?php echo $available_languages[$lang][1]; ?>"
96 dir
="<?php echo $GLOBALS['text_dir']; ?>">
99 <link rel
="icon" href
="./favicon.ico" type
="image/x-icon" />
100 <link rel
="shortcut icon" href
="./favicon.ico" type
="image/x-icon" />
101 <title
>phpMyAdmin
</title
>
102 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
103 <base target
="frame_content" />
104 <link rel
="stylesheet" type
="text/css"
105 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=left&nocache=<?php echo $GLOBALS['PMA_Config']->getThemeUniqueValue(); ?>" />
107 echo PMA_includeJS('jquery/jquery-1.6.2.js');
108 echo PMA_includeJS('jquery/jquery-ui-1.8.16.custom.js');
109 echo PMA_includeJS('jquery/jquery.qtip-1.0.0-rc3.js');
110 echo PMA_includeJS('navigation.js');
111 echo PMA_includeJS('functions.js');
112 echo PMA_includeJS('messages.php');
113 // Append the theme id to this url to invalidate the cache on a theme change
114 echo PMA_includeJS('get_image.js.php?theme=' . urlencode($_SESSION['PMA_Theme']->getId()));
116 <script type
="text/javascript">
118 // INIT PMA_setFrameSize
120 var onLoadHandler
= window
.onload
;
121 var resizeHandler
= window
.onresize
;
122 window
.document
.onresize
= resizeHandler
;
123 window
.onload
= function() {
124 if (onloadCnt
== 0) {
125 if (typeof(onLoadHandler
) == "function") {
128 if (typeof(PMA_setFrameSize
) != 'undefined' && typeof(PMA_setFrameSize
) == 'function') {
134 window
.onresize
= function() {
135 if (typeof(resizeHandler
) == "function") {
138 if (typeof(PMA_saveFrameSize
) != 'undefined' && typeof(PMA_saveFrameSize
) == 'function') {
146 * remove horizontal scroll bar bug in IE 6 by forcing a vertical scroll bar
150 <style type
="text/css">
160 <body id
="body_leftFrame">
162 require './libraries/navigation_header.inc.php';
164 // display recently used tables
165 if ($GLOBALS['cfg']['LeftRecentTable'] > 0) {
166 echo '<div id="recentTableList">' . "\n"
167 .'<form method="post" action="index.php" target="_parent">' . "\n"
168 .PMA_generate_common_hidden_inputs() . "\n"
169 .PMA_RecentTable
::getInstance()->getHtmlSelect()
171 .'<input type="submit" name="Go" value="' . __('Go') . '" />' . "\n"
172 .'</noscript>' . "\n"
177 if (! $GLOBALS['server']) {
178 // no server selected
179 PMA_exitNavigationFrame();
180 } elseif (! count($GLOBALS['pma']->databases
)) {
181 // no database available, so we break here
182 echo '<p>' . __('No databases') . '</p>';
183 PMA_exitNavigationFrame();
184 } elseif ($GLOBALS['cfg']['LeftFrameLight'] && count($GLOBALS['pma']->databases
) > 1) {
185 $list = $cfg['DisplayDatabasesList'];
186 if ($list === 'auto') {
187 if (empty($GLOBALS['db'])) {
194 // more than one database available and LeftFrameLight is true
195 // display db selectbox
197 // Light mode -> beginning of the select combo for databases
198 // Note: When javascript is active, the frameset will be changed from
199 // within navigation.php. With no JS (<noscript>) the whole frameset will
200 // be rebuilt with the new target frame.
203 <div id
="databaseList">
204 <form method
="post" action
="index.php" target
="_parent" id
="left">
206 echo PMA_generate_common_hidden_inputs() . "\n";
207 echo $GLOBALS['pma']->databases
->getHtmlSelectGrouped(true, $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
208 echo '<noscript>' . "\n"
209 .'<input type="submit" name="Go" value="' . __('Go') . '" />' . "\n"
210 .'</noscript>' . "\n"
214 echo $GLOBALS['pma']->databases
->getHtmlListGrouped(true, $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
216 $_url_params = array('pos' => $pos);
217 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
221 <div id
="left_tableList">
223 // Don't display expansible/collapsible database info if:
224 // 1. $GLOBALS['server'] == 0 (no server selected)
225 // This is the case when there are multiple servers and
226 // '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome
227 // screen to appear with no database info displayed.
228 // 2. there is only one database available (ie either only one database exists
229 // or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
230 // In this case, the database should not be collapsible/expandable
232 $img_plus = PMA_getImage('b_plus.png', '+', array('id' => 'el%dImg'));
233 $img_minus = PMA_getImage('b_minus.png', '-', array('id' => 'el%dImg'));
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 tables by name'); ?>" 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 (!PMA_is_system_schema($db)) {
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 . PMA_getImage('b_snewtbl.png', _pgettext('short form', 'Create table'), array('id' => "icon_newtable"))
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)
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']->databases
->getLimitedItems($offset, $count));
344 echo '<ul id="leftdatabaselist">';
345 $close_db_group = false;
346 foreach ($ext_dblist as $group => $db_group) {
347 if (count($GLOBALS['pma']->databases
) > 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 (count($GLOBALS['pma']->databases
) > 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 // Might be unset if CountTables directive is false
415 if (isset($db['num_tables'])) {
416 if ($GLOBALS['text_dir'] === 'rtl') {
417 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
420 echo htmlspecialchars($db['disp_name']);
421 if (isset($db['num_tables'])) {
422 if ($GLOBALS['text_dir'] === 'ltr') {
423 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
430 // with only 1 db available we dont need to refresh navi frame
431 // on db selection, only phpmain
433 <a href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
434 . '?' . $common_url_query; ?>"
435 id
="<?php echo htmlspecialchars($db['name']); ?>"
436 title
="<?php echo htmlspecialchars($db['comment']); ?>">
438 if (isset($db['num_tables'])) {
439 if ($GLOBALS['text_dir'] === 'rtl') {
440 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
443 echo htmlspecialchars($db['disp_name']);
444 if (isset($db['num_tables'])) {
445 if ($GLOBALS['text_dir'] === 'ltr') {
446 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
453 if (($GLOBALS['cfg']['Server']['CountTables'] === false) ||
$db['num_tables']) {
454 if (isset($tables_full[$db['name']])) {
455 $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
456 } elseif (isset($tables_full[strtolower($db['name'])])) {
457 // on windows with lower_case_table_names = 1
459 // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
460 // but information_schema.TABLES gives `test`
462 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
463 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
465 $tables = PMA_getTableList($db['name']);
468 (bool) (count($GLOBALS['pma']->databases
) === 1 ||
$db_start == $db['name']);
469 PMA_displayTableList($tables, $child_visible, '', $db['name']);
470 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
471 // no tables and LeftFrameLight:
472 // display message no tables in selected db
473 echo '<p>' . __('Please select a database') . '</p>' . "\n";
477 } // end foreach group
479 if ($close_db_group) {
483 $close_db_group = false;
490 * display unordered list of tables
491 * calls itself recursively if table in given list
494 * @global integer the element counter
495 * @global string html code for '-' image
496 * @global string html code for '+' image
497 * @global string html code for self link
498 * @param array $tables array of tables/tablegroups
499 * @param boolean $visible whether the list is visible or not
500 * @param string $tab_group_full full tab group name
501 * @param string $table_db db of this table
503 function PMA_displayTableList($tables, $visible = false,
504 $tab_group_full = '', $table_db = '')
506 if (! is_array($tables) ||
count($tables) === 0) {
510 global $element_counter, $img_minus, $img_plus, $href_left;
511 $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
514 echo '<ul id="subel' . $element_counter . '">';
516 echo '<ul id="subel' . $element_counter . '" style="display: none">';
518 foreach ($tables as $group => $table) {
519 // only allow grouping if the group has more than 1 table
520 if (isset($table['is' . $sep . 'group']) && $table['tab' . $sep . 'count'] > 1) {
521 $common_url_query = $GLOBALS['common_url_query']
522 . '&tbl_group=' . urlencode($tab_group_full . $group);
527 && ((isset($_REQUEST['tbl_group'])
528 && (strpos($_REQUEST['tbl_group'], $group) === 0
529 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
530 ||
strpos($GLOBALS['table'], $group) === 0)) {
531 printf($href_left, $element_counter,
532 $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full);
533 printf($img_minus, $element_counter);
535 printf($href_left, $element_counter, $common_url_query);
536 printf($img_plus, $element_counter);
540 <a href
="index.php?<?php echo $common_url_query; ?>"
543 if (! toggle('<?php echo $element_counter; ?>', true))
544 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
545 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
546 . '?' . $common_url_query; ?>', 'main');
549 if ($GLOBALS['text_dir'] === 'rtl') {
550 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
552 echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
553 if ($GLOBALS['text_dir'] === 'ltr') {
554 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
560 unset($table['is' . $sep . 'group']);
561 unset($table['tab' . $sep . 'group']);
562 unset($table['tab' . $sep . 'count']);
565 ((isset($_REQUEST['tbl_group'])
566 && (strpos($_REQUEST['tbl_group'], $group) === 0
567 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
568 ||
strpos($GLOBALS['table'], $group) === 0)) {
569 PMA_displayTableList($table, true,
570 $tab_group_full . $group, $table_db);
572 PMA_displayTableList($table, false, '', $table_db);
575 } elseif (is_array($table)) {
576 // the table was not grouped because it is the only one with its prefix
577 while (isset($table['is' . $sep . 'group'])) {
578 // get the array with the actual table information
579 foreach ($table as $value) {
580 if (is_array($value)) {
585 $link_title = PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']);
586 // quick access icon next to each table name
588 echo '<a class="tableicon" title="'
589 . htmlspecialchars($link_title)
590 . ': ' . htmlspecialchars($table['Comment'])
591 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"'
592 .' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
593 .' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
594 . $GLOBALS['common_url_query']
595 .'&table=' . urlencode($table['Name'])
596 .'&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable']
598 $attr = array('id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name']));
599 if (PMA_Table
::isView($table_db, $table['Name'])) {
600 echo PMA_getImage('s_views.png', htmlspecialchars($link_title), $attr);
602 echo PMA_getImage('b_browse.png', htmlspecialchars($link_title), $attr);
605 // link for the table name itself
606 $href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
607 .$GLOBALS['common_url_query'] . '&table='
608 .urlencode($table['Name']) . '&pos=0';
609 echo '<a href="' . $href
610 . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment']
611 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows')) . ')"'
612 .' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
613 // preserve spaces in table name
614 . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
621 echo '</div>' . "\n";
623 PMA_exitNavigationFrame();