2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Display form for changing/adding table fields/columns
6 * included by tbl_addfield.php, -_alter.php, -_create.php
9 if (! defined('PHPMYADMIN')) {
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';
26 * Class for partition management
28 require_once './libraries/Partition.class.php';
30 if (is_int($cfg['DefaultPropDisplay'])) {
31 if ($num_fields <= $cfg['DefaultPropDisplay']) {
32 $display_type = 'vertical';
34 $display_type = 'horizontal';
37 $display_type = $cfg['DefaultPropDisplay'];
40 if ('horizontal' == $display_type) {
41 $length_values_input_size = 8;
43 $length_values_input_size = 30;
46 $_form_params = array(
50 if ($action == 'tbl_create.php') {
51 $_form_params['reload'] = 1;
52 } elseif ($action == 'tbl_addfield.php') {
53 $_form_params['field_where'] = $_REQUEST['field_where'];
54 $_form_params['after_field'] = $_REQUEST['after_field'];
55 $_form_params['table'] = $table;
57 $_form_params['table'] = $table;
60 if (isset($num_fields)) {
61 $_form_params['orig_num_fields'] = $num_fields;
64 if (isset($_REQUEST['field_where'])) {
65 $_form_params['orig_field_where'] = $_REQUEST['field_where'];
68 if (isset($_REQUEST['after_field'])) {
69 $_form_params['orig_after_field'] = $_REQUEST['after_field'];
72 if (isset($selected) && is_array($selected)) {
73 foreach ($selected as $o_fld_nr => $o_fld_val) {
74 $_form_params['selected[' . $o_fld_nr . ']'] = $o_fld_val;
75 if (! isset($true_selected)) {
76 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
80 if (isset($true_selected) && is_array($true_selected)) {
81 foreach ($true_selected as $o_fld_nr => $o_fld_val) {
82 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
85 } elseif (isset($_REQUEST['field'])) {
86 $_form_params['orig_field'] = $_REQUEST['field'];
87 if (isset($orig_field)) {
88 $_form_params['true_selected[]'] = $orig_field;
90 $_form_params['true_selected[]'] = $_REQUEST['field'];
94 $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
96 $header_cells = array();
97 $content_cells = array();
99 $header_cells[] = __('Name');
100 $header_cells[] = __('Type')
101 . ($GLOBALS['cfg']['ReplaceHelpImg']
102 ?
PMA_showMySQLDocu('SQL-Syntax', 'data-types')
103 : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'data-types')
105 $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\').'));
106 $header_cells[] = __('Default') . PMA_showHint(__('For default values, please enter just a single value, without backslash escaping or quotes, using this format: a'));
107 $header_cells[] = __('Collation');
108 $header_cells[] = __('Attributes');
109 $header_cells[] = __('Null');
111 // We could remove this 'if' and let the key information be shown and
112 // editable. However, for this to work, tbl_alter must be modified to use the
113 // key fields, as tbl_addfield does.
116 $header_cells[] = __('Index');
119 $header_cells[] = '<abbr title="AUTO_INCREMENT">' . ($display_type == 'horizontal' ?
'A_I' : 'AUTO_INCREMENT') . '</abbr>';
121 require_once './libraries/transformations.lib.php';
122 $cfgRelation = PMA_getRelationsParam();
124 $comments_map = array();
126 $available_mime = array();
128 $comments_map = PMA_getComments($db, $table);
129 $header_cells[] = __('Comments');
131 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
132 $mime_map = PMA_getMIME($db, $table);
133 $available_mime = PMA_getAvailableMIMEtypes();
136 sprintf(__('For a list of available transformation options and their MIME type transformations, click on %stransformation descriptions%s'),
137 '<a href="transformation_overview.php?'
138 . PMA_generate_common_url($db, $table) . '" target="_blank">',
142 $header_cells[] = __('MIME type');
143 $header_cells[] = __('Browser transformation');
144 $header_cells[] = __('Transformation options')
145 . 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);
148 // workaround for field_fulltext, because its submitted indizes contain
149 // the index as a value, not a key. Inserted here for easier maintaineance
150 // and less code to change in existing files.
151 if (isset($field_fulltext) && is_array($field_fulltext)) {
152 foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
153 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
157 for ($i = 0; $i < $num_fields; $i++
) {
158 if (! empty($regenerate)) {
159 // An error happened with previous inputs, so we will restore the data
160 // to embed it once again in this form.
162 $row['Field'] = (isset($_REQUEST['field_name'][$i]) ?
$_REQUEST['field_name'][$i] : false);
163 $row['Type'] = (isset($_REQUEST['field_type'][$i]) ?
$_REQUEST['field_type'][$i] : false);
164 $row['Collation'] = (isset($_REQUEST['field_collation'][$i]) ?
$_REQUEST['field_collation'][$i] : '');
165 $row['Null'] = (isset($_REQUEST['field_null'][$i]) ?
$_REQUEST['field_null'][$i] : '');
167 if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i) {
169 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i) {
171 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i) {
173 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i) {
174 $row['Key'] = 'FULLTEXT';
179 // put None in the drop-down for Default, when someone adds a field
180 $row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ?
$_REQUEST['field_default_type'][$i] : 'NONE');
181 $row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ?
$_REQUEST['field_default_value'][$i] : '');
183 switch ($row['DefaultType']) {
185 $row['Default'] = null;
187 case 'USER_DEFINED' :
188 $row['Default'] = $row['DefaultValue'];
191 case 'CURRENT_TIMESTAMP' :
192 $row['Default'] = $row['DefaultType'];
196 $row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ?
$_REQUEST['field_extra'][$i] : false);
197 $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ?
'FULLTEXT' : false);
199 $submit_length = (isset($_REQUEST['field_length'][$i]) ?
$_REQUEST['field_length'][$i] : false);
200 $submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ?
$_REQUEST['field_attribute'][$i] : false);
202 $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ?
true : false);
204 if (isset($_REQUEST['field_comments'][$i])) {
205 $comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
208 if (isset($_REQUEST['field_mimetype'][$i])) {
209 $mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
212 if (isset($_REQUEST['field_transformation'][$i])) {
213 $mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i];
216 if (isset($_REQUEST['field_transformation_options'][$i])) {
217 $mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i];
220 } elseif (isset($fields_meta[$i])) {
221 $row = $fields_meta[$i];
222 switch ($row['Default']) {
224 if ($row['Null'] == 'YES') {
225 $row['DefaultType'] = 'NULL';
226 $row['DefaultValue'] = '';
227 // SHOW FULL COLUMNS does not report the case when there is a DEFAULT value
228 // which is empty so we need to use the results of SHOW CREATE TABLE
229 } elseif (isset($row) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_value'])) {
230 $row['DefaultType'] = 'USER_DEFINED';
231 $row['DefaultValue'] = $row['Default'];
233 $row['DefaultType'] = 'NONE';
234 $row['DefaultValue'] = '';
237 case 'CURRENT_TIMESTAMP':
238 $row['DefaultType'] = 'CURRENT_TIMESTAMP';
239 $row['DefaultValue'] = '';
242 $row['DefaultType'] = 'USER_DEFINED';
243 $row['DefaultValue'] = $row['Default'];
248 if (isset($row['Type'])) {
249 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
250 if ($extracted_fieldspec['type'] == 'bit') {
251 $row['Default'] = PMA_convert_bit_default_value($row['Default']);
254 // Cell index: If certain fields get left out, the counter shouldn't change.
256 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
257 // has to be incremented ($ci_offset++)
262 if (! empty($true_selected[$i])) {
263 $_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
264 } elseif (isset($row['Field'])) {
265 $_form_params['field_orig[' . $i . ']'] = $row['Field'];
267 $_form_params['field_orig[' . $i . ']'] = '';
272 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
273 . ' type="text" name="field_name[' . $i . ']"'
274 . ' maxlength="64" class="textfield" title="' . __('Column') . '"'
275 . ' size="' . ($GLOBALS['cfg']['DefaultPropDisplay'] == 'horizontal' ?
'10' : '30') . '"'
276 . ' value="' . (isset($row['Field']) ?
htmlspecialchars($row['Field']) : '') . '"'
281 $select_id = 'field_' . $i . '_' . ($ci - $ci_offset);
282 $content_cells[$i][$ci] = '<select class="column_type" name="field_type[' . $i . ']"'
283 .' id="' . $select_id . '">';
285 if (empty($row['Type'])) {
290 $type = $row['Type'];
293 if (! empty($row['Type'])) {
294 $type = $extracted_fieldspec['type'];
295 if ('set' == $extracted_fieldspec['type'] ||
'enum' == $extracted_fieldspec['type']) {
296 $length = $extracted_fieldspec['spec_in_brackets'];
298 // strip the "BINARY" attribute, except if we find "BINARY(" because
299 // this would be a BINARY or VARBINARY field type
300 $type = preg_replace('@BINARY([^\(])@i', '', $type);
301 $type = preg_replace('@ZEROFILL@i', '', $type);
302 $type = preg_replace('@UNSIGNED@i', '', $type);
303 $length = $extracted_fieldspec['spec_in_brackets'];
310 // some types, for example longtext, are reported as
311 // "longtext character set latin7" when their charset and / or collation
312 // differs from the ones of the corresponding database.
313 $tmp = strpos($type, 'character set');
315 $type = substr($type, 0, $tmp - 1);
318 if (isset($submit_length) && $submit_length != false) {
319 $length = $submit_length;
322 // rtrim the type, for cases like "float unsigned"
323 $type = rtrim($type);
324 $type_upper = strtoupper($type);
326 $content_cells[$i][$ci] .= PMA_getSupportedDatatypes(true, $type_upper);
327 $content_cells[$i][$ci] .= ' </select>';
332 $_form_params['field_length_orig[' . $i . ']'] = $length;
336 if (isset($extracted_fieldspec) && ('set' == $extracted_fieldspec['type'] ||
'enum' == $extracted_fieldspec['type'])) {
342 $unsigned = stristr($row['Type'], 'unsigned');
343 $zerofill = stristr($row['Type'], 'zerofill');
345 $length_to_display = $length;
347 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
348 . ' type="text" name="field_length[' . $i . ']" size="' . $length_values_input_size . '"'
349 . ' value="' . htmlspecialchars($length_to_display) . '"'
350 . ' class="textfield" />'
351 . '<p class="enum_notice" id="enum_notice_' . $i . '_' . ($ci - $ci_offset) . '">';
352 $content_cells[$i][$ci] .= __('ENUM or SET data too long?')
353 . '<a onclick="return false;" href="enum_editor.php?' . PMA_generate_common_url() . '&values=' . urlencode($length_to_display) . '&field=' . (isset($row['Field']) ?
urlencode($row['Field']) : "") . '" class="open_enum_editor" target="_blank"> '
354 . __('Get more editing space') . '</a></p>';
359 * having NULL enabled does not implicit having Default with NULL
362 && ! isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
363 $row['Default'] = 'NULL';
367 // old column default
369 $_form_params['field_default_orig[' . $i . ']'] =
370 (isset($row['Default']) ?
$row['Default'] : '');
373 // here we put 'NONE' as the default value of drop-down; otherwise
374 // users would have problems if they forget to enter the default
375 // value (example, for an INT)
376 $default_options = array(
377 'NONE' => _pgettext('for default', 'None'),
378 'USER_DEFINED' => __('As defined:'),
380 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
383 // for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value
384 if ($type_upper == 'TIMESTAMP'
385 && ! empty($default_current_timestamp)
386 && isset($row['Default'])) {
387 $row['Default'] = '';
390 if ($type_upper == 'BIT') {
391 $row['DefaultValue'] = PMA_convert_bit_default_value($row['DefaultValue']);
394 $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">';
395 foreach ($default_options as $key => $value) {
396 $content_cells[$i][$ci] .= '<option value="' . $key . '"';
397 // is only set when we go back to edit a field's structure
398 if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
399 $content_cells[$i][$ci] .= ' selected="selected"';
401 $content_cells[$i][$ci] .= ' >' . $value . '</option>';
403 $content_cells[$i][$ci] .= '</select>';
404 $content_cells[$i][$ci] .= '<br />';
405 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
406 . ' type="text" name="field_default_value[' . $i . ']" size="12"'
407 . ' value="' . (isset($row['DefaultValue']) ?
htmlspecialchars($row['DefaultValue']) : '') . '"'
408 . ' class="textfield" />';
412 $tmp_collation = empty($row['Collation']) ?
null : $row['Collation'];
413 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
414 PMA_CSDROPDOWN_COLLATION
, 'field_collation[' . $i . ']',
415 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
416 unset($tmp_collation);
420 $content_cells[$i][$ci] = '<select style="font-size: 70%;"'
421 . ' name="field_attribute[' . $i . ']"'
422 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
426 $attribute = 'BINARY';
429 $attribute = 'UNSIGNED';
432 $attribute = 'UNSIGNED ZEROFILL';
434 if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
435 $attribute = 'on update CURRENT_TIMESTAMP';
438 if (isset($submit_attribute) && $submit_attribute != false) {
439 $attribute = $submit_attribute;
442 // here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having the
443 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
445 if (PMA_MYSQL_INT_VERSION
< 50025
446 && isset($row['Field'])
447 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
448 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
449 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
453 // MySQL 4.1.2+ TIMESTAMP options
454 // (if on_update_current_timestamp is set, then it's TRUE)
455 if (isset($row['Field'])
456 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
457 $attribute = 'on update CURRENT_TIMESTAMP';
459 if ((isset($row['Field'])
460 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
461 ||
(isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
462 $default_current_timestamp = true;
464 $default_current_timestamp = false;
467 $cnt_attribute_types = count($cfg['AttributeTypes']);
468 for ($j = 0; $j < $cnt_attribute_types; $j++
) {
469 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
470 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
471 $content_cells[$i][$ci] .= ' selected="selected"';
473 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
476 $content_cells[$i][$ci] .= '</select>';
480 $content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
481 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
483 if (! empty($row['Null']) && $row['Null'] != 'NO' && $row['Null'] != 'NOT NULL') {
484 $content_cells[$i][$ci] .= ' checked="checked"';
487 $content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
491 // See my other comment about removing this 'if'.
493 $content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
494 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
495 $content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
497 $content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . __('Primary') . '"';
498 if (isset($row['Key']) && $row['Key'] == 'PRI') {
499 $content_cells[$i][$ci] .= ' selected="selected"';
501 $content_cells[$i][$ci] .= '>PRIMARY</option>';
503 $content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . __('Unique') . '"';
504 if (isset($row['Key']) && $row['Key'] == 'UNI') {
505 $content_cells[$i][$ci] .= ' selected="selected"';
507 $content_cells[$i][$ci] .= '>UNIQUE</option>';
509 $content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . __('Index') . '"';
510 if (isset($row['Key']) && $row['Key'] == 'MUL') {
511 $content_cells[$i][$ci] .= ' selected="selected"';
513 $content_cells[$i][$ci] .= '>INDEX</option>';
516 $content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . __('Fulltext') . '"';
517 if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
518 $content_cells[$i][$ci] .= ' selected="selected"';
520 $content_cells[$i][$ci] .= '>FULLTEXT</option>';
523 $content_cells[$i][$ci] .= '</select>';
525 } // end if ($action ==...)
527 // column auto_increment
528 $content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
529 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
531 if (isset($row['Extra']) && strtolower($row['Extra']) == 'auto_increment') {
532 $content_cells[$i][$ci] .= ' checked="checked"';
535 $content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
539 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
540 . ' type="text" name="field_comments[' . $i . ']" size="12"'
541 . ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ?
htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
542 . ' class="textfield" />';
546 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
547 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
548 $content_cells[$i][$ci] .= ' <option value=""> </option>';
550 if (is_array($available_mime['mimetype'])) {
551 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
552 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ?
'selected ' : '');
553 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
557 $content_cells[$i][$ci] .= '</select>';
560 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
561 $content_cells[$i][$ci] .= ' <option value="" title="' . __('None') . '"></option>';
562 if (is_array($available_mime['transformation'])) {
563 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
564 $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 ' : '');
565 $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
566 $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 . '()');
567 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
571 $content_cells[$i][$ci] .= '</select>';
574 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
575 . ' type="text" name="field_transformation_options[' . $i . ']"'
576 . ' size="16" class="textfield"'
577 . ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ?
htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
584 <script src
="./js/keyhandler.js" type
="text/javascript"></script
>
585 <script type
="text/javascript">
587 var switch_movement
= <?php
echo $display_type == 'horizontal' ?
'0' : '1'; ?
>;
588 document
.onkeydown
= onKeyDownArrowsHandler
;
592 <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"' : ''); ?
>>
594 echo PMA_generate_common_hidden_inputs($_form_params);
595 unset($_form_params);
596 if ($action == 'tbl_create.php') {
600 <th
><?php
echo __('Table name'); ?
>: 
;</th
>
602 <tr
><td
><input type
="text" name
="table" size
="40" maxlength
="80"
603 value
="<?php echo (isset($_REQUEST['table']) ? htmlspecialchars($_REQUEST['table']) : ''); ?>"
607 <?php
if ($action == 'tbl_create.php' ||
$action == 'tbl_addfield.php') { ?
>
608 <?php
echo sprintf(__('Add %s column(s)'), '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?
>
609 <input type
="submit" name
="submit_num_fields" value
="<?php echo __('Go'); ?>"
610 onclick
="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)"
620 if (is_array($content_cells) && is_array($header_cells)) {
621 // last row is for javascript insert
622 //$empty_row = array_pop($content_cells);
624 echo '<table id="table_columns">';
625 echo '<caption class="tblHeaders">' . __('Structure') . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE') . '</caption>';
627 if ($display_type == 'horizontal') {
630 <?php
foreach ($header_cells as $header_val) { ?
>
631 <th
><?php
echo $header_val; ?
></th
>
637 foreach ($content_cells as $content_row) {
638 echo '<tr class="' . ($odd_row ?
'odd' : 'even') . ' noclick">';
639 $odd_row = ! $odd_row;
641 if (is_array($content_row)) {
642 foreach ($content_row as $content_row_val) {
644 <td align
="center"><?php
echo $content_row_val; ?
></td
>
653 foreach ($header_cells as $header_val) {
654 echo '<tr class="' . ($odd_row ?
'odd' : 'even') . ' noclick">';
655 $odd_row = ! $odd_row;
657 <th
><?php
echo $header_val; ?
></th
>
659 foreach ($content_cells as $content_cell) {
660 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
662 <td
><?php
echo $content_cell[$i]; ?
></td
>
677 * needs to be finished
680 if ($display_type == 'horizontal') {
682 foreach ($empty_row as $content_row_val) {
683 $new_field .= '<td align="center">' . $content_row_val . '</td>';
686 <script type="text/javascript">
688 var odd_row = <?php echo $odd_row; ?>;
690 function addField() {
691 var new_fields = document.getElementById('added_fields').value;
692 var new_field_container = document.getElementById('table_columns');
693 var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';
695 for (i = 0; i < new_fields; i++) {
697 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
699 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
712 if ($action == 'tbl_create.php') {
716 <th
><?php
echo __('Table comments'); ?
>: 
;</th
>
717 <td width
="25"> 
;</td
>
718 <th
><?php
echo __('Storage Engine'); ?
>:
719 <?php
echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?
>
721 <td width
="25"> 
;</td
>
722 <th
><?php
echo __('Collation') ;?
>: 
;</th
>
724 <tr
><td
><input type
="text" name
="comment" size
="40" maxlength
="80"
725 value
="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
728 <td width
="25"> 
;</td
>
731 echo PMA_StorageEngine
::getHtmlSelect('tbl_type', null,
732 (isset($_REQUEST['tbl_type']) ?
$_REQUEST['tbl_type'] : null));
735 <td width
="25"> 
;</td
>
738 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION
, 'tbl_collation',
739 null, (isset($_REQUEST['tbl_collation']) ?
$_REQUEST['tbl_collation'] : null), false, 3);
744 if (PMA_Partition
::havePartitioning()) {
747 <th
><?php
echo __('PARTITION definition'); ?
>: 
;<?php
echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?
>
752 <textarea name
="partition_definition" id
="partitiondefinition"
753 cols
="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
754 rows
="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
755 dir
="<?php echo $GLOBALS['text_dir'];?>"><?php
echo (isset($_REQUEST['partition_definition']) ?
htmlspecialchars($_REQUEST['partition_definition']) : ''); ?
></textarea
>
764 } // end if ($action == 'tbl_create.php')
767 <fieldset
class="tblFooters">
768 <input type
="submit" name
="do_save_data" value
="<?php echo __('Save'); ?>" />
770 <div id
="properties_message"></div
>
773 <div id
="enum_editor">
774 <a
class="close_enum_editor"><?php
echo __('Close'); ?
></a
>
775 <h3
><?php
printf(__('Values for the column "%s"'), isset($row['Field']) ?
htmlspecialchars($row['Field']) : ""); ?
></h3
>
776 <p
><?php
echo __('Enter each value in a separate field.'); ?
></p
>
777 <div id
="values"></div
>
778 <p
><a
class="add_value"><?php
echo __('+ Add a value'); ?
></a
></p
>
779 <input type
="submit" value
="<?php echo __('Go'); ?>" /> <a
class="cancel_enum_editor"><?php
echo __('Cancel'); ?
></a
>
782 <div id
="popup_background"></div
>