remove todo, after upgrade PHPExcel
[phpmyadmin/arisferyanto.git] / libraries / tbl_properties.inc.php
blob43b4fe027b400ad4f6b3dda9b3d85e91678c5c90
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,
48 'table' => $table,
51 if ($action == 'tbl_create.php') {
52 $_form_params['reload'] = 1;
53 } elseif ($action == 'tbl_addfield.php') {
54 $_form_params['field_where'] = $_REQUEST['field_where'];
55 $_form_params['after_field'] = $_REQUEST['after_field'];
58 if (isset($num_fields)) {
59 $_form_params['orig_num_fields'] = $num_fields;
62 if (isset($_REQUEST['field_where'])) {
63 $_form_params['orig_field_where'] = $_REQUEST['field_where'];
66 if (isset($_REQUEST['after_field'])) {
67 $_form_params['orig_after_field'] = $_REQUEST['after_field'];
70 if (isset($selected) && is_array($selected)) {
71 foreach ($selected as $o_fld_nr => $o_fld_val) {
72 $_form_params['selected[' . $o_fld_nr . ']'] = $o_fld_val;
73 if (! isset($true_selected)) {
74 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
78 if (isset($true_selected) && is_array($true_selected)) {
79 foreach ($true_selected as $o_fld_nr => $o_fld_val) {
80 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
83 } elseif (isset($_REQUEST['field'])) {
84 $_form_params['orig_field'] = $_REQUEST['field'];
85 if (isset($orig_field)) {
86 $_form_params['true_selected[]'] = $orig_field;
87 } else {
88 $_form_params['true_selected[]'] = $_REQUEST['field'];
92 $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
94 $header_cells = array();
95 $content_cells = array();
97 $header_cells[] = $strField;
98 $header_cells[] = $strType
99 . ($GLOBALS['cfg']['ReplaceHelpImg']
100 ? PMA_showMySQLDocu('SQL-Syntax', 'data-types')
101 : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'data-types')
102 . '</span>');
103 $header_cells[] = $strLengthSet . PMA_showHint($strSetEnumVal);
104 $header_cells[] = $strDefault . PMA_showHint($strDefaultValueHelp);
105 $header_cells[] = $strCollation;
106 $header_cells[] = $strAttr;
107 $header_cells[] = $strNull;
109 // lem9: We could remove this 'if' and let the key information be shown and
110 // editable. However, for this to work, tbl_alter must be modified to use the
111 // key fields, as tbl_addfield does.
113 if (!$is_backup) {
114 $header_cells[] = $strIndex;
117 $header_cells[] = '<abbr title="AUTO_INCREMENT">' . ($display_type == 'horizontal' ? 'A_I' : 'AUTO_INCREMENT') . '</abbr>';
119 require_once './libraries/relation.lib.php';
120 require_once './libraries/transformations.lib.php';
121 $cfgRelation = PMA_getRelationsParam();
123 $comments_map = array();
124 $mime_map = array();
125 $available_mime = array();
127 $comments_map = PMA_getComments($db, $table);
128 $header_cells[] = $strComments;
130 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
131 $mime_map = PMA_getMIME($db, $table);
132 $available_mime = PMA_getAvailableMIMEtypes();
134 $hint = '<br />' .
135 sprintf($strMIME_transformation_note,
136 '<a href="transformation_overview.php?'
137 . PMA_generate_common_url($db, $table) . '" target="_blank">',
138 '</a>');
141 $header_cells[] = $strMIME_MIMEtype;
142 $header_cells[] = $strMIME_transformation;
143 $header_cells[] = $strMIME_transformation_options
144 . PMA_showHint($strMIME_transformation_options_note . $hint);
147 // garvin: workaround for field_fulltext, because its submitted indizes contain
148 // the index as a value, not a key. Inserted here for easier maintaineance
149 // and less code to change in existing files.
150 if (isset($field_fulltext) && is_array($field_fulltext)) {
151 foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
152 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
156 for ($i = 0; $i < $num_fields; $i++) {
157 if (! empty($regenerate)) {
158 // An error happened with previous inputs, so we will restore the data
159 // to embed it once again in this form.
161 $row['Field'] = (isset($_REQUEST['field_name'][$i]) ? $_REQUEST['field_name'][$i] : false);
162 $row['Type'] = (isset($_REQUEST['field_type'][$i]) ? $_REQUEST['field_type'][$i] : false);
163 $row['Collation'] = (isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '');
164 $row['Null'] = (isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : '');
166 if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i) {
167 $row['Key'] = 'PRI';
168 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i) {
169 $row['Key'] = 'MUL';
170 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i) {
171 $row['Key'] = 'UNI';
172 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i) {
173 $row['Key'] = 'FULLTEXT';
174 } else {
175 $row['Key'] = '';
178 // put None in the drop-down for Default, when someone adds a field
179 $row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ? $_REQUEST['field_default_type'][$i] : 'NONE');
180 $row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ? $_REQUEST['field_default_value'][$i] : '');
182 switch ($row['DefaultType']) {
183 case 'NONE' :
184 $row['Default'] = null;
185 break;
186 case 'USER_DEFINED' :
187 $row['Default'] = $row['DefaultValue'];
188 break;
189 case 'NULL' :
190 case 'CURRENT_TIMESTAMP' :
191 $row['Default'] = $row['DefaultType'];
192 break;
195 $row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false);
196 $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : false);
198 $submit_length = (isset($_REQUEST['field_length'][$i]) ? $_REQUEST['field_length'][$i] : false);
199 $submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ? $_REQUEST['field_attribute'][$i] : false);
201 $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ? true : false);
203 if (isset($_REQUEST['field_comments'][$i])) {
204 $comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
207 if (isset($_REQUEST['field_mimetype'][$i])) {
208 $mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
211 if (isset($_REQUEST['field_transformation'][$i])) {
212 $mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i];
215 if (isset($_REQUEST['field_transformation_options'][$i])) {
216 $mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i];
219 } elseif (isset($fields_meta[$i])) {
220 $row = $fields_meta[$i];
221 switch ($row['Default']) {
222 case null:
223 if ($row['Null'] == 'YES') {
224 $row['DefaultType'] = 'NULL';
225 $row['DefaultValue'] = '';
226 // SHOW FULL FIELDS does not report the case when there is a DEFAULT value
227 // which is empty so we need to use the results of SHOW CREATE TABLE
228 } elseif (isset($row) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_value'])) {
229 $row['DefaultType'] = 'USER_DEFINED';
230 $row['DefaultValue'] = $row['Default'];
231 } else {
232 $row['DefaultType'] = 'NONE';
233 $row['DefaultValue'] = '';
235 break;
236 case 'CURRENT_TIMESTAMP':
237 $row['DefaultType'] = 'CURRENT_TIMESTAMP';
238 $row['DefaultValue'] = '';
239 break;
240 default:
241 $row['DefaultType'] = 'USER_DEFINED';
242 $row['DefaultValue'] = $row['Default'];
243 break;
247 if (isset($row['Type'])) {
248 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
249 if ($extracted_fieldspec['type'] == 'bit') {
250 $row['Default'] = PMA_convert_bit_default_value($row['Default']);
253 // Cell index: If certain fields get left out, the counter shouldn't change.
254 $ci = 0;
255 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
256 // has to be incremented ($ci_offset++)
257 $ci_offset = -1;
259 // old column name
260 if ($is_backup) {
261 if (! empty($true_selected[$i])) {
262 $_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
263 } elseif (isset($row['Field'])) {
264 $_form_params['field_orig[' . $i . ']'] = $row['Field'];
265 } else {
266 $_form_params['field_orig[' . $i . ']'] = '';
270 // column name
271 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
272 . ' type="text" name="field_name[' . $i . ']"'
273 . ' maxlength="64" class="textfield" title="' . $strField . '"'
274 . ' size="' . ($GLOBALS['cfg']['DefaultPropDisplay'] == 'horizontal' ? '10' : '30') . '"'
275 . ' value="' . (isset($row['Field']) ? htmlspecialchars($row['Field']) : '') . '"'
276 . ' />';
277 $ci++;
279 // column type
280 $content_cells[$i][$ci] = '<select name="field_type[' . $i . ']"'
281 .' id="field_' . $i . '_' . ($ci - $ci_offset) . '" >';
283 if (empty($row['Type'])) {
284 // creating a column
285 $row['Type'] = '';
286 $type = '';
287 } else {
288 $type = $row['Type'];
291 if (! empty($row['Type'])) {
292 $type = $extracted_fieldspec['type'];
293 if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
294 $length = $extracted_fieldspec['spec_in_brackets'];
295 } else {
296 // strip the "BINARY" attribute, except if we find "BINARY(" because
297 // this would be a BINARY or VARBINARY field type
298 $type = preg_replace('@BINARY([^\(])@i', '', $type);
299 $type = preg_replace('@ZEROFILL@i', '', $type);
300 $type = preg_replace('@UNSIGNED@i', '', $type);
301 $length = $extracted_fieldspec['spec_in_brackets'];
302 } // end if else
303 } else {
304 // creating a column
305 $length = '';
308 // some types, for example longtext, are reported as
309 // "longtext character set latin7" when their charset and / or collation
310 // differs from the ones of the corresponding database.
311 $tmp = strpos($type, 'character set');
312 if ($tmp) {
313 $type = substr($type, 0, $tmp - 1);
316 if (isset($submit_length) && $submit_length != false) {
317 $length = $submit_length;
320 // rtrim the type, for cases like "float unsigned"
321 $type = rtrim($type);
322 $type_upper = strtoupper($type);
324 foreach ($cfg['ColumnTypes'] as $col_goup => $column_type) {
325 if (is_array($column_type)) {
326 $content_cells[$i][$ci] .= '<optgroup label="' . htmlspecialchars($col_goup) . '">';
327 foreach ($column_type as $col_group_type) {
328 $content_cells[$i][$ci] .= '<option value="'. $col_group_type . '"';
329 if ($type_upper == strtoupper($col_group_type)) {
330 $content_cells[$i][$ci] .= ' selected="selected"';
332 $content_cells[$i][$ci] .= '>' . $col_group_type . '</option>';
334 $content_cells[$i][$ci] .= '</optgroup>';
335 continue;
338 $content_cells[$i][$ci] .= '<option value="'. $column_type . '"';
339 if ($type_upper == strtoupper($column_type)) {
340 $content_cells[$i][$ci] .= ' selected="selected"';
342 $content_cells[$i][$ci] .= '>' . $column_type . '</option>';
343 } // end for
345 $content_cells[$i][$ci] .= ' </select>';
346 $ci++;
348 // old column length
349 if ($is_backup) {
350 $_form_params['field_length_orig[' . $i . ']'] = $length;
353 // column length
354 if (isset($extracted_fieldspec) && ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type'])) {
355 $binary = 0;
356 $unsigned = 0;
357 $zerofill = 0;
358 } else {
359 $binary = false;
360 $unsigned = stristr($row['Type'], 'unsigned');
361 $zerofill = stristr($row['Type'], 'zerofill');
363 $length_to_display = $length;
365 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
366 . ' type="text" name="field_length[' . $i . ']" size="' . $length_values_input_size . '"'
367 . ' value="' . htmlspecialchars($length_to_display) . '"'
368 . ' class="textfield" />';
369 $ci++;
371 // column default
373 * having NULL enabled does not implicit having Default with NULL
375 if (isset($row)
376 && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
377 $row['Default'] = 'NULL';
381 // old column default
382 if ($is_backup) {
383 $_form_params['field_default_orig[' . $i . ']'] =
384 (isset($row['Default']) ? $row['Default'] : '');
387 // here we put 'NONE' as the default value of drop-down; otherwise
388 // users would have problems if they forget to enter the default
389 // value (example, for an INT)
390 $default_options = array(
391 'NONE' => $strNoneDefault,
392 'USER_DEFINED' => $strAsDefined,
393 'NULL' => 'NULL',
394 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
397 // for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value
398 if ($type_upper == 'TIMESTAMP'
399 && ! empty($default_current_timestamp)
400 && isset($row['Default'])) {
401 $row['Default'] = '';
404 if ($type_upper == 'BIT') {
405 $row['DefaultValue'] = PMA_convert_bit_default_value($row['DefaultValue']);
408 $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">';
409 foreach ($default_options as $key => $value) {
410 $content_cells[$i][$ci] .= '<option value="' . $key . '"';
411 // is only set when we go back to edit a field's structure
412 if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
413 $content_cells[$i][$ci] .= ' selected="selected"';
415 $content_cells[$i][$ci] .= ' >' . $value . '</option>';
417 $content_cells[$i][$ci] .= '</select>';
418 $content_cells[$i][$ci] .= '<br />';
419 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
420 . ' type="text" name="field_default_value[' . $i . ']" size="12"'
421 . ' value="' . (isset($row['DefaultValue']) ? htmlspecialchars($row['DefaultValue']) : '') . '"'
422 . ' class="textfield" />';
423 $ci++;
425 // column collation
426 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
427 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
428 PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']',
429 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
430 unset($tmp_collation);
431 $ci++;
433 // column attribute
434 $content_cells[$i][$ci] = '<select style="font-size: 70%;"'
435 . ' name="field_attribute[' . $i . ']"'
436 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
438 $attribute = '';
439 if ($binary) {
440 $attribute = 'BINARY';
442 if ($unsigned) {
443 $attribute = 'UNSIGNED';
445 if ($zerofill) {
446 $attribute = 'UNSIGNED ZEROFILL';
448 if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
449 $attribute = 'on update CURRENT_TIMESTAMP';
452 if (isset($submit_attribute) && $submit_attribute != false) {
453 $attribute = $submit_attribute;
456 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
457 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
458 // the latter.
459 if (PMA_MYSQL_INT_VERSION < 50025
460 && isset($row['Field'])
461 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
462 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
463 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
464 $row['Null'] = '';
467 // MySQL 4.1.2+ TIMESTAMP options
468 // (if on_update_current_timestamp is set, then it's TRUE)
469 if (isset($row['Field'])
470 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
471 $attribute = 'on update CURRENT_TIMESTAMP';
473 if ((isset($row['Field'])
474 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
475 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
476 $default_current_timestamp = true;
477 } else {
478 $default_current_timestamp = false;
481 $cnt_attribute_types = count($cfg['AttributeTypes']);
482 for ($j = 0; $j < $cnt_attribute_types; $j++) {
483 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
484 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
485 $content_cells[$i][$ci] .= ' selected="selected"';
487 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
490 $content_cells[$i][$ci] .= '</select>';
491 $ci++;
493 // column NULL
494 $content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
495 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
497 if (! empty($row['Null']) && $row['Null'] != 'NO' && $row['Null'] != 'NOT NULL') {
498 $content_cells[$i][$ci] .= ' checked="checked"';
501 $content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
502 $ci++;
504 // column indexes
505 // lem9: See my other comment about removing this 'if'.
506 if (!$is_backup) {
507 $content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
508 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
509 $content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
511 $content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . $strPrimary . '"';
512 if (isset($row['Key']) && $row['Key'] == 'PRI') {
513 $content_cells[$i][$ci] .= ' selected="selected"';
515 $content_cells[$i][$ci] .= '>PRIMARY</option>';
517 $content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . $strUnique . '"';
518 if (isset($row['Key']) && $row['Key'] == 'UNI') {
519 $content_cells[$i][$ci] .= ' selected="selected"';
521 $content_cells[$i][$ci] .= '>UNIQUE</option>';
523 $content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . $strIndex . '"';
524 if (isset($row['Key']) && $row['Key'] == 'MUL') {
525 $content_cells[$i][$ci] .= ' selected="selected"';
527 $content_cells[$i][$ci] .= '>INDEX</option>';
529 $content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . $strIdxFulltext . '"';
530 if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
531 $content_cells[$i][$ci] .= ' selected="selected"';
533 $content_cells[$i][$ci] .= '>FULLTEXT</option>';
535 $content_cells[$i][$ci] .= '</select>';
536 $ci++;
537 } // end if ($action ==...)
539 // column auto_increment
540 $content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
541 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
543 if (isset($row['Extra']) && strtolower($row['Extra']) == 'auto_increment') {
544 $content_cells[$i][$ci] .= ' checked="checked"';
547 $content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
548 $ci++;
550 // column comments
551 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
552 . ' type="text" name="field_comments[' . $i . ']" size="12"'
553 . ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
554 . ' class="textfield" />';
555 $ci++;
557 // column MIME-types
558 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
559 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
560 $content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>';
562 if (is_array($available_mime['mimetype'])) {
563 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
564 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
565 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
569 $content_cells[$i][$ci] .= '</select>';
570 $ci++;
572 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
573 $content_cells[$i][$ci] .= ' <option value="" title="' . $strNone . '"></option>';
574 if (is_array($available_mime['transformation'])) {
575 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
576 $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 ' : '');
577 $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
578 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()');
579 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
583 $content_cells[$i][$ci] .= '</select>';
584 $ci++;
586 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
587 . ' type="text" name="field_transformation_options[' . $i . ']"'
588 . ' size="16" class="textfield"'
589 . ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
590 . ' />';
591 //$ci++;
593 } // end for
595 if ($cfg['CtrlArrowsMoving']) {
597 <script src="./js/keyhandler.js" type="text/javascript"></script>
598 <script type="text/javascript">
599 // <![CDATA[
600 var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
601 document.onkeydown = onKeyDownArrowsHandler;
602 // ]]>
603 </script>
604 <?php
608 <form method="post" action="<?php echo $action; ?>">
609 <?php
610 echo PMA_generate_common_hidden_inputs($_form_params);
611 unset($_form_params);
613 if (is_array($content_cells) && is_array($header_cells)) {
614 // last row is for javascript insert
615 //$empty_row = array_pop($content_cells);
617 echo '<table id="table_columns">';
618 if ($display_type == 'horizontal') {
620 <tr>
621 <?php foreach ($header_cells as $header_val) { ?>
622 <th><?php echo $header_val; ?></th>
623 <?php } ?>
624 </tr>
625 <?php
627 $odd_row = true;
628 foreach ($content_cells as $content_row) {
629 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
630 $odd_row = ! $odd_row;
632 if (is_array($content_row)) {
633 foreach ($content_row as $content_row_val) {
635 <td align="center"><?php echo $content_row_val; ?></td>
636 <?php
639 echo '</tr>';
641 } else {
642 $i = 0;
643 $odd_row = true;
644 foreach ($header_cells as $header_val) {
645 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
646 $odd_row = ! $odd_row;
648 <th><?php echo $header_val; ?></th>
649 <?php
650 foreach ($content_cells as $content_cell) {
651 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
653 <td><?php echo $content_cell[$i]; ?></td>
654 <?php
657 echo '</tr>';
658 $i++;
662 </table>
663 <br />
664 <?php
668 * needs to be finished
671 if ($display_type == 'horizontal') {
672 $new_field = '';
673 foreach ($empty_row as $content_row_val) {
674 $new_field .= '<td align="center">' . $content_row_val . '</td>';
677 <script type="text/javascript">
678 // <![CDATA[
679 var odd_row = <?php echo $odd_row; ?>;
681 function addField() {
682 var new_fields = document.getElementById('added_fields').value;
683 var new_field_container = document.getElementById('table_columns');
684 var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';
685 var i = 0;
686 for (i = 0; i < new_fields; i++) {
687 if (odd_row) {
688 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
689 } else {
690 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
692 odd_row = ! odd_row;
695 return true;
697 // ]]>
698 </script>
699 <?php
703 if ($action == 'tbl_create.php') {
705 <table>
706 <tr valign="top">
707 <th><?php echo $strTableComments; ?>:&nbsp;</th>
708 <td width="25">&nbsp;</td>
709 <th><?php echo $strStorageEngine; ?>:
710 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
711 </th>
712 <td width="25">&nbsp;</td>
713 <th><?php echo $strCollation ;?>:&nbsp;</th>
714 </tr>
715 <tr><td><input type="text" name="comment" size="40" maxlength="80"
716 value="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
717 class="textfield" />
718 </td>
719 <td width="25">&nbsp;</td>
720 <td>
721 <?php
722 echo PMA_StorageEngine::getHtmlSelect('tbl_type', null,
723 (isset($_REQUEST['tbl_type']) ? $_REQUEST['tbl_type'] : null));
725 </td>
726 <td width="25">&nbsp;</td>
727 <td>
728 <?php
729 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation',
730 null, (isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null), false, 3);
732 </td>
733 </tr>
734 <?php
735 if (PMA_Partition::havePartitioning()) {
737 <tr valign="top">
738 <th><?php echo $strPartitionDefinition; ?>:&nbsp;<?php echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?>
739 </th>
740 </tr>
741 <tr>
742 <td>
743 <textarea name="partition_definition" id="partitiondefinition"
744 cols="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
745 rows="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
746 dir="<?php echo $GLOBALS['text_dir'];?>"><?php echo (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : ''); ?></textarea>
747 </td>
748 </tr>
749 <?php
752 </table>
753 <br />
754 <?php
755 } // end if ($action == 'tbl_create.php')
758 <fieldset class="tblFooters">
759 <input type="submit" name="do_save_data" value="<?php echo $strSave; ?>"
760 onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
761 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
762 <?php echo $GLOBALS['strOr']; ?>
763 <?php echo sprintf($strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
764 <input type="submit" name="submit_num_fields"
765 value="<?php echo $GLOBALS['strGo']; ?>"
766 <?php /* onclick="if (addField()) return false;" */ ?>
767 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)"
769 <?php } ?>
770 </fieldset>
772 </form>
774 <center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>