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"?>'; */
92 <html lang
="<?php echo $available_languages[$lang][1]; ?>" dir
="<?php echo $GLOBALS['text_dir']; ?>">
95 <link rel
="icon" href
="favicon.ico" type
="image/x-icon" />
96 <link rel
="shortcut icon" href
="favicon.ico" type
="image/x-icon" />
97 <title
>phpMyAdmin
</title
>
98 <meta charset
="utf-8" />
99 <base target
="frame_content" />
100 <link rel
="stylesheet" type
="text/css"
101 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=left&nocache=<?php echo $GLOBALS['PMA_Config']->getThemeUniqueValue(); ?>" />
103 echo PMA_includeJS('jquery/jquery-1.6.2.js');
104 echo PMA_includeJS('jquery/jquery-ui-1.8.16.custom.js');
105 echo PMA_includeJS('jquery/jquery.qtip-1.0.0-rc3.js');
106 echo PMA_includeJS('navigation.js');
107 echo PMA_includeJS('functions.js');
108 echo PMA_includeJS('messages.php');
109 // Append the theme id to this url to invalidate the cache on a theme change
110 echo PMA_includeJS('get_image.js.php?theme=' . urlencode($_SESSION['PMA_Theme']->getId()));
112 <script type
="text/javascript">
114 // INIT PMA_setFrameSize
116 var onLoadHandler
= window
.onload
;
117 var resizeHandler
= window
.onresize
;
118 window
.document
.onresize
= resizeHandler
;
119 window
.onload
= function() {
120 if (onloadCnt
== 0) {
121 if (typeof(onLoadHandler
) == "function") {
124 if (typeof(PMA_setFrameSize
) != 'undefined' && typeof(PMA_setFrameSize
) == 'function') {
130 window
.onresize
= function() {
131 if (typeof(resizeHandler
) == "function") {
134 if (typeof(PMA_saveFrameSize
) != 'undefined' && typeof(PMA_saveFrameSize
) == 'function') {
142 * remove horizontal scroll bar bug in IE 6 by forcing a vertical scroll bar
146 <style type
="text/css">
156 <body id
="body_leftFrame">
158 require 'libraries/navigation_header.inc.php';
160 // display recently used tables
161 if ($GLOBALS['cfg']['LeftRecentTable'] > 0) {
162 echo '<div id="recentTableList">' . "\n"
163 .'<form method="post" action="index.php" target="_parent">' . "\n"
164 .PMA_generate_common_hidden_inputs() . "\n"
165 .PMA_RecentTable
::getInstance()->getHtmlSelect()
170 if (! $GLOBALS['server']) {
171 // no server selected
172 PMA_exitNavigationFrame();
173 } elseif (! count($GLOBALS['pma']->databases
)) {
174 // no database available, so we break here
175 echo '<p>' . __('No databases') . '</p>';
176 PMA_exitNavigationFrame();
177 } elseif ($GLOBALS['cfg']['LeftFrameLight'] && count($GLOBALS['pma']->databases
) > 1) {
178 $list = $cfg['DisplayDatabasesList'];
179 if ($list === 'auto') {
180 if (empty($GLOBALS['db'])) {
187 // more than one database available and LeftFrameLight is true
188 // display db selectbox
190 // Light mode -> beginning of the select combo for databases
191 // Note: When javascript is active, the frameset will be changed from
192 // within navigation.php. With no JS (<noscript>) the whole frameset will
193 // be rebuilt with the new target frame.
196 <div id
="databaseList">
197 <form method
="post" action
="index.php" target
="_parent" id
="left">
199 echo PMA_generate_common_hidden_inputs() . "\n";
200 echo $GLOBALS['pma']->databases
->getHtmlSelectGrouped(true, $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n"
204 echo $GLOBALS['pma']->databases
->getHtmlListGrouped(true, $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
206 $_url_params = array('pos' => $pos);
207 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
211 <div id
="left_tableList">
213 // Don't display expansible/collapsible database info if:
214 // 1. $GLOBALS['server'] == 0 (no server selected)
215 // This is the case when there are multiple servers and
216 // '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome
217 // screen to appear with no database info displayed.
218 // 2. there is only one database available (ie either only one database exists
219 // or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
220 // In this case, the database should not be collapsible/expandable
222 $img_plus = PMA_getImage('b_plus.png', '+', array('id' => 'el%dImg'));
223 $img_minus = PMA_getImage('b_minus.png', '-', array('id' => 'el%dImg'));
225 $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
226 .' href="navigation.php?%s" target="_self">';
228 $element_counter = 0;
231 if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
232 $table_list = PMA_getTableList($GLOBALS['db'], null, $tpos, $cfg['MaxTableList']);
233 $table_count = PMA_getTableCount($GLOBALS['db']);
235 // show selected databasename as link to DefaultTabDatabase-page
236 // with table count in ()
237 $common_url_query = PMA_generate_common_url($GLOBALS['db']);
241 if ($GLOBALS['cfg']['ShowTooltip']
242 && $GLOBALS['cfgRelation']['commwork']
244 $_db_tooltip = PMA_getDbComment($GLOBALS['db']);
246 $db_tooltip = $_db_tooltip;
250 $disp_name = $GLOBALS['db'];
251 if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
252 $disp_name = $db_tooltip;
253 $disp_name_cut = $db_tooltip;
254 $db_tooltip = $GLOBALS['db'];
257 if ($table_count >= $GLOBALS['cfg']['LeftDisplayTableFilterMinimum']) {
259 <span id
="NavFilter">
260 <span id
="clear_fast_filter" title
="<?php echo __('Clear'); ?>">X
</span
>
261 <input type
="text" class="gray" name
="fast_filter" id
="fast_filter" title
="<?php echo __('Filter tables by name'); ?>" value
="<?php echo __('Filter tables by name'); ?>" />
267 * This helps reducing the navi panel size; in the right panel,
268 * user can find a navigator to page thru all tables.
271 if (! empty($table_list)) {
272 // upper table list paginator
273 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
274 $_url_params = array(
277 'db' => $GLOBALS['db']
279 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
281 PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
282 // lower table list paginator
283 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) {
284 PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']);
287 echo __('No tables found in database.');
290 if (!PMA_is_system_schema($db)) {
292 $GLOBALS['cfg']['AjaxEnable'] ?
$class="ajax" : '';
293 echo '<ul id="newtable"><li><a target="frame_content" href="tbl_create.php' . PMA_generate_common_url(array('db' => $GLOBALS['db'])) . '" class="'.$class .'" >'
294 . PMA_getImage('b_snewtbl.png', _pgettext('short form', 'Create table'), array('id' => "icon_newtable"))
295 . _pgettext('short form', 'Create table') . '</a></li></ul>';
297 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
298 /* No need to tell user to select database if we're showing complete list */
300 echo '<p>' . __('Please select a database') . '</p>';
303 echo '<div id="databaseList">' . "\n";
304 $_url_params = array('pos' => $pos);
305 PMA_listNavigator(count($GLOBALS['pma']->databases
), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
306 echo '</div>' . "\n";
308 $common_url_query = PMA_generate_common_url();
309 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']);
313 * displays collapsable db list
315 * @global integer $element_counter
316 * @global string $img_minus
317 * @global string $img_plus
318 * @global string $href_left
319 * @global string $db_start
320 * @global string $common_url_query
321 * @param array $ext_dblist extended db list
322 * @param integer $offset
323 * @param integer $count
325 function PMA_displayDbList($ext_dblist, $offset, $count)
327 global $element_counter, $img_minus, $img_plus, $href_left,
328 $db_start, $common_url_query;
330 // get table list, for all databases
331 // doing this in one step takes advantage of a single query with information_schema!
332 $tables_full = PMA_DBI_get_tables_full($GLOBALS['pma']->databases
->getLimitedItems($offset, $count));
335 echo '<ul id="leftdatabaselist">';
336 $close_db_group = false;
337 foreach ($ext_dblist as $group => $db_group) {
338 if (count($GLOBALS['pma']->databases
) > 1) {
339 if ($close_db_group) {
343 $close_db_group = false;
345 if (count($db_group) > 1) {
346 $close_db_group = true;
347 $url_dbgroup = '&dbgroup=' . urlencode($group);
348 $common_url_query = PMA_generate_common_url() . $url_dbgroup;
350 echo '<li class="dbgroup">';
351 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
352 ||
$db_start == $group
353 ||
strpos($db_start, $group) === 0
355 // display + only if this db(group) is not preselected
356 printf($href_left, $element_counter, PMA_generate_common_url());
357 printf($img_minus, $element_counter);
359 printf($href_left, $element_counter, $common_url_query);
360 printf($img_plus, $element_counter);
362 echo '</a> ' . $group . "\n";
363 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
364 ||
$db_start == $group
365 ||
strpos($db_start, $group) === 0
367 echo '<ul id="subel' . $element_counter . '">' . "\n";
369 echo '<ul id="subel' . $element_counter . '"'
370 .' style="display: none">' . "\n";
374 foreach ($db_group as $db) {
375 $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup;
378 // Displays the database name
381 if (count($GLOBALS['pma']->databases
) > 1) {
382 // only with more than one db we need collapse ...
383 if ($db_start != $db['name'] ||
$db['num_tables'] < 1) {
384 // display + only if this db is not preselected
385 // or table count is 0
386 printf($href_left, $element_counter, $common_url_query);
387 printf($img_plus, $element_counter);
390 $href_left, $element_counter,
391 PMA_generate_common_url() . $url_dbgroup
393 printf($img_minus, $element_counter);
397 // ... and we need to refresh both frames on db selection
400 id
="<?php echo htmlspecialchars($db['name']); ?>"
401 href
="index.php?<?php echo $common_url_query; ?>"
403 title
="<?php echo htmlspecialchars($db['comment']); ?>"
405 if (! toggle('<?php echo $element_counter; ?>', true))
406 window.parent.goTo('navigation.php?<?php echo $common_url_query; ?>');
407 window.parent.goTo('<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
408 . '?' . $common_url_query; ?>', 'main');
411 // Might be unset if CountTables directive is false
412 if (isset($db['num_tables'])) {
413 if ($GLOBALS['text_dir'] === 'rtl') {
414 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
417 echo htmlspecialchars($db['disp_name']);
418 if (isset($db['num_tables'])) {
419 if ($GLOBALS['text_dir'] === 'ltr') {
420 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
427 // with only 1 db available we dont need to refresh navi frame
428 // on db selection, only phpmain
430 <a href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
431 . '?' . $common_url_query; ?>"
432 id
="<?php echo htmlspecialchars($db['name']); ?>"
433 title
="<?php echo htmlspecialchars($db['comment']); ?>">
435 if (isset($db['num_tables'])) {
436 if ($GLOBALS['text_dir'] === 'rtl') {
437 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
440 echo htmlspecialchars($db['disp_name']);
441 if (isset($db['num_tables'])) {
442 if ($GLOBALS['text_dir'] === 'ltr') {
443 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
450 if (($GLOBALS['cfg']['Server']['CountTables'] === false) ||
$db['num_tables']) {
451 if (isset($tables_full[$db['name']])) {
452 $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
453 } elseif (isset($tables_full[strtolower($db['name'])])) {
454 // on windows with lower_case_table_names = 1
456 // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
457 // but information_schema.TABLES gives `test`
459 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
460 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
462 $tables = PMA_getTableList($db['name']);
465 = (bool) (count($GLOBALS['pma']->databases
) === 1 ||
$db_start == $db['name']);
466 PMA_displayTableList($tables, $child_visible, '', $db['name']);
467 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
468 // no tables and LeftFrameLight:
469 // display message no tables in selected db
470 echo '<p>' . __('Please select a database') . '</p>' . "\n";
474 } // end foreach group
476 if ($close_db_group) {
480 $close_db_group = false;
487 * display unordered list of tables
488 * calls itself recursively if table in given list
491 * @global integer the element counter
492 * @global string html code for '-' image
493 * @global string html code for '+' image
494 * @global string html code for self link
495 * @param array $tables array of tables/tablegroups
496 * @param boolean $visible whether the list is visible or not
497 * @param string $tab_group_full full tab group name
498 * @param string $table_db db of this table
500 function PMA_displayTableList($tables, $visible = false,
501 $tab_group_full = '', $table_db = '')
503 if (! is_array($tables) ||
count($tables) === 0) {
507 global $element_counter, $img_minus, $img_plus, $href_left;
508 $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
511 echo '<ul id="subel' . $element_counter . '">';
513 echo '<ul id="subel' . $element_counter . '" style="display: none">';
515 foreach ($tables as $group => $table) {
516 // only allow grouping if the group has more than 1 table
517 if (isset($table['is' . $sep . 'group']) && $table['tab' . $sep . 'count'] > 1) {
518 $common_url_query = $GLOBALS['common_url_query']
519 . '&tbl_group=' . urlencode($tab_group_full . $group);
524 && ((isset($_REQUEST['tbl_group'])
525 && (strpos($_REQUEST['tbl_group'], $group) === 0
526 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
527 ||
strpos($GLOBALS['table'], $group) === 0)
530 $href_left, $element_counter,
531 $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)
570 PMA_displayTableList(
571 $table, true, $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 $attr = array('id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name']));
601 if (PMA_Table
::isView($table_db, $table['Name'])) {
602 echo PMA_getImage('s_views.png', htmlspecialchars($link_title), $attr);
604 echo PMA_getImage('b_browse.png', htmlspecialchars($link_title), $attr);
608 // link for the table name itself
609 $href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
610 .$GLOBALS['common_url_query'] . '&table='
611 .urlencode($table['Name']) . '&pos=0';
612 echo '<a href="' . $href . '" title="'
614 PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment']
615 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')'
617 .'" id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
618 // preserve spaces in table name
619 . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
626 echo '</div>' . "\n";
628 PMA_exitNavigationFrame();