2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Display the form to edit/create an index
8 if (! defined('PHPMYADMIN')) {
12 if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) {
13 // coming already from form
15 = count($_REQUEST['index']['columns']['names']) - $index->getColumnCount();
16 if (isset($_REQUEST['add_fields'])) {
17 $add_fields +
= $_REQUEST['added_fields'];
19 } elseif (isset($_REQUEST['create_index'])) {
20 $add_fields = $_REQUEST['added_fields'];
23 }// end preparing form values
26 $html .= '<form action="tbl_indexes.php" method="post" name="index_frm" id="index_frm" class="ajax"'
27 . 'onsubmit="if (typeof(this.elements[\'index[Key_name]\'].disabled) != \'undefined\') {'
28 . 'this.elements[\'index[Key_name]\'].disabled = false}">';
35 if (isset($_REQUEST['create_index'])) {
36 $form_params['create_index'] = 1;
37 } elseif (isset($_REQUEST['old_index'])) {
38 $form_params['old_index'] = $_REQUEST['old_index'];
39 } elseif (isset($_REQUEST['index'])) {
40 $form_params['old_index'] = $_REQUEST['index'];
43 $html .= PMA_generate_common_hidden_inputs($form_params);
45 $html .= '<fieldset id="index_edit_fields">';
47 if ($GLOBALS['is_ajax_request'] != true) {
49 if (isset($_REQUEST['create_index'])) {
50 $html .= __('Add index');
52 $html .= __('Edit index');
57 $html .= '<div class="index_info">';
60 . '<div class="label">'
62 . '<label for="input_index_name">'
67 '("PRIMARY" <b>must</b> be the name of'
68 . ' and <b>only of</b> a primary key!)'
75 . '<input type="text" name="index[Key_name]" id="input_index_name" size="25"'
76 . 'value="' . htmlspecialchars($index->getName()) . '"'
77 . 'onfocus="this.select()" />'
80 if (PMA_MYSQL_INT_VERSION
> 50500) {
82 . '<div class="label">'
84 . '<label for="input_index_comment">'
89 . '<input type="text" name="index[Index_comment]" id="input_index_comment" size="30"'
90 . 'value="' . htmlspecialchars($index->getComment()) . '"'
91 . 'onfocus="this.select()" />'
96 . '<div class="label">'
98 . '<label for="select_index_type">'
100 . PMA_Util
::showMySQLDocu('SQL-Syntax', 'ALTER_TABLE')
104 . '<select name="index[Index_type]" id="select_index_type" >'
105 . $index->generateIndexSelector()
109 $html .= '<div class="clearfloat"></div>';
113 $html .= '<table id="index_columns">';
117 . '<th>' . __('Column') . '</th>'
118 . '<th>' . __('Size') . '</th>'
123 $spatial_types = array(
124 'geometry', 'point', 'linestring', 'polygon', 'multipoint',
125 'multilinestring', 'multipolygon', 'geomtrycollection'
128 foreach ($index->getColumns() as $column) {
129 $html .= '<tr class="';
130 $html .= $odd_row ?
'odd' : 'even';
131 $html .= 'noclick">';
133 $html .= '<select name="index[columns][names][]">';
134 $html .= '<option value="">-- ' . __('Ignore') . ' --</option>';
135 foreach ($fields as $field_name => $field_type) {
136 if (($index->getType() != 'FULLTEXT'
137 ||
preg_match('/(char|text)/i', $field_type))
138 && ($index->getType() != 'SPATIAL'
139 ||
in_array($field_type, $spatial_types))
141 $html .= '<option value="' . htmlspecialchars($field_name) . '"'
142 . (($field_name == $column->getName())
143 ?
' selected="selected"'
145 . htmlspecialchars($field_name) . ' ['
146 . htmlspecialchars($field_type) . ']'
147 . '</option>' . "\n";
149 } // end foreach $fields
150 $html .= '</select>';
153 $html .= '<input type="text" size="5" onfocus="this.select()"'
154 . 'name="index[columns][sub_parts][]" value="';
155 if ($index->getType() != 'SPATIAL') {
156 $html .= $column->getSubPart();
161 $odd_row = !$odd_row;
162 } // end foreach $edited_index_info['Sequences']
164 for ($i = 0; $i < $add_fields; $i++
) {
165 $html .= '<tr class="';
166 $html .= $odd_row ?
'odd' : 'even';
167 $html .= 'noclick">';
169 $html .= '<select name="index[columns][names][]">';
170 $html .= '<option value="">-- ' . __('Ignore') . ' --</option>';
171 foreach ($fields as $field_name => $field_type) {
172 $html .= '<option value="' . htmlspecialchars($field_name) . '">'
173 . htmlspecialchars($field_name) . ' ['
174 . htmlspecialchars($field_type) . ']'
175 . '</option>' . "\n";
176 } // end foreach $fields
177 $html .= '</select>';
180 . '<input type="text" size="5" onfocus="this.select()"'
181 . 'name="index[columns][sub_parts][]" value="" />'
184 $odd_row = !$odd_row;
185 } // end foreach $edited_index_info['Sequences']
191 $html .= '</fieldset>';
193 $html .= '<fieldset class="tblFooters">';
194 if ($GLOBALS['is_ajax_request'] != true ||
! empty($_REQUEST['ajax_page_request'])) {
195 $html .= '<input type="submit" name="do_save_data" value="' . __('Save') . '" />';
196 $html .= '<span id="addMoreColumns">';
197 $html .= __('Or') . ' ';
199 __('Add %s column(s) to index') . "\n",
200 '<input type="text" name="added_fields" size="2" value="1" />'
202 $html .= '<input type="submit" name="add_fields" value="' . __('Go') . '" />' . "\n";
205 $btn_value = sprintf(__('Add %s column(s) to index'), 1);
206 $html .= '<div class="slider"></div>';
207 $html .= '<div class="add_fields">';
208 $html .= '<input type="submit" value="' . $btn_value . '" />';
211 $html .= '</fieldset>';
215 $response = PMA_Response
::getInstance();
216 $response->addHTML($html);
217 $header = $response->getHeader();
218 $scripts = $header->getScripts();
219 $scripts->addFile('indexes.js');