Translation update done using Pootle.
[phpmyadmin/last10db.git] / db_printview.php
blob36f297c99404e1a1d6c1e6f107588dd1797a4d18
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 /**
11 require_once './libraries/common.inc.php';
13 /**
14 * Gets the variables sent or posted to this script, then displays headers
16 $print_view = true;
17 require_once './libraries/header.inc.php';
19 PMA_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_generate_common_url($db);
26 /**
27 * Settings for relations stuff
29 $cfgRelation = PMA_getRelationsParam();
31 /**
32 * Gets the list of the table in the current db and informations about these
33 * tables if possible
35 * @todo merge this speedup _optionaly_ into PMA_DBI_get_tables_full()
37 // speedup view on locked tables
38 // Special speedup for newer MySQL Versions (in 4.0 format changed)
39 if ($cfg['SkipLockedTables'] == true) {
40 $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
41 // Blending out tables in use
42 if ($result != false && PMA_DBI_num_rows($result) > 0) {
43 while ($tmp = PMA_DBI_fetch_row($result)) {
44 // if in use memorize tablename
45 if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
46 $sot_cache[$tmp[0]] = true;
49 PMA_DBI_free_result($result);
51 if (isset($sot_cache)) {
52 $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
53 if ($result != false && PMA_DBI_num_rows($result) > 0) {
54 while ($tmp = PMA_DBI_fetch_row($result)) {
55 if (!isset($sot_cache[$tmp[0]])) {
56 $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
57 $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
58 $tables[] = $sts_tmp;
59 } else { // table in use
60 $tables[] = array('Name' => $tmp[0]);
63 PMA_DBI_free_result($result);
64 $sot_ready = true;
67 unset($tmp, $result);
71 if (! isset($sot_ready)) {
72 $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
73 if (PMA_DBI_num_rows($result) > 0) {
74 while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
75 $tables[] = $sts_tmp;
77 PMA_DBI_free_result($result);
78 unset($res);
83 /**
84 * If there is at least one table, displays the printer friendly view, else
85 * an error message
87 $tables = PMA_DBI_get_tables_full($db);
88 $num_tables = count($tables);
90 echo '<br />';
92 // 1. No table
93 if ($num_tables == 0) {
94 echo __('No tables found in database.');
96 // 2. Shows table informations on mysql >= 3.23.03
97 else {
99 <table>
100 <thead>
101 <tr>
102 <th><?php echo __('Table'); ?></th>
103 <th><?php echo __('Rows'); ?></th>
104 <th><?php echo __('Type'); ?></th>
105 <?php
106 if ($cfg['ShowStats']) {
107 echo '<th>' . __('Size') . '</th>';
110 <th><?php echo __('Comments'); ?></th>
111 </tr>
112 </thead>
113 <tbody>
114 <?php
115 $sum_entries = $sum_size = 0;
116 $odd_row = true;
117 foreach ($tables as $sts_data) {
118 if (PMA_Table::isMerge($db, $sts_data['TABLE_NAME'])
119 || strtoupper($sts_data['ENGINE']) == 'FEDERATED') {
120 $merged_size = true;
121 } else {
122 $merged_size = false;
124 $sum_entries += $sts_data['TABLE_ROWS'];
126 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
127 <th>
128 <?php echo htmlspecialchars($sts_data['TABLE_NAME']); ?>
129 </th>
130 <?php
132 if (isset($sts_data['TABLE_ROWS'])) {
134 <td align="right">
135 <?php
136 if ($merged_size) {
137 echo '<i>' . PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . '</i>' . "\n";
138 } else {
139 echo PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . "\n";
142 </td>
143 <td nowrap="nowrap">
144 <?php echo $sts_data['ENGINE']; ?>
145 </td>
146 <?php
147 if ($cfg['ShowStats']) {
148 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
149 $sum_size += $tblsize;
150 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
152 <td align="right" nowrap="nowrap">
153 <?php echo $formated_size . ' ' . $unit; ?>
154 </td>
155 <?php
156 } // end if
157 } else {
159 <td colspan="3" align="center">
160 <?php echo __('in use'); ?>
161 </td>
162 <?php
165 <td>
166 <?php
167 if (! empty($sts_data['Comment'])) {
168 echo htmlspecialchars($sts_data['Comment']);
169 $needs_break = '<br />';
170 } else {
171 $needs_break = '';
174 if (! empty($sts_data['Create_time'])
175 || ! empty($sts_data['Update_time'])
176 || ! empty($sts_data['Check_time'])) {
177 echo $needs_break;
179 <table width="100%">
180 <?php
182 if (! empty($sts_data['Create_time'])) {
184 <tr>
185 <td align="right"><?php echo __('Creation') . ': '; ?></td>
186 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
187 </tr>
188 <?php
191 if (! empty($sts_data['Update_time'])) {
193 <tr>
194 <td align="right"><?php echo __('Last update') . ': '; ?></td>
195 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
196 </tr>
197 <?php
200 if (! empty($sts_data['Check_time'])) {
202 <tr>
203 <td align="right"><?php echo __('Last check') . ': '; ?></td>
204 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
205 </tr>
206 <?php
209 </table>
210 <?php
213 </td>
214 </tr>
215 <?php
218 <tr>
219 <th align="center">
220 <?php echo sprintf(_ngettext('%s table', '%s tables', $num_tables), PMA_formatNumber($num_tables, 0)); ?>
221 </th>
222 <th align="right" nowrap="nowrap">
223 <?php echo PMA_formatNumber($sum_entries, 0); ?>
224 </th>
225 <th align="center">
227 </th>
228 <?php
229 if ($cfg['ShowStats']) {
230 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
232 <th align="right" nowrap="nowrap">
233 <?php echo $sum_formated . ' ' . $unit; ?>
234 </th>
235 <?php
238 <th></th>
239 </tr>
240 </tbody>
241 </table>
242 <?php
246 * Displays the footer
250 <script type="text/javascript">
251 //<![CDATA[
252 function printPage()
254 // Do print the page
255 if (typeof(window.print) != 'undefined') {
256 window.print();
259 //]]>
260 </script>
261 <br /><br />
263 <input type="button" class="print_ignore"
264 id="print" value="<?php echo __('Print'); ?>" onclick="printPage()" />
266 <?php
267 require './libraries/footer.inc.php';