2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * the navigation frame - displays server, db and table selection tree
7 * @uses $GLOBALS['PMA_List_Database']
8 * @uses $GLOBALS['server']
10 * @uses $GLOBALS['table']
11 * @uses $GLOBALS['available_languages']
12 * @uses $GLOBALS['lang']
13 * @uses $GLOBALS['text_dir']
14 * @uses $GLOBALS['charset']
15 * @uses $GLOBALS['pmaThemeImage']
16 * @uses $GLOBALS['strNoDatabases']
17 * @uses $GLOBALS['strDatabase']
18 * @uses $GLOBALS['strGo']
19 * @uses $GLOBALS['strSelectADb']
20 * @uses $GLOBALS['strNoTablesFound']
21 * @uses $GLOBALS['cfg']['LeftFrameLight']
22 * @uses $GLOBALS['cfg']['ShowTooltip']
23 * @uses $GLOBALS['cfg']['ShowTooltipAliasDB']
24 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
25 * @uses $GLOBALS['cfgRelation']['commwork']) {
26 * @uses PMA_List_Database::getSingleItem()
27 * @uses PMA_List_Database::count()
28 * @uses PMA_List_Database::getHtmlSelectGrouped()
29 * @uses PMA_List_Database::getGroupedDetails()
30 * @uses PMA_generate_common_url()
31 * @uses PMA_generate_common_hidden_inputs()
32 * @uses PMA_getDbComment();
33 * @uses PMA_getTableCount()
34 * @uses PMA_getTableList()
35 * @uses PMA_getRelationsParam()
36 * @uses PMA_outBufferPre()
37 * @uses session_write_close()
39 * @uses session_write_close()
42 * @uses htmlspecialchars()
46 * Gets a core script and starts output buffering work
48 require_once './libraries/common.inc.php';
51 * finish and cleanup navigation.php script execution
53 * @uses $GLOBALS['controllink'] to close it
54 * @uses $GLOBALS['userlink'] to close it
55 * @access private only to be used in navigation.php
57 function PMA_exitNavigationFrame()
59 echo '</body></html>';
63 // keep the offset of the db list in session before closing it
64 if (! isset($_SESSION['navi_limit_offset'])) {
65 $_SESSION['navi_limit_offset'] = 0;
67 if (isset($_REQUEST['pos'])) {
68 $_SESSION['navi_limit_offset'] = (int) $_REQUEST['pos'];
70 $pos = $_SESSION['navi_limit_offset'];
72 // free the session file, for the other frames to be loaded
73 session_write_close();
76 * the output compression library
78 require_once './libraries/ob.lib.php';
83 * selects the database if there is only one on current server
85 if ($GLOBALS['server'] && ! strlen($GLOBALS['db'])) {
86 $GLOBALS['db'] = $GLOBALS['PMA_List_Database']->getSingleItem();
89 $db_start = $GLOBALS['db'];
92 * the relation library
94 require_once './libraries/relation.lib.php';
95 $cfgRelation = PMA_getRelationsParam();
98 * garvin: For re-usability, moved http-headers to a seperate file.
99 * It can now be included by libraries/header.inc.php, querywindow.php.
101 require_once './libraries/header_http.inc.php';
103 if (! isset($_SESSION['navi_limit_offset'])) {
104 $_SESSION['navi_limit_offset'] = 0;
106 if (isset($_REQUEST['pos'])) {
107 $_SESSION['navi_limit_offset'] = (int) $_REQUEST['pos'];
109 $pos = $_SESSION['navi_limit_offset'];
114 // xml declaration moves IE into quirks mode, making much trouble with CSS
115 /* echo '<?xml version="1.0" encoding="' . $GLOBALS['charset'] . '"?>'; */
117 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
118 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
119 <html xmlns
="http://www.w3.org/1999/xhtml"
120 xml
:lang
="<?php echo $available_languages[$lang][2]; ?>"
121 lang
="<?php echo $available_languages[$lang][2]; ?>"
122 dir
="<?php echo $GLOBALS['text_dir']; ?>">
125 <link rel
="icon" href
="./favicon.ico" type
="image/x-icon" />
126 <link rel
="shortcut icon" href
="./favicon.ico" type
="image/x-icon" />
127 <title
>phpMyAdmin
</title
>
128 <meta http
-equiv
="Content-Type"
129 content
="text/html; charset=<?php echo $GLOBALS['charset']; ?>" />
130 <base target
="frame_content" />
131 <link rel
="stylesheet" type
="text/css"
132 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=left&nocache=<?php echo $_SESSION['PMA_Config']->getMtime(); ?>" />
133 <script type
="text/javascript" src
="js/navigation.js"></script
>
134 <script type
="text/javascript" src
="js/functions.js"></script
>
135 <script type
="text/javascript">
137 var image_minus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_minus.png';
138 var image_plus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_plus.png';
143 * remove horizontal scroll bar bug in IE 6 by forcing a vertical scroll bar
147 <style type
="text/css">
157 <body id
="body_leftFrame" onload
="PMA_setFrameSize();" onresize
="PMA_saveFrameSize();">
159 require './libraries/navigation_header.inc.php';
160 if (! $GLOBALS['server']) {
161 // no server selected
162 PMA_exitNavigationFrame();
163 } elseif (! $GLOBALS['PMA_List_Database']->count()) {
164 // no database available, so we break here
165 echo '<p>' . $GLOBALS['strNoDatabases'] . '</p>';
166 PMA_exitNavigationFrame();
167 } elseif ($GLOBALS['cfg']['LeftFrameLight'] && $GLOBALS['PMA_List_Database']->count() > 1) {
168 $list = $cfg['DisplayDatabasesList'];
169 if ($list === 'auto') {
170 if (empty($GLOBALS['db'])) {
177 // more than one database available and LeftFrameLight is true
178 // display db selectbox
180 // Light mode -> beginning of the select combo for databases
181 // Note: When javascript is active, the frameset will be changed from
182 // within navigation.php. With no JS (<noscript>) the whole frameset will
183 // be rebuilt with the new target frame.
186 <div id
="databaseList">
187 <form method
="post" action
="index.php" target
="_parent" id
="left">
188 <label
for="lightm_db"><?php
echo $GLOBALS['strDatabase']; ?
></label
>
190 echo PMA_generate_common_hidden_inputs() . "\n";
191 echo $GLOBALS['PMA_List_Database']->getHtmlSelectGrouped(true, $_SESSION['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
192 echo '<noscript>' . "\n"
193 .'<input type="submit" name="Go" value="' . $GLOBALS['strGo'] . '" />' . "\n"
194 .'</noscript>' . "\n"
198 echo '<div id="databaseList">' . "\n";
200 echo $GLOBALS['PMA_List_Database']->getHtmlListGrouped(true, $_SESSION['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
202 $_url_params = array('pos' => $pos);
203 PMA_listNavigator($GLOBALS['PMA_List_Database']->count(), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
205 echo '</div>' . "\n";
210 <div id
="left_tableList">
212 // Don't display expansible/collapsible database info if:
213 // 1. $GLOBALS['server'] == 0 (no server selected)
214 // This is the case when there are multiple servers and
215 // '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome
216 // screen to appear with no database info displayed.
217 // 2. there is only one database available (ie either only one database exists
218 // or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
219 // In this case, the database should not be collapsible/expandable
221 $img_plus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_plus.png"'
222 .' width="9" height="9" alt="+" />';
223 $img_minus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_minus.png"'
224 .' width="9" height="9" alt="-" />';
226 $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
227 .' href="navigation.php?%s" target="_self">';
229 $element_counter = 0;
231 if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
232 // show selected databasename as link to DefaultTabDatabase-page
233 // with table count in ()
234 $common_url_query = PMA_generate_common_url($GLOBALS['db']);
238 if ($GLOBALS['cfg']['ShowTooltip']
239 && $GLOBALS['cfgRelation']['commwork']) {
240 $_db_tooltip = PMA_getDbComment($GLOBALS['db']);
242 $db_tooltip = $_db_tooltip;
246 $disp_name = $GLOBALS['db'];
247 if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
248 $disp_name = $db_tooltip;
249 $disp_name_cut = $db_tooltip;
250 $db_tooltip = $GLOBALS['db'];
255 href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?>"
256 title
="<?php echo htmlspecialchars($db_tooltip); ?>" >
258 if ($GLOBALS['text_dir'] === 'rtl') {
259 echo ' <bdo dir="ltr">(' . PMA_getTableCount($GLOBALS['db']) . ')</bdo> ';
261 echo '<span class="navi_dbName">' . htmlspecialchars($disp_name) . '</span>';
262 if ($GLOBALS['text_dir'] === 'ltr') {
263 echo ' <bdo dir="ltr">(' . PMA_getTableCount($GLOBALS['db']) . ')</bdo> ';
268 * This helps reducing the navi panel size; in the right panel,
269 * user can find a navigator to page thru all tables.
271 * @todo instead of the 0 parameter, keep track of the
272 * offset in the list of tables ($_SESSION['navi_table_limit_offset'])
273 * and use PMA_listNavigator(); do not just check pos in REQUEST
274 * but add another hidden param to see if it's the pos of databases
275 * or the pos of tables.
277 $table_list = PMA_getTableList($GLOBALS['db'], null, 0, $cfg['MaxTableList']);
278 if (! empty($table_list)) {
279 PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
280 // hint user that the table list is larger, until the todo is done
281 if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && PMA_getTableCount($GLOBALS['db']) > $GLOBALS['cfg']['MaxTableList']) {
282 echo ' ( 1 .. ', $GLOBALS['cfg']['MaxTableList'], ' / ', PMA_getTableCount($GLOBALS['db']), ' )';
285 echo $GLOBALS['strNoTablesFound'];
288 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
289 echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
291 echo '<div id="databaseList">' . "\n";
292 $_url_params = array('pos' => $pos);
293 PMA_listNavigator($GLOBALS['PMA_List_Database']->count(), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
294 echo '</div>' . "\n";
296 $common_url_query = PMA_generate_common_url();
297 PMA_displayDbList($GLOBALS['PMA_List_Database']->getGroupedDetails($_SESSION['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']), $_SESSION['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']);
301 * displays collapsable db list
303 * @uses $_REQUEST['dbgroup']
304 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
305 * @uses $GLOBALS['strSelectADb']
309 * @uses htmlspecialchars()
310 * @uses PMA_generate_common_url()
311 * @uses PMA_getTableList()
312 * @uses PMA_displayTableList()
313 * @global $element_counter
318 * @global $common_url_query
319 * @param array $ext_dblist extended db list
320 * @param integer $offset
321 * @param integer $count
323 function PMA_displayDbList($ext_dblist, $offset, $count) {
324 global $element_counter, $img_minus, $img_plus, $href_left,
325 $db_start, $common_url_query;
327 // get table list, for all databases
328 // doing this in one step takes advantage of a single query with information_schema!
329 $tables_full = PMA_DBI_get_tables_full($GLOBALS['PMA_List_Database']->getLimitedItems($offset, $count));
332 echo '<ul id="leftdatabaselist">';
333 $close_db_group = false;
334 foreach ($ext_dblist as $group => $db_group) {
335 if ($GLOBALS['PMA_List_Database']->count() > 1) {
336 if ($close_db_group) {
340 $close_db_group = false;
342 if (count($db_group) > 1) {
343 $close_db_group = true;
344 $url_dbgroup = '&dbgroup=' . urlencode($group);
345 $common_url_query = PMA_generate_common_url() . $url_dbgroup;
347 echo '<li class="dbgroup">';
348 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
349 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
350 // display + only if this db(group) is not preselected
351 printf($href_left, $element_counter, PMA_generate_common_url());
352 printf($img_minus, $element_counter);
354 printf($href_left, $element_counter, $common_url_query);
355 printf($img_plus, $element_counter);
357 echo '</a> ' . $group . "\n";
358 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
359 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
360 echo '<ul id="subel' . $element_counter . '">' . "\n";
362 echo '<ul id="subel' . $element_counter . '"'
363 .' style="display: none">' . "\n";
367 foreach ($db_group as $db) {
368 $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup;
371 // Displays the database name
374 if ($GLOBALS['PMA_List_Database']->count() > 1) {
375 // only with more than one db we need collapse ...
376 if ($db_start != $db['name'] ||
$db['num_tables'] < 1) {
377 // display + only if this db is not preselected
378 // or table count is 0
379 printf($href_left, $element_counter, $common_url_query);
380 printf($img_plus, $element_counter);
382 printf($href_left, $element_counter,
383 PMA_generate_common_url() . $url_dbgroup);
384 printf($img_minus, $element_counter);
388 // ... and we need to refresh both frames on db selection
391 id
="<?php echo htmlspecialchars($db['name']); ?>"
392 href
="index.php?<?php echo $common_url_query; ?>"
394 title
="<?php echo htmlspecialchars($db['comment']); ?>"
396 if (! toggle('<?php echo $element_counter; ?>', true))
397 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
398 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
399 . '?' . $common_url_query; ?>', 'main');
402 if ($GLOBALS['text_dir'] === 'rtl') {
403 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
405 echo htmlspecialchars($db['disp_name']);
406 if ($GLOBALS['text_dir'] === 'ltr') {
407 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
413 // with only 1 db available we dont need to refresh left frame
414 // on db selection, only phpmain
416 <a href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
417 . '?' . $common_url_query; ?>"
418 id
="<?php echo htmlspecialchars($db['name']); ?>"
419 title
="<?php echo htmlspecialchars($db['comment']); ?>">
421 if ($GLOBALS['text_dir'] === 'rtl') {
422 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
424 echo htmlspecialchars($db['disp_name']);
425 if ($GLOBALS['text_dir'] === 'ltr') {
426 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
432 if ($db['num_tables']) {
433 if (isset($tables_full[$db['name']])) {
434 $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
435 } elseif (isset($tables_full[strtolower($db['name'])])) {
436 // on windows with lower_case_table_names = 1
438 // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
439 // but information_schema.TABLES gives `test`
441 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
442 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
444 $tables = PMA_getTableList($db['name']);
447 (bool) ($GLOBALS['PMA_List_Database']->count() === 1 ||
$db_start == $db['name']);
448 PMA_displayTableList($tables, $child_visible, '', $db['name']);
449 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
450 // no tables and LeftFrameLight:
451 // display message no tables in selected db
452 echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
456 } // end foreach group
458 if ($close_db_group) {
462 $close_db_group = false;
469 * display unordered list of tables
470 * calls itself recursively if table in given list
478 * @uses htmlspecialchars()
481 * @uses PMA_displayTableList()
482 * @uses $_REQUEST['tbl_group']
483 * @uses $GLOBALS['common_url_query']
484 * @uses $GLOBALS['table']
485 * @uses $GLOBALS['pmaThemeImage']
486 * @uses $GLOBALS['cfg']['LeftFrameTableSeparator']
487 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
488 * @uses $GLOBALS['cfg']['DefaultTabTable']
489 * @uses $GLOBALS['strRows']
490 * @uses $GLOBALS['strBrowse']
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 wether 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 if (isset($table['is' . $sep . 'group'])) {
517 $common_url_query = $GLOBALS['common_url_query']
518 . '&tbl_group=' . urlencode($tab_group_full . $group);
523 && ((isset($_REQUEST['tbl_group'])
524 && (strpos($_REQUEST['tbl_group'], $group) === 0
525 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
526 ||
strpos($GLOBALS['table'], $group) === 0)) {
527 printf($href_left, $element_counter,
528 $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full);
529 printf($img_minus, $element_counter);
531 printf($href_left, $element_counter, $common_url_query);
532 printf($img_plus, $element_counter);
536 <a href
="index.php?<?php echo $common_url_query; ?>"
539 if (! toggle('<?php echo $element_counter; ?>', true))
540 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
541 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
542 . '?' . $common_url_query; ?>', 'main');
545 if ($GLOBALS['text_dir'] === 'rtl') {
546 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
548 echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
549 if ($GLOBALS['text_dir'] === 'ltr') {
550 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
556 unset($table['is' . $sep . 'group']);
557 unset($table['tab' . $sep . 'group']);
558 unset($table['tab' . $sep . 'count']);
561 ((isset($_REQUEST['tbl_group'])
562 && (strpos($_REQUEST['tbl_group'], $group) === 0
563 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
564 ||
strpos($GLOBALS['table'], $group) === 0)) {
565 PMA_displayTableList($table, true,
566 $tab_group_full . $group, $table_db);
568 PMA_displayTableList($table, false, '', $table_db);
571 } elseif (is_array($table)) {
572 // quick access icon next to each table name
575 . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']))
576 . ': ' . htmlspecialchars($table['Comment'])
577 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')"'
578 .' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
579 .' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
580 . $GLOBALS['common_url_query']
581 .'&table=' . urlencode($table['Name'])
582 .'&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable']
584 .'<img class="icon"';
585 if ('VIEW' === strtoupper($table['Comment'])) {
586 echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"';
588 echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"';
590 echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
591 .' width="10" height="10" alt="' . $GLOBALS['strBrowse'] . '" /></a>' . "\n";
593 // link for the table name itself
594 $href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
595 .$GLOBALS['common_url_query'] . '&table='
596 .urlencode($table['Name']);
597 echo '<a href="' . $href
598 . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment']
599 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows']) . ')"'
600 .' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
601 // preserve spaces in table name
602 . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
610 * get the action word corresponding to a script name
611 * in order to display it as a title in navigation panel
615 * @param string a valid value for $cfg['LeftDefaultTabTable']
616 * or $cfg['DefaultTabTable']
618 function PMA_getTitleForTarget($target) {
620 case 'tbl_structure.php':
621 $message = 'strStructure';
626 case 'tbl_select.php':
627 $message = 'strSearch';
629 case 'tbl_change.php':
630 $message = 'strInsert';
633 $message = 'strBrowse';
638 return $GLOBALS[$message];
641 echo '</div>' . "\n";
643 PMA_exitNavigationFrame();