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

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