- Fix displaying indexes for print view, use same function as for normal view (bug #1119388).

- Use CSS for hiding print button rather than javascript.
This commit is contained in:
Michal Čihař
2005-02-14 17:00:08 +00:00
parent 0b1d932f3e
commit 74ec215abc
5 changed files with 45 additions and 98 deletions

View File

@@ -5,6 +5,14 @@ phpMyAdmin - Changelog
$Id$
$Source$
2005-02-14 Michal Čihař <michal@cihar.com>
* tbl_printview.php, libraries/tbl_indexes.lib.php: Fix displaying
indexes for print view, use same function as for normal view (bug
#1119388).
* css/print.css, libraries/tbl_indexes.lib.php,
libraries/header_meta_style.inc.php: Use CSS for hiding print button
rather than javascript.
2005-02-14 Marc Delisle <lem9@users.sourceforge.net>
* tbl_properties_table_info.php: avoid errors #1046, no database selected
in MySQL 5.0.2

3
css/print.css Normal file
View File

@@ -0,0 +1,3 @@
.print_ignore {
display: none;
}

View File

@@ -67,3 +67,4 @@ if (!empty($GLOBALS['cfg']['PmaAbsoluteUri'])) {
<noscript>
<link rel="stylesheet" type="text/css" href="<?php echo defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : './'; ?>css/phpmyadmin.css.php?lang=<?php echo $GLOBALS['lang']; ?>&amp;js_frame=right" />
</noscript>
<link rel="stylesheet" type="text/css" href="<?php echo defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : './'; ?>css/print.css" media="print" />

View File

@@ -136,12 +136,16 @@
* @return array Index collection array
* @author Garvin Hicking (pma@supergarv.de)
*/
function PMA_show_indexes($table, &$indexes, &$indexes_info, &$indexes_data, $display_html = true) {
function PMA_show_indexes($table, &$indexes, &$indexes_info, &$indexes_data, $display_html = true, $print_mode = false) {
$idx_collection = array();
foreach ($indexes AS $index_no => $index_name) {
if ($display_html) {
$cell_bgd = (($index_no % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']);
$index_td = ' <td bgcolor="' . $cell_bgd . '" rowspan="' . count($indexes_info[$index_name]['Sequences']) . '">' . "\n";
if ($print_mode) {
$index_td = ' <td class="print" rowspan="' . count($indexes_info[$index_name]['Sequences']) . '">' . "\n";
} else {
$cell_bgd = (($index_no % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']);
$index_td = ' <td bgcolor="' . $cell_bgd . '" rowspan="' . count($indexes_info[$index_name]['Sequences']) . '">' . "\n";
}
echo ' <tr>' . "\n";
echo $index_td
. ' ' . htmlspecialchars($index_name) . "\n"
@@ -168,9 +172,11 @@
. ' ' . (isset($indexes_info[$index_name]['Cardinality']) ? $indexes_info[$index_name]['Cardinality'] : $GLOBALS['strNone']) . '&nbsp;' . "\n"
. ' </td>' . "\n";
echo $index_td
. ' <a href="tbl_indexes.php?' . $GLOBALS['url_query'] . '&amp;index=' . urlencode($index_name) . '">' . $GLOBALS['edit_link_text'] . '</a>' . "\n"
. ' </td>' . "\n";
if (!$print_mode) {
echo $index_td
. ' <a href="tbl_indexes.php?' . $GLOBALS['url_query'] . '&amp;index=' . urlencode($index_name) . '">' . $GLOBALS['edit_link_text'] . '</a>' . "\n"
. ' </td>' . "\n";
}
if ($index_name == 'PRIMARY') {
$local_query = urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP PRIMARY KEY');
@@ -182,9 +188,11 @@
$zero_rows = urlencode(sprintf($GLOBALS['strIndexHasBeenDropped'], htmlspecialchars($index_name)));
}
echo $index_td
. ' <a href="sql.php?' . $GLOBALS['url_query'] . '&amp;sql_query=' . $local_query . '&amp;zero_rows=' . $zero_rows . '" onclick="return confirmLink(this, \'' . $js_msg . '\')">' . $GLOBALS['drop_link_text'] . '</a>' . "\n"
. ' </td>' . "\n";
if (!$print_mode) {
echo $index_td
. ' <a href="sql.php?' . $GLOBALS['url_query'] . '&amp;sql_query=' . $local_query . '&amp;zero_rows=' . $zero_rows . '" onclick="return confirmLink(this, \'' . $js_msg . '\')">' . $GLOBALS['drop_link_text'] . '</a>' . "\n"
. ' </td>' . "\n";
}
}
foreach ($indexes_info[$index_name]['Sequences'] AS $row_no => $seq_index) {
@@ -208,16 +216,22 @@
echo ' <tr>' . "\n";
}
if ($print_mode) {
$bgcolor = 'class="print"';
} else {
$bgcolor = 'bgcolor="' . $cell_bgd . '"';
}
if (!empty($indexes_data[$index_name][$seq_index]['Sub_part'])) {
echo ' <td bgcolor="' . $cell_bgd . '">' . "\n"
echo ' <td ' . $bgcolor . '>' . "\n"
. ' ' . $col_name . "\n"
. ' </td>' . "\n";
echo ' <td align="right" bgcolor="' . $cell_bgd . '">' . "\n"
echo ' <td align="right" ' . $bgcolor . '>' . "\n"
. ' ' . $indexes_data[$index_name][$seq_index]['Sub_part'] . "\n"
. ' </td>' . "\n";
echo ' </tr>' . "\n";
} else {
echo ' <td bgcolor="' . $cell_bgd . '" colspan="2">' . "\n"
echo ' <td ' . $bgcolor . ' colspan="2">' . "\n"
. ' ' . htmlspecialchars($col_name) . "\n"
. ' </td>' . "\n";
echo ' </tr>' . "\n";
@@ -260,4 +274,4 @@
$output .= "\n\n";
return $output;
}
?>
?>

View File

@@ -21,6 +21,7 @@ if (!isset($the_tables) || !is_array($the_tables)) {
*/
require_once('./libraries/relation.lib.php');
require_once('./libraries/transformations.lib.php');
require_once('./libraries/tbl_indexes.lib.php');
$cfgRelation = PMA_getRelationsParam();
@@ -86,47 +87,13 @@ foreach ($the_tables AS $key => $table) {
PMA_DBI_free_result($result);
/**
* Gets table keys and retains them
*/
$result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
$primary = '';
// Gets table keys and store them in arrays
$indexes = array();
$lastIndex = '';
$indexes_info = array();
$indexes_data = array();
$pk_array = array(); // will be use to emphasis prim. keys in the table
// view
while ($row = PMA_DBI_fetch_assoc($result)) {
// Backups the list of primary keys
if ($row['Key_name'] == 'PRIMARY') {
$primary .= $row['Column_name'] . ', ';
$pk_array[$row['Column_name']] = 1;
}
// Retains keys informations
if ($row['Key_name'] != $lastIndex ){
$indexes[] = $row['Key_name'];
$lastIndex = $row['Key_name'];
}
$indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
$indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
if (isset($row['Cardinality'])) {
$indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
}
// I don't know what does following column mean....
// $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
$indexes_info[$row['Key_name']]['Comment'] = $row['Comment'];
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
if (isset($row['Sub_part'])) {
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
}
} // end while
if ($result) {
PMA_DBI_free_result($result);
}
$ret_keys = PMA_get_indexes($table, $err_url_0);
PMA_extract_indexes($ret_keys, $indexes, $indexes_info, $indexes_data);
/**
* Gets fields properties
@@ -311,51 +278,7 @@ foreach ($the_tables AS $key => $table) {
</tr>
<?php
echo "\n";
foreach ($indexes AS $index_no => $index_name) {
$cell_bgd = (($index_no % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']);
$index_td = ' <td class="print" rowspan="' . count($indexes_info[$index_name]['Sequences']) . '">' . "\n";
echo ' <tr>' . "\n";
echo $index_td
. ' ' . htmlspecialchars($index_name) . "\n"
. ' </td>' . "\n";
if ($indexes_info[$index_name]['Comment'] == 'FULLTEXT') {
$index_type = 'FULLTEXT';
} else if ($index_name == 'PRIMARY') {
$index_type = 'PRIMARY';
} else if ($indexes_info[$index_name]['Non_unique'] == '0') {
$index_type = 'UNIQUE';
} else {
$index_type = 'INDEX';
}
echo $index_td
. ' ' . $index_type . "\n"
. ' </td>' . "\n";
echo $index_td
. ' ' . (isset($indexes_info[$index_name]['Cardinality']) ? $indexes_info[$index_name]['Cardinality'] : $strNone) . "\n"
. ' </td>' . "\n";
foreach ($indexes_info[$index_name]['Sequences'] AS $row_no => $seq_index) {
if ($row_no > 0) {
echo ' <tr>' . "\n";
}
if (!empty($indexes_data[$index_name][$seq_index]['Sub_part'])) {
echo ' <td class="print">' . "\n"
. ' ' . $indexes_data[$index_name][$seq_index]['Column_name'] . "\n"
. ' </td>' . "\n";
echo ' <td align="right" class="print">' . "\n"
. ' ' . $indexes_data[$index_name][$seq_index]['Sub_part'] . "\n"
. ' </td>' . "\n";
echo ' </tr>' . "\n";
} else {
echo ' <td class="print" colspan="2">' . "\n"
. ' ' . $indexes_data[$index_name][$seq_index]['Column_name'] . "\n"
. ' </td>' . "\n";
echo ' </tr>' . "\n";
}
} // end while
} // end while
PMA_show_indexes($table, $indexes, $indexes_info, $indexes_data, true, true);
echo "\n";
?>
</table>
@@ -615,17 +538,15 @@ echo "\n";
<!--
function printPage()
{
document.getElementById('print').style.visibility = 'hidden';
// Do print the page
if (typeof(window.print) != 'undefined') {
window.print();
}
document.getElementById('print').style.visibility = '';
}
//-->
</script>
<?php
echo '<br /><br />&nbsp;<input type="button" style="visibility: ; width: 100px; height: 25px" id="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
echo '<br /><br />&nbsp;<input type="button" class="print_ignore" style="width: 100px; height: 25px" id="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
require_once('./footer.inc.php');
?>