- XHTML compliance, styling outsourced, row marker outsourced

- do not too much if there is no table
This commit is contained in:
Sebastian Mendel
2005-10-20 14:35:10 +00:00
parent d76b1a831c
commit 0a3c8dc40b
3 changed files with 409 additions and 522 deletions

View File

@@ -19,6 +19,9 @@ $Source$
every table with class data now has mark and hover effect every table with class data now has mark and hover effect
* css/phpmyadmin.css.php: nowrap for IE and pre for the rest * css/phpmyadmin.css.php: nowrap for IE and pre for the rest
* css/phpmyadmin.css.php, server_status.php: css cleanup * css/phpmyadmin.css.php, server_status.php: css cleanup
* db_details_structure.php, db_details_db_info.php:
- XHTML compliance, styling outsourced, row marker outsourced
- do not too much if there is no table
2005-10-19 Alexander M. Turek <me@derrabus.de> 2005-10-19 Alexander M. Turek <me@derrabus.de>
* lang/*.inc.php, libraries/mysql_charsets.lib.php: Correct description * lang/*.inc.php, libraries/mysql_charsets.lib.php: Correct description

View File

@@ -36,7 +36,7 @@ $tables = array();
// When used in Nested table group mode, only show tables matching the given groupname // When used in Nested table group mode, only show tables matching the given groupname
if (!empty($tbl_group) && !$cfg['ShowTooltipAliasTB']) { if (!empty($tbl_group) && !$cfg['ShowTooltipAliasTB']) {
$tbl_group_sql = ' LIKE \'' . $tbl_group . '%\''; $tbl_group_sql = ' LIKE "' . PMA_escape_mysql_wildcards( $tbl_group ) . '%"';
} else { } else {
$tbl_group_sql = ''; $tbl_group_sql = '';
} }
@@ -86,9 +86,9 @@ if ($cfg['SkipLockedTables'] == TRUE) {
fillTooltip($tooltip_truename, $tooltip_aliasname, $sts_tmp); fillTooltip($tooltip_truename, $tooltip_aliasname, $sts_tmp);
} }
$tables[] = $sts_tmp; $tables[$sts_tmp['Name']] = $sts_tmp;
} else { // table in use } else { // table in use
$tables[] = array('Name' => $tmp[0]); $tables[$tmp[0]] = array('Name' => $tmp[0]);
} }
} }
PMA_DBI_free_result($db_info_result); PMA_DBI_free_result($db_info_result);
@@ -120,7 +120,7 @@ if (!isset($sot_ready)) {
fillTooltip($tooltip_truename, $tooltip_aliasname, $sts_tmp); fillTooltip($tooltip_truename, $tooltip_aliasname, $sts_tmp);
} }
$tables[] = $sts_tmp; $tables[$sts_tmp['Name']] = $sts_tmp;
} }
} }
@PMA_DBI_free_result($db_info_result); @PMA_DBI_free_result($db_info_result);
@@ -128,6 +128,10 @@ if (!isset($sot_ready)) {
} }
$num_tables = (isset($tables) ? count($tables) : 0); $num_tables = (isset($tables) ? count($tables) : 0);
if ( $GLOBALS['cfg']['NaturalOrder'] ) {
uksort( $tables, 'strnatcasecmp' );
}
/** /**
* Displays top menu links * Displays top menu links
*/ */

View File

