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_getComments();
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 * @uses PMA_DBI_close()
56 * @access private only to be used in navigation.php
58 function PMA_exitNavigationFrame()
60 echo '</body></html>';
63 * Close MySQL connections
65 if (isset($GLOBALS['controllink']) && $GLOBALS['controllink']) {
66 @PMA_DBI_close
($GLOBALS['controllink']);
68 if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) {
69 @PMA_DBI_close
($GLOBALS['userlink']);
75 // free the session file, for the other frames to be loaded
76 session_write_close();
79 * the output compression library
81 require_once './libraries/ob.lib.php';
86 * selects the database if there is only one on current server
88 if ($GLOBALS['server'] && ! strlen($GLOBALS['db'])) {
89 $GLOBALS['db'] = $GLOBALS['PMA_List_Database']->getSingleItem();
92 $db_start = $GLOBALS['db'];
95 * the relation library
97 require_once './libraries/relation.lib.php';
98 $cfgRelation = PMA_getRelationsParam();
101 * garvin: For re-usability, moved http-headers to a seperate file.
102 * It can now be included by libraries/header.inc.php, querywindow.php.
104 require_once './libraries/header_http.inc.php';
109 // xml declaration moves IE into quirks mode, making much trouble with CSS
110 /* echo '<?xml version="1.0" encoding="' . $GLOBALS['charset'] . '"?>'; */
112 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
113 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
114 <html xmlns
="http://www.w3.org/1999/xhtml"
115 xml
:lang
="<?php echo $available_languages[$lang][2]; ?>"
116 lang
="<?php echo $available_languages[$lang][2]; ?>"
117 dir
="<?php echo $GLOBALS['text_dir']; ?>">
120 <link rel
="icon" href
="./favicon.ico" type
="image/x-icon" />
121 <link rel
="shortcut icon" href
="./favicon.ico" type
="image/x-icon" />
122 <title
>phpMyAdmin
</title
>
123 <meta http
-equiv
="Content-Type"
124 content
="text/html; charset=<?php echo $GLOBALS['charset']; ?>" />
125 <base target
="frame_content" />
126 <link rel
="stylesheet" type
="text/css"
127 href
="phpmyadmin.css.php?<?php echo PMA_generate_common_url('', ''); ?>&js_frame=left&nocache=<?php echo $_SESSION['PMA_Config']->getMtime(); ?>" />
128 <script type
="text/javascript" src
="js/navigation.js"></script
>
129 <script type
="text/javascript">
131 var image_minus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_minus.png';
132 var image_plus
= '<?php echo $GLOBALS['pmaThemeImage
']; ?>b_plus.png';
137 * remove horizontal scroll bar bug in IE 6 by forcing a vertical scroll bar
141 <style type
="text/css">
151 <body id
="body_leftFrame" onload
="PMA_setFrameSize();" onresize
="PMA_saveFrameSize();">
153 require './libraries/navigation_header.inc.php';
154 if (! $GLOBALS['server']) {
155 // no server selected
156 PMA_exitNavigationFrame();
157 } elseif (! $GLOBALS['PMA_List_Database']->count()) {
158 // no database available, so we break here
159 echo '<p>' . $GLOBALS['strNoDatabases'] . '</p>';
160 PMA_exitNavigationFrame();
161 } elseif ($GLOBALS['cfg']['LeftFrameLight'] && $GLOBALS['PMA_List_Database']->count() > 1) {
162 $list = $cfg['DisplayDatabasesList'];
163 if ($list === 'auto') {
164 if (empty($GLOBALS['db'])) {
171 // more than one database available and LeftFrameLight is true
172 // display db selectbox
174 // Light mode -> beginning of the select combo for databases
175 // Note: When javascript is active, the frameset will be changed from
176 // within navigation.php. With no JS (<noscript>) the whole frameset will
177 // be rebuilt with the new target frame.
180 <div id
="databaseList">
181 <form method
="post" action
="index.php" target
="_parent" id
="left">
182 <label
for="lightm_db"><?php
echo $GLOBALS['strDatabase']; ?
></label
>
184 echo PMA_generate_common_hidden_inputs() . "\n";
185 echo $GLOBALS['PMA_List_Database']->getHtmlSelectGrouped(true) . "\n";
186 echo '<noscript>' . "\n"
187 .'<input type="submit" name="Go" value="' . $GLOBALS['strGo'] . '" />' . "\n"
188 .'</noscript>' . "\n"
192 echo $GLOBALS['PMA_List_Database']->getHtmlListGrouped(true) . "\n";
197 <div id
="left_tableList">
199 // Don't display expansible/collapsible database info if:
200 // 1. $GLOBALS['server'] == 0 (no server selected)
201 // This is the case when there are multiple servers and
202 // '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome
203 // screen to appear with no database info displayed.
204 // 2. there is only one database available (ie either only one database exists
205 // or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
206 // In this case, the database should not be collapsible/expandable
208 $img_plus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_plus.png"'
209 .' width="9" height="9" alt="+" />';
210 $img_minus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_minus.png"'
211 .' width="9" height="9" alt="-" />';
213 $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
214 .' href="navigation.php?%s" target="_self">';
216 $element_counter = 0;
218 if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
219 // show selected databasename as link to DefaultTabDatabase-page
220 // with table count in ()
221 $common_url_query = PMA_generate_common_url($GLOBALS['db']);
225 if ($GLOBALS['cfg']['ShowTooltip']
226 && $GLOBALS['cfgRelation']['commwork']) {
227 $_db_tooltip = PMA_getComments($GLOBALS['db']);
228 if (is_array($_db_tooltip)) {
229 $db_tooltip = implode(' ', $_db_tooltip);
233 $disp_name = $GLOBALS['db'];
234 if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
235 $disp_name = $db_tooltip;
236 $disp_name_cut = $db_tooltip;
237 $db_tooltip = $GLOBALS['db'];
242 href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?>"
243 title
="<?php echo htmlspecialchars($db_tooltip); ?>" >
245 if ($GLOBALS['text_dir'] === 'rtl') {
246 echo ' <bdo dir="ltr">(' . PMA_getTableCount($GLOBALS['db']) . ')</bdo> ';
248 echo htmlspecialchars($disp_name);
249 if ($GLOBALS['text_dir'] === 'ltr') {
250 echo ' <bdo dir="ltr">(' . PMA_getTableCount($GLOBALS['db']) . ')</bdo> ';
254 $table_list = PMA_getTableList($GLOBALS['db']);
255 if (count($table_list) > 0) {
256 PMA_displayTableList($table_list, true, '', $GLOBALS['db']);
258 echo $GLOBALS['strNoTablesFound'];
261 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
262 echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
264 $common_url_query = PMA_generate_common_url();
265 PMA_displayDbList($GLOBALS['PMA_List_Database']->getGroupedDetails());
269 * displays collapsable db list
271 * @uses $_REQUEST['dbgroup']
272 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
273 * @uses $GLOBALS['strSelectADb']
277 * @uses htmlspecialchars()
278 * @uses PMA_generate_common_url()
279 * @uses PMA_getTableList()
280 * @uses PMA_displayTableList()
281 * @global $element_counter
286 * @global $common_url_query
287 * @param array $ext_dblist extended db list
289 function PMA_displayDbList($ext_dblist) {
290 global $element_counter, $img_minus, $img_plus, $href_left,
291 $db_start, $common_url_query;
293 // get table list, for all databases
294 // doing this in one step takes advantage of a single query with information_schema!
295 $tables_full = PMA_DBI_get_tables_full($GLOBALS['PMA_List_Database']->items
);
298 echo '<ul id="leftdatabaselist">';
299 $close_db_group = false;
300 foreach ($ext_dblist as $group => $db_group) {
301 if ($GLOBALS['PMA_List_Database']->count() > 1) {
302 if ($close_db_group) {
306 $close_db_group = false;
308 if (count($db_group) > 1) {
309 $close_db_group = true;
310 $url_dbgroup = '&dbgroup=' . urlencode($group);
311 $common_url_query = PMA_generate_common_url() . $url_dbgroup;
313 echo '<li class="dbgroup">';
314 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
315 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
316 // display + only if this db(group) is not preselected
317 printf($href_left, $element_counter, PMA_generate_common_url());
318 printf($img_minus, $element_counter);
320 printf($href_left, $element_counter, $common_url_query);
321 printf($img_plus, $element_counter);
323 echo '</a> ' . $group . "\n";
324 if ((! empty($_REQUEST['dbgroup']) && $_REQUEST['dbgroup'] == $group)
325 ||
$db_start == $group ||
strpos($db_start, $group) === 0) {
326 echo '<ul id="subel' . $element_counter . '">' . "\n";
328 echo '<ul id="subel' . $element_counter . '"'
329 .' style="display: none">' . "\n";
333 foreach ($db_group as $db) {
334 $common_url_query = PMA_generate_common_url($db['name']) . $url_dbgroup;
337 // Displays the database name
340 if ($GLOBALS['PMA_List_Database']->count() > 1) {
341 // only with more than one db we need collapse ...
342 if ($db_start != $db['name'] ||
$db['num_tables'] < 1) {
343 // display + only if this db is not preselected
344 // or table count is 0
345 printf($href_left, $element_counter, $common_url_query);
346 printf($img_plus, $element_counter);
348 printf($href_left, $element_counter,
349 PMA_generate_common_url() . $url_dbgroup);
350 printf($img_minus, $element_counter);
354 // ... and we need to refresh both frames on db selection
357 id
="<?php echo htmlspecialchars($db['name']); ?>"
358 href
="index.php?<?php echo $common_url_query; ?>"
360 title
="<?php echo htmlspecialchars($db['comment']); ?>"
362 if (! toggle('<?php echo $element_counter; ?>', true))
363 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
364 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
365 . '?' . $common_url_query; ?>', 'main');
368 if ($GLOBALS['text_dir'] === 'rtl') {
369 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
371 echo htmlspecialchars($db['disp_name']);
372 if ($GLOBALS['text_dir'] === 'ltr') {
373 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
379 // with only 1 db available we dont need to refresh left frame
380 // on db selection, only phpmain
382 <a href
="<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
383 . '?' . $common_url_query; ?>"
384 id
="<?php echo htmlspecialchars($db['name']); ?>"
385 title
="<?php echo htmlspecialchars($db['comment']); ?>">
387 if ($GLOBALS['text_dir'] === 'rtl') {
388 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
390 echo htmlspecialchars($db['disp_name']);
391 if ($GLOBALS['text_dir'] === 'ltr') {
392 echo ' <bdo dir="ltr">(' . $db['num_tables'] . ')</bdo> ';
398 if ($db['num_tables']) {
399 if (isset($tables_full[$db['name']])) {
400 $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]);
401 } elseif (isset($tables_full[strtolower($db['name'])])) {
402 // on windows with lower_case_table_names = 1
404 // with SHOW DATABASES or information_schema.SCHEMATA: `Test`
405 // but information_schema.TABLES gives `test`
407 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
408 $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]);
410 $tables = PMA_getTableList($db['name']);
413 (bool) ($GLOBALS['PMA_List_Database']->count() === 1 ||
$db_start == $db['name']);
414 PMA_displayTableList($tables, $child_visible, '', $db['name']);
415 } elseif ($GLOBALS['cfg']['LeftFrameLight']) {
416 // no tables and LeftFrameLight:
417 // display message no tables in selected db
418 echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
422 } // end foreach group
424 if ($close_db_group) {
428 $close_db_group = false;
435 * display unordered list of tables
436 * calls itself recursively if table in given list
444 * @uses htmlspecialchars()
447 * @uses PMA_displayTableList()
448 * @uses $_REQUEST['tbl_group']
449 * @uses $GLOBALS['common_url_query']
450 * @uses $GLOBALS['table']
451 * @uses $GLOBALS['pmaThemeImage']
452 * @uses $GLOBALS['cfg']['LeftFrameTableSeparator']
453 * @uses $GLOBALS['cfg']['DefaultTabDatabase']
454 * @uses $GLOBALS['cfg']['DefaultTabTable']
455 * @uses $GLOBALS['strRows']
456 * @uses $GLOBALS['strBrowse']
457 * @global integer the element counter
458 * @global string html code for '-' image
459 * @global string html code for '+' image
460 * @global string html code for self link
461 * @param array $tables array of tables/tablegroups
462 * @param boolean $visible wether the list is visible or not
463 * @param string $tab_group_full full tab group name
464 * @param string $table_db db of this table
466 function PMA_displayTableList($tables, $visible = false,
467 $tab_group_full = '', $table_db = '')
469 if (! is_array($tables) ||
count($tables) === 0) {
473 global $element_counter, $img_minus, $img_plus, $href_left;
474 $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
477 echo '<ul id="subel' . $element_counter . '">';
479 echo '<ul id="subel' . $element_counter . '" style="display: none">';
481 foreach ($tables as $group => $table) {
482 if (isset($table['is' . $sep . 'group'])) {
483 $common_url_query = $GLOBALS['common_url_query']
484 . '&tbl_group=' . urlencode($tab_group_full . $group);
489 && ((isset($_REQUEST['tbl_group'])
490 && (strpos($_REQUEST['tbl_group'], $group) === 0
491 ||
strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
492 ||
strpos($GLOBALS['table'], $group) === 0)) {
493 printf($href_left, $element_counter,
494 $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full);
495 printf($img_minus, $element_counter);
497 printf($href_left, $element_counter, $common_url_query);
498 printf($img_plus, $element_counter);
502 <a href
="index.php?<?php echo $common_url_query; ?>"
505 if (! toggle('<?php echo $element_counter; ?>', true))
506 window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?>');
507 window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase']
508 . '?' . $common_url_query; ?>', 'main');
511 if ($GLOBALS['text_dir'] === 'rtl') {
512 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
514 echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
515 if ($GLOBALS['text_dir'] === 'ltr') {
516 echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
522 unset($table['is' . $sep . 'group']);
523 unset($table['tab' . $sep . 'group']);
524 unset($table['tab' . $sep . 'count']);
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 PMA_displayTableList($table, true,
532 $tab_group_full . $group, $table_db);
534 PMA_displayTableList($table, false, '', $table_db);
537 } elseif (is_array($table)) {
538 $href = $GLOBALS['cfg']['DefaultTabTable'] . '?'
539 .$GLOBALS['common_url_query'] . '&table='
540 .urlencode($table['Name']);
542 echo '<a title="' . $GLOBALS['strBrowse'] . ': '
543 . htmlspecialchars($table['Comment'])
544 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')"'
545 .' id="browse_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
546 .' href="sql.php?' . $GLOBALS['common_url_query']
547 .'&table=' . urlencode($table['Name'])
548 .'&goto=' . $GLOBALS['cfg']['DefaultTabTable']
550 .'<img class="icon"';
551 if ('VIEW' === strtoupper($table['Comment'])) {
552 echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"';
554 echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"';
556 echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
557 .' width="10" height="10" alt="' . $GLOBALS['strBrowse'] . '" /></a>' . "\n"
558 .'<a href="' . $href . '" title="' . htmlspecialchars($table['Comment']
559 .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows']) . ')"'
560 .' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
561 // preserve spaces in table name
562 . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>';
570 PMA_exitNavigationFrame();