Revert initial commit
[phpmyadmin/blinky.git] / libraries / tbl_properties.inc.php
blob7cce0977f90f458c46d238a58bed9a98b20b10ac
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 * @version $Id$
8 * @package phpMyAdmin
9 */
10 if (! defined('PHPMYADMIN')) {
11 exit;
14 /**
15 * Check parameters
17 require_once './libraries/common.inc.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 if (is_int($cfg['DefaultPropDisplay'])) {
31 if ($num_fields <= $cfg['DefaultPropDisplay']) {
32 $display_type = 'vertical';
33 } else {
34 $display_type = 'horizontal';
36 } else {
37 $display_type = $cfg['DefaultPropDisplay'];
40 if ('horizontal' == $display_type) {
41 $length_values_input_size = 8;
42 } else {
43 $length_values_input_size = 30;
46 $_form_params = array(
47 'db' => $db,
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;
56 } else {
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;
89 } else {
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[] = __('Field');
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')
104 . '</span>');
105 $header_cells[] = __('Length/Values') . PMA_showHint(__('If field 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.
115 if (!$is_backup) {
116 $header_cells[] = __('Index');
119 $header_cells[] = '<abbr title="AUTO_INCREMENT">' . ($display_type == 'horizontal' ? 'A_I' : 'AUTO_INCREMENT') . '</abbr>';
121 require_once './libraries/relation.lib.php';
122 require_once './libraries/transformations.lib.php';
123 $cfgRelation = PMA_getRelationsParam();
125 $comments_map = array();
126 $mime_map = array();
127 $available_mime = array();
129 $comments_map = PMA_getComments($db, $table);
130 $header_cells[] = __('Comments');
132 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
133 $mime_map = PMA_getMIME($db, $table);
134 $available_mime = PMA_getAvailableMIMEtypes();
136 $hint = '<br />' .
137 sprintf(__('For a list of available transformation options and their MIME type transformations, click on %stransformation descriptions%s'),
138 '<a href="transformation_overview.php?'
139 . PMA_generate_common_url($db, $table) . '" target="_blank">',
140 '</a>');
143 $header_cells[] = __('MIME type');
144 $header_cells[] = __('Browser transformation');
145 $header_cells[] = __('Transformation options')
146 . 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);
149 // workaround for field_fulltext, because its submitted indizes contain
150 // the index as a value, not a key. Inserted here for easier maintaineance
151 // and less code to change in existing files.
152 if (isset($field_fulltext) && is_array($field_fulltext)) {
153 foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
154 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
158 for ($i = 0; $i < $num_fields; $i++) {
159 if (! empty($regenerate)) {
160 // An error happened with previous inputs, so we will restore the data
161 // to embed it once again in this form.
163 $row['Field'] = (isset($_REQUEST['field_name'][$i]) ? $_REQUEST['field_name'][$i] : false);
164 $row['Type'] = (isset($_REQUEST['field_type'][$i]) ? $_REQUEST['field_type'][$i] : false);
165 $row['Collation'] = (isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '');
166 $row['Null'] = (isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : '');
168 if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i) {
169 $row['Key'] = 'PRI';
170 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i) {
171 $row['Key'] = 'MUL';
172 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i) {
173 $row['Key'] = 'UNI';
174 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i) {
175 $row['Key'] = 'FULLTEXT';
176 } else {
177 $row['Key'] = '';
180 // put None in the drop-down for Default, when someone adds a field
181 $row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ? $_REQUEST['field_default_type'][$i] : 'NONE');
182 $row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ? $_REQUEST['field_default_value'][$i] : '');
184 switch ($row['DefaultType']) {
185 case 'NONE' :
186 $row['Default'] = null;
187 break;
188 case 'USER_DEFINED' :
189 $row['Default'] = $row['DefaultValue'];
190 break;
191 case 'NULL' :
192 case 'CURRENT_TIMESTAMP' :
193 $row['Default'] = $row['DefaultType'];
194 break;
197 $row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false);
198 $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : false);
200 $submit_length = (isset($_REQUEST['field_length'][$i]) ? $_REQUEST['field_length'][$i] : false);
201 $submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ? $_REQUEST['field_attribute'][$i] : false);
203 $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ? true : false);
205 if (isset($_REQUEST['field_comments'][$i])) {
206 $comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
209 if (isset($_REQUEST['field_mimetype'][$i])) {
210 $mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
213 if (isset($_REQUEST['field_transformation'][$i])) {
214 $mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i];
217 if (isset($_REQUEST['field_transformation_options'][$i])) {
218 $mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i];
221 } elseif (isset($fields_meta[$i])) {
222 $row = $fields_meta[$i];
223 switch ($row['Default']) {
224 case null:
225 if ($row['Null'] == 'YES') {
226 $row['DefaultType'] = 'NULL';
227 $row['DefaultValue'] = '';
228 // SHOW FULL FIELDS does not report the case when there is a DEFAULT value
229 // which is empty so we need to use the results of SHOW CREATE TABLE
230 } elseif (isset($row) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_value'])) {
231 $row['DefaultType'] = 'USER_DEFINED';
232 $row['DefaultValue'] = $row['Default'];
233 } else {
234 $row['DefaultType'] = 'NONE';
235 $row['DefaultValue'] = '';
237 break;
238 case 'CURRENT_TIMESTAMP':
239 $row['DefaultType'] = 'CURRENT_TIMESTAMP';
240 $row['DefaultValue'] = '';
241 break;
242 default:
243 $row['DefaultType'] = 'USER_DEFINED';
244 $row['DefaultValue'] = $row['Default'];
245 break;
249 if (isset($row['Type'])) {
250 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
251 if ($extracted_fieldspec['type'] == 'bit') {
252 $row['Default'] = PMA_convert_bit_default_value($row['Default']);
255 // Cell index: If certain fields get left out, the counter shouldn't change.
256 $ci = 0;
257 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
258 // has to be incremented ($ci_offset++)
259 $ci_offset = -1;
261 // old column name
262 if ($is_backup) {
263 if (! empty($true_selected[$i])) {
264 $_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
265 } elseif (isset($row['Field'])) {
266 $_form_params['field_orig[' . $i . ']'] = $row['Field'];
267 } else {
268 $_form_params['field_orig[' . $i . ']'] = '';
272 // column name
273 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
274 . ' type="text" name="field_name[' . $i . ']"'
275 . ' maxlength="64" class="textfield" title="' . __('Field') . '"'
276 . ' size="' . ($GLOBALS['cfg']['DefaultPropDisplay'] == 'horizontal' ? '10' : '30') . '"'
277 . ' value="' . (isset($row['Field']) ? htmlspecialchars($row['Field']) : '') . '"'
278 . ' />';
279 $ci++;
281 // column type
282 $content_cells[$i][$ci] = '<select name="field_type[' . $i . ']"'
283 .' id="field_' . $i . '_' . ($ci - $ci_offset) . '" >';
285 if (empty($row['Type'])) {
286 // creating a column
287 $row['Type'] = '';
288 $type = '';
289 } else {
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'];
297 } else {
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'];
304 } // end if else
305 } else {
306 // creating a column
307 $length = '';
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');
314 if ($tmp) {
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 foreach ($cfg['ColumnTypes'] as $col_goup => $column_type) {
327 if (is_array($column_type)) {
328 $content_cells[$i][$ci] .= '<optgroup label="' . htmlspecialchars($col_goup) . '">';
329 foreach ($column_type as $col_group_type) {
330 $content_cells[$i][$ci] .= '<option value="'. $col_group_type . '"';
331 if ($type_upper == strtoupper($col_group_type)) {
332 $content_cells[$i][$ci] .= ' selected="selected"';
334 $content_cells[$i][$ci] .= '>' . $col_group_type . '</option>';
336 $content_cells[$i][$ci] .= '</optgroup>';
337 continue;
340 $content_cells[$i][$ci] .= '<option value="'. $column_type . '"';
341 if ($type_upper == strtoupper($column_type)) {
342 $content_cells[$i][$ci] .= ' selected="selected"';
344 $content_cells[$i][$ci] .= '>' . $column_type . '</option>';
345 } // end for
347 $content_cells[$i][$ci] .= ' </select>';
348 $ci++;
350 // old column length
351 if ($is_backup) {
352 $_form_params['field_length_orig[' . $i . ']'] = $length;
355 // column length
356 if (isset($extracted_fieldspec) && ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type'])) {
357 $binary = 0;
358 $unsigned = 0;
359 $zerofill = 0;
360 } else {
361 $binary = false;
362 $unsigned = stristr($row['Type'], 'unsigned');
363 $zerofill = stristr($row['Type'], 'zerofill');
365 $length_to_display = $length;
367 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
368 . ' type="text" name="field_length[' . $i . ']" size="' . $length_values_input_size . '"'
369 . ' value="' . htmlspecialchars($length_to_display) . '"'
370 . ' class="textfield" />';
371 $ci++;
373 // column default
375 * having NULL enabled does not implicit having Default with NULL
377 if (isset($row)
378 && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
379 $row['Default'] = 'NULL';
383 // old column default
384 if ($is_backup) {
385 $_form_params['field_default_orig[' . $i . ']'] =
386 (isset($row['Default']) ? $row['Default'] : '');
389 // here we put 'NONE' as the default value of drop-down; otherwise
390 // users would have problems if they forget to enter the default
391 // value (example, for an INT)
392 $default_options = array(
393 'NONE' => _pgettext('for default', 'None'),
394 'USER_DEFINED' => __('As defined:'),
395 'NULL' => 'NULL',
396 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
399 // for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value
400 if ($type_upper == 'TIMESTAMP'
401 && ! empty($default_current_timestamp)
402 && isset($row['Default'])) {
403 $row['Default'] = '';
406 if ($type_upper == 'BIT') {
407 $row['DefaultValue'] = PMA_convert_bit_default_value($row['DefaultValue']);
410 $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">';
411 foreach ($default_options as $key => $value) {
412 $content_cells[$i][$ci] .= '<option value="' . $key . '"';
413 // is only set when we go back to edit a field's structure
414 if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
415 $content_cells[$i][$ci] .= ' selected="selected"';
417 $content_cells[$i][$ci] .= ' >' . $value . '</option>';
419 $content_cells[$i][$ci] .= '</select>';
420 $content_cells[$i][$ci] .= '<br />';
421 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
422 . ' type="text" name="field_default_value[' . $i . ']" size="12"'
423 . ' value="' . (isset($row['DefaultValue']) ? htmlspecialchars($row['DefaultValue']) : '') . '"'
424 . ' class="textfield" />';
425 $ci++;
427 // column collation
428 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
429 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
430 PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']',
431 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
432 unset($tmp_collation);
433 $ci++;
435 // column attribute
436 $content_cells[$i][$ci] = '<select style="font-size: 70%;"'
437 . ' name="field_attribute[' . $i . ']"'
438 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
440 $attribute = '';
441 if ($binary) {
442 $attribute = 'BINARY';
444 if ($unsigned) {
445 $attribute = 'UNSIGNED';
447 if ($zerofill) {
448 $attribute = 'UNSIGNED ZEROFILL';
450 if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
451 $attribute = 'on update CURRENT_TIMESTAMP';
454 if (isset($submit_attribute) && $submit_attribute != false) {
455 $attribute = $submit_attribute;
458 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
459 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
460 // the latter.
461 if (PMA_MYSQL_INT_VERSION < 50025
462 && isset($row['Field'])
463 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
464 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
465 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
466 $row['Null'] = '';
469 // MySQL 4.1.2+ TIMESTAMP options
470 // (if on_update_current_timestamp is set, then it's TRUE)
471 if (isset($row['Field'])
472 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
473 $attribute = 'on update CURRENT_TIMESTAMP';
475 if ((isset($row['Field'])
476 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
477 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
478 $default_current_timestamp = true;
479 } else {
480 $default_current_timestamp = false;
483 $cnt_attribute_types = count($cfg['AttributeTypes']);
484 for ($j = 0; $j < $cnt_attribute_types; $j++) {
485 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
486 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
487 $content_cells[$i][$ci] .= ' selected="selected"';
489 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
492 $content_cells[$i][$ci] .= '</select>';
493 $ci++;
495 // column NULL
496 $content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
497 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
499 if (! empty($row['Null']) && $row['Null'] != 'NO' && $row['Null'] != 'NOT NULL') {
500 $content_cells[$i][$ci] .= ' checked="checked"';
503 $content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
504 $ci++;
506 // column indexes
507 // See my other comment about removing this 'if'.
508 if (!$is_backup) {
509 $content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
510 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
511 $content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
513 $content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . __('Primary') . '"';
514 if (isset($row['Key']) && $row['Key'] == 'PRI') {
515 $content_cells[$i][$ci] .= ' selected="selected"';
517 $content_cells[$i][$ci] .= '>PRIMARY</option>';
519 $content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . __('Unique') . '"';
520 if (isset($row['Key']) && $row['Key'] == 'UNI') {
521 $content_cells[$i][$ci] .= ' selected="selected"';
523 $content_cells[$i][$ci] .= '>UNIQUE</option>';
525 $content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . __('Index') . '"';
526 if (isset($row['Key']) && $row['Key'] == 'MUL') {
527 $content_cells[$i][$ci] .= ' selected="selected"';
529 $content_cells[$i][$ci] .= '>INDEX</option>';
531 $content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . __('Fulltext') . '"';
532 if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
533 $content_cells[$i][$ci] .= ' selected="selected"';
535 $content_cells[$i][$ci] .= '>FULLTEXT</option>';
537 $content_cells[$i][$ci] .= '</select>';
538 $ci++;
539 } // end if ($action ==...)
541 // column auto_increment
542 $content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
543 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
545 if (isset($row['Extra']) && strtolower($row['Extra']) == 'auto_increment') {
546 $content_cells[$i][$ci] .= ' checked="checked"';
549 $content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
550 $ci++;
552 // column comments
553 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
554 . ' type="text" name="field_comments[' . $i . ']" size="12"'
555 . ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
556 . ' class="textfield" />';
557 $ci++;
559 // column MIME-types
560 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
561 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
562 $content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>';
564 if (is_array($available_mime['mimetype'])) {
565 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
566 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
567 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
571 $content_cells[$i][$ci] .= '</select>';
572 $ci++;
574 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
575 $content_cells[$i][$ci] .= ' <option value="" title="' . __('None') . '"></option>';
576 if (is_array($available_mime['transformation'])) {
577 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
578 $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 ' : '');
579 $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
580 $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 . '()');
581 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
585 $content_cells[$i][$ci] .= '</select>';
586 $ci++;
588 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
589 . ' type="text" name="field_transformation_options[' . $i . ']"'
590 . ' size="16" class="textfield"'
591 . ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
592 . ' />';
593 //$ci++;
595 } // end for
597 if ($cfg['CtrlArrowsMoving']) {
599 <script src="./js/keyhandler.js" type="text/javascript"></script>
600 <script type="text/javascript">
601 // <![CDATA[
602 var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
603 document.onkeydown = onKeyDownArrowsHandler;
604 // ]]>
605 </script>
606 <?php
610 <form method="post" action="<?php echo $action; ?>">
611 <?php
612 echo PMA_generate_common_hidden_inputs($_form_params);
613 unset($_form_params);
614 if ($action == 'tbl_create.php') {
616 <table>
617 <tr valign="top">
618 <th><?php echo __('Table name'); ?>:&nbsp;</th>
619 </tr>
620 <tr><td><input type="text" name="table" size="40" maxlength="80"
621 value="<?php echo (isset($_REQUEST['table']) ? htmlspecialchars($_REQUEST['table']) : ''); ?>"
622 class="textfield" />
623 </td>
624 </tr>
625 </table>
626 <?php
630 if (is_array($content_cells) && is_array($header_cells)) {
631 // last row is for javascript insert
632 //$empty_row = array_pop($content_cells);
634 echo '<table id="table_columns">';
635 if ($display_type == 'horizontal') {
637 <tr>
638 <?php foreach ($header_cells as $header_val) { ?>
639 <th><?php echo $header_val; ?></th>
640 <?php } ?>
641 </tr>
642 <?php
644 $odd_row = true;
645 foreach ($content_cells as $content_row) {
646 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
647 $odd_row = ! $odd_row;
649 if (is_array($content_row)) {
650 foreach ($content_row as $content_row_val) {
652 <td align="center"><?php echo $content_row_val; ?></td>
653 <?php
656 echo '</tr>';
658 } else {
659 $i = 0;
660 $odd_row = true;
661 foreach ($header_cells as $header_val) {
662 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
663 $odd_row = ! $odd_row;
665 <th><?php echo $header_val; ?></th>
666 <?php
667 foreach ($content_cells as $content_cell) {
668 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
670 <td><?php echo $content_cell[$i]; ?></td>
671 <?php
674 echo '</tr>';
675 $i++;
679 </table>
680 <br />
681 <?php
685 * needs to be finished
688 if ($display_type == 'horizontal') {
689 $new_field = '';
690 foreach ($empty_row as $content_row_val) {
691 $new_field .= '<td align="center">' . $content_row_val . '</td>';
694 <script type="text/javascript">
695 // <![CDATA[
696 var odd_row = <?php echo $odd_row; ?>;
698 function addField() {
699 var new_fields = document.getElementById('added_fields').value;
700 var new_field_container = document.getElementById('table_columns');
701 var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';
702 var i = 0;
703 for (i = 0; i < new_fields; i++) {
704 if (odd_row) {
705 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
706 } else {
707 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
709 odd_row = ! odd_row;
712 return true;
714 // ]]>
715 </script>
716 <?php
720 if ($action == 'tbl_create.php') {
722 <table>
723 <tr valign="top">
724 <th><?php echo __('Table comments'); ?>:&nbsp;</th>
725 <td width="25">&nbsp;</td>
726 <th><?php echo __('Storage Engine'); ?>:
727 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
728 </th>
729 <td width="25">&nbsp;</td>
730 <th><?php echo __('Collation') ;?>:&nbsp;</th>
731 </tr>
732 <tr><td><input type="text" name="comment" size="40" maxlength="80"
733 value="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
734 class="textfield" />
735 </td>
736 <td width="25">&nbsp;</td>
737 <td>
738 <?php
739 echo PMA_StorageEngine::getHtmlSelect('tbl_type', null,
740 (isset($_REQUEST['tbl_type']) ? $_REQUEST['tbl_type'] : null));
742 </td>
743 <td width="25">&nbsp;</td>
744 <td>
745 <?php
746 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation',
747 null, (isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null), false, 3);
749 </td>
750 </tr>
751 <?php
752 if (PMA_Partition::havePartitioning()) {
754 <tr valign="top">
755 <th><?php echo __('PARTITION definition'); ?>:&nbsp;<?php echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?>
756 </th>
757 </tr>
758 <tr>
759 <td>
760 <textarea name="partition_definition" id="partitiondefinition"
761 cols="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
762 rows="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
763 dir="<?php echo $GLOBALS['text_dir'];?>"><?php echo (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : ''); ?></textarea>
764 </td>
765 </tr>
766 <?php
769 </table>
770 <br />
771 <?php
772 } // end if ($action == 'tbl_create.php')
775 <fieldset class="tblFooters">
776 <input type="submit" name="do_save_data" value="<?php echo __('Save'); ?>"
777 onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
778 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
779 <?php echo __('Or'); ?>
780 <?php echo sprintf(__('Add %s field(s)'), '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
781 <input type="submit" name="submit_num_fields"
782 value="<?php echo __('Go'); ?>"
783 <?php /* onclick="if (addField()) return false;" */ ?>
784 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one field.')); ?>', 1)"
786 <?php } ?>
787 </fieldset>
789 </form>
791 <center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>