@@ -4,7 +4,6 @@
require_once('./libraries/grab_globals.lib.php'); require_once('./libraries/grab_globals.lib.php');
require_once('./libraries/common.lib.php'); require_once('./libraries/common.lib.php');
require_once('./libraries/mysql_charsets.lib.php');
/** /**
* Prepares the tables list if the user where not redirected to this script * Prepares the tables list if the user where not redirected to this script
@@ -25,108 +24,106 @@ if (empty($is_info)) {
// Gets the database structure // Gets the database structure
$sub_part = '_structure'; $sub_part = '_structure';
require('./db_details_db_info.php'); require('./db_details_db_info.php');
echo "\n"; }
// 1. No tables
if ( $num_tables == 0 ) {
echo '<p>' . $strNoTablesFound . '</p>' . "\n";
if ( empty( $table_is_schema ) ) {
require('./libraries/display_create_table.lib.php');
} // end if (Create Table dialog)
/**
* Displays the footer
*/
require_once('./footer.inc.php');
exit;
}
// else
// 2. Shows table informations - staybyte - 11 June 2001
require_once('./libraries/bookmark.lib.php');
// rabus: disable statistics for information_schema.
if ( PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema' ) {
$cfg['ShowStats'] = false;
$table_is_schema = true;
} else {
$table_is_schema = false;
} }
if ( PMA_MYSQL_INT_VERSION >= 40101 ) { if ( PMA_MYSQL_INT_VERSION >= 40101 ) {
require_once('./libraries/mysql_charsets.lib.php');
$db_collation = PMA_getDbCollation( $db ); $db_collation = PMA_getDbCollation( $db );
} }
// Display function // Display function
function pma_TableHeader( $is_schema = false ) { function PMA_TableHeader( $table_is_schema = false ) {
$cnt = 0; // Let's count the columns... $cnt = 0; // Let's count the columns...
if ( $is_schema ) { if ( $table_is_schema ) {
$action_colspan = 3; $action_colspan = 3;
} else { } else {
$action_colspan = 6; $action_colspan = 6;
} }
echo ' <table border="' . $GLOBALS['cfg']['Border'] . '" cellpadding="2" cellspacing="1">' . "\n" echo '<table class="data" style="float: left;">' . "\n"
. ' <tr>' . "\n" .'<thead>' . "\n"
. ' <td></td>' . "\n" .'<tr><td></td>' . "\n"
. ' <th>' . "\n" .' <th>' . $GLOBALS['strTable'] . '</th>' . "\n"
. ' &nbsp;' . $GLOBALS['strTable'] . '&nbsp;' . "\n"
. ' </th>' . "\n"
.' <th colspan="' . $action_colspan . '">' . "\n" .' <th colspan="' . $action_colspan . '">' . "\n"
. ' &nbsp;' . $GLOBALS['strAction'] . '&nbsp;' . "\n" .' ' . $GLOBALS['strAction'] . "\n"
.' </th>'
.' <th>' . $GLOBALS['strRecords']
.PMA_showHint( $GLOBALS['strApproximateCount'] ) . "\n"
.' </th>' . "\n"; .' </th>' . "\n";
$cnt += 2 + $action_colspan;
echo ' <th>' . "\n"
. ' &nbsp;' . $GLOBALS['strRecords'] . PMA_showHint($GLOBALS['strApproximateCount']) . '&nbsp;' . "\n"
. ' </th>' . "\n";
$cnt++;
if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) { if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
echo ' <th>' . "\n" echo ' <th>' . $GLOBALS['strType'] . '</th>' . "\n";
. ' &nbsp;' . $GLOBALS['strType'] . '&nbsp;' . "\n"
. ' </th>' . "\n";
$cnt++; $cnt++;
if (PMA_MYSQL_INT_VERSION >= 40100) { if (PMA_MYSQL_INT_VERSION >= 40100) {
echo ' <th>' . "\n" echo ' <th>' . $GLOBALS['strCollation'] . '</th>' . "\n";
. ' &nbsp;' . $GLOBALS['strCollation'] . '&nbsp;' . "\n"
. ' </th>' . "\n";
$cnt++; $cnt++;
} }
} }
if ($GLOBALS['cfg']['ShowStats']) { if ($GLOBALS['cfg']['ShowStats']) {
echo ' <th>' . "\n" echo ' <th>' . $GLOBALS['strSize'] . '</th>' . "\n"
. ' &nbsp;' . $GLOBALS['strSize'] . '&nbsp;' . "\n" . ' <th>' . $GLOBALS['strOverhead'] . '</th>' . "\n";
. ' </th>' . "\n"
. ' <th>' . "\n"
. ' &nbsp;' . $GLOBALS['strOverhead'] . '&nbsp;' . "\n"
. ' </th>' . "\n";
$cnt += 2; $cnt += 2;
} }
echo "\n";
echo '</tr>' . "\n"; echo '</tr>' . "\n";
$GLOBALS['structure_tbl_col_cnt'] = $cnt; echo '</thead>' . "\n";
echo '<tbody>' . "\n";
$GLOBALS['structure_tbl_col_cnt'] = $cnt + $action_colspan + 3;
} }
/**
* Displays the tables list
*/
?>
<!-- TABLE LIST -->
<?php
$titles = array(); $titles = array();
if ($cfg['PropertiesIconic'] == true) { if ( true == $cfg['PropertiesIconic'] ) {
// We need to copy the value or else the == 'both' check will always return true $titles['Browse'] = '<img class="icon" width="16" height="16" src="' .$pmaThemeImage . 'b_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" />';
$propicon = (string)$cfg['PropertiesIconic']; $titles['NoBrowse'] = '<img class="icon" width="16" height="16" src="' .$pmaThemeImage . 'bd_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" />';
$titles['Search'] = '<img class="icon" width="16" height="16" src="' .$pmaThemeImage . 'b_select.png" alt="' . $strSearch . '" title="' . $strSearch . '" />';
$titles['NoSearch'] = '<img class="icon" width="16" height="16" src="' .$pmaThemeImage . 'bd_select.png" alt="' . $strSearch . '" title="' . $strSearch . '" />';
$titles['Insert'] = '<img class="icon" width="16" height="16" src="' .$pmaThemeImage . 'b_insrow.png" alt="' . $strInsert . '" title="' . $strInsert . '" />';
$titles['NoInsert'] = '<img class="icon" width="16" height="16" src="' .$pmaThemeImage . 'bd_insrow.png" alt="' . $strInsert . '" title="' . $strInsert . '" />';
$titles['Structure'] = '<img class="icon" width="16" height="16" src="' .$pmaThemeImage . 'b_props.png" alt="' . $strStructure . '" title="' . $strStructure . '" />';
$titles['Drop'] = '<img class="icon" width="16" height="16" src="' .$pmaThemeImage . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
$titles['NoDrop'] = '<img class="icon" width="16" height="16" src="' .$pmaThemeImage . 'bd_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
$titles['Empty'] = '<img class="icon" width="16" height="16" src="' .$pmaThemeImage . 'b_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" />';
$titles['NoEmpty'] = '<img class="icon" width="16" height="16" src="' .$pmaThemeImage . 'bd_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" />';
if ($propicon == 'both') { if ( 'both' === $cfg['PropertiesIconic'] ) {
$iconic_spacer = '<div class="nowrap">'; $titles['Browse'] .= $strBrowse;
} else { $titles['Search'] .= $strSearch;
$iconic_spacer = ''; $titles['NoBrowse'] .= $strBrowse;
} $titles['NoSearch'] .= $strSearch;
$titles['Insert'] .= $strInsert;
$titles['Browse'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" border="0" />'; $titles['NoInsert'] .= $strInsert;
$titles['NoBrowse'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" border="0" />'; $titles['Structure'] .= $strStructure;
$titles['Search'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_select.png" alt="' . $strSearch . '" title="' . $strSearch . '" border="0" />'; $titles['Drop'] .= $strDrop;
$titles['NoSearch'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_select.png" alt="' . $strSearch . '" title="' . $strSearch . '" border="0" />'; $titles['NoDrop'] .= $strDrop;
$titles['Insert'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_insrow.png" alt="' . $strInsert . '" title="' . $strInsert . '" border="0" />'; $titles['Empty'] .= $strEmpty;
$titles['NoInsert'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_insrow.png" alt="' . $strInsert . '" title="' . $strInsert . '" border="0" />'; $titles['NoEmpty'] .= $strEmpty;
$titles['Structure'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_props.png" alt="' . $strStructure . '" title="' . $strStructure . '" border="0" />';
$titles['Drop'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" border="0" />';
$titles['NoDrop'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" border="0" />';
$titles['Empty'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" border="0" />';
$titles['NoEmpty'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" border="0" />';
if ($propicon == 'both') {
$titles['Browse'] .= '&nbsp;' . $strBrowse . '</div>';
$titles['Search'] .= '&nbsp;' . $strSearch . '</div>';
$titles['NoBrowse'] .= '&nbsp;' . $strBrowse . '</div>';
$titles['NoSearch'] .= '&nbsp;' . $strSearch . '</div>';
$titles['Insert'] .= '&nbsp;' . $strInsert . '</div>';
$titles['NoInsert'] .= '&nbsp;' . $strInsert . '</div>';
$titles['Structure'] .= '&nbsp;' . $strStructure . '</div>';
$titles['Drop'] .= '&nbsp;' . $strDrop . '</div>';
$titles['NoDrop'] .= '&nbsp;' . $strDrop . '</div>';
$titles['Empty'] .= '&nbsp;' . $strEmpty . '</div>';
$titles['NoEmpty'] .= '&nbsp;' . $strEmpty . '</div>';
} }
} else { } else {
$titles['Browse'] = $strBrowse; $titles['Browse'] = $strBrowse;
@@ -142,198 +139,103 @@ if ($cfg['PropertiesIconic'] == true) {
$titles['NoEmpty'] = $strEmpty; $titles['NoEmpty'] = $strEmpty;
} }
// 1. No tables /**
if ($num_tables == 0) { * Displays the tables list
echo $strNoTablesFound . "\n"; */
}
// 2. Shows table informations - staybyte - 11 June 2001
else {
?> ?>
<form method="post" action="db_details_structure.php" name="tablesForm"> <form method="post" action="db_details_structure.php" name="tablesForm">
<?php echo PMA_generate_common_hidden_inputs($db); ?>
<?php <?php
if ($cfg['PropertiesNumColumns'] > 1) { echo PMA_generate_common_hidden_inputs( $db );
?>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="top">
<?php
}
// rabus: disable statistics for information_schema. PMA_TableHeader( $table_is_schema );
if (PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema') {
$cfg['ShowStats'] = false;
$table_is_schema = true;
} else {
$table_is_schema = false;
}
pma_TableHeader( $table_is_schema );
$i = $sum_entries = 0; $i = $sum_entries = 0;
(double) $sum_size = 0; $sum_size = (double) 0;
(double) $overhead_size = 0; $overhead_size = (double) 0;
$overhead_check = ''; $overhead_check = '';
$checked = (!empty($checkall) ? ' checked="checked"' : ''); $checked = !empty($checkall) ? ' checked="checked"' : '';
$num_columns = ($cfg['PropertiesNumColumns'] > 1 ? (ceil($num_tables / $cfg['PropertiesNumColumns']) + 1) : 0); $num_columns = $cfg['PropertiesNumColumns'] > 1 ? ceil($num_tables / $cfg['PropertiesNumColumns']) + 1 : 0;
$row_count = 0; $row_count = 0;
if ($cfg['NaturalOrder']) {
$tables_temp = $tables;
foreach (array_keys($tables_temp) as $each) {
$tables_sort[$each] = $tables_temp[$each]['Name'];
}
natsort($tables_sort);
$sort_i = 0;
foreach (array_keys($tables_sort) as $each) {
$tables_temp[$sort_i] = $tables[$each];
$sort_i++;
}
$tables = $tables_temp;
}
foreach ($tables AS $keyname => $sts_data) { $hidden_fields = array();
$table = $sts_data['Name']; $odd_row = true;
$table_encoded = urlencode($table); foreach ( $tables as $keyname => $sts_data ) {
$table_name = htmlspecialchars($table); $sts_data['Type'] = isset( $sts_data['Type'] ) ? $sts_data['Type'] : '';
$table_encoded = urlencode($sts_data['Name']);
// MySQL < 5.0.13 returns "view", >= 5.0.13 returns "VIEW" // MySQL < 5.0.13 returns "view", >= 5.0.13 returns "VIEW"
$is_view = (PMA_MYSQL_INT_VERSION >= 50000 $table_is_view = (PMA_MYSQL_INT_VERSION >= 50000
&& !isset($sts_data['Type']) && empty($sts_data['Type'])
&& strtoupper($sts_data['Comment']) == 'VIEW'); && strtoupper($sts_data['Comment']) == 'VIEW');
$alias = (!empty($tooltip_aliasname) && isset($tooltip_aliasname[$table])) $alias = (!empty($tooltip_aliasname) && isset($tooltip_aliasname[$sts_data['Name']]))
? htmlspecialchars($tooltip_aliasname[$table]) ? htmlspecialchars($tooltip_aliasname[$sts_data['Name']])
: htmlspecialchars($sts_data['Name']); : htmlspecialchars($sts_data['Name']);
$truename = (!empty($tooltip_truename) && isset($tooltip_truename[$table])) $truename = (!empty($tooltip_truename) && isset($tooltip_truename[$sts_data['Name']]))
? htmlspecialchars($tooltip_truename[$table]) ? htmlspecialchars($tooltip_truename[$sts_data['Name']])
: htmlspecialchars($sts_data['Name']); : htmlspecialchars($sts_data['Name']);
// Sets parameters for links // Sets parameters for links
$tbl_url_query = $url_query . '&amp;table=' . $table_encoded; $tbl_url_query = $url_query . '&amp;table=' . $table_encoded;
$bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; $i++;
echo "\n";
if ($GLOBALS['cfg']['BrowsePointerEnable'] == TRUE) {
$on_mouse = ' onmouseover="setPointer(this, ' . $i . ', \'over\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
. ' onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
} else {
$on_mouse = '';
}
if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) {
$on_mouse .= ' onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
}
$click_mouse = ' onmousedown="document.getElementById(\'checkbox_tbl_' . $i . '\').checked = (document.getElementById(\'checkbox_tbl_' . $i . '\').checked ? false : true);" ';
$row_count++; $row_count++;
if ($num_columns > 0 && $num_tables > $num_columns && (($row_count % ($num_columns)) == 0)) {
$bgcolor = $cfg['BgcolorTwo'];
$row_count = 1;
?>
</tr>
</table>
</td>
<td><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" border="0" width="10" height="1" alt="" /></td>
<td valign="top">
<?php
pma_TableHeader();
}
?>
<tr <?php echo $on_mouse; ?>>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<input type="checkbox" name="selected_tbl[]" value="<?php echo $table_encoded; ?>" id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> />
<?php
if ($is_view) {
?>
<input type="hidden" name="views[]" value="<?php echo $table_encoded; ?>" />
<?php
}
?>
</td>
<td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap" <?php echo $click_mouse; ?>>
&nbsp;<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>&nbsp;</b>&nbsp;
</td>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<?php
require_once('./libraries/bookmark.lib.php');
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
if ( ! empty( $sts_data['Rows'] ) || $is_view ) { if ( $table_is_view ) {
echo '<a href="sql.php?' . $tbl_url_query . '&amp;sql_query=' $hidden_fields[] = '<input type="hidden" name="views[]" value="' . $table_encoded . '" />';
. (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) }
if ( ! empty( $sts_data['Rows'] ) || $table_is_view ) {
$book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($sts_data['Name']) . '\'', 'label');
$browse_table = '<a href="sql.php?' . $tbl_url_query . '&amp;sql_query='
. ( $book_sql_query ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($sts_data['Name'])))
. '&amp;pos=0">' . $titles['Browse'] . '</a>'; . '&amp;pos=0">' . $titles['Browse'] . '</a>';
} else { } else {
echo $titles['NoBrowse']; $browse_table = $titles['NoBrowse'];
} }
?>
</td> if ( ! empty($sts_data['Rows'] ) || $table_is_view ) {
<td align="center" bgcolor="<?php echo $bgcolor; ?>"> $search_table = '<a href="tbl_select.php?' . $tbl_url_query . '">'
<a href="tbl_properties_structure.php?<?php echo $tbl_url_query; ?>">
<?php echo $titles['Structure']; ?></a>
</td>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<?php
if ( ! empty($sts_data['Rows'] ) || $is_view ) {
echo '<a href="tbl_select.php?' . $tbl_url_query . '">'
. $titles['Search'] . '</a>'; . $titles['Search'] . '</a>';
} else { } else {
echo $titles['NoSearch']; $search_table = $titles['NoSearch'];
} }
?>
</td>
<?php
if ( ! $table_is_schema ) { if ( ! $table_is_schema ) {
?>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_change.php?<?php echo $tbl_url_query; ?>">
<?php echo $titles['Insert']; ?></a>
</td>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<?php
if ( ! empty($sts_data['Rows']) ) { if ( ! empty($sts_data['Rows']) ) {
echo '<a href="sql.php?' . $tbl_url_query $empty_table = '<a href="sql.php?' . $tbl_url_query
. '&amp;sql_query='; . '&amp;sql_query=';
if (PMA_MYSQL_INT_VERSION >= 40000) { if (PMA_MYSQL_INT_VERSION >= 40000) {
echo urlencode('TRUNCATE ' . PMA_backquote($table)) $empty_table .= urlencode('TRUNCATE ' . PMA_backquote($sts_data['Name']))
. '&amp;zero_rows=' . '&amp;zero_rows='
. urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table))) . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($sts_data['Name'])))
. '" onclick="return confirmLink(this, \'TRUNCATE '; . '" onclick="return confirmLink(this, \'TRUNCATE ';
} else { } else {
echo urlencode('DELETE FROM ' . PMA_backquote($table)) $empty_table .= urlencode('DELETE FROM ' . PMA_backquote($sts_data['Name']))
. '&amp;zero_rows=' . '&amp;zero_rows='
. urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table))) . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($sts_data['Name'])))
. '" onclick="return confirmLink(this, \'DELETE FROM '; . '" onclick="return confirmLink(this, \'DELETE FROM ';
} }
echo PMA_jsFormat($table) . '\')">' . $titles['Empty'] . '</a>'; $empty_table .= PMA_jsFormat($sts_data['Name']) . '\')">' . $titles['Empty'] . '</a>';
} else { } else {
echo $titles['NoEmpty']; $empty_table = $titles['NoEmpty'];
} }
?>
</td>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<?php
$drop_query = 'DROP ' $drop_query = 'DROP '
. ($is_view ? 'VIEW' : 'TABLE') . ( $table_is_view ? 'VIEW' : 'TABLE' )
. ' ' . PMA_backquote($table); . ' ' . PMA_backquote($sts_data['Name']);
$drop_message = sprintf(($is_view ? $strViewHasBeenDropped : $strTableHasBeenDropped), htmlspecialchars($table)); $drop_message = sprintf(
?> $table_is_view ? $strViewHasBeenDropped : $strTableHasBeenDropped,
<a href="sql.php?<?php echo $tbl_url_query; ?>&amp;reload=1&amp;purge=1&amp;sql_query=<?php echo urlencode($drop_query); ?>&amp;zero_rows=<?php echo urlencode($drop_message); ?>" htmlspecialchars( $sts_data['Name'] ) );
onclick="return confirmLink(this, '<?php echo PMA_jsFormat($drop_query, FALSE); ?>')">
<?php echo $titles['Drop']; ?></a>
<?php
unset($drop_query, $drop_message);
} }
?>
</td>
<?php
// loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid // loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid
// statistics whatever is the table type // statistics whatever is the table type
if ( isset( $sts_data['Rows'] ) ) { if ( isset( $sts_data['Rows'] ) ) {
// MyISAM, ISAM or Heap table: Row count, data size and index size // MyISAM, ISAM or Heap table: Row count, data size and index size
// is accurate. // is accurate.
if (isset($sts_data['Type']) && preg_match('@^(MyISAM|ISAM|HEAP|MEMORY)$@', $sts_data['Type'])) { if ( preg_match('@^(MyISAM|ISAM|HEAP|MEMORY)$@', $sts_data['Type']) ) {
if ($cfg['ShowStats']) { if ($cfg['ShowStats']) {
$tblsize = doubleval($sts_data['Data_length']) + doubleval($sts_data['Index_length']); $tblsize = doubleval($sts_data['Data_length']) + doubleval($sts_data['Index_length']);
$sum_size += $tblsize; $sum_size += $tblsize;
@@ -344,200 +246,203 @@ else {
} }
} }
$sum_entries += $sts_data['Rows']; $sum_entries += $sts_data['Rows'];
$display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator); $display_rows = $sts_data['Rows'];
} } elseif ( $sts_data['Type'] == 'InnoDB' ) {
// InnoDB table: Row count is not accurate but data and index // InnoDB table: Row count is not accurate but data and index
// sizes are. // sizes are.
else if (isset($sts_data['Type']) && $sts_data['Type'] == 'InnoDB') {
if ($cfg['ShowStats']) { if ($cfg['ShowStats']) {
$tblsize = $sts_data['Data_length'] + $sts_data['Index_length']; $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
$sum_size += $tblsize; $sum_size += $tblsize;
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
} }
//$display_rows = '&nbsp;-&nbsp;'; //$display_rows = ' - ';
// get row count with another method // get row count with another method
if ($sts_data['Rows'] < $cfg['MaxExactCount']) { if ($sts_data['Rows'] < $cfg['MaxExactCount']) {
$local_query = 'SELECT COUNT(*) AS count FROM ' $local_query = 'SELECT COUNT(*) AS count FROM '
. PMA_backquote($db) . '.' . PMA_backquote($db) . '.'
. PMA_backquote($table); . PMA_backquote($sts_data['Name']);
$table_info_result = PMA_DBI_query($local_query); $sum_entries += PMA_DBI_fetch_value( $local_query );
list($row_count) = PMA_DBI_fetch_row($table_info_result); unset( $local_query );
PMA_DBI_free_result($table_info_result);
unset($table_info_result);
$sum_entries += $row_count;
} else { } else {
$row_count = $sts_data['Rows']; $row_count = $sts_data['Rows'];
$sum_entries += $sts_data['Rows']; $sum_entries += $sts_data['Rows'];
} }
$display_rows = number_format($row_count, 0, $number_decimal_separator, $number_thousands_separator); $display_rows = $row_count;
} } elseif ( preg_match('@^(MRG_MyISAM|BerkeleyDB)$@', $sts_data['Type']) ) {
// Merge or BerkleyDB table: Only row count is accurate. // Merge or BerkleyDB table: Only row count is accurate.
else if (isset($sts_data['Type']) && preg_match('@^(MRG_MyISAM|BerkeleyDB)$@', $sts_data['Type'])) {
if ($cfg['ShowStats']) { if ($cfg['ShowStats']) {
$formated_size = '&nbsp;-&nbsp;'; $formated_size = ' - ';
$unit = ''; $unit = '';
} }
$sum_entries += $sts_data['Rows']; $sum_entries += $sts_data['Rows'];
$display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator); $display_rows = $sts_data['Rows'];
} } else {
// Unknown table type. // Unknown table type.
else {
if ($cfg['ShowStats']) { if ($cfg['ShowStats']) {
$formated_size = 'unknown'; $formated_size = 'unknown';
$unit = ''; $unit = '';
} }
$display_rows = 'unknown'; $display_rows = 'unknown';
} }
?>
<td align="right" bgcolor="<?php echo $bgcolor; ?>" <?php echo $click_mouse; ?>>
<?php
echo "\n" . ' ' . $display_rows . "\n";
?>
</td>
<?php
if (!($cfg['PropertiesNumColumns'] > 1)) {
echo ' <td bgcolor="' . $bgcolor . '" nowrap="nowrap" ' . $click_mouse . '>' . "\n"
. ' &nbsp;' . (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;') . '&nbsp;' . "\n"
. ' </td>' . "\n";
if (PMA_MYSQL_INT_VERSION >= 40100) { if (PMA_MYSQL_INT_VERSION >= 40100) {
echo ' <td bgcolor="' . $bgcolor . '" nowrap="nowrap" ' . $click_mouse . '>' . "\n" if ( isset( $sts_data['Collation'] ) ) {
. ' &nbsp;' . (isset($sts_data['Collation']) ? '<dfn title="' . PMA_getCollationDescr($sts_data['Collation']) . '">' . $sts_data['Collation'] . '</dfn>' : '---') . '&nbsp;' . "\n" $collation = '<dfn title="'
. ' </td>' . "\n"; . PMA_getCollationDescr($sts_data['Collation']) . '">'
. $sts_data['Collation'] . '</dfn>';
} else {
$collation = '---';
} }
} }
if ( $cfg['ShowStats']) { if ( $cfg['ShowStats']) {
echo "\n";
?>
<td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap" <?php echo $click_mouse; ?>>
&nbsp;&nbsp;
<a href="tbl_properties_structure.php?<?php echo $tbl_url_query; ?>#showusage"><?php echo $formated_size . ' ' . $unit; ?></a>
</td>
<td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap" <?php echo $click_mouse; ?>>
&nbsp;&nbsp;
<?php
if (isset($formated_overhead)) { if (isset($formated_overhead)) {
echo '<a href="tbl_properties_structure.php?' . $tbl_url_query . '#showusage">' . $formated_overhead . ' ' . $overhead_unit . '</a>' . "\n"; $overhead = '<a href="tbl_properties_structure.php?'
. $tbl_url_query . '#showusage">' . $formated_overhead
. ' ' . $overhead_unit . '</a>' . "\n";
unset($formated_overhead); unset($formated_overhead);
$overhead_check .= "document.getElementById('checkbox_tbl_$i').checked = true;"; $overhead_check .=
"document.getElementById('checkbox_tbl_$i').checked = true;";
} else { } else {
echo "&nbsp;-&nbsp;\n"; $overhead = '-';
} }
?>
</td>
<?php
echo "\n";
} // end if } // end if
// MySQL < 5.0.13 returns "view", >= 5.0.13 returns "VIEW"
} else if (PMA_MYSQL_INT_VERSION >= 50000 && strtoupper($sts_data['Comment']) == 'VIEW') {
// rabus: We've found a view
?>
<td align="right" bgcolor="<?php echo $bgcolor; ?>">
&nbsp;-&nbsp;
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
&nbsp;<?php echo $strView ; ?>&nbsp;
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
&nbsp;---&nbsp;
</td>
<?php
if ($cfg['ShowStats']) {
?>
<td align="right" bgcolor="<?php echo $bgcolor; ?>">
&nbsp;-&nbsp;
</td>
<td align="right" bgcolor="<?php echo $bgcolor; ?>">
&nbsp;-&nbsp;
</td>
<?php
} }
} else {
?> if ( $num_columns > 0 && $num_tables > $num_columns
<td colspan="<?php echo ($structure_tbl_col_cnt - ($table_is_schema ? 5 : 8)) ?>" align="center" bgcolor="<?php echo $bgcolor; ?>" <?php echo $click_mouse; ?>> && ( ($row_count % $num_columns) == 0 )) {
<?php echo $strInUse . "\n"; ?> $row_count = 1;
</td> $odd_row = true;
<?php
}
echo "\n";
?> ?>
</tr> </tr>
</tbody>
</table>
<?php <?php
PMA_TableHeader();
} }
?>
<tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
<td align="center">
<input type="checkbox" name="selected_tbl[]"
value="<?php echo $table_encoded; ?>"
id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> /></td>
<th><label for="checkbox_tbl_<?php echo $i; ?>"
title="<?php echo $alias; ?>"><?php echo $truename; ?></label>
</th>
<td align="center"><?php echo $browse_table; ?></td>
<td align="center">
<a href="tbl_properties_structure.php?<?php echo $tbl_url_query; ?>">
<?php echo $titles['Structure']; ?></a></td>
<td align="center"><?php echo $search_table; ?></td>
<?php if ( ! $table_is_schema ) { ?>
<td align="center">
<a href="tbl_change.php?<?php echo $tbl_url_query; ?>">
<?php echo $titles['Insert']; ?></a></td>
<td align="center"><?php echo $empty_table; ?></td>
<td align="center">
<a href="sql.php?<?php echo $tbl_url_query;
?>&amp;reload=1&amp;purge=1&amp;sql_query=<?php
echo urlencode($drop_query); ?>&amp;zero_rows=<?php
echo urlencode($drop_message); ?>"
onclick="return confirmLink(this, '<?php echo PMA_jsFormat($drop_query, FALSE); ?>')">
<?php echo $titles['Drop']; ?></a></td>
<?php } // end if ( ! $table_is_schema ) ?>
<?php if ( isset( $sts_data['Rows'] ) ) { ?>
<td class="value"><?php echo PMA_formatNumber( $display_rows ); ?></td>
<?php if (!($cfg['PropertiesNumColumns'] > 1)) { ?>
<td nowrap="nowrap"><?php echo $sts_data['Type']; ?></td>
<?php if ( isset( $collation ) ) { ?>
<td nowrap="nowrap"><?php echo $collation ?></td>
<?php } ?>
<?php } ?>
<?php if ( $cfg['ShowStats']) { ?>
<td class="value"><a
href="tbl_properties_structure.php?<?php echo $tbl_url_query; ?>#showusage"
><?php echo $formated_size . ' ' . $unit; ?></a></td>
<td class="value"><?php echo $overhead; ?></td>
<?php } // end if ?>
<?php } elseif ( $table_is_view ) { ?>
<td class="value">-</td>
<td><?php echo $strView; ?></td>
<td>---</td>
<?php if ($cfg['ShowStats']) { ?>
<td class="value">-</td>
<td class="value">-</td>
<?php } ?>
<?php } else { ?>
<td colspan="<?php echo ($structure_tbl_col_cnt - ($table_is_schema ? 5 : 8)) ?>"
align="center">
<?php echo $strInUse; ?></td>
<?php } // end if ( isset( $sts_data['Rows'] ) ) else ?>
</tr>
<?php
} // end foreach
// Show Summary // Show Summary
if ($cfg['ShowStats']) { if ($cfg['ShowStats']) {
list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1); list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
list($overhead_formated, $overhead_unit) = PMA_formatByteDown($overhead_size, 3, 1); list($overhead_formated, $overhead_unit) =
PMA_formatByteDown($overhead_size, 3, 1);
} }
echo "\n";
?> ?>
<tr> </tbody>
<td></td> <tbody>
<tr><td></td>
<th align="center" nowrap="nowrap"> <th align="center" nowrap="nowrap">
&nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp; <?php echo sprintf( $strTables, PMA_formatNumber( $num_tables ) ); ?>
</th> </th>
<th colspan="<?php echo ( $table_is_schema ? 3 : 6 ) ?>" align="center"> <th colspan="<?php echo ( $table_is_schema ? 3 : 6 ) ?>" align="center">
<b><?php echo $strSum; ?></b> <?php echo $strSum; ?>
</th>
<th align="right" nowrap="nowrap">
<b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
</th> </th>
<th class="value"><?php echo PMA_formatNumber( $sum_entries ); ?></th>
<?php <?php
if (!($cfg['PropertiesNumColumns'] > 1)) { if (!($cfg['PropertiesNumColumns'] > 1)) {
echo ' <th align="center">--</th>' . "\n";
if ( ! empty( $db_collation ) ) {
echo ' <th align="center">' . "\n" echo ' <th align="center">' . "\n"
. ' <b>--</b>' . "\n" . ' <dfn title="'
. ' </th>' . "\n"; . PMA_getCollationDescr($db_collation) . '">' . $db_collation
if (PMA_MYSQL_INT_VERSION >= 40101) { . '</dfn>' . "\n"
echo ' <th align="center">' . "\n"
. ' &nbsp;<b><dfn title="' . PMA_getCollationDescr($db_collation) . '">' . $db_collation . '</dfn></b>&nbsp;' . "\n"
. ' </th>' . "\n"; . ' </th>' . "\n";
} }
} }
if ($cfg['ShowStats']) { if ($cfg['ShowStats']) {
echo "\n";
?> ?>
<th align="right" nowrap="nowrap"> <th class="value"><?php echo $sum_formated . ' ' . $unit; ?></th>
&nbsp; <th class="value"><?php echo $overhead_formated . ' ' . $overhead_unit; ?></th>
<b><?php echo $sum_formated . ' ' . $unit; ?></b>
</th>
<th align="right" nowrap="nowrap">
&nbsp;
<b><?php echo $overhead_formated . ' ' . $overhead_unit; ?></b>
</th>
<?php <?php
} }
echo "\n";
?> ?>
</tr> </tr>
</tbody>
</table>
<div class="clearfloat">&nbsp;</div>
<?php <?php
// Check all tables url // Check all tables url
$checkall_url = 'db_details_structure.php?' . PMA_generate_common_url($db); $checkall_url = 'db_details_structure.php?' . PMA_generate_common_url($db);
echo "\n";
?> ?>
<tr> <img src="<?php echo $pmaThemeImage .'arrow_'.$text_dir.'.png'; ?>"
<td colspan="<?php echo $structure_tbl_col_cnt; ?>" valign="bottom"> width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
<img src="<?php echo $pmaThemeImage .'arrow_'.$text_dir.'.png'; ?>" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" /> <a href="<?php echo $checkall_url; ?>&amp;checkall=1"
<a href="<?php echo $checkall_url; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;"> onclick="setCheckboxes('tablesForm', true); return false;">
<?php echo $strCheckAll; ?></a> <?php echo $strCheckAll; ?></a>
&nbsp;/&nbsp; /
<a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;"> <a href="<?php echo $checkall_url; ?>"
onclick="setCheckboxes('tablesForm', false); return false;">
<?php echo $strUncheckAll; ?></a> <?php echo $strUncheckAll; ?></a>
<?php if ($overhead_check != '') { ?> <?php if ($overhead_check != '') { ?>
&nbsp;/&nbsp; /
<a href="#" onclick="setCheckboxes('tablesForm', false); <?php echo $overhead_check; ?> return false;"> <a href="#" onclick="setCheckboxes('tablesForm', false);
<?php echo $overhead_check; ?> return false;">
<?php echo $strCheckOverhead; ?></a> <?php echo $strCheckOverhead; ?></a>
<?php } ?> <?php } ?>
&nbsp;&nbsp;&nbsp;
<img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" border="0" width="38" height="1" alt="" /> <img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
width="38" height="1" alt="" />
<select name="submit_mult" dir="ltr" onchange="this.form.submit();"> <select name="submit_mult" dir="ltr" onchange="this.form.submit();">
<?php <?php
echo "\n";
echo ' <option value="' . $strWithChecked . '" selected="selected">' echo ' <option value="' . $strWithChecked . '" selected="selected">'
. $strWithChecked . '</option>' . "\n"; . $strWithChecked . '</option>' . "\n";
echo ' <option value="' . $strDrop . '" >' echo ' <option value="' . $strDrop . '" >'
@@ -564,24 +469,8 @@ else {
<noscript> <noscript>
<input type="submit" value="<?php echo $strGo; ?>" /> <input type="submit" value="<?php echo $strGo; ?>" />
</noscript> </noscript>
</td> <?php echo implode( "\n", $hidden_fields ) . "\n"; ?>
</tr>
</table>
<?php
if ($cfg['PropertiesNumColumns'] > 1) {
?>
</td>
</tr>
</table>
<?php
}
?>
</form> </form>
<?php
} // end if more than one table
echo "\n";
?>
<hr /> <hr />
<?php <?php
@@ -589,31 +478,23 @@ echo "\n";
* Work on the database * Work on the database
* redesigned 2004-05-08 by mkkeck * redesigned 2004-05-08 by mkkeck
*/ */
?> /* DATABASE WORK */
<!-- DATABASE WORK --> /* Printable view of a table */
echo '<p>';
<?php
if ($num_tables > 0) {
?>
<!-- Printable view of a table -->
<table border="0" cellpadding="2" cellspacing="0">
<tr><td nowrap="nowrap" colspan="3"><?php
echo '<a href="db_printview.php?' . $url_query . '">'; echo '<a href="db_printview.php?' . $url_query . '">';
if ( $cfg['PropertiesIconic'] ) { if ( $cfg['PropertiesIconic'] ) {
echo '<img src="' . $pmaThemeImage . 'b_print.png" border="0" width="16" height="16" hspace="2" align="middle" />'; echo '<img class="icon" src="' . $pmaThemeImage
.'b_print.png" width="16" height="16" alt="" />';
} }
echo $strPrintView . '</a> '; echo $strPrintView . '</a> ';
?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php
echo '<a href="./db_datadict.php?' . $url_query . '">'; echo '<a href="./db_datadict.php?' . $url_query . '">';
if($cfg['PropertiesIconic']){ if($cfg['PropertiesIconic']){
echo '<img src="' . $pmaThemeImage . 'b_tblanalyse.png" border="0" width="16" height="16" hspace="2" align="middle" />'; echo '<img class="icon" src="' . $pmaThemeImage
.'b_tblanalyse.png" width="16" height="16" alt="" />';
} }
echo $strDataDict . '</a>'; echo $strDataDict . '</a>';
?></td></tr> echo '</p>';
<tr><td colspan="3"><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width="1" height="1" border="0" alt="" /></td></tr></table>
<?php
} // end if
if ( empty( $table_is_schema ) ) { if ( empty( $table_is_schema ) ) {
require('./libraries/display_create_table.lib.php'); require('./libraries/display_create_table.lib.php');
@@ -622,6 +503,5 @@ if ( empty( $table_is_schema ) ) {
/** /**
* Displays the footer * Displays the footer
*/ */
echo "\n";
require_once('./footer.inc.php'); require_once('./footer.inc.php');
?> ?>