db_printview.php 5.1 KB

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