Merge remote-tracking branch 'origin/master'
[phpmyadmin.git] / db_printview.php
blob61676d686fae1b750b22dbda7be15942b979c24b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Print view of a database
6 * @package PhpMyAdmin
7 */
9 /**
12 require_once 'libraries/common.inc.php';
13 require_once 'libraries/db_printview.lib.php';
15 $response = PMA_Response::getInstance();
16 $header = $response->getHeader();
17 $header->enablePrintView();
19 PMA_Util::checkParameters(array('db'));
21 /**
22 * Defines the url to return to in case of error in a sql statement
24 $err_url = 'db_sql.php' . PMA_URL_getCommon(array('db' => $db));
26 /**
27 * Settings for relations stuff
29 $cfgRelation = PMA_getRelationsParam();
31 /**
32 * If there is at least one table, displays the printer friendly view, else
33 * an error message
35 $tables = $GLOBALS['dbi']->getTablesFull($db);
36 $num_tables = count($tables);
38 echo '<br />';
40 // 1. No table
41 if ($num_tables == 0) {
42 echo __('No tables found in database.');
43 } else {
44 // 2. Shows table information
45 echo '<table>';
46 echo '<thead>';
47 echo '<tr>';
48 echo '<th>' . __('Table') . '</th>';
49 echo '<th>' . __('Rows') . '</th>';
50 echo '<th>' . __('Type') . '</th>';
51 if ($cfg['ShowStats']) {
52 echo '<th>' . __('Size') . '</th>';
54 echo '<th>' . __('Comments') . '</th>';
55 echo '</tr>';
56 echo '</thead>';
57 echo '<tbody>';
58 $sum_entries = $sum_size = 0;
59 $odd_row = true;
60 foreach ($tables as $sts_data) {
61 if (PMA_Table::isMerge($db, $sts_data['TABLE_NAME'])
62 || /*overload*/mb_strtoupper($sts_data['ENGINE']) == 'FEDERATED'
63 ) {
64 $merged_size = true;
65 } else {
66 $merged_size = false;
68 $sum_entries += $sts_data['TABLE_ROWS'];
69 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
70 echo '<th>';
71 echo htmlspecialchars($sts_data['TABLE_NAME']);
72 echo '</th>';
74 if (isset($sts_data['TABLE_ROWS'])) {
75 echo '<td class="right">';
76 if ($merged_size) {
77 echo '<i>';
78 echo PMA_Util::formatNumber($sts_data['TABLE_ROWS'], 0);
79 echo '</i>';
80 } else {
81 echo PMA_Util::formatNumber($sts_data['TABLE_ROWS'], 0);
83 echo '</td>';
84 echo '<td class="nowrap">';
85 echo $sts_data['ENGINE'];
86 echo '</td>';
87 if ($cfg['ShowStats']) {
88 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
89 $sum_size += $tblsize;
90 list($formated_size, $unit)
91 = PMA_Util::formatByteDown($tblsize, 3, 1);
92 echo '<td class="right nowrap">';
93 echo $formated_size . ' ' . $unit;
94 echo '</td>';
95 } // end if
96 } else {
97 echo '<td colspan="3" class="center">';
98 if (! PMA_Table::isView($db, $sts_data['TABLE_NAME'])) {
99 echo __('in use');
101 echo '</td>';
103 echo '<td>';
104 if (! empty($sts_data['Comment'])) {
105 echo htmlspecialchars($sts_data['Comment']);
106 $needs_break = '<br />';
107 } else {
108 $needs_break = '';
111 if (! empty($sts_data['Create_time'])
112 || ! empty($sts_data['Update_time'])
113 || ! empty($sts_data['Check_time'])
115 echo $needs_break;
116 echo '<table width="100%">';
118 if (! empty($sts_data['Create_time'])) {
119 echo PMA_getHtmlForOneDate(
120 __('Creation:'),
121 $sts_data['Create_time']
125 if (! empty($sts_data['Update_time'])) {
126 echo PMA_getHtmlForOneDate(
127 __('Last update:'),
128 $sts_data['Update_time']
132 if (! empty($sts_data['Check_time'])) {
133 echo PMA_getHtmlForOneDate(
134 __('Last check:'),
135 $sts_data['Check_time']
138 echo '</table>';
140 echo '</td>';
141 echo '</tr>';
143 echo '<tr>';
144 echo '<th class="center">';
145 printf(
146 _ngettext('%s table', '%s tables', $num_tables),
147 PMA_Util::formatNumber($num_tables, 0)
149 echo '</th>';
150 echo '<th class="right nowrap">';
151 echo PMA_Util::formatNumber($sum_entries, 0);
152 echo '</th>';
153 echo '<th class="center">';
154 echo '--';
155 echo '</th>';
156 if ($cfg['ShowStats']) {
157 list($sum_formated, $unit)
158 = PMA_Util::formatByteDown($sum_size, 3, 1);
159 echo '<th class="right nowrap">';
160 echo $sum_formated . ' ' . $unit;
161 echo '</th>';
163 echo '<th></th>';
164 echo '</tr>';
165 echo '</tbody>';
166 echo '</table>';
170 * Displays the footer
172 echo PMA_Util::getButton();
174 echo "<div id='PMA_disable_floating_menubar'></div>\n";