Merge remote-tracking branch 'origin/master'
[phpmyadmin/madhuracj.git] / libraries / tbl_properties.inc.php
blob336545bd6cf9f010d6389fe6c61ecaa07cf95fec
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 require_once './libraries/common.lib.php';
18 PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
21 // Get available character sets and storage engines
22 require_once './libraries/mysql_charsets.lib.php';
23 require_once './libraries/StorageEngine.class.php';
25 /**
26 * Class for partition management
28 require_once './libraries/Partition.class.php';
30 // load additional configuration variables
31 if (PMA_DRIZZLE) {
32 include_once './libraries/data_drizzle.inc.php';
33 } else {
34 include_once './libraries/data_mysql.inc.php';
37 $length_values_input_size = 8;
39 $_form_params = array(
40 'db' => $db,
43 if ($action == 'tbl_create.php') {
44 $_form_params['reload'] = 1;
45 } elseif ($action == 'tbl_addfield.php') {
46 $_form_params['field_where'] = $_REQUEST['field_where'];
47 $_form_params['after_field'] = $_REQUEST['after_field'];
48 $_form_params['table'] = $table;
49 } else {
50 $_form_params['table'] = $table;
53 if (isset($num_fields)) {
54 $_form_params['orig_num_fields'] = $num_fields;
57 if (isset($_REQUEST['field_where'])) {
58 $_form_params['orig_field_where'] = $_REQUEST['field_where'];
61 if (isset($_REQUEST['after_field'])) {
62 $_form_params['orig_after_field'] = $_REQUEST['after_field'];
65 if (isset($selected) && is_array($selected)) {
66 foreach ($selected as $o_fld_nr => $o_fld_val) {
67 $_form_params['selected[' . $o_fld_nr . ']'] = $o_fld_val;
68 if (! isset($true_selected)) {
69 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
73 if (isset($true_selected) && is_array($true_selected)) {
74 foreach ($true_selected as $o_fld_nr => $o_fld_val) {
75 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
78 } elseif (isset($_REQUEST['field'])) {
79 $_form_params['orig_field'] = $_REQUEST['field'];
80 if (isset($orig_field)) {
81 $_form_params['true_selected[]'] = $orig_field;
82 } else {
83 $_form_params['true_selected[]'] = $_REQUEST['field'];
87 $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
89 $header_cells = array();
90 $content_cells = array();
92 $header_cells[] = __('Name');
93 $header_cells[] = __('Type')
94 . ($GLOBALS['cfg']['ReplaceHelpImg']
95 ? PMA_showMySQLDocu('SQL-Syntax', 'data-types')
96 : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'data-types')
97 . '</span>');
98 $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\').'));
99 $header_cells[] = __('Default') . PMA_showHint(__('For default values, please enter just a single value, without backslash escaping or quotes, using this format: a'));
100 $header_cells[] = __('Collation');
101 $header_cells[] = __('Attributes');
102 $header_cells[] = __('Null');
104 // We could remove this 'if' and let the key information be shown and
105 // editable. However, for this to work, tbl_alter must be modified to use the
106 // key fields, as tbl_addfield does.
108 if (!$is_backup) {
109 $header_cells[] = __('Index');
112 $header_cells[] = '<abbr title="AUTO_INCREMENT">A_I</abbr>';
114 require_once './libraries/transformations.lib.php';
115 $cfgRelation = PMA_getRelationsParam();
117 $comments_map = array();
118 $mime_map = array();
119 $available_mime = array();
121 $comments_map = PMA_getComments($db, $table);
122 $header_cells[] = __('Comments');
124 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
125 $mime_map = PMA_getMIME($db, $table);
126 $available_mime = PMA_getAvailableMIMEtypes();
128 $hint = '<br />' .
129 sprintf(__('For a list of available transformation options and their MIME type transformations, click on %stransformation descriptions%s'),
130 '<a href="transformation_overview.php?'
131 . PMA_generate_common_url($db, $table) . '" target="_blank">',
132 '</a>');
135 $header_cells[] = __('MIME type');
136 $header_cells[] = __('Browser transformation');
137 $header_cells[] = __('Transformation options')
138 . 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);
141 // workaround for field_fulltext, because its submitted indizes contain
142 // the index as a value, not a key. Inserted here for easier maintaineance
143 // and less code to change in existing files.
144 if (isset($field_fulltext) && is_array($field_fulltext)) {
145 foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
146 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
150 for ($i = 0; $i < $num_fields; $i++) {
151 if (! empty($regenerate)) {
152 // An error happened with previous inputs, so we will restore the data
153 // to embed it once again in this form.
155 $row['Field'] = (isset($_REQUEST['field_name'][$i]) ? $_REQUEST['field_name'][$i] : false);
156 $row['Type'] = (isset($_REQUEST['field_type'][$i]) ? $_REQUEST['field_type'][$i] : false);
157 $row['Collation'] = (isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '');
158 $row['Null'] = (isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : '');
160 if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i) {
161 $row['Key'] = 'PRI';
162 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i) {
163 $row['Key'] = 'MUL';
164 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i) {
165 $row['Key'] = 'UNI';
166 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i) {
167 $row['Key'] = 'FULLTEXT';
168 } else {
169 $row['Key'] = '';
172 // put None in the drop-down for Default, when someone adds a field
173 $row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ? $_REQUEST['field_default_type'][$i] : 'NONE');
174 $row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ? $_REQUEST['field_default_value'][$i] : '');
176 switch ($row['DefaultType']) {
177 case 'NONE' :
178 $row['Default'] = null;
179 break;
180 case 'USER_DEFINED' :
181 $row['Default'] = $row['DefaultValue'];
182 break;
183 case 'NULL' :
184 case 'CURRENT_TIMESTAMP' :
185 $row['Default'] = $row['DefaultType'];
186 break;
189 $row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false);
190 $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : false);
192 $submit_length = (isset($_REQUEST['field_length'][$i]) ? $_REQUEST['field_length'][$i] : false);
193 $submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ? $_REQUEST['field_attribute'][$i] : false);
195 $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ? true : false);
197 if (isset($_REQUEST['field_comments'][$i])) {
198 $comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
201 if (isset($_REQUEST['field_mimetype'][$i])) {
202 $mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
205 if (isset($_REQUEST['field_transformation'][$i])) {
206 $mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i];
209 if (isset($_REQUEST['field_transformation_options'][$i])) {
210 $mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i];
213 } elseif (isset($fields_meta[$i])) {
214 $row = $fields_meta[$i];
215 switch ($row['Default']) {
216 case null:
217 if ($row['Null'] == 'YES') {
218 $row['DefaultType'] = 'NULL';
219 $row['DefaultValue'] = '';
220 // SHOW FULL COLUMNS does not report the case when there is a DEFAULT value
221 // which is empty so we need to use the results of SHOW CREATE TABLE
222 } elseif (isset($row) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_value'])) {
223 $row['DefaultType'] = 'USER_DEFINED';
224 $row['DefaultValue'] = $row['Default'];
225 } else {
226 $row['DefaultType'] = 'NONE';
227 $row['DefaultValue'] = '';
229 break;
230 case 'CURRENT_TIMESTAMP':
231 $row['DefaultType'] = 'CURRENT_TIMESTAMP';
232 $row['DefaultValue'] = '';
233 break;
234 default:
235 $row['DefaultType'] = 'USER_DEFINED';
236 $row['DefaultValue'] = $row['Default'];
237 break;
241 if (isset($row['Type'])) {
242 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
243 if ($extracted_fieldspec['type'] == 'bit') {
244 $row['Default'] = PMA_convert_bit_default_value($row['Default']);
247 // Cell index: If certain fields get left out, the counter shouldn't change.
248 $ci = 0;
249 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
250 // has to be incremented ($ci_offset++)
251 $ci_offset = -1;
253 // old column name
254 if ($is_backup) {
255 if (! empty($true_selected[$i])) {
256 $_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
257 } elseif (isset($row['Field'])) {
258 $_form_params['field_orig[' . $i . ']'] = $row['Field'];
259 } else {
260 $_form_params['field_orig[' . $i . ']'] = '';
264 // column name
265 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
266 . ' type="text" name="field_name[' . $i . ']"'
267 . ' maxlength="64" class="textfield" title="' . __('Column') . '"'
268 . ' size="10"'
269 . ' value="' . (isset($row['Field']) ? htmlspecialchars($row['Field']) : '') . '"'
270 . ' />';
271 $ci++;
273 // column type
274 $select_id = 'field_' . $i . '_' . ($ci - $ci_offset);
275 $content_cells[$i][$ci] = '<select class="column_type" name="field_type[' . $i . ']"'
276 .' id="' . $select_id . '">';
278 if (empty($row['Type'])) {
279 // creating a column
280 $row['Type'] = '';
281 $type = '';
282 $length = '';
283 } else {
284 $type = $extracted_fieldspec['type'];
285 $length = $extracted_fieldspec['spec_in_brackets'];
288 // some types, for example longtext, are reported as
289 // "longtext character set latin7" when their charset and / or collation
290 // differs from the ones of the corresponding database.
291 $tmp = strpos($type, 'character set');
292 if ($tmp) {
293 $type = substr($type, 0, $tmp - 1);
296 if (isset($submit_length) && $submit_length != false) {
297 $length = $submit_length;
300 // rtrim the type, for cases like "float unsigned"
301 $type = rtrim($type);
302 $type_upper = strtoupper($type);
304 $content_cells[$i][$ci] .= PMA_getSupportedDatatypes(true, $type_upper);
305 $content_cells[$i][$ci] .= ' </select>';
306 $ci++;
308 // old column length
309 if ($is_backup) {
310 $_form_params['field_length_orig[' . $i . ']'] = $length;
313 // column length
314 $length_to_display = $length;
316 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
317 . ' type="text" name="field_length[' . $i . ']" size="' . $length_values_input_size . '"'
318 . ' value="' . htmlspecialchars($length_to_display) . '"'
319 . ' class="textfield" />'
320 . '<p class="enum_notice" id="enum_notice_' . $i . '_' . ($ci - $ci_offset) . '">';
321 $content_cells[$i][$ci] .= __('ENUM or SET data too long?')
322 . '<a onclick="return false;" href="enum_editor.php?'
323 . PMA_generate_common_url()
324 . '&amp;values=' . urlencode($length_to_display)
325 . '&amp;field=' . (isset($row['Field']) ? urlencode($row['Field']) : "")
326 . '" class="open_enum_editor" target="_blank"> '
327 . __('Get more editing space') . '</a>'
328 . '</p>';
329 $ci++;
331 // column default
333 * having NULL enabled does not implicit having Default with NULL
335 if (isset($row)
336 && ! isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
337 $row['Default'] = 'NULL';
341 // old column default
342 if ($is_backup) {
343 $_form_params['field_default_orig[' . $i . ']'] =
344 (isset($row['Default']) ? $row['Default'] : '');
347 // here we put 'NONE' as the default value of drop-down; otherwise
348 // users would have problems if they forget to enter the default
349 // value (example, for an INT)
350 $default_options = array(
351 'NONE' => _pgettext('for default', 'None'),
352 'USER_DEFINED' => __('As defined:'),
353 'NULL' => 'NULL',
354 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
357 // for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value
358 if ($type_upper == 'TIMESTAMP'
359 && ! empty($default_current_timestamp)
360 && isset($row['Default'])) {
361 $row['Default'] = '';
364 if ($type_upper == 'BIT') {
365 $row['DefaultValue'] = PMA_convert_bit_default_value($row['DefaultValue']);
368 $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']" class="default_type">';
369 foreach ($default_options as $key => $value) {
370 $content_cells[$i][$ci] .= '<option value="' . $key . '"';
371 // is only set when we go back to edit a field's structure
372 if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
373 $content_cells[$i][$ci] .= ' selected="selected"';
375 $content_cells[$i][$ci] .= ' >' . $value . '</option>';
377 $content_cells[$i][$ci] .= '</select>';
378 $content_cells[$i][$ci] .= '<br />';
379 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
380 . ' type="text" name="field_default_value[' . $i . ']" size="12"'
381 . ' value="' . (isset($row['DefaultValue']) ? htmlspecialchars($row['DefaultValue']) : '') . '"'
382 . ' class="textfield default_value" />';
383 $ci++;
385 // column collation
386 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
387 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
388 PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']',
389 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
390 unset($tmp_collation);
391 $ci++;
393 // column attribute
394 $content_cells[$i][$ci] = '<select style="font-size: 70%;"'
395 . ' name="field_attribute[' . $i . ']"'
396 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
398 $attribute = '';
399 if (isset($extracted_fieldspec)) {
400 $attribute = $extracted_fieldspec['attribute'];
403 if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
404 $attribute = 'on update CURRENT_TIMESTAMP';
407 if (isset($submit_attribute) && $submit_attribute != false) {
408 $attribute = $submit_attribute;
411 // here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having the
412 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
413 // the latter.
414 if (PMA_MYSQL_INT_VERSION < 50025
415 && isset($row['Field'])
416 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
417 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
418 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
419 $row['Null'] = '';
422 // MySQL 4.1.2+ TIMESTAMP options
423 // (if on_update_current_timestamp is set, then it's TRUE)
424 if (isset($row['Field'])
425 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
426 $attribute = 'on update CURRENT_TIMESTAMP';
428 if ((isset($row['Field'])
429 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
430 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
431 $default_current_timestamp = true;
432 } else {
433 $default_current_timestamp = false;
436 $cnt_attribute_types = count($cfg['AttributeTypes']);
437 for ($j = 0; $j < $cnt_attribute_types; $j++) {
438 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
439 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
440 $content_cells[$i][$ci] .= ' selected="selected"';
442 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
445 $content_cells[$i][$ci] .= '</select>';
446 $ci++;
448 // column NULL
449 $content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
450 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
452 if (! empty($row['Null']) && $row['Null'] != 'NO' && $row['Null'] != 'NOT NULL') {
453 $content_cells[$i][$ci] .= ' checked="checked"';
456 $content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
457 $ci++;
459 // column indexes
460 // See my other comment about removing this 'if'.
461 if (!$is_backup) {
462 $content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
463 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
464 $content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
466 $content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . __('Primary') . '"';
467 if (isset($row['Key']) && $row['Key'] == 'PRI') {
468 $content_cells[$i][$ci] .= ' selected="selected"';
470 $content_cells[$i][$ci] .= '>PRIMARY</option>';
472 $content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . __('Unique') . '"';
473 if (isset($row['Key']) && $row['Key'] == 'UNI') {
474 $content_cells[$i][$ci] .= ' selected="selected"';
476 $content_cells[$i][$ci] .= '>UNIQUE</option>';
478 $content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . __('Index') . '"';
479 if (isset($row['Key']) && $row['Key'] == 'MUL') {
480 $content_cells[$i][$ci] .= ' selected="selected"';
482 $content_cells[$i][$ci] .= '>INDEX</option>';
484 if (!PMA_DRIZZLE) {
485 $content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . __('Fulltext') . '"';
486 if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
487 $content_cells[$i][$ci] .= ' selected="selected"';
489 $content_cells[$i][$ci] .= '>FULLTEXT</option>';
492 $content_cells[$i][$ci] .= '</select>';
493 $ci++;
494 } // end if ($action ==...)
496 // column auto_increment
497 $content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
498 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
500 if (isset($row['Extra']) && strtolower($row['Extra']) == 'auto_increment') {
501 $content_cells[$i][$ci] .= ' checked="checked"';
504 $content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
505 $ci++;
507 // column comments
508 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
509 . ' type="text" name="field_comments[' . $i . ']" size="12"'
510 . ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
511 . ' class="textfield" />';
512 $ci++;
514 // column MIME-types
515 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
516 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
517 $content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>';
519 if (is_array($available_mime['mimetype'])) {
520 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
521 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
522 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
526 $content_cells[$i][$ci] .= '</select>';
527 $ci++;
529 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
530 $content_cells[$i][$ci] .= ' <option value="" title="' . __('None') . '"></option>';
531 if (is_array($available_mime['transformation'])) {
532 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
533 $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 ' : '');
534 $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
535 $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 . '()');
536 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
540 $content_cells[$i][$ci] .= '</select>';
541 $ci++;
543 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
544 . ' type="text" name="field_transformation_options[' . $i . ']"'
545 . ' size="16" class="textfield"'
546 . ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
547 . ' />';
548 //$ci++;
550 } // end for
553 <script src="./js/keyhandler.js" type="text/javascript"></script>
554 <script type="text/javascript">
555 // <![CDATA[
556 var switch_movement = 0;
557 document.onkeydown = onKeyDownArrowsHandler;
558 // ]]>
559 </script>
561 <form id="<?php echo ($action == 'tbl_create.php' ? 'create_table' : 'append_fields'); ?>_form" method="post" action="<?php echo $action; ?>" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?>>
562 <?php
563 echo PMA_generate_common_hidden_inputs($_form_params);
564 unset($_form_params);
565 if ($action == 'tbl_create.php') {
567 <table>
568 <tr><td><?php echo __('Table name'); ?>:&nbsp;<input type="text" name="table" size="40" maxlength="80"
569 value="<?php echo (isset($_REQUEST['table']) ? htmlspecialchars($_REQUEST['table']) : ''); ?>"
570 class="textfield" />
571 </td>
572 <td>
573 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
574 <?php echo sprintf(__('Add %s column(s)'), '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
575 <input type="submit" name="submit_num_fields" value="<?php echo __('Go'); ?>"
576 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)"
578 <?php } ?>
579 </td>
580 </tr>
581 </table>
582 <?php
586 if (is_array($content_cells) && is_array($header_cells)) {
587 // last row is for javascript insert
588 //$empty_row = array_pop($content_cells);
590 echo '<table id="table_columns" class="noclick">';
591 echo '<caption class="tblHeaders">' . __('Structure') . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE') . '</caption>';
594 <tr>
595 <?php foreach ($header_cells as $header_val) { ?>
596 <th><?php echo $header_val; ?></th>
597 <?php } ?>
598 </tr>
599 <?php
601 $odd_row = true;
602 foreach ($content_cells as $content_row) {
603 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
604 $odd_row = ! $odd_row;
606 if (is_array($content_row)) {
607 foreach ($content_row as $content_row_val) {
609 <td align="center"><?php echo $content_row_val; ?></td>
610 <?php
613 echo '</tr>';
616 </table>
617 <br />
618 <?php
622 * needs to be finished
625 if ($display_type == 'horizontal') {
626 $new_field = '';
627 foreach ($empty_row as $content_row_val) {
628 $new_field .= '<td align="center">' . $content_row_val . '</td>';
631 <script type="text/javascript">
632 // <![CDATA[
633 var odd_row = <?php echo $odd_row; ?>;
635 function addField()
637 var new_fields = document.getElementById('added_fields').value;
638 var new_field_container = document.getElementById('table_columns');
639 var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';
640 var i = 0;
641 for (i = 0; i < new_fields; i++) {
642 if (odd_row) {
643 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
644 } else {
645 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
647 odd_row = ! odd_row;
650 return true;
652 // ]]>
653 </script>
654 <?php
658 if ($action == 'tbl_create.php') {
660 <table>
661 <tr valign="top">
662 <th><?php echo __('Table comments'); ?>:&nbsp;</th>
663 <td width="25">&nbsp;</td>
664 <th><?php echo __('Storage Engine'); ?>:
665 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
666 </th>
667 <td width="25">&nbsp;</td>
668 <th><?php echo __('Collation') ;?>:&nbsp;</th>
669 </tr>
670 <tr><td><input type="text" name="comment" size="40" maxlength="80"
671 value="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
672 class="textfield" />
673 </td>
674 <td width="25">&nbsp;</td>
675 <td>
676 <?php
677 echo PMA_StorageEngine::getHtmlSelect('tbl_type', null,
678 (isset($_REQUEST['tbl_type']) ? $_REQUEST['tbl_type'] : null));
680 </td>
681 <td width="25">&nbsp;</td>
682 <td>
683 <?php
684 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation',
685 null, (isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null), false, 3);
687 </td>
688 </tr>
689 <?php
690 if (PMA_Partition::havePartitioning()) {
692 <tr valign="top">
693 <th><?php echo __('PARTITION definition'); ?>:&nbsp;<?php echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?>
694 </th>
695 </tr>
696 <tr>
697 <td>
698 <textarea name="partition_definition" id="partitiondefinition"
699 cols="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
700 rows="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
701 dir="<?php echo $GLOBALS['text_dir'];?>"><?php echo (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : ''); ?></textarea>
702 </td>
703 </tr>
704 <?php
707 </table>
708 <br />
709 <?php
710 } // end if ($action == 'tbl_create.php')
713 <fieldset class="tblFooters">
714 <input type="submit" name="do_save_data" value="<?php echo __('Save'); ?>" />
715 </fieldset>
716 <div id="properties_message"></div>
717 </form>
719 <div id="popup_background"></div>