diff --git a/ChangeLog b/ChangeLog index e170864cbd..5f04bbb474 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ phpMyAdmin - ChangeLog + rfe #1597 Fast filter improvement: remove "x other results found" - bug #4720 No error message on Missing extension mbstring + rfe #801 Builtin transformations and relations ++ rfe #767 USING BTREE support for HEAP/MEMORY tables 4.3.9.0 (not yet released) - bug #4728 Incorrect headings in routine editor diff --git a/js/functions.js b/js/functions.js index df9697df7d..4091ecefac 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3219,10 +3219,10 @@ function checkIndexName(form_id) // Gets the elements pointers var $the_idx_name = $("#input_index_name"); - var $the_idx_type = $("#select_index_type"); + var $the_idx_choice = $("#select_index_choice"); // Index is a primary key - if ($the_idx_type.find("option:selected").val() == 'PRIMARY') { + if ($the_idx_choice.find("option:selected").val() == 'PRIMARY') { $the_idx_name.val('PRIMARY'); $the_idx_name.prop("disabled", true); } diff --git a/js/indexes.js b/js/indexes.js index fbca67e9ac..b1040a7f28 100644 --- a/js/indexes.js +++ b/js/indexes.js @@ -14,6 +14,10 @@ */ function checkIndexType() { + /** + * @var Object Dropdown to select the index choice. + */ + $select_index_choice = $('#select_index_choice'); /** * @var Object Dropdown to select the index type. */ @@ -35,7 +39,7 @@ function checkIndexType() */ $add_more = $('#index_frm .tblFooters'); - if ($select_index_type.val() == 'SPATIAL') { + if ($select_index_choice.val() == 'SPATIAL') { // Disable and hide the size column $size_header.hide(); $size_inputs.each(function () { @@ -78,22 +82,29 @@ function checkIndexType() // Show controllers to add more columns $add_more.show(); } + + if ($select_index_choice.val() == 'SPATIAL' || + $select_index_choice.val() == 'FULLTEXT') { + $select_index_type.val('').prop('disabled', true); + } else { + $select_index_type.prop('disabled', false) + } } /** * Sets current index information into form parameters. * * @param array source_array Array containing index columns - * @param string index_type Type of index + * @param string index_choice Choice of index * * @return void */ -function PMA_setIndexFormParameters(source_array, index_type) +function PMA_setIndexFormParameters(source_array, index_choice) { - if (index_type == 'index') { + if (index_choice == 'index') { $('input[name="indexes"]').val(JSON.stringify(source_array)); } else { - $('input[name="' + index_type + '_indexes"]').val(JSON.stringify(source_array)); + $('input[name="' + index_choice + '_indexes"]').val(JSON.stringify(source_array)); } } @@ -153,12 +164,12 @@ function PMA_removeColumnFromIndex(col_index) * * @param array source_array Array holding corresponding indexes * @param string array_index Index of an INDEX in array - * @param string index_type Type of Index + * @param string index_choice Choice of Index * @param string col_index Index of column on form * * @return void */ -function PMA_addColumnToIndex(source_array, array_index, index_type, col_index) +function PMA_addColumnToIndex(source_array, array_index, index_choice, col_index) { // Remove column from other indexes (if any). PMA_removeColumnFromIndex(col_index); @@ -179,20 +190,20 @@ function PMA_addColumnToIndex(source_array, array_index, index_type, col_index) source_array[array_index] = { 'Key_name': index_name, 'Index_comment': index_comment, - 'Index_type': index_type.toUpperCase(), + 'Index_choice': index_choice.toUpperCase(), 'columns': columns }; // Update index details on form. $('select[name="field_key[' + col_index + ']"]') - .attr('data-index', index_type + ',' + array_index); - PMA_setIndexFormParameters(source_array, index_type.toLowerCase()); + .attr('data-index', index_choice + ',' + array_index); + PMA_setIndexFormParameters(source_array, index_choice.toLowerCase()); } /** * Get choices list for a column to create a composite index with. * - * @param string index_type Type of index + * @param string index_choice Choice of index * @param array source_array Array hodling columns for particular index * * @return jQuery Object @@ -288,7 +299,7 @@ function PMA_showAddIndexDialog(source_array, array_index, target_columns, col_i PMA_addColumnToIndex( source_array, array_index, - index.Index_type, + index.Index_choice, col_index ); } else { @@ -354,21 +365,21 @@ function PMA_showAddIndexDialog(source_array, array_index, target_columns, col_i * Creates a advanced index type selection dialog. * * @param array source_array Array holding a particular type of indexes - * @param string index_type Type of index + * @param string index_choice Choice of index * @param string col_index Index of new column on form * * @return void */ -function PMA_indexTypeSelectionDialog(source_array, index_type, col_index) +function PMA_indexTypeSelectionDialog(source_array, index_choice, col_index) { - var $single_column_radio = $('' + ''); var $composite_index_radio = $('' + + ' name="index_choice">' + ''); var $dialog_content = $('
'); - $dialog_content.append(''); + $dialog_content.append(''); // For UNIQUE/INDEX type, show choice for single-column and composite index. @@ -380,8 +391,8 @@ function PMA_indexTypeSelectionDialog(source_array, index_type, col_index) button_options[PMA_messages.strGo] = function () { if ($('#single_column').is(':checked')) { var index = { - 'Key_name': (index_type == 'primary' ? 'PRIMARY' : ''), - 'Index_type': index_type.toUpperCase() + 'Key_name': (index_choice == 'primary' ? 'PRIMARY' : ''), + 'Index_choice': index_choice.toUpperCase() }; PMA_showAddIndexDialog(source_array, (source_array.length), [col_index], col_index, index); } @@ -458,7 +469,7 @@ function PMA_indexTypeSelectionDialog(source_array, index_type, col_index) * Unbind all event handlers before tearing down a page */ AJAX.registerTeardown('indexes.js', function () { - $(document).off('change', '#select_index_type'); + $(document).off('change', '#select_index_choice'); $(document).off('click', 'a.drop_primary_key_index_anchor.ajax'); $(document).off('click', "#table_index tbody tr td.edit_index.ajax, #indexes .add_index.ajax"); $(document).off('click', '#index_frm input[type=submit]'); @@ -483,7 +494,7 @@ AJAX.registerOnload('indexes.js', function () { checkIndexType(); checkIndexName("index_frm"); - $(document).on('change', '#select_index_type', function (event) { + $(document).on('change', '#select_index_choice', function (event) { event.preventDefault(); checkIndexType(); checkIndexName("index_frm"); @@ -596,19 +607,19 @@ AJAX.registerOnload('indexes.js', function () { // Index of column on Table edit and create page. var col_index = /\d/.exec($(this).attr('name')); col_index = col_index[0]; - // Type of selected index. - var index_type = /[a-z]+/.exec($(this).val()); - index_type = index_type[0]; + // Choice of selected index. + var index_choice = /[a-z]+/.exec($(this).val()); + index_choice = index_choice[0]; // Array containing corresponding indexes. var source_array = null; - if (index_type == 'none') { + if (index_choice == 'none') { PMA_removeColumnFromIndex(col_index); return false; } // Select a source array. - switch (index_type) { + switch (index_choice) { case 'primary': source_array = primary_indexes; break; @@ -625,12 +636,12 @@ AJAX.registerOnload('indexes.js', function () { if (source_array.length === 0) { var index = { - 'Key_name': (index_type == 'primary' ? 'PRIMARY' : ''), - 'Index_type': index_type.toUpperCase() + 'Key_name': (index_choice == 'primary' ? 'PRIMARY' : ''), + 'Index_choice': index_choice.toUpperCase() }; PMA_showAddIndexDialog(source_array, 0, [col_index], col_index, index); } else { - if (index_type == 'primary') { + if (index_choice == 'primary') { var array_index = 0; var source_length = source_array[array_index].columns.length; var target_columns = []; @@ -643,7 +654,7 @@ AJAX.registerOnload('indexes.js', function () { source_array[array_index]); } else { // If there are multiple columns selected for an index, show advanced dialog. - PMA_indexTypeSelectionDialog(source_array, index_type, col_index); + PMA_indexTypeSelectionDialog(source_array, index_choice, col_index); } } }); diff --git a/libraries/Index.class.php b/libraries/Index.class.php index 9917473750..e4b366d4c7 100644 --- a/libraries/Index.class.php +++ b/libraries/Index.class.php @@ -47,7 +47,7 @@ class PMA_Index private $_columns = array(); /** - * The index method used (BTREE, SPATIAL, FULLTEXT, HASH, RTREE). + * The index method used (BTREE, HASH, RTREE). * * @var string */ @@ -290,16 +290,22 @@ class PMA_Index if (isset($params['Packed'])) { $this->_packed = $params['Packed']; } - if ('PRIMARY' == $this->_name) { - $this->_choice = 'PRIMARY'; - } elseif ('FULLTEXT' == $this->_type) { - $this->_choice = 'FULLTEXT'; - } elseif ('SPATIAL' == $this->_type) { - $this->_choice = 'SPATIAL'; - } elseif ('0' == $this->_non_unique) { - $this->_choice = 'UNIQUE'; + if (isset($params['Index_choice'])) { + $this->_choice = $params['Index_choice']; } else { - $this->_choice = 'INDEX'; + if ('PRIMARY' == $this->_name) { + $this->_choice = 'PRIMARY'; + } elseif ('FULLTEXT' == $this->_type) { + $this->_choice = 'FULLTEXT'; + $this->_type = ''; + } elseif ('SPATIAL' == $this->_type) { + $this->_choice = 'SPATIAL'; + $this->_type = ''; + } elseif ('0' == $this->_non_unique) { + $this->_choice = 'UNIQUE'; + } else { + $this->_choice = 'INDEX'; + } } } @@ -350,7 +356,7 @@ class PMA_Index } /** - * Returns index type ((BTREE, SPATIAL, FULLTEXT, HASH, RTREE) + * Returns index type (BTREE, HASH, RTREE) * * @return string index type */ @@ -385,14 +391,31 @@ class PMA_Index ); } + /** + * Returns a lit of all index types + * + * @return string[] index types + */ + static public function getIndexTypes() + { + return array( + 'BTREE', + 'HASH' + ); + } + /** * Returns HTML for the index choice selector * + * @param boolean $edit_table whether this is table editing + * * @return string HTML for the index choice selector */ - public function generateIndexSelector() + public function generateIndexChoiceSelector($edit_table) { - $html_options = ''; + $html_options = ''; return $html_options; } + /** + * Returns HTML for the index type selector + * + * @return string HTML for the index type selector + */ + public function generateIndexTypeSelector() + { + $types = array("" => "--"); + foreach (PMA_Index::getIndexTypes() as $type) { + $types[$type] = $type; + } + + return PMA_Util::getDropdown( + "index[Index_type]", $types, + $this->_type, "select_index_type" + ); + } + /** * Returns how the index is packed * @@ -637,9 +679,13 @@ class PMA_Index . htmlspecialchars($index->getName()) . ''; } - $r .= '