revised XHTML output

This commit is contained in:
Sebastian Mendel
2005-12-02 13:04:22 +00:00
parent e922ebee97
commit 0237ab7160
3 changed files with 457 additions and 394 deletions

View File

@@ -1,25 +1,27 @@
<?php <?php
/* $Id$ */ /* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
/**
* function library for handling table indexes
*/
/** /**
* Return a list of all index types * Return a list of all index types
* *
* @access public * @access public
* @return array Index types * @return array Index types
* @author Garvin Hicking (pma@supergarv.de) * @author Garvin Hicking (pma@supergarv.de)
*/ */
function PMA_get_indextypes() {
function PMA_get_indextypes() {
return array( return array(
'PRIMARY', 'PRIMARY',
'INDEX', 'INDEX',
'UNIQUE', 'UNIQUE',
'FULLTEXT' 'FULLTEXT'
); );
} }
/** /**
* Function to get all index information from a certain table * Function to get all index information from a certain table
* *
* @param string Table name * @param string Table name
@@ -28,7 +30,7 @@
* @access public * @access public
* @return array Index keys * @return array Index keys
*/ */
function PMA_get_indexes($tbl_name, $err_url_0 = '') { function PMA_get_indexes($tbl_name, $err_url_0 = '') {
$tbl_local_query = 'SHOW KEYS FROM ' . PMA_backquote($tbl_name); $tbl_local_query = 'SHOW KEYS FROM ' . PMA_backquote($tbl_name);
$tbl_result = PMA_DBI_query($tbl_local_query) or PMA_mysqlDie('', $tbl_local_query, '', $err_url_0); $tbl_result = PMA_DBI_query($tbl_local_query) or PMA_mysqlDie('', $tbl_local_query, '', $err_url_0);
$tbl_ret_keys = array(); $tbl_ret_keys = array();
@@ -38,9 +40,9 @@
PMA_DBI_free_result($tbl_result); PMA_DBI_free_result($tbl_result);
return $tbl_ret_keys; return $tbl_ret_keys;
} }
/** /**
* Function to check over array of indexes and look for common problems * Function to check over array of indexes and look for common problems
* *
* @param array Array of indexes * @param array Array of indexes
@@ -50,10 +52,14 @@
* @return string Output HTML * @return string Output HTML
* @author Garvin Hicking (pma@supergarv.de) * @author Garvin Hicking (pma@supergarv.de)
*/ */
function PMA_check_indexes($idx_collection, $table = true) { function PMA_check_indexes($idx_collection, $table = true) {
$index_types = PMA_get_indextypes(); $index_types = PMA_get_indextypes();
$output = ''; $output = '';
if (is_array($idx_collection) && isset($idx_collection['ALL'])) {
if ( ! is_array($idx_collection) || empty($idx_collection['ALL'])) {
return $output;
}
foreach($idx_collection['ALL'] AS $w_keyname => $w_count) { foreach($idx_collection['ALL'] AS $w_keyname => $w_count) {
if (isset($idx_collection['PRIMARY'][$w_keyname]) && (isset($idx_collection['INDEX'][$w_keyname]) || isset($idx_collection['UNIQUE'][$w_keyname]))) { if (isset($idx_collection['PRIMARY'][$w_keyname]) && (isset($idx_collection['INDEX'][$w_keyname]) || isset($idx_collection['UNIQUE'][$w_keyname]))) {
$output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningPrimary'], htmlspecialchars($w_keyname)), $table); $output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningPrimary'], htmlspecialchars($w_keyname)), $table);
@@ -67,12 +73,11 @@
} }
} }
} }
}
return $output; return $output;
} }
/** /**
* Loop array of returned index keys and extract key information to * Loop array of returned index keys and extract key information to
* seperate arrays. Those arrays are passed by reference. * seperate arrays. Those arrays are passed by reference.
* *
@@ -85,7 +90,7 @@
* @return boolean void * @return boolean void
* @author Garvin Hicking (pma@supergarv.de) * @author Garvin Hicking (pma@supergarv.de)
*/ */
function PMA_extract_indexes(&$ret_keys, &$indexes, &$indexes_info, &$indexes_data) { function PMA_extract_indexes(&$ret_keys, &$indexes, &$indexes_info, &$indexes_data) {
if (!is_array($ret_keys)) { if (!is_array($ret_keys)) {
return false; return false;
} }
@@ -120,63 +125,58 @@
} // end while } // end while
return true; return true;
} }
/** /**
* Show index data and prepare returned collection array for index * Show index data and prepare returned collection array for index
* key checks. * key checks.
* *
* @param string The tablename * @param string $table The tablename
* @param array Referenced Array of indexes * @param array $indexes Referenced Array of indexes
* @param array Referenced info array * @param array $indexes_info Referenced info array
* @param array Referenced data array * @param array $indexes_data Referenced data array
* @param boolean Output HTML code, or just return collection array? * @param boolean $display_html Output HTML code, or just return collection array?
* * @param boolean $print_mode
* @access public * @access public
* @return array Index collection array * @return array Index collection array
* @author Garvin Hicking (pma@supergarv.de) * @author Garvin Hicking (pma@supergarv.de)
*/ */
function PMA_show_indexes($table, &$indexes, &$indexes_info, &$indexes_data, $display_html = true, $print_mode = false) { function PMA_show_indexes($table, &$indexes, &$indexes_info, &$indexes_data, $display_html = true, $print_mode = false) {
$idx_collection = array(); $idx_collection = array();
foreach ($indexes AS $index_no => $index_name) { $odd_row = true;
foreach ($indexes as $index_name) {
if ($display_html) { if ($display_html) {
if ($print_mode) { $row_span = ' rowspan="' . count($indexes_info[$index_name]['Sequences']) . '" ';
$index_td = ' <td class="print" rowspan="' . count($indexes_info[$index_name]['Sequences']) . '">' . "\n";
} else { echo ' <tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n";
$cell_bgd = (($index_no % 2) ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']); echo ' <th ' . $row_span . '>' . "\n"
$index_td = ' <td bgcolor="' . $cell_bgd . '" rowspan="' . count($indexes_info[$index_name]['Sequences']) . '">' . "\n";
}
echo ' <tr>' . "\n";
echo $index_td
. ' ' . htmlspecialchars($index_name) . "\n" . ' ' . htmlspecialchars($index_name) . "\n"
. ' </td>' . "\n"; . ' </th>' . "\n";
} }
if ((PMA_MYSQL_INT_VERSION < 40002 && $indexes_info[$index_name]['Comment'] == 'FULLTEXT') if ((PMA_MYSQL_INT_VERSION < 40002 && $indexes_info[$index_name]['Comment'] == 'FULLTEXT')
|| (PMA_MYSQL_INT_VERSION >= 40002 && $indexes_info[$index_name]['Index_type'] == 'FULLTEXT')) { || (PMA_MYSQL_INT_VERSION >= 40002 && $indexes_info[$index_name]['Index_type'] == 'FULLTEXT')) {
$index_type = 'FULLTEXT'; $index_type = 'FULLTEXT';
} else if ($index_name == 'PRIMARY') { } elseif ($index_name == 'PRIMARY') {
$index_type = 'PRIMARY'; $index_type = 'PRIMARY';
} else if ($indexes_info[$index_name]['Non_unique'] == '0') { } elseif ($indexes_info[$index_name]['Non_unique'] == '0') {
$index_type = 'UNIQUE'; $index_type = 'UNIQUE';
} else { } else {
$index_type = 'INDEX'; $index_type = 'INDEX';
} }
if ($display_html) { if ($display_html) {
echo $index_td echo ' <td ' . $row_span . '>' . "\n"
. ' ' . $index_type . "\n" . ' ' . $index_type . '</td>' . "\n";
. ' </td>' . "\n";
echo str_replace('">' . "\n", '" align="right">' . "\n", $index_td) echo ' <td ' . $row_span . ' align="right">' . "\n"
. ' ' . (isset($indexes_info[$index_name]['Cardinality']) ? $indexes_info[$index_name]['Cardinality'] : $GLOBALS['strNone']) . '&nbsp;' . "\n" . ' ' . (isset($indexes_info[$index_name]['Cardinality']) ? $indexes_info[$index_name]['Cardinality'] : $GLOBALS['strNone']) . '&nbsp;' . "\n"
. ' </td>' . "\n"; . ' </td>' . "\n";
if (!$print_mode) { if (!$print_mode) {
echo $index_td echo ' <td ' . $row_span . '>' . "\n"
. ' <a href="tbl_indexes.php?' . $GLOBALS['url_query'] . '&amp;index=' . urlencode($index_name) . '">' . $GLOBALS['edit_link_text'] . '</a>' . "\n" . ' <a href="tbl_indexes.php?' . $GLOBALS['url_query'] . '&amp;index=' . urlencode($index_name) . '">' . $GLOBALS['edit_link_text'] . '</a>' . "\n"
. ' </td>' . "\n"; . ' </td>' . "\n";
}
if ($index_name == 'PRIMARY') { if ($index_name == 'PRIMARY') {
$local_query = urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP PRIMARY KEY'); $local_query = urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP PRIMARY KEY');
@@ -188,8 +188,7 @@
$zero_rows = urlencode(sprintf($GLOBALS['strIndexHasBeenDropped'], htmlspecialchars($index_name))); $zero_rows = urlencode(sprintf($GLOBALS['strIndexHasBeenDropped'], htmlspecialchars($index_name)));
} }
if (!$print_mode) { echo ' <td ' . $row_span . '>' . "\n"
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" . ' <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"; . ' </td>' . "\n";
} }
@@ -213,65 +212,46 @@
if ($display_html) { if ($display_html) {
if ($row_no > 0) { if ($row_no > 0) {
echo ' <tr>' . "\n"; echo ' <tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n";
}
if ($print_mode) {
$bgcolor = 'class="print"';
} else {
$bgcolor = 'bgcolor="' . $cell_bgd . '"';
} }
if (!empty($indexes_data[$index_name][$seq_index]['Sub_part'])) { if (!empty($indexes_data[$index_name][$seq_index]['Sub_part'])) {
echo ' <td ' . $bgcolor . '>' . "\n" echo ' <td>' . $col_name . '</td>' . "\n";
. ' ' . $col_name . "\n" echo ' <td align="right">' . "\n"
. ' </td>' . "\n";
echo ' <td align="right" ' . $bgcolor . '>' . "\n"
. ' ' . $indexes_data[$index_name][$seq_index]['Sub_part'] . "\n" . ' ' . $indexes_data[$index_name][$seq_index]['Sub_part'] . "\n"
. ' </td>' . "\n"; . ' </td>' . "\n";
echo ' </tr>' . "\n"; echo ' </tr>' . "\n";
} else { } else {
echo ' <td ' . $bgcolor . ' colspan="2">' . "\n" echo ' <td colspan="2">' . "\n"
. ' ' . htmlspecialchars($col_name) . "\n" . ' ' . htmlspecialchars($col_name) . "\n"
. ' </td>' . "\n"; . ' </td>' . "\n";
echo ' </tr>' . "\n"; echo ' </tr>' . "\n";
} }
} }
} // end while } // end foreach $indexes_info[$index_name]['Sequences']
$odd_row = ! $odd_row;
} // end while } // end while
return $idx_collection; return $idx_collection;
} }
/** /**
* Function to emit a index warning * Function to emit a index warning
* *
* @param string Message string
* @param boolean Whether to output HTML in table layout
*
* @access public
* @output string Output HTML
* @author Garvin Hicking (pma@supergarv.de) * @author Garvin Hicking (pma@supergarv.de)
* @access public
* @param string $string Message string
* @param boolean $table Whether to output HTML in table layout
* @return string Output HTML
*/ */
function PMA_index_warning($string, $table = true) { function PMA_index_warning($string, $table = true) {
$output = ''; $output = '<div class="warning">' . $string . '</div>';
if ($table) {
$output .= "\n" . ' <tr><td colspan=7">' . "\n"; if ( $table ) {
$output = '<tr><td colspan=7">' . $output . '</td></tr>';
} }
if ($GLOBALS['cfg']['ErrorIconic']) { return $output . "\n";
$output .= '<img src="' . $GLOBALS['pmaThemeImage'] . 's_warn.png" width="16" height="16" border="0" alt="Warning" hspace="2" align="middle" />'; }
}
$output .= ' <b>' . $string . '</b>';
if ($table) {
$output .= '</td></tr>';
} else {
$output .= '<br />';
}
$output .= "\n\n";
return $output;
}
?> ?>

View File

@@ -21,27 +21,41 @@ $index_types_cnt = count($index_types);
*/ */
if (!defined('PMA_IDX_INCLUDED')) { if (!defined('PMA_IDX_INCLUDED')) {
// Not a valid db name -> back to the welcome page // Not a valid db name -> back to the welcome page
if (!empty($db)) { if ( !empty($db) ) {
$is_db = PMA_DBI_select_db($db); $is_db = PMA_DBI_select_db($db);
} }
if (empty($db) || !$is_db) { if ( empty($db) || !$is_db ) {
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); $uri_params = array( 'reload' => '1' );
if ( isset($message) ) {
$uri_params['message'] = $message;
}
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php'
. PMA_generate_common_url($uri_params, '&'));
exit; exit;
} }
// Not a valid table name -> back to the default db_details sub-page // Not a valid table name -> back to the default db_details sub-page
if (!empty($table)) { if ( !empty($table) ) {
$is_table = PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'', NULL, PMA_DBI_QUERY_STORE); $is_table = PMA_DBI_query('SHOW TABLES LIKE \''
. PMA_sqlAddslashes($table, TRUE) . '\'', NULL, PMA_DBI_QUERY_STORE);
} }
if (empty($table) if ( empty($table)
|| !($is_table && PMA_DBI_num_rows($is_table))) { || !( $is_table && PMA_DBI_num_rows($is_table) ) ) {
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db, '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); $uri_params = array( 'reload' => '1', 'db' => $db );
if ( isset($message) ) {
$uri_params['message'] = $message;
}
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri']
. $cfg['DefaultTabDatabase']
. PMA_generate_common_url($uri_params, '&'));
exit; exit;
} else if (isset($is_table)) { } elseif ( isset($is_table) ) {
PMA_DBI_free_result($is_table); PMA_DBI_free_result($is_table);
} }
// Displays headers (if needed) // Displays headers (if needed)
$js_to_run = ((isset($index) && isset($do_save_data)) ? 'functions.js' : 'indexes.js'); $js_to_run = isset($index) && isset($do_save_data)
? 'functions.js'
: 'indexes.js';
require_once('./libraries/header.inc.php'); require_once('./libraries/header.inc.php');
} // end if } // end if
@@ -67,7 +81,8 @@ PMA_extract_indexes($ret_keys, $indexes, $indexes_info, $indexes_data);
// Get fields and stores their name/type // Get fields and stores their name/type
// fields had already been grabbed in "tbl_properties.php" // fields had already been grabbed in "tbl_properties.php"
if (!defined('PMA_IDX_INCLUDED')) { if (!defined('PMA_IDX_INCLUDED')) {
$fields_rs = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';'); $fields_rs = PMA_DBI_query('SHOW FIELDS FROM '
. PMA_backquote($table) . ';');
$save_row = array(); $save_row = array();
while ($row = PMA_DBI_fetch_assoc($fields_rs)) { while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
$save_row[] = $row; $save_row[] = $row;
@@ -80,7 +95,8 @@ foreach ($save_row AS $saved_row_key => $row) {
$fields_names[] = $row['Field']; $fields_names[] = $row['Field'];
// loic1: set or enum types: slashes single quotes inside options // loic1: set or enum types: slashes single quotes inside options
if (preg_match('@^(set|enum)\((.+)\)$@i', $row['Type'], $tmp)) { if (preg_match('@^(set|enum)\((.+)\)$@i', $row['Type'], $tmp)) {
$tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1); $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'',
',' . $tmp[2]), 1);
$fields_types[] = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $fields_types[] = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
} else { } else {
$fields_types[] = $row['Type']; $fields_types[] = $row['Type'];
@@ -135,13 +151,16 @@ if (!defined('PMA_IDX_INCLUDED')
$sql_query .= ' ADD PRIMARY KEY ('; $sql_query .= ' ADD PRIMARY KEY (';
break; break;
case 'FULLTEXT': case 'FULLTEXT':
$sql_query .= ' ADD FULLTEXT ' . (empty($index) ? '' : PMA_backquote($index)) . ' ('; $sql_query .= ' ADD FULLTEXT '
. (empty($index) ? '' : PMA_backquote($index)) . ' (';
break; break;
case 'UNIQUE': case 'UNIQUE':
$sql_query .= ' ADD UNIQUE ' . (empty($index) ? '' : PMA_backquote($index)) . ' ('; $sql_query .= ' ADD UNIQUE '
. (empty($index) ? '' : PMA_backquote($index)) . ' (';
break; break;
case 'INDEX': case 'INDEX':
$sql_query .= ' ADD INDEX ' . (empty($index) ? '' : PMA_backquote($index)) . ' ('; $sql_query .= ' ADD INDEX '
. (empty($index) ? '' : PMA_backquote($index)) . ' (';
break; break;
} // end switch } // end switch
$index_fields = ''; $index_fields = '';
@@ -149,7 +168,9 @@ if (!defined('PMA_IDX_INCLUDED')
if ($name != '--ignore--') { if ($name != '--ignore--') {
$index_fields .= (empty($index_fields) ? '' : ',') $index_fields .= (empty($index_fields) ? '' : ',')
. PMA_backquote($name) . PMA_backquote($name)
. (empty($sub_part[$i]) ? '' : '(' . $sub_part[$i] . ')'); . (empty($sub_part[$i])
? ''
: '(' . $sub_part[$i] . ')');
} }
} // end while } // end while
if (empty($index_fields)){ if (empty($index_fields)){
@@ -159,7 +180,8 @@ if (!defined('PMA_IDX_INCLUDED')
} }
$result = PMA_DBI_query($sql_query); $result = PMA_DBI_query($sql_query);
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered; $message = $strTable . ' ' . htmlspecialchars($table) . ' '
. $strHasBeenAltered;
$active_page = 'tbl_properties_structure.php'; $active_page = 'tbl_properties_structure.php';
require('./tbl_properties_structure.php'); require('./tbl_properties_structure.php');
@@ -187,7 +209,8 @@ else if (!defined('PMA_IDX_INCLUDED')
$edited_index_data = array(); $edited_index_data = array();
for ($i = 1; $i <= $idx_num_fields; $i++) { for ($i = 1; $i <= $idx_num_fields; $i++) {
$edited_index_info['Sequences'][] = $i; $edited_index_info['Sequences'][] = $i;
$edited_index_data[$i] = array('Column_name' => '', 'Sub_part' => ''); $edited_index_data[$i] = array('Column_name' => '',
'Sub_part' => '');
} // end for } // end for
if ($old_index == '' if ($old_index == ''
&& !isset($indexes_info['PRIMARY']) && !isset($indexes_info['PRIMARY'])
@@ -199,8 +222,10 @@ else if (!defined('PMA_IDX_INCLUDED')
$edited_index_data = $indexes_data[$old_index]; $edited_index_data = $indexes_data[$old_index];
if ((PMA_MYSQL_INT_VERSION < 40002 && $edited_index_info['Comment'] == 'FULLTEXT') if ((PMA_MYSQL_INT_VERSION < 40002
|| (PMA_MYSQL_INT_VERSION >= 40002 && $edited_index_info['Index_type'] == 'FULLTEXT')) { && $edited_index_info['Comment'] == 'FULLTEXT')
|| (PMA_MYSQL_INT_VERSION >= 40002
&& $edited_index_info['Index_type'] == 'FULLTEXT')) {
$index_type = 'FULLTEXT'; $index_type = 'FULLTEXT';
} else if ($index == 'PRIMARY') { } else if ($index == 'PRIMARY') {
$index_type = 'PRIMARY'; $index_type = 'PRIMARY';
@@ -218,7 +243,8 @@ else if (!defined('PMA_IDX_INCLUDED')
$field_cnt = count($edited_index_info['Sequences']) + 1; $field_cnt = count($edited_index_info['Sequences']) + 1;
for ($i = $field_cnt; $i < ($added_fields + $field_cnt); $i++) { for ($i = $field_cnt; $i < ($added_fields + $field_cnt); $i++) {
$edited_index_info['Sequences'][] = $i; $edited_index_info['Sequences'][] = $i;
$edited_index_data[$i] = array('Column_name' => '', 'Sub_part' => ''); $edited_index_data[$i] = array('Column_name' => '',
'Sub_part' => '');
} // end for } // end for
// Restore entered values // Restore entered values
@@ -232,67 +258,79 @@ else if (!defined('PMA_IDX_INCLUDED')
// end preparing form values // end preparing form values
?> ?>
<!-- Build index form --> <div style="float: left;">
<form action="./tbl_indexes.php" method="post" name="index_frm" <form action="./tbl_indexes.php" method="post" name="index_frm"
onsubmit="if (typeof(this.elements['index'].disabled) != 'undefined') {this.elements['index'].disabled = false}"> onsubmit="if (typeof(this.elements['index'].disabled) != 'undefined') {
<table border="0" cellpadding="2" cellspacing="1"> this.elements['index'].disabled = false}">
<tr><td class="tblHeaders" colspan="2">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?> <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<?php <?php
if (isset($create_index)) { if (isset($create_index)) {
echo '<input type="hidden" name="create_index" value="1" />'; echo '<input type="hidden" name="create_index" value="1" />' . "\n";
}
if (isset($added_fields)) {
echo ' <input type="hidden" name="prev_add_fields" value="'
. $added_fields . '" />' . "\n";
}
if (isset($idx_num_fields)) {
echo ' <input type="hidden" name="idx_num_fields" value="'
. $idx_num_fields . '" />' . "\n";
} }
echo "\n";
?> ?>
<input type="hidden" name="old_index" value="<?php echo (isset($create_index) ? '' : htmlspecialchars($old_index)); ?>" /> <input type="hidden" name="old_index" value="<?php
<?php echo ' ' . (isset($create_index) ? $strCreateIndexTopic : $strModifyIndexTopic) . ' '; ?> echo (isset($create_index) ? '' : htmlspecialchars($old_index)); ?>" />
</th></tr>
<fieldset>
<tr> <legend>
<td align="right"><b><?php echo $strIndexName; ?></b>&nbsp;</th> <?php
<td> echo (isset($create_index) ? $strCreateIndexTopic : $strModifyIndexTopic);
<input type="text" name="index" value="<?php echo htmlspecialchars($index); ?>" size="25" onfocus="this.select()" /> ?>
</td> </legend>
</tr>
<tr><td align="right"><?php <div class="formelement">
if ($cfg['ErrorIconic']) { <label for="input_index_name"><?php echo $strIndexName; ?></label>
echo '<img src="' . $pmaThemeImage . 's_warn.png" width="16" height="16" border="0" alt="Attention" />'; <input type="text" name="index" id="input_index_name" size="25"
} value="<?php echo htmlspecialchars($index); ?>" onfocus="this.select()" />
?></td><td><?php echo $strPrimaryKeyWarning . "\n"; ?></td></tr> </div>
<tr>
<td align="right"><b><?php echo $strIndexType; ?></b>&nbsp;</td> <div class="formelement">
<td> <label for="select_index_type"><?php echo $strIndexType; ?></label>
<select name="index_type" onchange="return checkIndexName()"> <select name="index_type" id="select_index_type" onchange="return checkIndexName()">
<?php <?php
echo "\n";
for ($i = 0; $i < $index_types_cnt; $i++) { for ($i = 0; $i < $index_types_cnt; $i++) {
if ($index_types[$i] == 'PRIMARY') { if ($index_types[$i] == 'PRIMARY') {
if ($index == 'PRIMARY' || !isset($indexes_info['PRIMARY'])) { if ($index == 'PRIMARY' || !isset($indexes_info['PRIMARY'])) {
echo ' ' echo ' '
. '<option value="PRIMARY"' . (($index_type == 'PRIMARY') ? ' selected="selected"' : '') . '>PRIMARY</option>' . '<option value="PRIMARY"'
. "\n"; . (($index_type == 'PRIMARY') ? ' selected="selected"' : '')
. '>PRIMARY</option>' . "\n";
} }
} else { } else {
echo ' ' echo ' '
. '<option value="' . $index_types[$i] . '"' . (($index_type == $index_types[$i]) ? ' selected="selected"' : '') . '>'. $index_types[$i] . '</option>' . '<option value="' . $index_types[$i] . '"'
. "\n"; . (($index_type == $index_types[$i]) ? ' selected="selected"' : '')
. '>'. $index_types[$i] . '</option>' . "\n";
} // end if... else... } // end if... else...
} // end for } // end for
?> ?>
</select> </select>
<?php echo PMA_showMySQLDocu('SQL-Syntax', 'ALTER_TABLE') . "\n"; ?> <?php echo PMA_showMySQLDocu('SQL-Syntax', 'ALTER_TABLE'); ?>
</td> </div>
</tr>
<tr><td valign="top" align="right"><b><?php echo $strFields; ?> :</b>&nbsp;</td><td><table border="<?php echo $cfg['Border']; ?>" cellpadding="2" cellspacing="1">
<tr> <br class="clearfloat" />
<th><?php echo $strField; ?></th> <div class="warning"><?php echo $strPrimaryKeyWarning; ?></div>
<table border="<?php echo $cfg['Border']; ?>" cellpadding="2" cellspacing="1">
<thead>
<tr><th><?php echo $strField; ?></th>
<th><?php echo $strSize; ?></th> <th><?php echo $strSize; ?></th>
</tr> </tr>
</thead>
<tbody>
<?php <?php
foreach ($edited_index_info['Sequences'] AS $row_no => $seq_index) { $odd_row = true;
foreach ($edited_index_info['Sequences'] as $seq_index) {
$add_type = (is_array($fields_types) && count($fields_types) == count($fields_names)); $add_type = (is_array($fields_types) && count($fields_types) == count($fields_names));
$selected = $edited_index_data[$seq_index]['Column_name']; $selected = $edited_index_data[$seq_index]['Column_name'];
if (!empty($edited_index_data[$seq_index]['Sub_part'])) { if (!empty($edited_index_data[$seq_index]['Sub_part'])) {
@@ -300,79 +338,93 @@ else if (!defined('PMA_IDX_INCLUDED')
} else { } else {
$sub_part = ''; $sub_part = '';
} }
$bgcolor = (($row_no % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']);
echo "\n";
?> ?>
<tr>
<td bgcolor="<?php echo $bgcolor; ?>"> <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
<select name="column[]"> <td><select name="column[]">
<option value="--ignore--"<?php if ('--ignore--' == $selected) echo ' selected="selected"'; ?>> <option value="--ignore--"
<?php if ('--ignore--' == $selected) echo ' selected="selected"'; ?>>
-- <?php echo $strIgnore; ?> --</option> -- <?php echo $strIgnore; ?> --</option>
<?php <?php
foreach ($fields_names AS $key => $val) { foreach ($fields_names AS $key => $val) {
if ($index_type != 'FULLTEXT' if ($index_type != 'FULLTEXT'
|| preg_match('@^(varchar|text|tinytext|mediumtext|longtext)@i', $fields_types[$key])) { || preg_match('@^(varchar|text|tinytext|mediumtext|longtext)@i', $fields_types[$key])) {
echo "\n" . ' ' echo "\n" . ' '
. '<option value="' . htmlspecialchars($val) . '"' . (($val == $selected) ? ' selected="selected"' : '') . '>' . '<option value="' . htmlspecialchars($val) . '"'
. htmlspecialchars($val) . (($add_type) ? ' [' . $fields_types[$key] . ']' : '' ) . '</option>' . "\n"; . (($val == $selected) ? ' selected="selected"' : '') . '>'
. htmlspecialchars($val) . (($add_type) ? ' ['
. $fields_types[$key] . ']' : '' ) . '</option>' . "\n";
} }
} // end while } // end foreach $fields_names
echo "\n";
?> ?>
</select> </select>
</td> </td>
<td bgcolor="<?php echo $bgcolor; ?>"> <td><input type="text" size="5" onfocus="this.select()"
<input type="text" size="5" name="sub_part[]"<?php echo $sub_part; ?> onfocus="this.select()" /> name="sub_part[]"<?php echo $sub_part; ?> />
</td> </td>
</tr>
<?php
} // end while
echo "\n";
?>
<tr><td colspan="2"><?php
echo "\n";
if (isset($added_fields)) {
echo ' <input type="hidden" name="prev_add_fields" value="' . $added_fields . '" />';
}
if (isset($idx_num_fields)) {
echo ' <input type="hidden" name="idx_num_fields" value="' . $idx_num_fields . '" />' . "\n";
}
echo ' ' . "\n";
echo ' ' . sprintf($strAddToIndex, '<input type="text" name="added_fields" size="2" value="1" onfocus="this.select()" style="vertical-align: middle;" />') . "\n";
echo ' &nbsp;<input type="submit" name="add_fields" value="' . $strGo . '" onclick="return checkFormElementInRange(this.form, \'added_fields\', \'' . str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']) . '\', 1)" style="vertical-align: middle;" />' . "\n";
?></td>
</tr> </tr>
</table></td></tr> <?php
<tr><td colspan="2" class="tblFooters" align="center"> $odd_row = !$odd_row;
<input type="submit" name="do_save_data" value="<?php echo $strSave; ?>" /></td></tr> } // end foreach $edited_index_info['Sequences']
?>
</tbody>
</table> </table>
</fieldset>
<fieldset class="tblFooters">
<input type="submit" name="do_save_data" value="<?php echo $strSave; ?>" />
<?php
echo $strOr;
echo ' ' . sprintf($strAddToIndex,
'<input type="text" name="added_fields" size="2" value="1"'
.' onfocus="this.select()" />') . "\n";
echo ' <input type="submit" name="add_fields" value="' . $strGo . '"'
.' onclick="return checkFormElementInRange(this.form,'
.' \'added_fields\', \''
. str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount'])
. '\', 1)" />' . "\n";
?>
</fieldset>
</form> </form>
</div>
<?php <?php
} else { } else {
/** /**
* Display indexes * Display indexes
*/ */
?> ?>
<!-- Indexes form --> <form action="./tbl_indexes.php" method="post"
<form action="./tbl_indexes.php" method="post" onsubmit="return checkFormElementInRange(this, 'idx_num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']); ?>', 1)"> onsubmit="return checkFormElementInRange(this, 'idx_num_fields',
<table border="0" cellpadding="2" cellspacing="1"> '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']); ?>',
<tr><td class="tblHeaders" colspan="7"> 1)">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?> <table id="table_indexes" class="data">
<caption class="tblHeaders">
<?php <?php
echo "\n"; echo $strIndexes . ':' . "\n";
echo ' ' . $strIndexes . ':' . "\n"; echo ' ' . PMA_showMySQLDocu('optimization',
echo ' ' . PMA_showMySQLDocu('optimization', 'optimizing-database-structure') . "\n"; 'optimizing-database-structure');
?></td></tr><?php ?>
</caption>
<?php
echo PMA_generate_common_hidden_inputs( $db, $table );
if ( count($ret_keys) > 0) {
$edit_link_text = ''; $edit_link_text = '';
$drop_link_text = ''; $drop_link_text = '';
// We need to copy the value or else the == 'both' check will always return true // We need to copy the value or else the == 'both' check will always
$propicon = (string)$cfg['PropertiesIconic']; // return true
$propicon = (string) $cfg['PropertiesIconic'];
if ($cfg['PropertiesIconic'] === true || $propicon == 'both') { if ($cfg['PropertiesIconic'] === true || $propicon == 'both') {
$edit_link_text = '<img src="' . $pmaThemeImage . 'b_edit.png" width="16" height="16" hspace="2" border="0" title="' . $strEdit . '" alt="' . $strEdit . '" />'; $edit_link_text = '<img class="icon" src="' . $pmaThemeImage
$drop_link_text = '<img src="' . $pmaThemeImage . 'b_drop.png" width="16" height="16" hspace="2" border="0" title="' . $strDrop . '" alt="' . $strDrop . '" />'; . 'b_edit.png" width="16" height="16" title="' . $strEdit
. '" alt="' . $strEdit . '" />';
$drop_link_text = '<img class="icon" src="' . $pmaThemeImage
. 'b_drop.png" width="16" height="16" title="' . $strDrop
. '" alt="' . $strDrop . '" />';
} }
if ($cfg['PropertiesIconic'] === false || $propicon == 'both') { if ($cfg['PropertiesIconic'] === false || $propicon == 'both') {
$edit_link_text .= $strEdit; $edit_link_text .= $strEdit;
@@ -382,37 +434,43 @@ else if (!defined('PMA_IDX_INCLUDED')
$edit_link_text = '<nobr>' . $edit_link_text . '</nobr>'; $edit_link_text = '<nobr>' . $edit_link_text . '</nobr>';
$drop_link_text = '<nobr>' . $drop_link_text . '</nobr>'; $drop_link_text = '<nobr>' . $drop_link_text . '</nobr>';
} }
if (count($ret_keys) > 0) {
?> ?>
<!--table border="<?php echo $cfg['Border']; ?>" cellpadding="2" cellspacing="1"-->
<tr> <thead>
<th><?php echo $strKeyname; ?></th> <tr><th><?php echo $strKeyname; ?></th>
<th><?php echo $strType; ?></th> <th><?php echo $strType; ?></th>
<th><?php echo $strCardinality; ?></th> <th><?php echo $strCardinality; ?></th>
<th colspan="2"><?php echo $strAction; ?></th> <th colspan="2"><?php echo $strAction; ?></th>
<th colspan="2"><?php echo $strField; ?></th> <th colspan="2"><?php echo $strField; ?></th>
</tr> </tr>
</thead>
<tbody>
<?php <?php
$idx_collection = PMA_show_indexes($table, $indexes, $indexes_info, $indexes_data, true); $idx_collection = PMA_show_indexes($table, $indexes, $indexes_info,
$indexes_data, true);
echo PMA_check_indexes($idx_collection); echo PMA_check_indexes($idx_collection);
} // end display indexes } // end display indexes
else { else {
// none indexes // none indexes
echo "\n" . ' <tr><td colspan=7" align="center">' . "\n"; echo '<tbody>'
if ($cfg['ErrorIconic']) { .'<tr><td colspan="7"><div class="warning">' . $strNoIndex
echo '<img src="' . $pmaThemeImage . 's_warn.png" width="16" height="16" border="0" alt="Warning" hspace="2" align="middle" />'; .'</div></td></tr>' . "\n";
}
echo ' <b>' . $strNoIndex . '</b></td></tr>' . "\n\n";
} }
?>
echo '<tr><td colspan="7" class="tblFooters" nowrap="nowrap" align="center"> ' <tr class="tblFooters"><td colspan="7">
. sprintf($strCreateIndex, '<input type="text" size="2" name="idx_num_fields" value="1" style="vertical-align: middle;" />') . "\n"; <?php echo sprintf($strCreateIndex,
echo ' &nbsp;<input type="submit" name="create_index" value="' . $strGo . '" onclick="return checkFormElementInRange(this.form, \'idx_num_fields\', \'' . str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']) . '\', 1)" style="vertical-align: middle;" />' . "\n"; '<input type="text" size="2" name="idx_num_fields" value="1" />'); ?>
echo '</td></tr> '; <input type="submit" name="create_index" value="<?php echo $strGo; ?>"
?> onclick="return checkFormElementInRange(this.form,
</table></form> 'idx_num_fields',
<?php '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']); ?>',
1)" />
</td></tr>
</tbody>
</table>
</form>
<?php
} // end display indexes } // end display indexes

View File

@@ -106,18 +106,42 @@ if ( $cfg['PropertiesIconic'] == true ) {
} }
// images replaced 2004-05-08 by mkkeck // images replaced 2004-05-08 by mkkeck
$titles['Change'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_edit.png" alt="' . $strChange . '" title="' . $strChange . '" />'; $titles['Change'] = $iconic_spacer
$titles['Drop'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />'; . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
$titles['NoDrop'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />'; . 'b_edit.png" alt="' . $strChange . '" title="' . $strChange . '" />';
$titles['Primary'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />'; $titles['Drop'] = $iconic_spacer
$titles['Index'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />'; . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
$titles['Unique'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />'; . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
$titles['IdxFulltext'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />'; $titles['NoDrop'] = $iconic_spacer
$titles['NoPrimary'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'bd_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />'; . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
$titles['NoIndex'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'bd_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />'; . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
$titles['NoUnique'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'bd_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />'; $titles['Primary'] = $iconic_spacer
$titles['NoIdxFulltext'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'bd_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />'; . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
$titles['Browse'] = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" />'; . 'b_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
$titles['Index'] = $iconic_spacer
. '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
. 'b_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
$titles['Unique'] = $iconic_spacer
. '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
. 'b_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
$titles['IdxFulltext'] = $iconic_spacer
. '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
. 'b_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
$titles['NoPrimary'] = $iconic_spacer
. '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
. 'bd_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
$titles['NoIndex'] = $iconic_spacer
. '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
. 'bd_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
$titles['NoUnique'] = $iconic_spacer
. '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
. 'bd_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
$titles['NoIdxFulltext'] = $iconic_spacer
. '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
. 'bd_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
$titles['Browse'] = $iconic_spacer
. '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
. 'b_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" />';
if ( $cfg['PropertiesIconic'] === 'both' ) { if ( $cfg['PropertiesIconic'] === 'both' ) {
$titles['Change'] .= $strChange . '</div>'; $titles['Change'] .= $strChange . '</div>';
@@ -169,9 +193,9 @@ $i = 0;
<th id="th<?php echo ++$i; ?>"><?php echo $strDefault; ?></th> <th id="th<?php echo ++$i; ?>"><?php echo $strDefault; ?></th>
<th id="th<?php echo ++$i; ?>"><?php echo $strExtra; ?></th> <th id="th<?php echo ++$i; ?>"><?php echo $strExtra; ?></th>
<?php if ( $db_is_information_schema || $tbl_is_view ) { ?> <?php if ( $db_is_information_schema || $tbl_is_view ) { ?>
<th id="<?php echo ++$i; ?>"><?php echo $strView; ?></th> <th id="th<?php echo ++$i; ?>"><?php echo $strView; ?></th>
<?php } else { ?> <?php } else { ?>
<th colspan="7" id="<?php echo ++$i; ?>"><?php echo $strAction; ?></th> <th colspan="7" id="th<?php echo ++$i; ?>"><?php echo $strAction; ?></th>
<?php } ?> <?php } ?>
</tr> </tr>
</thead> </thead>
@@ -572,6 +596,7 @@ if ( ! $tbl_is_view && ! $db_is_information_schema ) {
define('PMA_IDX_INCLUDED', 1); define('PMA_IDX_INCLUDED', 1);
require ('./tbl_indexes.php'); require ('./tbl_indexes.php');
} }
/** /**
* Displays Space usage and row statistics * Displays Space usage and row statistics
*/ */
@@ -638,7 +663,7 @@ if ( $cfg['ShowStats'] ) {
} }
if ( isset( $free_size ) ) { if ( isset( $free_size ) ) {
?> ?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
<th class="name"><?php echo $strOverhead; ?></th> <th class="name"><?php echo $strOverhead; ?></th>
<td class="value"><?php echo $free_size; ?></td> <td class="value"><?php echo $free_size; ?></td>
<td class="unit"><?php echo $free_unit; ?></td> <td class="unit"><?php echo $free_unit; ?></td>
@@ -662,7 +687,7 @@ if ( $cfg['ShowStats'] ) {
// Optimize link if overhead // Optimize link if overhead
if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'BDB')) { if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'BDB')) {
?> ?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> <tr class="tblFooters">
<td colspan="3" align="center"> <td colspan="3" align="center">
<a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php <a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
if ($cfg['PropertiesIconic']) { if ($cfg['PropertiesIconic']) {