Documentation TYPO3 par Ameos |
00001 <?php 00002 /* $Id: tbl_printview.php,v 2.12 2005/05/22 17:09:27 lem9 Exp $ */ 00003 00004 00008 $print_view = TRUE; 00009 if (!isset($selected_tbl)) { 00010 require_once('./libraries/grab_globals.lib.php'); 00011 require_once('./header.inc.php'); 00012 } 00013 00014 // Check parameters 00015 00016 if (!isset($the_tables) || !is_array($the_tables)) { 00017 $the_tables = array(); 00018 } 00019 00023 require_once('./libraries/relation.lib.php'); 00024 require_once('./libraries/transformations.lib.php'); 00025 require_once('./libraries/tbl_indexes.lib.php'); 00026 00027 $cfgRelation = PMA_getRelationsParam(); 00028 00029 00033 if (isset($table)) { 00034 $err_url = 'tbl_properties.php?' . PMA_generate_common_url($db, $table); 00035 } else { 00036 $err_url = 'db_details.php?' . PMA_generate_common_url($db); 00037 } 00038 00039 00043 PMA_DBI_select_db($db); 00044 00045 00050 if (isset($selected_tbl) && is_array($selected_tbl)) { 00051 $the_tables = $selected_tbl; 00052 } else if (isset($table)) { 00053 $the_tables[] = $table; 00054 } 00055 $multi_tables = (count($the_tables) > 1); 00056 00057 if ($multi_tables) { 00058 if (empty($GLOBALS['is_header_sent'])) { 00059 require_once('./header.inc.php'); 00060 } 00061 $tbl_list = ''; 00062 foreach ($the_tables AS $key => $table) { 00063 $tbl_list .= (empty($tbl_list) ? '' : ', ') 00064 . PMA_backquote(urldecode($table)); 00065 } 00066 echo '<b>'. $strShowTables . ': ' . $tbl_list . '</b>' . "\n"; 00067 echo '<hr />' . "\n"; 00068 } // end if 00069 00070 $tables_cnt = count($the_tables); 00071 $counter = 0; 00072 00073 foreach ($the_tables AS $key => $table) { 00074 $table = urldecode($table); 00075 if ($counter + 1 >= $tables_cnt) { 00076 $breakstyle = ''; 00077 } else { 00078 $breakstyle = ' style="page-break-after: always;"'; 00079 } 00080 $counter++; 00081 echo '<div' . $breakstyle . '>' . "\n"; 00082 echo '<h1>' . $table . '</h1>' . "\n"; 00083 00087 $result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';'); 00088 $showtable = PMA_DBI_fetch_assoc($result); 00089 $num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); 00090 $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); 00091 PMA_DBI_free_result($result); 00092 00093 00094 // Gets table keys and store them in arrays 00095 $indexes = array(); 00096 $indexes_info = array(); 00097 $indexes_data = array(); 00098 $ret_keys = PMA_get_indexes($table, $err_url_0); 00099 00100 PMA_extract_indexes($ret_keys, $indexes, $indexes_info, $indexes_data); 00101 00105 $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE); 00106 $fields_cnt = PMA_DBI_num_rows($result); 00107 00108 // Check if we can use Relations (Mike Beck) 00109 if (!empty($cfgRelation['relation'])) { 00110 // Find which tables are related with the current one and write it in 00111 // an array 00112 $res_rel = PMA_getForeigners($db, $table); 00113 00114 if (count($res_rel) > 0) { 00115 $have_rel = TRUE; 00116 } else { 00117 $have_rel = FALSE; 00118 } 00119 } 00120 else { 00121 $have_rel = FALSE; 00122 } // end if 00123 00124 00128 if (!empty($show_comment)) { 00129 echo $strTableComments . ': ' . $show_comment . '<br /><br />'; 00130 } 00131 00135 ?> 00136 00137 <!-- TABLE INFORMATIONS --> 00138 <table width="95%" bordercolorlight="black" border="border" style="border-collapse: collapse; background-color: white"> 00139 <tr> 00140 <th width="50"><?php echo $strField; ?></th> 00141 <th width="80"><?php echo $strType; ?></th> 00142 <!--<th width="50"><?php echo $strAttr; ?></th>--> 00143 <th width="40"><?php echo $strNull; ?></th> 00144 <th width="70"><?php echo $strDefault; ?></th> 00145 <!--<th width="50"><?php echo $strExtra; ?></th>--> 00146 <?php 00147 echo "\n"; 00148 if ($have_rel) { 00149 echo ' <th>' . $strLinksTo . '</th>' . "\n"; 00150 } 00151 if ($cfgRelation['commwork']) { 00152 echo ' <th>' . $strComments . '</th>' . "\n"; 00153 } 00154 if ($cfgRelation['mimework']) { 00155 echo ' <th>MIME</th>' . "\n"; 00156 } 00157 ?> 00158 </tr> 00159 00160 <?php 00161 $i = 0; 00162 while ($row = PMA_DBI_fetch_assoc($result)) { 00163 $bgcolor = ($i % 2) ?$cfg['BgcolorOne'] : $cfg['BgcolorTwo']; 00164 $i++; 00165 00166 $type = $row['Type']; 00167 // reformat mysql query output - staybyte - 9. June 2001 00168 // loic1: set or enum types: slashes single quotes inside options 00169 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) { 00170 $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1); 00171 $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; 00172 $type_nowrap = ''; 00173 00174 $binary = 0; 00175 $unsigned = 0; 00176 $zerofill = 0; 00177 } else { 00178 $type_nowrap = ' nowrap="nowrap"'; 00179 $type = preg_replace('@BINARY@i', '', $type); 00180 $type = preg_replace('@ZEROFILL@i', '', $type); 00181 $type = preg_replace('@UNSIGNED@i', '', $type); 00182 if (empty($type)) { 00183 $type = ' '; 00184 } 00185 00186 $binary = stristr($row['Type'], 'binary'); 00187 $unsigned = stristr($row['Type'], 'unsigned'); 00188 $zerofill = stristr($row['Type'], 'zerofill'); 00189 } 00190 $strAttribute = ' '; 00191 if ($binary) { 00192 $strAttribute = 'BINARY'; 00193 } 00194 if ($unsigned) { 00195 $strAttribute = 'UNSIGNED'; 00196 } 00197 if ($zerofill) { 00198 $strAttribute = 'UNSIGNED ZEROFILL'; 00199 } 00200 if (!isset($row['Default'])) { 00201 if ($row['Null'] != '') { 00202 $row['Default'] = '<i>NULL</i>'; 00203 } 00204 } else { 00205 $row['Default'] = htmlspecialchars($row['Default']); 00206 } 00207 $field_name = htmlspecialchars($row['Field']); 00208 echo "\n"; 00209 ?> 00210 <tr> 00211 <td width="50" class="print" nowrap="nowrap"> 00212 <?php 00213 if (isset($pk_array[$row['Field']])) { 00214 echo ' <u>' . $field_name . '</u> ' . "\n"; 00215 } else { 00216 echo ' ' . $field_name . ' ' . "\n"; 00217 } 00218 ?> 00219 </td> 00220 <td width="80" class="print"<?php echo $type_nowrap; ?>><?php echo $type; ?><bdo dir="ltr"></bdo></td> 00221 <!--<td width="50" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $strAttribute; ?></td>--> 00222 <td width="40" class="print"><?php echo (($row['Null'] == '') ? $strNo : $strYes); ?> </td> 00223 <td width="70" class="print" nowrap="nowrap"><?php if (isset($row['Default'])) echo $row['Default']; ?> </td> 00224 <!--<td width="50" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $row['Extra']; ?> </td>--> 00225 <?php 00226 echo "\n"; 00227 if ($have_rel) { 00228 echo ' <td class="print">'; 00229 if (isset($res_rel[$field_name])) { 00230 echo htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] ); 00231 } 00232 echo ' </td>' . "\n"; 00233 } 00234 if ($cfgRelation['commwork']) { 00235 echo ' <td class="print">'; 00236 $comments = PMA_getComments($db, $table); 00237 if (isset($comments[$field_name])) { 00238 echo htmlspecialchars($comments[$field_name]); 00239 } 00240 echo ' </td>' . "\n"; 00241 } 00242 if ($cfgRelation['mimework']) { 00243 $mime_map = PMA_getMIME($db, $table, true); 00244 00245 echo ' <td class="print">'; 00246 if (isset($mime_map[$field_name])) { 00247 echo htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])); 00248 } 00249 echo ' </td>' . "\n"; 00250 } 00251 ?> 00252 </tr> 00253 <?php 00254 } // end while 00255 PMA_DBI_free_result($result); 00256 00257 echo "\n"; 00258 ?> 00259 </table> 00260 00261 00262 <?php 00266 $index_count = (isset($indexes)) 00267 ? count($indexes) 00268 : 0; 00269 if ($index_count > 0) { 00270 echo "\n"; 00271 ?> 00272 <br /><br /> 00273 00274 <!-- Indexes --> 00275 <big><?php echo $strIndexes . ':'; ?></big> 00276 <table bordercolorlight="black" border="border" style="border-collapse: collapse; background-color: white"> 00277 <tr> 00278 <th><?php echo $strKeyname; ?></th> 00279 <th><?php echo $strType; ?></th> 00280 <th><?php echo $strCardinality; ?></th> 00281 <th colspan="2"><?php echo $strField; ?></th> 00282 </tr> 00283 <?php 00284 echo "\n"; 00285 PMA_show_indexes($table, $indexes, $indexes_info, $indexes_data, true, true); 00286 echo "\n"; 00287 ?> 00288 </table> 00289 <?php 00290 echo "\n"; 00291 } // end display indexes 00292 00293 00299 if ($cfg['ShowStats']) { 00300 $nonisam = FALSE; 00301 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) { 00302 $nonisam = TRUE; 00303 } 00304 if ($nonisam == FALSE) { 00305 // Gets some sizes 00306 $mergetable = FALSE; 00307 if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') { 00308 $mergetable = TRUE; 00309 } 00310 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length']); 00311 if ($mergetable == FALSE) { 00312 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length']); 00313 } 00314 if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) { 00315 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free']); 00316 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free']); 00317 } else { 00318 unset($free_size); 00319 unset($free_unit); 00320 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']); 00321 } 00322 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']); 00323 if ($num_rows > 0) { 00324 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1); 00325 } 00326 00327 // Displays them 00328 ?> 00329 <br /><br /> 00330 00331 <table border="0" cellspacing="0" cellpadding="0" class="noborder"> 00332 <tr> 00333 00334 <!-- Space usage --> 00335 <td class="print" valign="top"> 00336 <big><?php echo $strSpaceUsage . ':'; ?></big> 00337 <table width="100%" bordercolorlight="black" border="border" style="border-collapse: collapse; background-color: white"> 00338 <tr> 00339 <th><?php echo $strType; ?></th> 00340 <th colspan="2" align="center"><?php echo $strUsage; ?></th> 00341 </tr> 00342 <tr> 00343 <td class="print" style="padding-right: 10px"><?php echo $strData; ?></td> 00344 <td align="right" class="print" nowrap="nowrap"><?php echo $data_size; ?></td> 00345 <td class="print"><?php echo $data_unit; ?></td> 00346 </tr> 00347 <?php 00348 if (isset($index_size)) { 00349 echo "\n"; 00350 ?> 00351 <tr> 00352 <td class="print" style="padding-right: 10px"><?php echo $strIndex; ?></td> 00353 <td align="right" class="print" nowrap="nowrap"><?php echo $index_size; ?></td> 00354 <td class="print"><?php echo $index_unit; ?></td> 00355 </tr> 00356 <?php 00357 } 00358 if (isset($free_size)) { 00359 echo "\n"; 00360 ?> 00361 <tr style="color: #bb0000"> 00362 <td class="print" style="padding-right: 10px"><?php echo $strOverhead; ?></td> 00363 <td align="right" class="print" nowrap="nowrap"><?php echo $free_size; ?></td> 00364 <td class="print"><?php echo $free_unit; ?></td> 00365 </tr> 00366 <tr> 00367 <td class="print" style="padding-right: 10px"><?php echo $strEffective; ?></td> 00368 <td align="right" class="print" nowrap="nowrap"><?php echo $effect_size; ?></td> 00369 <td class="print"><?php echo $effect_unit; ?></td> 00370 </tr> 00371 <?php 00372 } 00373 if (isset($tot_size) && $mergetable == FALSE) { 00374 echo "\n"; 00375 ?> 00376 <tr> 00377 <td class="print" style="padding-right: 10px"><?php echo $strTotalUC; ?></td> 00378 <td align="right" class="print" nowrap="nowrap"><?php echo $tot_size; ?></td> 00379 <td class="print"><?php echo $tot_unit; ?></td> 00380 </tr> 00381 <?php 00382 } 00383 echo "\n"; 00384 ?> 00385 </table> 00386 </td> 00387 00388 <td width="20" class="print"> </td> 00389 00390 <!-- Rows Statistic --> 00391 <td valign="top"> 00392 <big><?php echo $strRowsStatistic . ':'; ?></big> 00393 <table width=100% bordercolorlight="black" border="border" style="border-collapse: collapse; background-color: white"> 00394 <tr> 00395 <th><?php echo $strStatement; ?></th> 00396 <th align="center"><?php echo $strValue; ?></th> 00397 </tr> 00398 <?php 00399 $i = 0; 00400 if (isset($showtable['Row_format'])) { 00401 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']); 00402 echo "\n"; 00403 ?> 00404 <tr> 00405 <td class="print"><?php echo ucfirst($strFormat); ?></td> 00406 <td align="<?php echo $cell_align_left; ?>" class="print" nowrap="nowrap"> 00407 <?php 00408 echo ' '; 00409 if ($showtable['Row_format'] == 'Fixed') { 00410 echo $strFixed; 00411 } else if ($showtable['Row_format'] == 'Dynamic') { 00412 echo $strDynamic; 00413 } else { 00414 echo $showtable['Row_format']; 00415 } 00416 echo "\n"; 00417 ?> 00418 </td> 00419 </tr> 00420 <?php 00421 } 00422 if (isset($showtable['Rows'])) { 00423 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']); 00424 echo "\n"; 00425 ?> 00426 <tr> 00427 <td class="print"><?php echo ucfirst($strRows); ?></td> 00428 <td align="right" class="print" nowrap="nowrap"> 00429 <?php echo number_format($showtable['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?> 00430 </td> 00431 </tr> 00432 <?php 00433 } 00434 if (isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) { 00435 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']); 00436 echo "\n"; 00437 ?> 00438 <tr> 00439 <td class="print"><?php echo ucfirst($strRowLength); ?> ø</td> 00440 <td class="print" nowrap="nowrap"> 00441 <?php echo number_format($showtable['Avg_row_length'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?> 00442 </td> 00443 </tr> 00444 <?php 00445 } 00446 if (isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == FALSE) { 00447 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']); 00448 echo "\n"; 00449 ?> 00450 <tr> 00451 <td class="print"><?php echo ucfirst($strRowSize); ?> ø</td> 00452 <td align="right" class="print" nowrap="nowrap"> 00453 <?php echo $avg_size . ' ' . $avg_unit . "\n"; ?> 00454 </td> 00455 </tr> 00456 <?php 00457 } 00458 if (isset($showtable['Auto_increment'])) { 00459 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']); 00460 echo "\n"; 00461 ?> 00462 <tr> 00463 <td class="print"><?php echo ucfirst($strNext); ?> Autoindex</td> 00464 <td align="right" class="print" nowrap="nowrap"> 00465 <?php echo number_format($showtable['Auto_increment'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?> 00466 </td> 00467 </tr> 00468 <?php 00469 } 00470 echo "\n"; 00471 00472 if (isset($showtable['Create_time'])) { 00473 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']); 00474 echo "\n"; 00475 ?> 00476 <tr> 00477 <td class="print"><?php echo $strStatCreateTime; ?></td> 00478 <td align="right" class="print" nowrap="nowrap"> 00479 <?php echo PMA_localisedDate(strtotime($showtable['Create_time'])) . "\n"; ?> 00480 </td> 00481 </tr> 00482 <?php 00483 } 00484 echo "\n"; 00485 00486 if (isset($showtable['Update_time'])) { 00487 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']); 00488 echo "\n"; 00489 ?> 00490 <tr> 00491 <td class="print"><?php echo $strStatUpdateTime; ?></td> 00492 <td align="right" class="print" nowrap="nowrap"> 00493 <?php echo PMA_localisedDate(strtotime($showtable['Update_time'])) . "\n"; ?> 00494 </td> 00495 </tr> 00496 <?php 00497 } 00498 echo "\n"; 00499 00500 if (isset($showtable['Check_time'])) { 00501 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']); 00502 echo "\n"; 00503 ?> 00504 <tr> 00505 <td class="print"><?php echo $strStatCheckTime; ?></td> 00506 <td align="right" class="print" nowrap="nowrap"> 00507 <?php echo PMA_localisedDate(strtotime($showtable['Check_time'])) . "\n"; ?> 00508 </td> 00509 </tr> 00510 <?php 00511 } 00512 echo "\n"; 00513 ?> 00514 </table> 00515 </td> 00516 </tr> 00517 </table> 00518 00519 <?php 00520 } // end if ($nonisam == FALSE) 00521 } // end if ($cfg['ShowStats']) 00522 00523 echo "\n"; 00524 if ($multi_tables) { 00525 unset($ret_keys); 00526 unset($num_rows); 00527 unset($show_comment); 00528 echo '<hr />' . "\n"; 00529 } // end if 00530 echo '</div>' . "\n"; 00531 00532 } // end while 00533 00534 00535 00539 echo "\n"; 00540 ?> 00541 <script type="text/javascript" language="javascript1.2"> 00542 <!-- 00543 function printPage() 00544 { 00545 // Do print the page 00546 if (typeof(window.print) != 'undefined') { 00547 window.print(); 00548 } 00549 } 00550 //--> 00551 </script> 00552 <?php 00553 echo '<br /><br /> <input type="button" class="print_ignore" style="width: 100px; height: 25px" id="print" value="' . $strPrint . '" onclick="printPage()" />' . "\n"; 00554 00555 require_once('./footer.inc.php'); 00556 ?>