more cleanup/refactoring on index code

This commit is contained in:
Sebastian Mendel
2008-02-07 11:40:37 +00:00
parent c09b69bfa8
commit bda5a218a1
3 changed files with 251 additions and 290 deletions

View File

@@ -20,9 +20,9 @@ class PMA_Index
protected static $_registry = array(); protected static $_registry = array();
/** /**
* @var string The name of the database * @var string The name of the schema
*/ */
protected $_database = ''; protected $_schema = '';
/** /**
* @var string The name of the table * @var string The name of the table
@@ -86,21 +86,36 @@ class PMA_Index
$this->set($params); $this->set($params);
} }
static public function singleton($schema, $table, $index_name = '')
{
PMA_Index::_loadIndexes($table, $schema);
if (! isset(PMA_Index::$_registry[$schema][$table][$index_name])) {
$index = new PMA_Index;
if (strlen($index_name)) {
$index->setName($index_name);
PMA_Index::$_registry[$schema][$table][$index->getName()] = $index;
}
return $index;
} else {
return PMA_Index::$_registry[$schema][$table][$index_name];
}
}
/** /**
* returns an array with all indexes from the given table * returns an array with all indexes from the given table
* *
* @uses PMA_Index::_loadIndexes() * @uses PMA_Index::_loadIndexes()
* @uses PMA_Index::$_registry * @uses PMA_Index::$_registry
* @param string $table * @param string $table
* @param string $database * @param string $schema
* @return array * @return array
*/ */
static public function getFromTable($table, $database) static public function getFromTable($table, $schema)
{ {
PMA_Index::_loadIndexes($table, $database); PMA_Index::_loadIndexes($table, $schema);
if (isset(PMA_Index::$_registry[$database][$table])) { if (isset(PMA_Index::$_registry[$schema][$table])) {
return PMA_Index::$_registry[$database][$table]; return PMA_Index::$_registry[$schema][$table];
} else { } else {
return array(); return array();
} }
@@ -112,15 +127,15 @@ class PMA_Index
* @uses PMA_Index::_loadIndexes() * @uses PMA_Index::_loadIndexes()
* @uses PMA_Index::$_registry * @uses PMA_Index::$_registry
* @param string $table * @param string $table
* @param string $database * @param string $schema
* @return mixed primary index or false if no one exists * @return mixed primary index or false if no one exists
*/ */
static public function getPrimary($table, $database) static public function getPrimary($table, $schema)
{ {
PMA_Index::_loadIndexes($table, $database); PMA_Index::_loadIndexes($table, $schema);
if (isset(PMA_Index::$_registry[$database][$table]['PRIMARY'])) { if (isset(PMA_Index::$_registry[$schema][$table]['PRIMARY'])) {
return PMA_Index::$_registry[$database][$table]['PRIMARY']; return PMA_Index::$_registry[$schema][$table]['PRIMARY'];
} else { } else {
return false; return false;
} }
@@ -135,22 +150,23 @@ class PMA_Index
* @uses PMA_Index * @uses PMA_Index
* @uses PMA_Index->addColumn() * @uses PMA_Index->addColumn()
* @param string $table * @param string $table
* @param string $database * @param string $schema
* @return boolean * @return boolean
*/ */
static protected function _loadIndexes($table, $database) static protected function _loadIndexes($table, $schema)
{ {
if (isset(PMA_Index::$_registry[$database][$table])) { if (isset(PMA_Index::$_registry[$schema][$table])) {
return true; return true;
} }
$_raw_indexes = PMA_DBI_fetch_result('SHOW INDEX FROM ' . PMA_backquote($database) . '.' . PMA_backquote($table)); $_raw_indexes = PMA_DBI_fetch_result('SHOW INDEX FROM ' . PMA_backquote($schema) . '.' . PMA_backquote($table));
foreach ($_raw_indexes as $_each_index) { foreach ($_raw_indexes as $_each_index) {
if (! isset(PMA_Index::$_registry[$database][$table][$_each_index['Key_name']])) { $_each_index['Schema'] = $schema;
if (! isset(PMA_Index::$_registry[$schema][$table][$_each_index['Key_name']])) {
$key = new PMA_Index($_each_index); $key = new PMA_Index($_each_index);
PMA_Index::$_registry[$database][$table][$_each_index['Key_name']] = $key; PMA_Index::$_registry[$schema][$table][$_each_index['Key_name']] = $key;
} else { } else {
$key = PMA_Index::$_registry[$database][$table][$_each_index['Key_name']]; $key = PMA_Index::$_registry[$schema][$table][$_each_index['Key_name']];
} }
$key->addColumn($_each_index); $key->addColumn($_each_index);
@@ -168,8 +184,37 @@ class PMA_Index
*/ */
public function addColumn($params) public function addColumn($params)
{ {
if (strlen($params['Column_name'])) {
$this->_columns[$params['Column_name']] = new PMA_Index_Column($params); $this->_columns[$params['Column_name']] = new PMA_Index_Column($params);
} }
}
public function addColumns($columns)
{
$_columns = array();
if (isset($columns['names'])) {
// coming from form
// $columns[names][]
// $columns[sub_parts][]
foreach ($columns['names'] as $key => $name) {
$_columns[] = array(
'Column_name' => $name,
'Sub_part' => $columns['sub_parts'][$key],
);
}
} else {
// coming from SHOW INDEXES
// $columns[][name]
// $columns[][sub_part]
// ...
$_columns = $columns;
}
foreach ($_columns as $column) {
$this->addColumn($column);
}
}
/** /**
* Returns true if $column indexed in this index * Returns true if $column indexed in this index
@@ -185,8 +230,11 @@ class PMA_Index
public function set($params) public function set($params)
{ {
if (isset($params['Column_name'])) { if (isset($params['columns'])) {
$this->_database = $params['Column_name']; $this->addColumns($params['columns']);
}
if (isset($params['Schema'])) {
$this->_schema = $params['Schema'];
} }
if (isset($params['Table'])) { if (isset($params['Table'])) {
$this->_table = $params['Table']; $this->_table = $params['Table'];
@@ -295,6 +343,11 @@ class PMA_Index
return $this->_name; return $this->_name;
} }
public function setName($name)
{
$this->_name = (string) $name;
}
public function getColumns() public function getColumns()
{ {
return $this->_columns; return $this->_columns;

View File

@@ -12,49 +12,7 @@
require_once './libraries/common.inc.php'; require_once './libraries/common.inc.php';
require_once './libraries/tbl_indexes.lib.php'; require_once './libraries/tbl_indexes.lib.php';
require_once './libraries/Index.class.php'; require_once './libraries/Index.class.php';
require_once './libraries/tbl_common.php';
/**
* Ensures the db & table are valid, then loads headers and gets indexes
* informations.
* Skipped if this script is called by "tbl_sql.php"
*/
// Not a valid db name -> back to the welcome page
if (strlen($db)) {
$is_db = PMA_DBI_select_db($db);
}
if (!strlen($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 sub-page
if (strlen($table)) {
$is_table = PMA_DBI_query('SHOW TABLES LIKE \''
. PMA_sqlAddslashes($table, TRUE) . '\'', null, PMA_DBI_QUERY_STORE);
}
if (! strlen($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;
} elseif (isset($is_table)) {
PMA_DBI_free_result($is_table);
}
// Displays headers (if needed)
$GLOBALS['js_include'][] = 'functions.js';
$GLOBALS['js_include'][] = 'indexes.js';
require_once './libraries/header.inc.php';
/** /**
* Gets fields and indexes informations * Gets fields and indexes informations
@@ -68,232 +26,176 @@ $ret_keys = PMA_get_indexes($table, $err_url_0);
PMA_extract_indexes($ret_keys, $indexes_info, $indexes_data); PMA_extract_indexes($ret_keys, $indexes_info, $indexes_data);
$indexes = PMA_Index::getFromTable($table, $db);
// Get fields and stores their name/type // Get fields and stores their name/type
// fields had already been grabbed in "tbl_sql.php" $fields = array();
$fields_rs = PMA_DBI_query('SHOW FIELDS FROM ' foreach (PMA_DBI_get_fields($db, $table) as $row) {
. PMA_backquote($table) . ';');
$save_row = array();
while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
$save_row[] = $row;
}
$fields_names = array();
$fields_types = array();
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)) { if (preg_match('@^(set|enum)\((.+)\)$@i', $row['Type'], $tmp)) {
$tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'',
',' . $tmp[2]), 1); ',' . $tmp[2]), 1);
$fields_types[] = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; $fields[$row['Field']] = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
} else { } else {
$fields_types[] = $row['Type']; $fields[$row['Field']] = $row['Type'];
} }
} // end while } // end while
if ($fields_rs) { // Prepares the form values
PMA_DBI_free_result($fields_rs); if (isset($_REQUEST['index'])) {
if (is_array($_REQUEST['index'])) {
// coming already from form
$index = new PMA_Index($_REQUEST['index']);
} else {
$index = PMA_Index::singleton($db, $table, $_REQUEST['index']);
}
} else {
$index = new PMA_Index;
} }
/** /**
* Do run the query to build the new index and moves back to * Process the data from the edit/create index form,
* "tbl_sql.php" * run the query to build the new index
* and moves back to "tbl_sql.php"
*/ */
if (isset($index) && isset($do_save_data)) { if (isset($_REQUEST['do_save_data'])) {
$err_url = 'tbl_indexes.php?' . PMA_generate_common_url($db, $table); $error = false;
if (empty($old_index)) {
$err_url .= '&create_index=1&idx_num_fields=' . $idx_num_fields;
} else {
$err_url .= '&index=' . urlencode($old_index);
}
if ($index_type == 'PRIMARY') {
if ($index == '') {
$index = 'PRIMARY';
} elseif ($index != 'PRIMARY') {
PMA_mysqlDie($strPrimaryKeyName, '', FALSE, $err_url);
}
} elseif ($index == 'PRIMARY') {
PMA_mysqlDie($strCantRenameIdxToPrimary, '', FALSE, $err_url);
}
// $sql_query is the one displayed in the query box // $sql_query is the one displayed in the query box
$sql_query = 'ALTER TABLE ' . PMA_backquote($table); $sql_query = 'ALTER TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table);
// Drops the old index // Drops the old index
if (!empty($old_index)) { if (! empty($_REQUEST['old_index'])) {
if ($old_index == 'PRIMARY') { if ($_REQUEST['old_index'] == 'PRIMARY') {
$sql_query .= ' DROP PRIMARY KEY,'; $sql_query .= ' DROP PRIMARY KEY,';
} else { } else {
$sql_query .= ' DROP INDEX ' . PMA_backquote($old_index) .','; $sql_query .= ' DROP INDEX ' . PMA_backquote($_REQUEST['old_index']) . ',';
} }
} // end if } // end if
// Builds the new one // Builds the new one
switch ($index_type) { switch ($index->getType()) {
case 'PRIMARY': case 'PRIMARY':
$sql_query .= ' ADD PRIMARY KEY ('; if ($index->getName() == '') {
$index->setName('PRIMARY');
} elseif ($index->getName() != 'PRIMARY') {
$error = PMA_Message::error('strPrimaryKeyName');
}
$sql_query .= ' ADD PRIMARY KEY';
break; break;
case 'FULLTEXT': case 'FULLTEXT':
$sql_query .= ' ADD FULLTEXT '
. (empty($index) ? '' : PMA_backquote($index)) . ' (';
break;
case 'UNIQUE': case 'UNIQUE':
$sql_query .= ' ADD UNIQUE '
. (empty($index) ? '' : PMA_backquote($index)) . ' (';
break;
case 'INDEX': case 'INDEX':
$sql_query .= ' ADD INDEX ' if ($index->getName() == 'PRIMARY') {
. (empty($index) ? '' : PMA_backquote($index)) . ' ('; $error = PMA_Message::error('strCantRenameIdxToPrimary');
}
$sql_query .= ' ADD ' . $index->getType() . ' '
. ($index->getName() ? PMA_backquote($index->getName()) : '');
break; break;
} // end switch } // end switch
$index_fields = '';
foreach ($column AS $i => $name) { $index_fields = array();
if ($name != '--ignore--') { foreach ($index->getColumns() as $key => $column) {
$index_fields .= (empty($index_fields) ? '' : ',') $index_fields[$key] = PMA_backquote($column->getName());
. PMA_backquote($name) if ($column->getSubPart()) {
. (empty($sub_part[$i]) $index_fields[$key] .= '(' . $column->getSubPart() . ')';
? ''
: '(' . $sub_part[$i] . ')');
} }
} // end while } // end while
if (empty($index_fields)){ if (empty($index_fields)){
PMA_mysqlDie($strNoIndexPartsDefined, '', FALSE, $err_url); $error = PMA_Message::error('strNoIndexPartsDefined');
} else { } else {
$sql_query .= $index_fields . ')'; $sql_query .= ' (' . implode(', ', $index_fields) . ')';
} }
$result = PMA_DBI_query($sql_query); if (! $error) {
PMA_DBI_query($sql_query);
$message = PMA_Message::success('strTableAlteredSuccessfully'); $message = PMA_Message::success('strTableAlteredSuccessfully');
$message->addParam($table); $message->addParam($table);
$active_page = 'tbl_structure.php'; $active_page = 'tbl_structure.php';
require './tbl_structure.php'; require './tbl_structure.php';
exit;
} else {
$error->display();
}
} // end builds the new index } // end builds the new index
/** /**
* Edits an index or defines a new one * Display the form to edit/create an index
*/ */
elseif (isset($index) || isset($create_index)) {
// Prepares the form values // Displays headers (if needed)
if (!isset($index)) { $GLOBALS['js_include'][] = 'functions.js';
$index = ''; $GLOBALS['js_include'][] = 'indexes.js';
}
if (!isset($old_index)){
$old_index = $index;
}
if (!isset($index_type)) {
$index_type = '';
}
if ($old_index == '' || !isset($indexes_info[$old_index])) {
$edited_index_info['Sequences'] = array();
$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' => '');
} // end for
if ($old_index == ''
&& !isset($indexes_info['PRIMARY'])
&& ($index_type == '' || $index_type == 'PRIMARY')) {
$old_index = 'PRIMARY';
}
} else {
$edited_index_info = $indexes_info[$old_index];
$edited_index_data = $indexes_data[$old_index];
require_once './libraries/tbl_info.inc.php';
require_once './libraries/tbl_links.inc.php';
if ($edited_index_info['Index_type'] == 'FULLTEXT') { if (is_array($_REQUEST['index'])) {
$index_type = 'FULLTEXT'; // coming already from form
} elseif ($index == 'PRIMARY') { $add_fields =
$index_type = 'PRIMARY'; count($_REQUEST['index']['columns']['names']) - $index->getColumnCount();
} elseif ($edited_index_info['Non_unique'] == '0') { if (isset($_REQUEST['add_fields'])) {
$index_type = 'UNIQUE'; $add_fields += $_REQUEST['added_fields'];
} else {
$index_type = 'INDEX';
} }
} // end if... else... } elseif (isset($_REQUEST['create_index'])) {
$add_fields = $_REQUEST['added_fields'];
} else {
$add_fields = 1;
}
if (isset($add_fields)) { // end preparing form values
if (isset($prev_add_fields)) { ?>
$added_fields += $prev_add_fields;
}
$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' => '');
} // end for
// Restore entered values
foreach ($column AS $i => $name) {
if ($name != '--ignore--'){
$edited_index_data[$i+1]['Column_name'] = $name;
$edited_index_data[$i+1]['Sub_part'] = $sub_part[$i];
}
} // end while
} // end if
// end preparing form values
?>
<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') { onsubmit="if (typeof(this.elements['index'].disabled) != 'undefined') {
this.elements['index'].disabled = false}"> this.elements['index'].disabled = false}">
<?php <?php
echo PMA_generate_common_hidden_inputs($db, $table); $form_params = array(
'db' => $db,
'table' => $table,
);
if (isset($create_index)) { if (isset($_REQUEST['create_index'])) {
echo '<input type="hidden" name="create_index" value="1" />' . "\n"; $form_params['create_index'] = 1;
} } elseif (isset($_REQUEST['old_index'])) {
if (isset($added_fields)) { $form_params['old_index'] = $_REQUEST['old_index'];
echo ' <input type="hidden" name="prev_add_fields" value="' } elseif (isset($_REQUEST['index'])) {
. $added_fields . '" />' . "\n"; $form_params['old_index'] = $_REQUEST['index'];
} }
if (isset($idx_num_fields)) {
echo ' <input type="hidden" name="idx_num_fields" value="'
. $idx_num_fields . '" />' . "\n";
}
?>
<input type="hidden" name="old_index" value="<?php
echo (isset($create_index) ? '' : htmlspecialchars($old_index)); ?>" />
echo PMA_generate_common_hidden_inputs($form_params);
?>
<fieldset> <fieldset>
<legend> <legend>
<?php <?php
echo (isset($create_index) ? $strCreateIndexTopic : $strModifyIndexTopic); echo (isset($_REQUEST['create_index'])
?> ? $strCreateIndexTopic
: $strModifyIndexTopic);
?>
</legend> </legend>
<div class="formelement"> <div class="formelement">
<label for="input_index_name"><?php echo $strIndexName; ?></label> <label for="input_index_name"><?php echo $strIndexName; ?></label>
<input type="text" name="index" id="input_index_name" size="25" <input type="text" name="index[Key_name]" id="input_index_name" size="25"
value="<?php echo htmlspecialchars($index); ?>" onfocus="this.select()" /> value="<?php echo htmlspecialchars($index->getName()); ?>" onfocus="this.select()" />
</div> </div>
<div class="formelement"> <div class="formelement">
<label for="select_index_type"><?php echo $strIndexType; ?></label> <label for="select_index_type"><?php echo $strIndexType; ?></label>
<select name="index_type" id="select_index_type" onchange="return checkIndexName()"> <select name="index[Index_type]" id="select_index_type" onchange="return checkIndexName()">
<?php <?php
foreach (PMA_get_indextypes() as $each_index_type) { foreach (PMA_get_indextypes() as $each_index_type) {
if ($each_index_type === 'PRIMARY' if ($each_index_type === 'PRIMARY'
&& $index !== 'PRIMARY' && $index->getName() !== 'PRIMARY'
&& isset($indexes_info['PRIMARY'])) { && isset($indexes_info['PRIMARY'])) {
// skip PRIMARY if there is already one in the table // skip PRIMARY if there is already one in the table
continue; continue;
} }
echo ' ' echo '<option value="' . $each_index_type . '"'
. '<option value="' . $each_index_type . '"' . (($index->getType() == $each_index_type) ? ' selected="selected"' : '')
. (($index_type == $each_index_type) ? ' selected="selected"' : '')
. '>'. $each_index_type . '</option>' . "\n"; . '>'. $each_index_type . '</option>' . "\n";
} }
?> ?>
</select> </select>
<?php echo PMA_showMySQLDocu('SQL-Syntax', 'ALTER_TABLE'); ?> <?php echo PMA_showMySQLDocu('SQL-Syntax', 'ALTER_TABLE'); ?>
</div> </div>
@@ -311,68 +213,74 @@ PMA_Message::warning('strPrimaryKeyWarning')->display();
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
$odd_row = true; $odd_row = true;
foreach ($edited_index_info['Sequences'] as $seq_index) { foreach ($index->getColumns() as $column) {
$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'])) {
$sub_part = ' value="' . $edited_index_data[$seq_index]['Sub_part'] . '"';
} else {
$sub_part = '';
}
?> ?>
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>"> <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
<td><select name="column[]"> <td><select name="index[columns][names][]">
<option value="--ignore--" <option value="">-- <?php echo $strIgnore; ?> --</option>
<?php if ('--ignore--' == $selected) { echo ' selected="selected"'; } ?>>
-- <?php echo $strIgnore; ?> --</option>
<?php <?php
foreach ($fields_names AS $key => $val) { foreach ($fields as $field_name => $field_type) {
if ($index_type != 'FULLTEXT' if ($index->getType() != 'FULLTEXT'
|| preg_match('@^(varchar|text|tinytext|mediumtext|longtext)@i', $fields_types[$key])) { || preg_match('/(char|text)/i', $field_type)) {
echo "\n" . ' ' echo '<option value="' . htmlspecialchars($field_name) . '"'
. '<option value="' . htmlspecialchars($val) . '"' . (($field_name == $column->getName()) ? ' selected="selected"' : '') . '>'
. (($val == $selected) ? ' selected="selected"' : '') . '>' . htmlspecialchars($field_name) . ' [' . $field_type . ']'
. htmlspecialchars($val) . (($add_type) ? ' [' . '</option>' . "\n";
. $fields_types[$key] . ']' : '') . '</option>' . "\n";
} }
} // end foreach $fields_names } // end foreach $fields
?> ?>
</select> </select>
</td> </td>
<td><input type="text" size="5" onfocus="this.select()" <td><input type="text" size="5" onfocus="this.select()"
name="sub_part[]"<?php echo $sub_part; ?> /> name="index[columns][sub_parts][]" value="<?php echo $column->getSubPart(); ?>" />
</td> </td>
</tr> </tr>
<?php <?php
$odd_row = !$odd_row; $odd_row = !$odd_row;
} // end foreach $edited_index_info['Sequences'] } // end foreach $edited_index_info['Sequences']
for ($i = 0; $i < $add_fields; $i++) {
?> ?>
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
<td><select name="index[columns][names][]">
<option value="">-- <?php echo $strIgnore; ?> --</option>
<?php
foreach ($fields as $field_name => $field_type) {
echo '<option value="' . htmlspecialchars($field_name) . '">'
. htmlspecialchars($field_name) . ' [' . $field_type . ']'
. '</option>' . "\n";
} // end foreach $fields
?>
</select>
</td>
<td><input type="text" size="5" onfocus="this.select()"
name="index[columns][sub_parts][]" value="" />
</td>
</tr>
<?php
$odd_row = !$odd_row;
} // end foreach $edited_index_info['Sequences']
?>
</tbody> </tbody>
</table> </table>
</fieldset> </fieldset>
<fieldset class="tblFooters"> <fieldset class="tblFooters">
<input type="submit" name="do_save_data" value="<?php echo $strSave; ?>" /> <input type="submit" name="do_save_data" value="<?php echo $strSave; ?>" />
<?php <?php
echo $strOr; echo $strOr . ' ';
echo ' ' . sprintf($strAddToIndex, echo sprintf($strAddToIndex,
'<input type="text" name="added_fields" size="2" value="1"' '<input type="text" name="added_fields" size="2" value="1"'
.' onfocus="this.select()" />') . "\n"; .' onfocus="this.select()" />') . "\n";
echo ' <input type="submit" name="add_fields" value="' . $strGo . '"' echo '<input type="submit" name="add_fields" value="' . $strGo . '"'
.' onclick="return checkFormElementInRange(this.form,' .' onclick="return checkFormElementInRange(this.form,'
.' \'added_fields\', \'' ." 'added_fields', '" . PMA_jsFormat($GLOBALS['strInvalidColumnCount']) . "', 1"
. str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']) .')" />' . "\n";
. '\', 1)" />' . "\n"; ?>
?>
</fieldset> </fieldset>
</form> </form>
</div> <?php
<?php
}
/** /**
* Displays the footer * Displays the footer

View File

@@ -546,7 +546,7 @@ if (! $tbl_is_view && ! $db_is_information_schema) {
<?php <?php
echo PMA_generate_common_hidden_inputs($db, $table); echo PMA_generate_common_hidden_inputs($db, $table);
echo sprintf($strCreateIndex, echo sprintf($strCreateIndex,
'<input type="text" size="2" name="idx_num_fields" value="1" />'); '<input type="text" size="2" name="added_fields" value="1" />');
?> ?>
<input type="submit" name="create_index" value="<?php echo $strGo; ?>" <input type="submit" name="create_index" value="<?php echo $strGo; ?>"
onclick="return checkFormElementInRange(this.form, onclick="return checkFormElementInRange(this.form,