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.2.js');
109 echo PMA_includeJS('jquery/jquery-ui-1.8.16.custom.js');
110 echo PMA_includeJS('jquery/jquery.qtip-1.0.0-rc3.js');
111 echo PMA_includeJS('navigation.js');
112 echo PMA_includeJS('functions.js');
113 echo PMA_includeJS('messages.php');
114 // Append the theme id to this url to invalidate the cache on a theme change
115 echo PMA_includeJS('get_image.js.php?theme=' . urlencode($_SESSION['PMA_Theme']->getId()));
117 <script type
="text/javascript">
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 = PMA_getImage('b_plus.png', '+', array('id' => 'el%dImg'));
234 $img_minus = PMA_getImage('b_minus.png', '-', array('id' => 'el%dImg'));
236 $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
237 .' href="navigation.php?%s" target="_self">';
239 $element_counter = 0;
242 if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
243 $table_list = PMA_getTableList($GLOBALS['db'], null, $tpos, $cfg['MaxTableList']);
244 $table_count = PMA_getTableCount($GLOBALS['db']);
246 // show selected databasename as link to DefaultTabDatabase-page
247 // with table count in ()
248 $common_url_query = PMA_generate_common_url($GLOBALS['db']);
252 if ($GLOBALS['cfg']['ShowTooltip']
253 && $GLOBALS['cfgRelation']['commwork']) {
254 $_db_tooltip = PMA_getDbComment($GLOBALS['db']);
256 $db_tooltip = $_db_tooltip;
260 $disp_name = $GLOBALS['db'];
261 if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
262 $disp_name = $db_tooltip;
263 $disp_name_cut = $db_tooltip;
264 $db_tooltip = $GLOBALS['db'];
267 if ($table_count >= $GLOBALS['cfg']['LeftDisplayTableFilterMinimum']) {
269 <span id
="NavFilter">
270 <span id
="clear_fast_filter" title
="<?php echo __('Clear'); ?>">X
</span
>
271 <input type
="text" name
="fast_filter" id
="fast_filter" title
="<?php echo __('Filter tables by name'); ?>" value
="<?php echo __('Filter tables by name'); ?>" />
277 * This helps reducing the navi panel size; in the right panel,
278 * user can find a navigator to page thru all tables.
281 if (! empty($table_list)) {
282 // upper table list paginator
283 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
284 $_url_params = array(
287 'db' => $GLOBALS['db']
289 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
291 PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
292 // lower table list paginator
293 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
294 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
297 echo __('No tables found in database.');
300 if (!PMA_is_system_schema($db)) {
302 $GLOBALS['cfg']['AjaxEnable'] ?
$class="ajax" : '';
303 echo '<ul id="newtable"><li><a target="frame_content" href="tbl_create.php' . PMA_generate_common_url(array('db' => $GLOBALS['db'])) . '" class="'.$class .'" >'
304 . PMA_getImage('b_snewtbl.png', _pgettext('short form', 'Create table'), array('id' => "icon_newtable"))
305 . _pgettext('short form', 'Create table') . '</a></li></ul>';
307 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
308 /* No need to tell user to select database if we're showing complete list */
310 echo '<p>' . __('Please select a database') . '</p>';
313 echo '<div id="databaseList">' . "\n";
314 $_url_params = array('pos' => $pos);
315 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
316 echo '</div>' . "\n";
318 $common_url_query = PMA_generate_common_url();
319 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']);
323 * displays collapsable db list
325 * @global integer $element_counter
326 * @global string $img_minus
327 * @global string $img_plus
328 * @global string $href_left
329 * @global string $db_start
330 * @global string $common_url_query
331 * @param array $ext_dblist extended db list
332 * @param integer $offset
333 * @param integer $count
335 function PMA_displayDbList($ext_dblist, $offset, $count)
337 global $element_counter, $img_minus, $img_plus, $href_left,
338 $db_start, $common_url_query;
340 // get table list, for all databases
341 // doing this in one step takes advantage of a single query with information_schema!
342 $tables_full = PMA_DBI_get_tables_full($GLOBALS['pma']->databases
->getLimitedItems($offset, $count));
345 echo '<ul id="leftdatabaselist">';
346 $close_db_group = false;
347 foreach ($ext_dblist as $group => $db_group) {
348 if (count($GLOBALS['pma']->databases
) > 1) {
349 if ($close_db_group) {
353 $close_db_group = false;
355 if (count($db_group) > 1) {
356 $close_db_group = true;
357 $url_dbgroup = '&dbgroup=' . urlencode($group);
358 $common_url_query = PMA_generate_common_url() . $url_dbgroup;
360 echo '<li class="dbgroup">';
361 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
362 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
363 // display + only if this db(group) is not preselected
364 printf($href_left, $element_counter, PMA_generate_common_url());
365 printf($img_minus, $element_counter);
367 printf($href_left, $element_counter, $common_url_query);
368 printf($img_plus, $element_counter);
370 echo '</a> ' . $group . "\n";
371 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
372 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
373 echo '<ul id="subel' . $element_counter . '">' . "\n";
375 echo '<ul id="subel' . $element_counter . '"'
376 .' style="display: none">' . "\n";
380 foreach ($db_group as $db) {
381 $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup;
384 // Displays the database name
387 if (count($GLOBALS['pma']->databases
) > 1) {
388 // only with more than one db we need collapse ...
389 if ($db_start != $db['name'] ||
$db['num_tables'] < 1) {
390 // display + only if this db is not preselected
391 // or table count is 0
392 printf($href_left, $element_counter, $common_url_query);
393 printf($img_plus, $element_counter);
395 printf($href_left, $element_counter,
396 PMA_generate_common_url() . $url_dbgroup);
397 printf($img_minus, $element_counter);
401 // ... and we need to refresh both frames on db selection
404 id
="<?php echo htmlspecialchars($db['name']); ?>"
405 href
="index.php?<?php echo $common_url_query; ?>"
407 title
="<?php echo htmlspecialchars($db['comment']); ?>"
409 if (! toggle('<?php echo $element_counter; ?>', true))
410 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
411 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
412 . '?' . $common_url_query; ?>', 'main');
415 // Might be unset if CountTables directive is false
416 if (isset($db['num_tables'])) {
417 if ($GLOBALS['text_dir'] === 'rtl') {
418 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
421 echo htmlspecialchars($db['disp_name']);
422 if (isset($db['num_tables'])) {
423 if ($GLOBALS['text_dir'] === 'ltr') {
424 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
431 // with only 1 db available we dont need to refresh navi frame
432 // on db selection, only phpmain
434 <a href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
435 . '?' . $common_url_query; ?>"
436 id
="<?php echo htmlspecialchars($db['name']); ?>"
437 title
="<?php echo htmlspecialchars($db['comment']); ?>">
439 if (isset($db['num_tables'])) {
440 if ($GLOBALS['text_dir'] === 'rtl') {
441 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
444 echo htmlspecialchars($db['disp_name']);
445 if (isset($db['num_tables'])) {
446 if ($GLOBALS['text_dir'] === 'ltr') {
447 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
454 if (($GLOBALS['cfg']['Server']['CountTables'] === false) ||
$db['num_tables']) {
455 if (isset($tables_full[$db['name']])) {
456 $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
457 } elseif (isset($tables_full[strtolower($db['name'])])) {
458 // on windows with lower_case_table_names = 1
460 // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
461 // but information_schema.TABLES gives `test`
463 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
464 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
466 $tables = PMA_getTableList($db['name']);
469 (bool) (count($GLOBALS['pma']->databases
) === 1 ||
$db_start == $db['name']);
470 PMA_displayTableList($tables, $child_visible, '', $db['name']);
471 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
472 // no tables and LeftFrameLight:
473 // display message no tables in selected db
474 echo '<p>' . __('Please select a database') . '</p>' . "\n";
478 } // end foreach group
480 if ($close_db_group) {
484 $close_db_group = false;
491 * display unordered list of tables
492 * calls itself recursively if table in given list
495 * @global integer the element counter
496 * @global string html code for '-' image
497 * @global string html code for '+' image
498 * @global string html code for self link
499 * @param array $tables array of tables/tablegroups
500 * @param boolean $visible whether the list is visible or not
501 * @param string $tab_group_full full tab group name
502 * @param string $table_db db of this table
504 function PMA_displayTableList($tables, $visible = false,
505 $tab_group_full = '', $table_db = '')
507 if (! is_array($tables) ||
count($tables) === 0) {
511 global $element_counter, $img_minus, $img_plus, $href_left;
512 $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
515 echo '<ul id="subel' . $element_counter . '">';
517 echo '<ul id="subel' . $element_counter . '" style="display: none">';
519 foreach ($tables as $group => $table) {
520 // only allow grouping if the group has more than 1 table
521 if (isset($table['is' . $sep . 'group']) && $table['tab' . $sep . 'count'] > 1) {
522 $common_url_query = $GLOBALS['common_url_query']
523 . '&tbl_group=' . urlencode($tab_group_full . $group);
528 && ((isset($_REQUEST['tbl_group'])
529 && (strpos($_REQUEST['tbl_group'], $group) === 0
530 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
531 ||
strpos($GLOBALS['table'], $group) === 0)) {
532 printf($href_left, $element_counter,
533 $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full);
534 printf($img_minus, $element_counter);
536 printf($href_left, $element_counter, $common_url_query);
537 printf($img_plus, $element_counter);
541 <a href
="index.php?<?php echo $common_url_query; ?>"
544 if (! toggle('<?php echo $element_counter; ?>', true))
545 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
546 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
547 . '?' . $common_url_query; ?>', 'main');
550 if ($GLOBALS['text_dir'] === 'rtl') {
551 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
553 echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
554 if ($GLOBALS['text_dir'] === 'ltr') {
555 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
561 unset($table['is' . $sep . 'group']);
562 unset($table['tab' . $sep . 'group']);
563 unset($table['tab' . $sep . 'count']);
566 ((isset($_REQUEST['tbl_group'])
567 && (strpos($_REQUEST['tbl_group'], $group) === 0
568 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
569 ||
strpos($GLOBALS['table'], $group) === 0)) {
570 PMA_displayTableList($table, true,
571 $tab_group_full . $group, $table_db);
573 PMA_displayTableList($table, false, '', $table_db);
576 } elseif (is_array($table)) {
577 // the table was not grouped because it is the only one with its prefix
578 while (isset($table['is' . $sep . 'group'])) {
579 // get the array with the actual table information
580 foreach ($table as $value) {
581 if (is_array($value)) {
586 $link_title = PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']);
587 // quick access icon next to each table name
589 echo '<a class="tableicon" title="'
590 . htmlspecialchars($link_title)
591 . ': ' . htmlspecialchars($table['Comment'])
592 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"'
593 .' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
594 .' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
595 . $GLOBALS['common_url_query']
596 .'&table=' . urlencode($table['Name'])
597 .'&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable']
599 $attr = array('id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name']));
600 if (PMA_Table
::isView($table_db, $table['Name'])) {
601 echo PMA_getImage('s_views.png', htmlspecialchars($link_title), $attr);
603 echo PMA_getImage('b_browse.png', htmlspecialchars($link_title), $attr);
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();