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 // load additional configuration variables
31 require_once './libraries/data_mysql.inc.php';
33 if (is_int($cfg['DefaultPropDisplay'])) {
34 if ($num_fields <= $cfg['DefaultPropDisplay']) {
35 $display_type = 'vertical';
37 $display_type = 'horizontal';
40 $display_type = $cfg['DefaultPropDisplay'];
43 if ('horizontal' == $display_type) {
44 $length_values_input_size = 8;
46 $length_values_input_size = 30;
49 $_form_params = array(
53 if ($action == 'tbl_create.php') {
54 $_form_params['reload'] = 1;
55 } elseif ($action == 'tbl_addfield.php') {
56 $_form_params['field_where'] = $_REQUEST['field_where'];
57 $_form_params['after_field'] = $_REQUEST['after_field'];
58 $_form_params['table'] = $table;
60 $_form_params['table'] = $table;
63 if (isset($num_fields)) {
64 $_form_params['orig_num_fields'] = $num_fields;
67 if (isset($_REQUEST['field_where'])) {
68 $_form_params['orig_field_where'] = $_REQUEST['field_where'];
71 if (isset($_REQUEST['after_field'])) {
72 $_form_params['orig_after_field'] = $_REQUEST['after_field'];
75 if (isset($selected) && is_array($selected)) {
76 foreach ($selected as $o_fld_nr => $o_fld_val) {
77 $_form_params['selected[' . $o_fld_nr . ']'] = $o_fld_val;
78 if (! isset($true_selected)) {
79 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
83 if (isset($true_selected) && is_array($true_selected)) {
84 foreach ($true_selected as $o_fld_nr => $o_fld_val) {
85 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
88 } elseif (isset($_REQUEST['field'])) {
89 $_form_params['orig_field'] = $_REQUEST['field'];
90 if (isset($orig_field)) {
91 $_form_params['true_selected[]'] = $orig_field;
93 $_form_params['true_selected[]'] = $_REQUEST['field'];
97 $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
99 $header_cells = array();
100 $content_cells = array();
102 $header_cells[] = __('Name');
103 $header_cells[] = __('Type')
104 . ($GLOBALS['cfg']['ReplaceHelpImg']
105 ?
PMA_showMySQLDocu('SQL-Syntax', 'data-types')
106 : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'data-types')
108 $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\').'));
109 $header_cells[] = __('Default') . PMA_showHint(__('For default values, please enter just a single value, without backslash escaping or quotes, using this format: a'));
110 $header_cells[] = __('Collation');
111 $header_cells[] = __('Attributes');
112 $header_cells[] = __('Null');
114 // We could remove this 'if' and let the key information be shown and
115 // editable. However, for this to work, tbl_alter must be modified to use the
116 // key fields, as tbl_addfield does.
119 $header_cells[] = __('Index');
122 $header_cells[] = '<abbr title="AUTO_INCREMENT">' . ($display_type == 'horizontal' ?
'A_I' : 'AUTO_INCREMENT') . '</abbr>';
124 require_once './libraries/transformations.lib.php';
125 $cfgRelation = PMA_getRelationsParam();
127 $comments_map = array();
129 $available_mime = array();
131 $comments_map = PMA_getComments($db, $table);
132 $header_cells[] = __('Comments');
134 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
135 $mime_map = PMA_getMIME($db, $table);
136 $available_mime = PMA_getAvailableMIMEtypes();
139 sprintf(__('For a list of available transformation options and their MIME type transformations, click on %stransformation descriptions%s'),
140 '<a href="transformation_overview.php?'
141 . PMA_generate_common_url($db, $table) . '" target="_blank">',
145 $header_cells[] = __('MIME type');
146 $header_cells[] = __('Browser transformation');
147 $header_cells[] = __('Transformation options')
148 . 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);
151 // workaround for field_fulltext, because its submitted indizes contain
152 // the index as a value, not a key. Inserted here for easier maintaineance
153 // and less code to change in existing files.
154 if (isset($field_fulltext) && is_array($field_fulltext)) {
155 foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
156 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
160 for ($i = 0; $i < $num_fields; $i++
) {
161 if (! empty($regenerate)) {
162 // An error happened with previous inputs, so we will restore the data
163 // to embed it once again in this form.
165 $row['Field'] = (isset($_REQUEST['field_name'][$i]) ?
$_REQUEST['field_name'][$i] : false);
166 $row['Type'] = (isset($_REQUEST['field_type'][$i]) ?
$_REQUEST['field_type'][$i] : false);
167 $row['Collation'] = (isset($_REQUEST['field_collation'][$i]) ?
$_REQUEST['field_collation'][$i] : '');
168 $row['Null'] = (isset($_REQUEST['field_null'][$i]) ?
$_REQUEST['field_null'][$i] : '');
170 if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i) {
172 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i) {
174 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i) {
176 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i) {
177 $row['Key'] = 'FULLTEXT';
182 // put None in the drop-down for Default, when someone adds a field
183 $row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ?
$_REQUEST['field_default_type'][$i] : 'NONE');
184 $row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ?
$_REQUEST['field_default_value'][$i] : '');
186 switch ($row['DefaultType']) {
188 $row['Default'] = null;
190 case 'USER_DEFINED' :
191 $row['Default'] = $row['DefaultValue'];
194 case 'CURRENT_TIMESTAMP' :
195 $row['Default'] = $row['DefaultType'];
199 $row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ?
$_REQUEST['field_extra'][$i] : false);
200 $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ?
'FULLTEXT' : false);
202 $submit_length = (isset($_REQUEST['field_length'][$i]) ?
$_REQUEST['field_length'][$i] : false);
203 $submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ?
$_REQUEST['field_attribute'][$i] : false);
205 $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ?
true : false);
207 if (isset($_REQUEST['field_comments'][$i])) {
208 $comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
211 if (isset($_REQUEST['field_mimetype'][$i])) {
212 $mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
215 if (isset($_REQUEST['field_transformation'][$i])) {
216 $mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i];
219 if (isset($_REQUEST['field_transformation_options'][$i])) {
220 $mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i];
223 } elseif (isset($fields_meta[$i])) {
224 $row = $fields_meta[$i];
225 switch ($row['Default']) {
227 if ($row['Null'] == 'YES') {
228 $row['DefaultType'] = 'NULL';
229 $row['DefaultValue'] = '';
230 // SHOW FULL FIELDS does not report the case when there is a DEFAULT value
231 // which is empty so we need to use the results of SHOW CREATE TABLE
232 } elseif (isset($row) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_value'])) {
233 $row['DefaultType'] = 'USER_DEFINED';
234 $row['DefaultValue'] = $row['Default'];
236 $row['DefaultType'] = 'NONE';
237 $row['DefaultValue'] = '';
240 case 'CURRENT_TIMESTAMP':
241 $row['DefaultType'] = 'CURRENT_TIMESTAMP';
242 $row['DefaultValue'] = '';
245 $row['DefaultType'] = 'USER_DEFINED';
246 $row['DefaultValue'] = $row['Default'];
251 if (isset($row['Type'])) {
252 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
253 if ($extracted_fieldspec['type'] == 'bit') {
254 $row['Default'] = PMA_convert_bit_default_value($row['Default']);
257 // Cell index: If certain fields get left out, the counter shouldn't change.
259 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
260 // has to be incremented ($ci_offset++)
265 if (! empty($true_selected[$i])) {
266 $_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
267 } elseif (isset($row['Field'])) {
268 $_form_params['field_orig[' . $i . ']'] = $row['Field'];
270 $_form_params['field_orig[' . $i . ']'] = '';
275 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
276 . ' type="text" name="field_name[' . $i . ']"'
277 . ' maxlength="64" class="textfield" title="' . __('Column') . '"'
278 . ' size="' . ($GLOBALS['cfg']['DefaultPropDisplay'] == 'horizontal' ?
'10' : '30') . '"'
279 . ' value="' . (isset($row['Field']) ?
htmlspecialchars($row['Field']) : '') . '"'
284 $select_id = 'field_' . $i . '_' . ($ci - $ci_offset);
285 $content_cells[$i][$ci] = '<select class="column_type" name="field_type[' . $i . ']"'
286 .' id="' . $select_id . '">';
288 if (empty($row['Type'])) {
293 $type = $row['Type'];
296 if (! empty($row['Type'])) {
297 $type = $extracted_fieldspec['type'];
298 if ('set' == $extracted_fieldspec['type'] ||
'enum' == $extracted_fieldspec['type']) {
299 $length = $extracted_fieldspec['spec_in_brackets'];
301 $type = $extracted_fieldspec['print_type'];
302 $length = $extracted_fieldspec['spec_in_brackets'];
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');
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 $content_cells[$i][$ci] .= PMA_getSupportedDatatypes(true, $type_upper);
326 $content_cells[$i][$ci] .= ' </select>';
331 $_form_params['field_length_orig[' . $i . ']'] = $length;
335 $length_to_display = $length;
337 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
338 . ' type="text" name="field_length[' . $i . ']" size="' . $length_values_input_size . '"'
339 . ' value="' . htmlspecialchars($length_to_display) . '"'
340 . ' class="textfield" />'
341 . '<p class="enum_notice" id="enum_notice_' . $i . '_' . ($ci - $ci_offset) . '">';
342 $content_cells[$i][$ci] .= __('ENUM or SET data too long?')
343 . '<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"> '
344 . __('Get more editing space') . '</a></p>';
349 * having NULL enabled does not implicit having Default with NULL
352 && ! isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
353 $row['Default'] = 'NULL';
357 // old column default
359 $_form_params['field_default_orig[' . $i . ']'] =
360 (isset($row['Default']) ?
$row['Default'] : '');
363 // here we put 'NONE' as the default value of drop-down; otherwise
364 // users would have problems if they forget to enter the default
365 // value (example, for an INT)
366 $default_options = array(
367 'NONE' => _pgettext('for default', 'None'),
368 'USER_DEFINED' => __('As defined:'),
370 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
373 // for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value
374 if ($type_upper == 'TIMESTAMP'
375 && ! empty($default_current_timestamp)
376 && isset($row['Default'])) {
377 $row['Default'] = '';
380 if ($type_upper == 'BIT') {
381 $row['DefaultValue'] = PMA_convert_bit_default_value($row['DefaultValue']);
384 $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">';
385 foreach ($default_options as $key => $value) {
386 $content_cells[$i][$ci] .= '<option value="' . $key . '"';
387 // is only set when we go back to edit a field's structure
388 if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
389 $content_cells[$i][$ci] .= ' selected="selected"';
391 $content_cells[$i][$ci] .= ' >' . $value . '</option>';
393 $content_cells[$i][$ci] .= '</select>';
394 $content_cells[$i][$ci] .= '<br />';
395 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
396 . ' type="text" name="field_default_value[' . $i . ']" size="12"'
397 . ' value="' . (isset($row['DefaultValue']) ?
htmlspecialchars($row['DefaultValue']) : '') . '"'
398 . ' class="textfield" />';
402 $tmp_collation = empty($row['Collation']) ?
null : $row['Collation'];
403 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
404 PMA_CSDROPDOWN_COLLATION
, 'field_collation[' . $i . ']',
405 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
406 unset($tmp_collation);
410 $content_cells[$i][$ci] = '<select style="font-size: 70%;"'
411 . ' name="field_attribute[' . $i . ']"'
412 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
415 if (isset($extracted_fieldspec)) {
416 $attribute = $extracted_fieldspec['attribute'];
419 if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
420 $attribute = 'on update CURRENT_TIMESTAMP';
423 if (isset($submit_attribute) && $submit_attribute != false) {
424 $attribute = $submit_attribute;
427 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
428 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
430 if (PMA_MYSQL_INT_VERSION
< 50025
431 && isset($row['Field'])
432 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
433 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
434 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
438 // MySQL 4.1.2+ TIMESTAMP options
439 // (if on_update_current_timestamp is set, then it's TRUE)
440 if (isset($row['Field'])
441 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
442 $attribute = 'on update CURRENT_TIMESTAMP';
444 if ((isset($row['Field'])
445 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
446 ||
(isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
447 $default_current_timestamp = true;
449 $default_current_timestamp = false;
452 $cnt_attribute_types = count($cfg['AttributeTypes']);
453 for ($j = 0; $j < $cnt_attribute_types; $j++
) {
454 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
455 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
456 $content_cells[$i][$ci] .= ' selected="selected"';
458 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
461 $content_cells[$i][$ci] .= '</select>';
465 $content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
466 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
468 if (! empty($row['Null']) && $row['Null'] != 'NO' && $row['Null'] != 'NOT NULL') {
469 $content_cells[$i][$ci] .= ' checked="checked"';
472 $content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
476 // See my other comment about removing this 'if'.
478 $content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
479 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
480 $content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
482 $content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . __('Primary') . '"';
483 if (isset($row['Key']) && $row['Key'] == 'PRI') {
484 $content_cells[$i][$ci] .= ' selected="selected"';
486 $content_cells[$i][$ci] .= '>PRIMARY</option>';
488 $content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . __('Unique') . '"';
489 if (isset($row['Key']) && $row['Key'] == 'UNI') {
490 $content_cells[$i][$ci] .= ' selected="selected"';
492 $content_cells[$i][$ci] .= '>UNIQUE</option>';
494 $content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . __('Index') . '"';
495 if (isset($row['Key']) && $row['Key'] == 'MUL') {
496 $content_cells[$i][$ci] .= ' selected="selected"';
498 $content_cells[$i][$ci] .= '>INDEX</option>';
500 $content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . __('Fulltext') . '"';
501 if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
502 $content_cells[$i][$ci] .= ' selected="selected"';
504 $content_cells[$i][$ci] .= '>FULLTEXT</option>';
506 $content_cells[$i][$ci] .= '</select>';
508 } // end if ($action ==...)
510 // column auto_increment
511 $content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
512 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
514 if (isset($row['Extra']) && strtolower($row['Extra']) == 'auto_increment') {
515 $content_cells[$i][$ci] .= ' checked="checked"';
518 $content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
522 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
523 . ' type="text" name="field_comments[' . $i . ']" size="12"'
524 . ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ?
htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
525 . ' class="textfield" />';
529 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
530 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
531 $content_cells[$i][$ci] .= ' <option value=""> </option>';
533 if (is_array($available_mime['mimetype'])) {
534 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
535 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ?
'selected ' : '');
536 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
540 $content_cells[$i][$ci] .= '</select>';
543 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
544 $content_cells[$i][$ci] .= ' <option value="" title="' . __('None') . '"></option>';
545 if (is_array($available_mime['transformation'])) {
546 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
547 $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 ' : '');
548 $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
549 $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 . '()');
550 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
554 $content_cells[$i][$ci] .= '</select>';
557 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
558 . ' type="text" name="field_transformation_options[' . $i . ']"'
559 . ' size="16" class="textfield"'
560 . ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ?
htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
567 <script src
="./js/keyhandler.js" type
="text/javascript"></script
>
568 <script type
="text/javascript">
570 var switch_movement
= <?php
echo $display_type == 'horizontal' ?
'0' : '1'; ?
>;
571 document
.onkeydown
= onKeyDownArrowsHandler
;
575 <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"' : ''); ?
>>
577 echo PMA_generate_common_hidden_inputs($_form_params);
578 unset($_form_params);
579 if ($action == 'tbl_create.php') {
583 <th
><?php
echo __('Table name'); ?
>: 
;</th
>
585 <tr
><td
><input type
="text" name
="table" size
="40" maxlength
="80"
586 value
="<?php echo (isset($_REQUEST['table']) ? htmlspecialchars($_REQUEST['table']) : ''); ?>"
590 <?php
if ($action == 'tbl_create.php' ||
$action == 'tbl_addfield.php') { ?
>
591 <?php
echo sprintf(__('Add %s column(s)'), '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?
>
592 <input type
="submit" name
="submit_num_fields" value
="<?php echo __('Go'); ?>"
593 onclick
="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)"
603 if (is_array($content_cells) && is_array($header_cells)) {
604 // last row is for javascript insert
605 //$empty_row = array_pop($content_cells);
607 echo '<table id="table_columns" class="noclick">';
608 echo '<caption class="tblHeaders">' . __('Structure') . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE') . '</caption>';
610 if ($display_type == 'horizontal') {
613 <?php
foreach ($header_cells as $header_val) { ?
>
614 <th
><?php
echo $header_val; ?
></th
>
620 foreach ($content_cells as $content_row) {
621 echo '<tr class="' . ($odd_row ?
'odd' : 'even') . '">';
622 $odd_row = ! $odd_row;
624 if (is_array($content_row)) {
625 foreach ($content_row as $content_row_val) {
627 <td align
="center"><?php
echo $content_row_val; ?
></td
>
636 foreach ($header_cells as $header_val) {
637 echo '<tr class="' . ($odd_row ?
'odd' : 'even') . '">';
638 $odd_row = ! $odd_row;
640 <th
><?php
echo $header_val; ?
></th
>
642 foreach ($content_cells as $content_cell) {
643 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
645 <td
><?php
echo $content_cell[$i]; ?
></td
>
660 * needs to be finished
663 if ($display_type == 'horizontal') {
665 foreach ($empty_row as $content_row_val) {
666 $new_field .= '<td align="center">' . $content_row_val . '</td>';
669 <script type="text/javascript">
671 var odd_row = <?php echo $odd_row; ?>;
675 var new_fields = document.getElementById('added_fields').value;
676 var new_field_container = document.getElementById('table_columns');
677 var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';
679 for (i = 0; i < new_fields; i++) {
681 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
683 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
696 if ($action == 'tbl_create.php') {
700 <th
><?php
echo __('Table comments'); ?
>: 
;</th
>
701 <td width
="25"> 
;</td
>
702 <th
><?php
echo __('Storage Engine'); ?
>:
703 <?php
echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?
>
705 <td width
="25"> 
;</td
>
706 <th
><?php
echo __('Collation') ;?
>: 
;</th
>
708 <tr
><td
><input type
="text" name
="comment" size
="40" maxlength
="80"
709 value
="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
712 <td width
="25"> 
;</td
>
715 echo PMA_StorageEngine
::getHtmlSelect('tbl_type', null,
716 (isset($_REQUEST['tbl_type']) ?
$_REQUEST['tbl_type'] : null));
719 <td width
="25"> 
;</td
>
722 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION
, 'tbl_collation',
723 null, (isset($_REQUEST['tbl_collation']) ?
$_REQUEST['tbl_collation'] : null), false, 3);
728 if (PMA_Partition
::havePartitioning()) {
731 <th
><?php
echo __('PARTITION definition'); ?
>: 
;<?php
echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?
>
736 <textarea name
="partition_definition" id
="partitiondefinition"
737 cols
="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
738 rows
="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
739 dir
="<?php echo $GLOBALS['text_dir'];?>"><?php
echo (isset($_REQUEST['partition_definition']) ?
htmlspecialchars($_REQUEST['partition_definition']) : ''); ?
></textarea
>
748 } // end if ($action == 'tbl_create.php')
751 <fieldset
class="tblFooters">
752 <input type
="submit" name
="do_save_data" value
="<?php echo __('Save'); ?>" />
754 <div id
="properties_message"></div
>
757 <div id
="enum_editor">
758 <a
class="close_enum_editor"><?php
echo __('Close'); ?
></a
>
759 <h3
><?php
printf(__('Values for the column "%s"'), isset($row['Field']) ?
htmlspecialchars($row['Field']) : ""); ?
></h3
>
760 <p
><?php
echo __('Enter each value in a separate field.'); ?
></p
>
761 <div id
="values"></div
>
762 <p
><a
class="add_value"><?php
echo __('+ Add a value'); ?
></a
></p
>
763 <input type
="submit" value
="<?php echo __('Go'); ?>" /> <a
class="cancel_enum_editor"><?php
echo __('Cancel'); ?
></a
>
766 <div id
="popup_background"></div
>