2
/* $Id: db_details_structure.php,v 2.42 2004/12/01 11:33:20 lem9 Exp $ */
2
/* $Id: db_details_structure.php,v 2.55 2005/07/22 15:25:53 lem9 Exp $ */
3
3
// vim: expandtab sw=4 ts=4 sts=4:
5
5
require_once('./libraries/grab_globals.lib.php');
36
36
// Display function
37
function pma_TableHeader($alternate = FALSE) {
37
function pma_TableHeader($alternate = FALSE, $record_count = TRUE) {
38
$cnt = 0; // Let's count the columns...
38
39
echo ' <table border="' . $GLOBALS['cfg']['Border'] . '" cellpadding="2" cellspacing="1">' . "\n"
40
41
. ' <td></td>' . "\n"
44
45
. ' <th colspan="6">' . "\n"
45
46
. ' ' . $GLOBALS['strAction'] . ' ' . "\n"
48
. ' ' . $GLOBALS['strRecords'] . PMA_showHint($GLOBALS['strApproximateCount']) . ' ' . "\n"
51
. ' ' . $GLOBALS['strRecords'] . PMA_showHint($GLOBALS['strApproximateCount']) . ' ' . "\n"
51
56
if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
52
57
echo ' <th>' . "\n"
53
58
. ' ' . $GLOBALS['strType'] . ' ' . "\n"
55
61
if (PMA_MYSQL_INT_VERSION >= 40100) {
56
62
echo ' <th>' . "\n"
57
63
. ' ' . $GLOBALS['strCollation'] . ' ' . "\n"
61
68
if ($GLOBALS['cfg']['ShowStats']) {
66
73
. ' ' . $GLOBALS['strOverhead'] . ' ' . "\n"
71
79
echo ' </tr>' . "\n";
80
$GLOBALS['structure_tbl_col_cnt'] = $cnt;
76
* Settings for relations stuff
78
require_once('./libraries/relation.lib.php');
79
$cfgRelation = PMA_getRelationsParam();
82
85
* Displays the tables list
100
103
$titles['Browse'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" border="0" />';
104
$titles['NoBrowse'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" border="0" />';
101
105
$titles['Search'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_select.png" alt="' . $strSearch . '" title="' . $strSearch . '" border="0" />';
102
$titles['NoBrowse'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" border="0" />';
103
106
$titles['NoSearch'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_select.png" alt="' . $strSearch . '" title="' . $strSearch . '" border="0" />';
104
107
$titles['Insert'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_insrow.png" alt="' . $strInsert . '" title="' . $strInsert . '" border="0" />';
108
$titles['NoInsert'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_insrow.png" alt="' . $strInsert . '" title="' . $strInsert . '" border="0" />';
105
109
$titles['Structure'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_props.png" alt="' . $strStructure . '" title="' . $strStructure . '" border="0" />';
106
110
$titles['Drop'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" border="0" />';
111
$titles['NoDrop'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" border="0" />';
107
112
$titles['Empty'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" border="0" />';
108
113
$titles['NoEmpty'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" border="0" />';
113
118
$titles['NoBrowse'] .= ' ' . $strBrowse . '</div>';
114
119
$titles['NoSearch'] .= ' ' . $strSearch . '</div>';
115
120
$titles['Insert'] .= ' ' . $strInsert . '</div>';
121
$titles['NoInsert'] .= ' ' . $strInsert . '</div>';
116
122
$titles['Structure'] .= ' ' . $strStructure . '</div>';
117
123
$titles['Drop'] .= ' ' . $strDrop . '</div>';
124
$titles['NoDrop'] .= ' ' . $strDrop . '</div>';
118
125
$titles['Empty'] .= ' ' . $strEmpty . '</div>';
119
126
$titles['NoEmpty'] .= ' ' . $strEmpty . '</div>';
124
131
$titles['NoBrowse'] = $strBrowse;
125
132
$titles['NoSearch'] = $strSearch;
126
133
$titles['Insert'] = $strInsert;
134
$titles['NoInsert'] = $strInsert;
127
135
$titles['Structure'] = $strStructure;
128
136
$titles['Drop'] = $strDrop;
137
$titles['NoDrop'] = $strDrop;
129
138
$titles['Empty'] = $strEmpty;
130
139
$titles['NoEmpty'] = $strEmpty;
137
146
// 2. Shows table informations - staybyte - 11 June 2001
139
// Get additional information about tables for tooltip is done in db_details_db_info.php only once
140
if ($cfgRelation['commwork']) {
141
$comment = PMA_getComments($db);
144
* Displays table comment
146
if (is_array($comment)) {
149
<p id="dbComment"><i>
150
<?php echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?>
156
149
<form method="post" action="db_details_structure.php" name="tablesForm">
157
150
<?php echo PMA_generate_common_hidden_inputs($db); ?>
161
// rabus: disable statistics for information_schema.
162
if (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema') {
163
$cfg['ShowStats'] = FALSE;
164
pma_TableHeader(FALSE, FALSE);
170
169
$i = $sum_entries = 0;
171
170
(double) $sum_size = 0;
193
192
$table = $sts_data['Name'];
194
193
$table_encoded = urlencode($table);
195
194
$table_name = htmlspecialchars($table);
195
$is_view = (PMA_MYSQL_INT_VERSION >= 50000
196
&& !isset($sts_data['Type'])
197
&& $sts_data['Comment'] == 'view');
197
199
$alias = (!empty($tooltip_aliasname) && isset($tooltip_aliasname[$table]))
198
200
? htmlspecialchars($tooltip_aliasname[$table])
229
231
<td><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" border="0" width="10" height="1" alt="" /></td>
230
232
<td valign="top">
234
pma_TableHeader(FALSE, !(PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema'));
235
237
<tr <?php echo $on_mouse; ?>>
236
238
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
237
239
<input type="checkbox" name="selected_tbl[]" value="<?php echo $table_encoded; ?>" id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> />
243
<input type="hidden" name="views[]" value="<?php echo $table_encoded; ?>" />
239
248
<td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap" <?php echo $click_mouse; ?>>
240
249
<b><label onclick="javascript: return (document.getElementById('checkbox_tbl_<?php echo $i; ?>') ? false : true)" for="checkbox_tbl_<?php echo $i; ?>" title="<?php echo $alias; ?>"><?php echo $truename; ?></label> </b>
244
253
require_once('./libraries/bookmark.lib.php');
245
254
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
247
if (!empty($sts_data['Rows'])) {
256
if (!empty($sts_data['Rows']) || $is_view || (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema')) {
248
257
echo '<a href="sql.php?' . $tbl_url_query . '&sql_query='
249
258
. (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table)))
250
259
. '&pos=0">' . $titles['Browse'] . '</a>';
256
<td bgcolor="<?php echo $bgcolor; ?>">
265
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
266
<a href="tbl_properties_structure.php?<?php echo $tbl_url_query; ?>">
267
<?php echo $titles['Structure']; ?></a>
269
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
258
if (!empty($sts_data['Rows'])) {
271
if (!empty($sts_data['Rows']) || $is_view || (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema')) {
259
272
echo '<a href="tbl_select.php?' . $tbl_url_query . '">'
260
273
. $titles['Search'] . '</a>';
266
279
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
281
if (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema') {
282
// rabus: We cannot insert into information_schema tables!
283
echo $titles['NoInsert'];
267
286
<a href="tbl_change.php?<?php echo $tbl_url_query; ?>">
268
287
<?php echo $titles['Insert']; ?></a>
270
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
271
<a href="tbl_properties_structure.php?<?php echo $tbl_url_query; ?>">
272
<?php echo $titles['Structure']; ?></a>
274
292
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
276
294
if (!empty($sts_data['Rows'])) {
292
310
echo $titles['NoEmpty'];
313
$drop_query = 'DROP '
314
. ($is_view ? 'VIEW' : 'TABLE')
315
. ' ' . PMA_backquote($table);
316
$drop_message = sprintf(($is_view ? $strViewHasBeenDropped : $strTableHasBeenDropped), htmlspecialchars($table));
296
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
297
<a href="sql.php?<?php echo $tbl_url_query; ?>&reload=1&purge=1&sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table))); ?>"
298
onclick="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
319
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
321
// rabus: We cannot drop information_schema tables!
322
if (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema') {
323
echo $titles['NoDrop'];
326
<a href="sql.php?<?php echo $tbl_url_query; ?>&reload=1&purge=1&sql_query=<?php echo urlencode($drop_query); ?>&zero_rows=<?php echo urlencode($drop_message); ?>"
327
onclick="return confirmLink(this, '<?php echo PMA_jsFormat($drop_query, FALSE); ?>')">
299
328
<?php echo $titles['Drop']; ?></a>
334
unset($drop_query, $drop_message);
304
337
// loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid
305
338
// statistics whatever is the table type
306
if (isset($sts_data['Rows'])) {
339
if (isset($sts_data['Rows']) || (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema')) {
307
340
// MyISAM, ISAM or Heap table: Row count, data size and index size
309
342
if (isset($sts_data['Type']) && preg_match('@^(MyISAM|ISAM|HEAP)$@', $sts_data['Type'])) {
365
398
$display_rows = 'unknown';
400
// Don't display number of rows for information_schema tables.
401
if (!(PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema')) {
368
403
<td align="right" bgcolor="<?php echo $bgcolor; ?>" <?php echo $click_mouse; ?>>
370
echo "\n" . ' ' . $display_rows . "\n";
405
echo "\n" . ' ' . $display_rows . "\n";
374
410
if (!($cfg['PropertiesNumColumns'] > 1)) {
375
411
echo ' <td bgcolor="' . $bgcolor . '" nowrap="nowrap" ' . $click_mouse . '>' . "\n"
376
412
. ' ' . (isset($sts_data['Type']) ? $sts_data['Type'] : ' ') . ' ' . "\n"
443
} else if (PMA_MYSQL_INT_VERSION >= 50000 && $sts_data['Comment'] == 'view') {
444
// rabus: We've found a view
446
<td align="right" bgcolor="<?php echo $bgcolor; ?>">
449
<td bgcolor="<?php echo $bgcolor; ?>">
450
<?php echo $strView ; ?>
452
<td bgcolor="<?php echo $bgcolor; ?>">
456
if ($cfg['ShowStats']) {
458
<td align="right" bgcolor="<?php echo $bgcolor; ?>">
461
<td align="right" bgcolor="<?php echo $bgcolor; ?>">
409
<td colspan="4" align="center" bgcolor="<?php echo $bgcolor; ?>" <?php echo $click_mouse; ?>>
468
<td colspan="<?php echo ($structure_tbl_col_cnt - 8) ?>" align="center" bgcolor="<?php echo $bgcolor; ?>" <?php echo $click_mouse; ?>>
410
469
<?php echo $strInUse . "\n"; ?>
428
487
<th align="center" nowrap="nowrap">
429
488
<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>
491
if (PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema') {
493
<th colspan="6"> </th>
431
497
<th colspan="6" align="center">
432
498
<b><?php echo $strSum; ?></b>
434
500
<th align="right" nowrap="nowrap">
435
501
<b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
438
505
if (!($cfg['PropertiesNumColumns'] > 1)) {
439
506
echo ' <th align="center">' . "\n"
440
507
. ' <b>--</b>' . "\n"
468
535
$checkall_url = 'db_details_structure.php?' . PMA_generate_common_url($db);
472
if (!($cfg['PropertiesNumColumns'] > 1)) {
474
if (PMA_MYSQL_INT_VERSION >= 40100) {
479
if ($cfg['ShowStats']) {
484
<td colspan="<?php echo $basecolspan; ?>" valign="bottom">
540
<td colspan="<?php echo $structure_tbl_col_cnt; ?>" valign="bottom">
485
541
<img src="<?php echo $pmaThemeImage .'arrow_'.$text_dir.'.png'; ?>" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
486
542
<a href="<?php echo $checkall_url; ?>&checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
487
543
<?php echo $strCheckAll; ?></a>
574
630
<tr><td colspan="3"><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width="1" height="1" border="0" alt="" /></td></tr></table>
634
if (PMA_MYSQL_INT_VERSION < 50002 || (PMA_MYSQL_INT_VERSION >= 50002 && $db != 'information_schema')) {
578
<table border="0" cellpadding="2" cellspacing="0">
579
636
<!-- Create a new table -->
580
<form method="post" action="tbl_create.php" onsubmit="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', 1))">
637
<form method="post" action="tbl_create.php" onsubmit="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldCount']); ?>', 1))">
638
<table border="0" cellpadding="2" cellspacing="0">
582
640
<td class="tblHeaders" colspan="3" nowrap="nowrap"><?php
583
641
echo PMA_generate_common_hidden_inputs($db);
587
645
. htmlspecialchars($GLOBALS['db']) . '</a>';
589
647
// $strDBLink = htmlspecialchars($db);
590
echo ' ' . sprintf($strCreateNewTable, $strDBLink) . ': ' . "\n";
592
echo ' <tr bgcolor="'.$cfg['BgcolorOne'].'"><td nowrap="nowrap">';
593
echo ' ' . $strName . ': ' . "\n";
595
echo ' <td nowrap="nowrap">';
596
echo ' ' . '<input type="text" name="table" maxlength="64" size="30" class="textfield" />';
597
echo ' </td><td> </td></tr>';
598
echo ' <tr bgcolor="'.$cfg['BgcolorOne'].'"><td nowrap="nowrap">';
599
echo ' ' . $strFields . ': ' . "\n";
601
echo ' <td nowrap="nowrap">';
602
echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
604
echo ' <td align="right">';
605
echo ' ' . ' <input type="submit" value="' . $strGo . '" />' . "\n";
648
echo ' ' . sprintf($strCreateNewTable, $strDBLink) . ': ' . "\n";
650
echo ' <tr bgcolor="'.$cfg['BgcolorOne'].'"><td nowrap="nowrap">';
651
echo ' ' . $strName . ': ' . "\n";
653
echo ' <td nowrap="nowrap">';
654
echo ' ' . '<input type="text" name="table" maxlength="64" size="30" class="textfield" />';
655
echo ' </td><td> </td></tr>';
656
echo ' <tr bgcolor="'.$cfg['BgcolorOne'].'"><td nowrap="nowrap">';
657
if (!isset($strNumberOfFields)) {
658
$strNumberOfFields = $strFields;
660
echo ' ' . $strNumberOfFields . ': ' . "\n";
662
echo ' <td nowrap="nowrap">';
663
echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
665
echo ' <td align="right">';
666
echo ' ' . ' <input type="submit" value="' . $strGo . '" />' . "\n";
670
} // end if (Create Table dialog)
610
673
* Displays the footer