Translation update done using Pootle.
[phpmyadmin/last10db.git] / libraries / tbl_properties.inc.php
bloba00a1649730af837c6a2589e8387d5e667222826
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Display form for changing/adding table fields/columns
6 * included by tbl_addfield.php, -_alter.php, -_create.php
7 * @package phpMyAdmin
8 */
9 if (! defined('PHPMYADMIN')) {
10 exit;
13 /**
14 * Check parameters
16 require_once './libraries/common.inc.php';
17 PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
20 // Get available character sets and storage engines
21 require_once './libraries/mysql_charsets.lib.php';
22 require_once './libraries/StorageEngine.class.php';
24 /**
25 * Class for partition management
27 require_once './libraries/Partition.class.php';
29 if (is_int($cfg['DefaultPropDisplay'])) {
30 if ($num_fields <= $cfg['DefaultPropDisplay']) {
31 $display_type = 'vertical';
32 } else {
33 $display_type = 'horizontal';
35 } else {
36 $display_type = $cfg['DefaultPropDisplay'];
39 if ('horizontal' == $display_type) {
40 $length_values_input_size = 8;
41 } else {
42 $length_values_input_size = 30;
45 $_form_params = array(
46 'db' => $db,
49 if ($action == 'tbl_create.php') {
50 $_form_params['reload'] = 1;
51 } elseif ($action == 'tbl_addfield.php') {
52 $_form_params['field_where'] = $_REQUEST['field_where'];
53 $_form_params['after_field'] = $_REQUEST['after_field'];
54 $_form_params['table'] = $table;
55 } else {
56 $_form_params['table'] = $table;
59 if (isset($num_fields)) {
60 $_form_params['orig_num_fields'] = $num_fields;
63 if (isset($_REQUEST['field_where'])) {
64 $_form_params['orig_field_where'] = $_REQUEST['field_where'];
67 if (isset($_REQUEST['after_field'])) {
68 $_form_params['orig_after_field'] = $_REQUEST['after_field'];
71 if (isset($selected) && is_array($selected)) {
72 foreach ($selected as $o_fld_nr => $o_fld_val) {
73 $_form_params['selected[' . $o_fld_nr . ']'] = $o_fld_val;
74 if (! isset($true_selected)) {
75 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
79 if (isset($true_selected) && is_array($true_selected)) {
80 foreach ($true_selected as $o_fld_nr => $o_fld_val) {
81 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
84 } elseif (isset($_REQUEST['field'])) {
85 $_form_params['orig_field'] = $_REQUEST['field'];
86 if (isset($orig_field)) {
87 $_form_params['true_selected[]'] = $orig_field;
88 } else {
89 $_form_params['true_selected[]'] = $_REQUEST['field'];
93 $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
95 $header_cells = array();
96 $content_cells = array();
98 $header_cells[] = __('Column');
99 $header_cells[] = __('Type')
100 . ($GLOBALS['cfg']['ReplaceHelpImg']
101 ? PMA_showMySQLDocu('SQL-Syntax', 'data-types')
102 : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'data-types')
103 . '</span>');
104 $header_cells[] = __('Length/Values') . PMA_showHint(__('If column type is "enum" or "set", please enter the values using this format: \'a\',\'b\',\'c\'...<br />If you ever need to put a backslash ("\") or a single quote ("\'") amongst those values, precede it with a backslash (for example \'\\\\xyz\' or \'a\\\'b\').'));
105 $header_cells[] = __('Default') . PMA_showHint(__('For default values, please enter just a single value, without backslash escaping or quotes, using this format: a'));
106 $header_cells[] = __('Collation');
107 $header_cells[] = __('Attributes');
108 $header_cells[] = __('Null');
110 // We could remove this 'if' and let the key information be shown and
111 // editable. However, for this to work, tbl_alter must be modified to use the
112 // key fields, as tbl_addfield does.
114 if (!$is_backup) {
115 $header_cells[] = __('Index');
118 $header_cells[] = '<abbr title="AUTO_INCREMENT">' . ($display_type == 'horizontal' ? 'A_I' : 'AUTO_INCREMENT') . '</abbr>';
120 require_once './libraries/transformations.lib.php';
121 $cfgRelation = PMA_getRelationsParam();
123 $comments_map = array();
124 $mime_map = array();
125 $available_mime = array();
127 $comments_map = PMA_getComments($db, $table);
128 $header_cells[] = __('Comments');
130 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
131 $mime_map = PMA_getMIME($db, $table);
132 $available_mime = PMA_getAvailableMIMEtypes();
134 $hint = '<br />' .
135 sprintf(__('For a list of available transformation options and their MIME type transformations, click on %stransformation descriptions%s'),
136 '<a href="transformation_overview.php?'
137 . PMA_generate_common_url($db, $table) . '" target="_blank">',
138 '</a>');
141 $header_cells[] = __('MIME type');
142 $header_cells[] = __('Browser transformation');
143 $header_cells[] = __('Transformation options')
144 . PMA_showHint(__('Please enter the values for transformation options using this format: \'a\', 100, b,\'c\'...<br />If you ever need to put a backslash ("\") or a single quote ("\'") amongst those values, precede it with a backslash (for example \'\\\\xyz\' or \'a\\\'b\').') . $hint);
147 // workaround for field_fulltext, because its submitted indizes contain
148 // the index as a value, not a key. Inserted here for easier maintaineance
149 // and less code to change in existing files.
150 if (isset($field_fulltext) && is_array($field_fulltext)) {
151 foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
152 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
156 for ($i = 0; $i < $num_fields; $i++) {
157 if (! empty($regenerate)) {
158 // An error happened with previous inputs, so we will restore the data
159 // to embed it once again in this form.
161 $row['Field'] = (isset($_REQUEST['field_name'][$i]) ? $_REQUEST['field_name'][$i] : false);
162 $row['Type'] = (isset($_REQUEST['field_type'][$i]) ? $_REQUEST['field_type'][$i] : false);
163 $row['Collation'] = (isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '');
164 $row['Null'] = (isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : '');
166 if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i) {
167 $row['Key'] = 'PRI';
168 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i) {
169 $row['Key'] = 'MUL';
170 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i) {
171 $row['Key'] = 'UNI';
172 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i) {
173 $row['Key'] = 'FULLTEXT';
174 } else {
175 $row['Key'] = '';
178 // put None in the drop-down for Default, when someone adds a field
179 $row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ? $_REQUEST['field_default_type'][$i] : 'NONE');
180 $row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ? $_REQUEST['field_default_value'][$i] : '');
182 switch ($row['DefaultType']) {
183 case 'NONE' :
184 $row['Default'] = null;
185 break;
186 case 'USER_DEFINED' :
187 $row['Default'] = $row['DefaultValue'];
188 break;
189 case 'NULL' :
190 case 'CURRENT_TIMESTAMP' :
191 $row['Default'] = $row['DefaultType'];
192 break;
195 $row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false);
196 $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : false);
198 $submit_length = (isset($_REQUEST['field_length'][$i]) ? $_REQUEST['field_length'][$i] : false);
199 $submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ? $_REQUEST['field_attribute'][$i] : false);
201 $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ? true : false);
203 if (isset($_REQUEST['field_comments'][$i])) {
204 $comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
207 if (isset($_REQUEST['field_mimetype'][$i])) {
208 $mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
211 if (isset($_REQUEST['field_transformation'][$i])) {
212 $mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i];
215 if (isset($_REQUEST['field_transformation_options'][$i])) {
216 $mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i];
219 } elseif (isset($fields_meta[$i])) {
220 $row = $fields_meta[$i];
221 switch ($row['Default']) {
222 case null:
223 if ($row['Null'] == 'YES') {
224 $row['DefaultType'] = 'NULL';
225 $row['DefaultValue'] = '';
226 // SHOW FULL FIELDS does not report the case when there is a DEFAULT value
227 // which is empty so we need to use the results of SHOW CREATE TABLE
228 } elseif (isset($row) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_value'])) {
229 $row['DefaultType'] = 'USER_DEFINED';
230 $row['DefaultValue'] = $row['Default'];
231 } else {
232 $row['DefaultType'] = 'NONE';
233 $row['DefaultValue'] = '';
235 break;
236 case 'CURRENT_TIMESTAMP':
237 $row['DefaultType'] = 'CURRENT_TIMESTAMP';
238 $row['DefaultValue'] = '';
239 break;
240 default:
241 $row['DefaultType'] = 'USER_DEFINED';
242 $row['DefaultValue'] = $row['Default'];
243 break;
247 if (isset($row['Type'])) {
248 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
249 if ($extracted_fieldspec['type'] == 'bit') {
250 $row['Default'] = PMA_convert_bit_default_value($row['Default']);
253 // Cell index: If certain fields get left out, the counter shouldn't change.
254 $ci = 0;
255 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
256 // has to be incremented ($ci_offset++)
257 $ci_offset = -1;
259 // old column name
260 if ($is_backup) {
261 if (! empty($true_selected[$i])) {
262 $_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
263 } elseif (isset($row['Field'])) {
264 $_form_params['field_orig[' . $i . ']'] = $row['Field'];
265 } else {
266 $_form_params['field_orig[' . $i . ']'] = '';
270 // column name
271 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
272 . ' type="text" name="field_name[' . $i . ']"'
273 . ' maxlength="64" class="textfield" title="' . __('Column') . '"'
274 . ' size="' . ($GLOBALS['cfg']['DefaultPropDisplay'] == 'horizontal' ? '10' : '30') . '"'
275 . ' value="' . (isset($row['Field']) ? htmlspecialchars($row['Field']) : '') . '"'
276 . ' />';
277 $ci++;
279 // column type
280 $select_id = 'field_' . $i . '_' . ($ci - $ci_offset);
281 $content_cells[$i][$ci] = '<select class="column_type" name="field_type[' . $i . ']"'
282 .' id="' . $select_id . '">';
284 if (empty($row['Type'])) {
285 // creating a column
286 $row['Type'] = '';
287 $type = '';
288 } else {
289 $type = $row['Type'];
292 if (! empty($row['Type'])) {
293 $type = $extracted_fieldspec['type'];
294 if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
295 $length = $extracted_fieldspec['spec_in_brackets'];
296 } else {
297 // strip the "BINARY" attribute, except if we find "BINARY(" because
298 // this would be a BINARY or VARBINARY field type
299 $type = preg_replace('@BINARY([^\(])@i', '', $type);
300 $type = preg_replace('@ZEROFILL@i', '', $type);
301 $type = preg_replace('@UNSIGNED@i', '', $type);
302 $length = $extracted_fieldspec['spec_in_brackets'];
303 } // end if else
304 } else {
305 // creating a column
306 $length = '';
309 // some types, for example longtext, are reported as
310 // "longtext character set latin7" when their charset and / or collation
311 // differs from the ones of the corresponding database.
312 $tmp = strpos($type, 'character set');
313 if ($tmp) {
314 $type = substr($type, 0, $tmp - 1);
317 if (isset($submit_length) && $submit_length != false) {
318 $length = $submit_length;
321 // rtrim the type, for cases like "float unsigned"
322 $type = rtrim($type);
323 $type_upper = strtoupper($type);
325 foreach ($cfg['ColumnTypes'] as $col_goup => $column_type) {
326 if (is_array($column_type)) {
327 $content_cells[$i][$ci] .= '<optgroup label="' . htmlspecialchars($col_goup) . '">';
328 foreach ($column_type as $col_group_type) {
329 $content_cells[$i][$ci] .= '<option value="'. $col_group_type . '"';
330 if ($type_upper == strtoupper($col_group_type)) {
331 $content_cells[$i][$ci] .= ' selected="selected"';
333 $content_cells[$i][$ci] .= '>' . $col_group_type . '</option>';
335 $content_cells[$i][$ci] .= '</optgroup>';
336 continue;
339 $content_cells[$i][$ci] .= '<option value="'. $column_type . '"';
340 if ($type_upper == strtoupper($column_type)) {
341 $content_cells[$i][$ci] .= ' selected="selected"';
343 $content_cells[$i][$ci] .= '>' . $column_type . '</option>';
344 } // end for
346 $content_cells[$i][$ci] .= ' </select>';
347 $ci++;
349 // old column length
350 if ($is_backup) {
351 $_form_params['field_length_orig[' . $i . ']'] = $length;
354 // column length
355 if (isset($extracted_fieldspec) && ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type'])) {
356 $binary = 0;
357 $unsigned = 0;
358 $zerofill = 0;
359 } else {
360 $binary = false;
361 $unsigned = stristr($row['Type'], 'unsigned');
362 $zerofill = stristr($row['Type'], 'zerofill');
364 $length_to_display = $length;
366 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
367 . ' type="text" name="field_length[' . $i . ']" size="' . $length_values_input_size . '"'
368 . ' value="' . htmlspecialchars($length_to_display) . '"'
369 . ' class="textfield" />'
370 . '<p class="enum_notice" id="enum_notice_' . $i . '_' . ($ci - $ci_offset) . '">';
371 $content_cells[$i][$ci] .= __('ENUM or SET data too long?')
372 . '<a onclick="return false;" href="enum_editor.php?' . PMA_generate_common_url() . '&amp;values=' . urlencode($length_to_display) . '&amp;field=' . (isset($row['Field']) ? urlencode($row['Field']) : "") . '" class="open_enum_editor" target="_blank"> '
373 . __('Get more editing space') . '</a></p>';
374 $ci++;
376 // column default
378 * having NULL enabled does not implicit having Default with NULL
380 if (isset($row)
381 && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
382 $row['Default'] = 'NULL';
386 // old column default
387 if ($is_backup) {
388 $_form_params['field_default_orig[' . $i . ']'] =
389 (isset($row['Default']) ? $row['Default'] : '');
392 // here we put 'NONE' as the default value of drop-down; otherwise
393 // users would have problems if they forget to enter the default
394 // value (example, for an INT)
395 $default_options = array(
396 'NONE' => _pgettext('for default', 'None'),
397 'USER_DEFINED' => __('As defined:'),
398 'NULL' => 'NULL',
399 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
402 // for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value
403 if ($type_upper == 'TIMESTAMP'
404 && ! empty($default_current_timestamp)
405 && isset($row['Default'])) {
406 $row['Default'] = '';
409 if ($type_upper == 'BIT') {
410 $row['DefaultValue'] = PMA_convert_bit_default_value($row['DefaultValue']);
413 $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">';
414 foreach ($default_options as $key => $value) {
415 $content_cells[$i][$ci] .= '<option value="' . $key . '"';
416 // is only set when we go back to edit a field's structure
417 if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
418 $content_cells[$i][$ci] .= ' selected="selected"';
420 $content_cells[$i][$ci] .= ' >' . $value . '</option>';
422 $content_cells[$i][$ci] .= '</select>';
423 $content_cells[$i][$ci] .= '<br />';
424 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
425 . ' type="text" name="field_default_value[' . $i . ']" size="12"'
426 . ' value="' . (isset($row['DefaultValue']) ? htmlspecialchars($row['DefaultValue']) : '') . '"'
427 . ' class="textfield" />';
428 $ci++;
430 // column collation
431 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
432 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
433 PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']',
434 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
435 unset($tmp_collation);
436 $ci++;
438 // column attribute
439 $content_cells[$i][$ci] = '<select style="font-size: 70%;"'
440 . ' name="field_attribute[' . $i . ']"'
441 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
443 $attribute = '';
444 if ($binary) {
445 $attribute = 'BINARY';
447 if ($unsigned) {
448 $attribute = 'UNSIGNED';
450 if ($zerofill) {
451 $attribute = 'UNSIGNED ZEROFILL';
453 if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
454 $attribute = 'on update CURRENT_TIMESTAMP';
457 if (isset($submit_attribute) && $submit_attribute != false) {
458 $attribute = $submit_attribute;
461 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
462 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
463 // the latter.
464 if (PMA_MYSQL_INT_VERSION < 50025
465 && isset($row['Field'])
466 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
467 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
468 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
469 $row['Null'] = '';
472 // MySQL 4.1.2+ TIMESTAMP options
473 // (if on_update_current_timestamp is set, then it's TRUE)
474 if (isset($row['Field'])
475 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
476 $attribute = 'on update CURRENT_TIMESTAMP';
478 if ((isset($row['Field'])
479 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
480 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
481 $default_current_timestamp = true;
482 } else {
483 $default_current_timestamp = false;
486 $cnt_attribute_types = count($cfg['AttributeTypes']);
487 for ($j = 0; $j < $cnt_attribute_types; $j++) {
488 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
489 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
490 $content_cells[$i][$ci] .= ' selected="selected"';
492 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
495 $content_cells[$i][$ci] .= '</select>';
496 $ci++;
498 // column NULL
499 $content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
500 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
502 if (! empty($row['Null']) && $row['Null'] != 'NO' && $row['Null'] != 'NOT NULL') {
503 $content_cells[$i][$ci] .= ' checked="checked"';
506 $content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
507 $ci++;
509 // column indexes
510 // See my other comment about removing this 'if'.
511 if (!$is_backup) {
512 $content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
513 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
514 $content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
516 $content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . __('Primary') . '"';
517 if (isset($row['Key']) && $row['Key'] == 'PRI') {
518 $content_cells[$i][$ci] .= ' selected="selected"';
520 $content_cells[$i][$ci] .= '>PRIMARY</option>';
522 $content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . __('Unique') . '"';
523 if (isset($row['Key']) && $row['Key'] == 'UNI') {
524 $content_cells[$i][$ci] .= ' selected="selected"';
526 $content_cells[$i][$ci] .= '>UNIQUE</option>';
528 $content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . __('Index') . '"';
529 if (isset($row['Key']) && $row['Key'] == 'MUL') {
530 $content_cells[$i][$ci] .= ' selected="selected"';
532 $content_cells[$i][$ci] .= '>INDEX</option>';
534 $content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . __('Fulltext') . '"';
535 if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
536 $content_cells[$i][$ci] .= ' selected="selected"';
538 $content_cells[$i][$ci] .= '>FULLTEXT</option>';
540 $content_cells[$i][$ci] .= '</select>';
541 $ci++;
542 } // end if ($action ==...)
544 // column auto_increment
545 $content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
546 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
548 if (isset($row['Extra']) && strtolower($row['Extra']) == 'auto_increment') {
549 $content_cells[$i][$ci] .= ' checked="checked"';
552 $content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
553 $ci++;
555 // column comments
556 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
557 . ' type="text" name="field_comments[' . $i . ']" size="12"'
558 . ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
559 . ' class="textfield" />';
560 $ci++;
562 // column MIME-types
563 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
564 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
565 $content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>';
567 if (is_array($available_mime['mimetype'])) {
568 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
569 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
570 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
574 $content_cells[$i][$ci] .= '</select>';
575 $ci++;
577 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
578 $content_cells[$i][$ci] .= ' <option value="" title="' . __('None') . '"></option>';
579 if (is_array($available_mime['transformation'])) {
580 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
581 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation']) && (preg_match('@' . preg_quote($available_mime['transformation_file'][$mimekey]) . '3?@i', $mime_map[$row['Field']]['transformation'])) ? 'selected ' : '');
582 $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
583 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', __('No description is available for this transformation.<br />Please ask the author what %s does.')), 'PMA_transformation_' . $tooltip . '()');
584 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
588 $content_cells[$i][$ci] .= '</select>';
589 $ci++;
591 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
592 . ' type="text" name="field_transformation_options[' . $i . ']"'
593 . ' size="16" class="textfield"'
594 . ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
595 . ' />';
596 //$ci++;
598 } // end for
601 <script src="./js/keyhandler.js" type="text/javascript"></script>
602 <script type="text/javascript">
603 // <![CDATA[
604 var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
605 document.onkeydown = onKeyDownArrowsHandler;
606 // ]]>
607 </script>
609 <form id="<?php echo ($action == 'tbl_create.php' ? 'create_table' : 'append_fields'); ?>_form" method="post" action="<?php echo $action; ?>">
610 <?php
611 echo PMA_generate_common_hidden_inputs($_form_params);
612 unset($_form_params);
613 if ($action == 'tbl_create.php') {
615 <table>
616 <tr valign="top">
617 <th><?php echo __('Table name'); ?>:&nbsp;</th>
618 </tr>
619 <tr><td><input type="text" name="table" size="40" maxlength="80"
620 value="<?php echo (isset($_REQUEST['table']) ? htmlspecialchars($_REQUEST['table']) : ''); ?>"
621 class="textfield" />
622 </td>
623 </tr>
624 </table>
625 <?php
629 if (is_array($content_cells) && is_array($header_cells)) {
630 // last row is for javascript insert
631 //$empty_row = array_pop($content_cells);
633 echo '<table id="table_columns">';
634 if ($display_type == 'horizontal') {
636 <tr>
637 <?php foreach ($header_cells as $header_val) { ?>
638 <th><?php echo $header_val; ?></th>
639 <?php } ?>
640 </tr>
641 <?php
643 $odd_row = true;
644 foreach ($content_cells as $content_row) {
645 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
646 $odd_row = ! $odd_row;
648 if (is_array($content_row)) {
649 foreach ($content_row as $content_row_val) {
651 <td align="center"><?php echo $content_row_val; ?></td>
652 <?php
655 echo '</tr>';
657 } else {
658 $i = 0;
659 $odd_row = true;
660 foreach ($header_cells as $header_val) {
661 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
662 $odd_row = ! $odd_row;
664 <th><?php echo $header_val; ?></th>
665 <?php
666 foreach ($content_cells as $content_cell) {
667 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
669 <td><?php echo $content_cell[$i]; ?></td>
670 <?php
673 echo '</tr>';
674 $i++;
678 </table>
679 <br />
680 <?php
684 * needs to be finished
687 if ($display_type == 'horizontal') {
688 $new_field = '';
689 foreach ($empty_row as $content_row_val) {
690 $new_field .= '<td align="center">' . $content_row_val . '</td>';
693 <script type="text/javascript">
694 // <![CDATA[
695 var odd_row = <?php echo $odd_row; ?>;
697 function addField() {
698 var new_fields = document.getElementById('added_fields').value;
699 var new_field_container = document.getElementById('table_columns');
700 var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';
701 var i = 0;
702 for (i = 0; i < new_fields; i++) {
703 if (odd_row) {
704 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
705 } else {
706 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
708 odd_row = ! odd_row;
711 return true;
713 // ]]>
714 </script>
715 <?php
719 if ($action == 'tbl_create.php') {
721 <table>
722 <tr valign="top">
723 <th><?php echo __('Table comments'); ?>:&nbsp;</th>
724 <td width="25">&nbsp;</td>
725 <th><?php echo __('Storage Engine'); ?>:
726 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
727 </th>
728 <td width="25">&nbsp;</td>
729 <th><?php echo __('Collation') ;?>:&nbsp;</th>
730 </tr>
731 <tr><td><input type="text" name="comment" size="40" maxlength="80"
732 value="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
733 class="textfield" />
734 </td>
735 <td width="25">&nbsp;</td>
736 <td>
737 <?php
738 echo PMA_StorageEngine::getHtmlSelect('tbl_type', null,
739 (isset($_REQUEST['tbl_type']) ? $_REQUEST['tbl_type'] : null));
741 </td>
742 <td width="25">&nbsp;</td>
743 <td>
744 <?php
745 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation',
746 null, (isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null), false, 3);
748 </td>
749 </tr>
750 <?php
751 if (PMA_Partition::havePartitioning()) {
753 <tr valign="top">
754 <th><?php echo __('PARTITION definition'); ?>:&nbsp;<?php echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?>
755 </th>
756 </tr>
757 <tr>
758 <td>
759 <textarea name="partition_definition" id="partitiondefinition"
760 cols="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
761 rows="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
762 dir="<?php echo $GLOBALS['text_dir'];?>"><?php echo (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : ''); ?></textarea>
763 </td>
764 </tr>
765 <?php
768 </table>
769 <br />
770 <?php
771 } // end if ($action == 'tbl_create.php')
774 <fieldset class="tblFooters">
775 <input type="submit" name="do_save_data" value="<?php echo __('Save'); ?>"
776 onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
777 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
778 <?php echo __('Or'); ?>
779 <?php echo sprintf(__('Add %s column(s)'), '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
780 <input type="submit" name="submit_num_fields"
781 value="<?php echo __('Go'); ?>"
782 <?php /* onclick="if (addField()) return false;" */ ?>
783 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)"
785 <?php } ?>
786 </fieldset>
788 </form>
790 <center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>
792 <div id="enum_editor">
793 <a class="close_enum_editor">Close</a>
794 <h3><?php printf(__('Values for the column "%s"'), isset($row['Field']) ? htmlspecialchars($row['Field']) : ""); ?></h3>
795 <p><?php echo __('Enter each value in a separate field.'); ?></p>
796 <div id="values"></div>
797 <p><a class="add_value">+ Add a new value</a></p>
798 <input type="submit" value="Go" /> <a class="cancel_enum_editor">Cancel</a>
799 </div>
801 <div id="popup_background"></div>