patch #2709040 [doc] Wrong link in ChangeLog formatter
[phpmyadmin/crack.git] / libraries / tbl_properties.inc.php
blobd99470ab31dfbe35e84b333643ce6db346e9df2e
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 } else {
226 $row['DefaultType'] = 'NONE';
228 $row['DefaultValue'] = '';
229 break;
230 case 'CURRENT_TIMESTAMP':
231 $row['DefaultType'] = 'CURRENT_TIMESTAMP';
232 $row['DefaultValue'] = '';
233 break;
234 default:
235 $row['DefaultType'] = 'USER_DEFINED';
236 $row['DefaultValue'] = $row['Default'];
237 break;
241 if (isset($row['Type'])) {
242 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
243 if ($extracted_fieldspec['type'] == 'bit') {
244 $row['Default'] = PMA_printable_bit_value($row['Default'], $extracted_fieldspec['spec_in_brackets']);
247 // Cell index: If certain fields get left out, the counter shouldn't change.
248 $ci = 0;
249 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
250 // has to be incremented ($ci_offset++)
251 $ci_offset = -1;
253 // old column name
254 if ($is_backup) {
255 if (! empty($true_selected[$i])) {
256 $_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
257 } elseif (isset($row['Field'])) {
258 $_form_params['field_orig[' . $i . ']'] = $row['Field'];
259 } else {
260 $_form_params['field_orig[' . $i . ']'] = '';
264 // column name
265 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
266 . ' type="text" name="field_name[' . $i . ']"'
267 . ' maxlength="64" class="textfield" title="' . $strField . '"'
268 . ' size="' . ($GLOBALS['cfg']['DefaultPropDisplay'] == 'horizontal' ? '10' : '30') . '"'
269 . ' value="' . (isset($row['Field']) ? htmlspecialchars($row['Field']) : '') . '"'
270 . ' />';
271 $ci++;
273 // column type
274 $content_cells[$i][$ci] = '<select name="field_type[' . $i . ']"'
275 .' id="field_' . $i . '_' . ($ci - $ci_offset) . '" >';
277 if (empty($row['Type'])) {
278 // creating a column
279 $row['Type'] = '';
280 $type = '';
281 } else {
282 $type = $row['Type'];
285 if (! empty($row['Type'])) {
286 $type = $extracted_fieldspec['type'];
287 if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
288 $length = $extracted_fieldspec['spec_in_brackets'];
289 } else {
290 // strip the "BINARY" attribute, except if we find "BINARY(" because
291 // this would be a BINARY or VARBINARY field type
292 $type = preg_replace('@BINARY([^\(])@i', '', $type);
293 $type = preg_replace('@ZEROFILL@i', '', $type);
294 $type = preg_replace('@UNSIGNED@i', '', $type);
295 $length = $extracted_fieldspec['spec_in_brackets'];
296 } // end if else
297 } else {
298 // creating a column
299 $length = '';
302 // some types, for example longtext, are reported as
303 // "longtext character set latin7" when their charset and / or collation
304 // differs from the ones of the corresponding database.
305 $tmp = strpos($type, 'character set');
306 if ($tmp) {
307 $type = substr($type, 0, $tmp - 1);
310 if (isset($submit_length) && $submit_length != false) {
311 $length = $submit_length;
314 // rtrim the type, for cases like "float unsigned"
315 $type = rtrim($type);
316 $type_upper = strtoupper($type);
318 foreach ($cfg['ColumnTypes'] as $col_goup => $column_type) {
319 if (is_array($column_type)) {
320 $content_cells[$i][$ci] .= '<optgroup label="' . htmlspecialchars($col_goup) . '">';
321 foreach ($column_type as $col_group_type) {
322 $content_cells[$i][$ci] .= '<option value="'. $col_group_type . '"';
323 if ($type_upper == strtoupper($col_group_type)) {
324 $content_cells[$i][$ci] .= ' selected="selected"';
326 $content_cells[$i][$ci] .= '>' . $col_group_type . '</option>';
328 $content_cells[$i][$ci] .= '</optgroup>';
329 continue;
332 $content_cells[$i][$ci] .= '<option value="'. $column_type . '"';
333 if ($type_upper == strtoupper($column_type)) {
334 $content_cells[$i][$ci] .= ' selected="selected"';
336 $content_cells[$i][$ci] .= '>' . $column_type . '</option>';
337 } // end for
339 $content_cells[$i][$ci] .= ' </select>';
340 $ci++;
342 // old column length
343 if ($is_backup) {
344 $_form_params['field_length_orig[' . $i . ']'] = $length;
347 // column length
348 if (isset($extracted_fieldspec) && ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type'])) {
349 $binary = 0;
350 $unsigned = 0;
351 $zerofill = 0;
352 $length_to_display = htmlspecialchars($length);
353 } else {
354 $length_to_display = $length;
355 $binary = false;
356 $unsigned = stristr($row['Type'], 'unsigned');
357 $zerofill = stristr($row['Type'], 'zerofill');
360 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
361 . ' type="text" name="field_length[' . $i . ']" size="' . $length_values_input_size . '"'
362 . ' value="' . htmlspecialchars($length_to_display) . '"'
363 . ' class="textfield" />';
364 $ci++;
366 // column default
368 * having NULL enabled does not implicit having Default with NULL
370 if (isset($row)
371 && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
372 $row['Default'] = 'NULL';
376 // old column default
377 if ($is_backup) {
378 $_form_params['field_default_orig[' . $i . ']'] =
379 (isset($row['Default']) ? $row['Default'] : '');
382 // here we put 'NONE' as the default value of drop-down; otherwise
383 // users would have problems if they forget to enter the default
384 // value (example, for an INT)
385 $default_options = array(
386 'NONE' => $strNoneDefault,
387 'USER_DEFINED' => $strAsDefined,
388 'NULL' => 'NULL',
389 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
392 // for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
393 if ($type_upper == 'TIMESTAMP'
394 && $default_current_timestamp
395 && isset($row['Default'])) {
396 $row['Default'] = '';
399 $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">';
400 foreach ($default_options as $key => $value) {
401 $content_cells[$i][$ci] .= '<option value="' . $key . '"';
402 // is only set when we go back to edit a field's structure
403 if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
404 $content_cells[$i][$ci] .= ' selected="selected"';
406 $content_cells[$i][$ci] .= ' >' . $value . '</option>';
408 $content_cells[$i][$ci] .= '</select>';
409 $content_cells[$i][$ci] .= '<br />';
410 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
411 . ' type="text" name="field_default_value[' . $i . ']" size="12"'
412 . ' value="' . (isset($row['DefaultValue']) ? htmlspecialchars($row['DefaultValue']) : '') . '"'
413 . ' class="textfield" />';
414 $ci++;
416 // column collation
417 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
418 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
419 PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']',
420 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
421 unset($tmp_collation);
422 $ci++;
424 // column attribute
425 $content_cells[$i][$ci] = '<select style="font-size: 70%;"'
426 . ' name="field_attribute[' . $i . ']"'
427 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
429 $attribute = '';
430 if ($binary) {
431 $attribute = 'BINARY';
433 if ($unsigned) {
434 $attribute = 'UNSIGNED';
436 if ($zerofill) {
437 $attribute = 'UNSIGNED ZEROFILL';
439 if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
440 $attribute = 'on update CURRENT_TIMESTAMP';
443 if (isset($submit_attribute) && $submit_attribute != false) {
444 $attribute = $submit_attribute;
447 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
448 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
449 // the latter.
450 if (PMA_MYSQL_INT_VERSION < 50025
451 && isset($row['Field'])
452 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
453 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
454 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
455 $row['Null'] = '';
458 // MySQL 4.1.2+ TIMESTAMP options
459 // (if on_update_current_timestamp is set, then it's TRUE)
460 if (isset($row['Field'])
461 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
462 $attribute = 'on update CURRENT_TIMESTAMP';
464 if ((isset($row['Field'])
465 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
466 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
467 $default_current_timestamp = true;
468 } else {
469 $default_current_timestamp = false;
472 $cnt_attribute_types = count($cfg['AttributeTypes']);
473 for ($j = 0; $j < $cnt_attribute_types; $j++) {
474 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
475 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
476 $content_cells[$i][$ci] .= ' selected="selected"';
478 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
481 $content_cells[$i][$ci] .= '</select>';
482 $ci++;
484 // column NULL
485 $content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
486 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
488 if (! empty($row['Null']) && $row['Null'] != 'NO' && $row['Null'] != 'NOT NULL') {
489 $content_cells[$i][$ci] .= ' checked="checked"';
492 $content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
493 $ci++;
495 // column indexes
496 // lem9: See my other comment about removing this 'if'.
497 if (!$is_backup) {
498 $content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
499 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
500 $content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
502 $content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . $strPrimary . '"';
503 if (isset($row['Key']) && $row['Key'] == 'PRI') {
504 $content_cells[$i][$ci] .= ' selected="selected"';
506 $content_cells[$i][$ci] .= '>PRIMARY</option>';
508 $content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . $strUnique . '"';
509 if (isset($row['Key']) && $row['Key'] == 'UNI') {
510 $content_cells[$i][$ci] .= ' selected="selected"';
512 $content_cells[$i][$ci] .= '>UNIQUE</option>';
514 $content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . $strIndex . '"';
515 if (isset($row['Key']) && $row['Key'] == 'MUL') {
516 $content_cells[$i][$ci] .= ' selected="selected"';
518 $content_cells[$i][$ci] .= '>INDEX</option>';
520 $content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . $strIdxFulltext . '"';
521 if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
522 $content_cells[$i][$ci] .= ' selected="selected"';
524 $content_cells[$i][$ci] .= '>FULLTEXT</option>';
526 $content_cells[$i][$ci] .= '</select>';
527 $ci++;
528 } // end if ($action ==...)
530 // column auto_increment
531 $content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
532 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
534 if (isset($row['Extra']) && strtolower($row['Extra']) == 'auto_increment') {
535 $content_cells[$i][$ci] .= ' checked="checked"';
538 $content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
539 $ci++;
541 // column comments
542 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
543 . ' type="text" name="field_comments[' . $i . ']" size="12"'
544 . ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
545 . ' class="textfield" />';
546 $ci++;
548 // column MIME-types
549 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
550 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
551 $content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>';
553 if (is_array($available_mime['mimetype'])) {
554 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
555 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
556 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
560 $content_cells[$i][$ci] .= '</select>';
561 $ci++;
563 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
564 $content_cells[$i][$ci] .= ' <option value="" title="' . $strNone . '"></option>';
565 if (is_array($available_mime['transformation'])) {
566 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
567 $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 ' : '');
568 $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
569 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()');
570 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
574 $content_cells[$i][$ci] .= '</select>';
575 $ci++;
577 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
578 . ' type="text" name="field_transformation_options[' . $i . ']"'
579 . ' size="16" class="textfield"'
580 . ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
581 . ' />';
582 //$ci++;
584 } // end for
586 if ($cfg['CtrlArrowsMoving']) {
588 <script src="./js/keyhandler.js" type="text/javascript"></script>
589 <script type="text/javascript">
590 // <![CDATA[
591 var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
592 document.onkeydown = onKeyDownArrowsHandler;
593 // ]]>
594 </script>
595 <?php
599 <form method="post" action="<?php echo $action; ?>">
600 <?php
601 echo PMA_generate_common_hidden_inputs($_form_params);
602 unset($_form_params);
604 if (is_array($content_cells) && is_array($header_cells)) {
605 // last row is for javascript insert
606 //$empty_row = array_pop($content_cells);
608 echo '<table id="table_columns">';
609 if ($display_type == 'horizontal') {
611 <tr>
612 <?php foreach ($header_cells as $header_val) { ?>
613 <th><?php echo $header_val; ?></th>
614 <?php } ?>
615 </tr>
616 <?php
618 $odd_row = true;
619 foreach ($content_cells as $content_row) {
620 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
621 $odd_row = ! $odd_row;
623 if (is_array($content_row)) {
624 foreach ($content_row as $content_row_val) {
626 <td align="center"><?php echo $content_row_val; ?></td>
627 <?php
630 echo '</tr>';
632 } else {
633 $i = 0;
634 $odd_row = true;
635 foreach ($header_cells as $header_val) {
636 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
637 $odd_row = ! $odd_row;
639 <th><?php echo $header_val; ?></th>
640 <?php
641 foreach ($content_cells as $content_cell) {
642 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
644 <td><?php echo $content_cell[$i]; ?></td>
645 <?php
648 echo '</tr>';
649 $i++;
653 </table>
654 <br />
655 <?php
659 * needs to be finished
662 if ($display_type == 'horizontal') {
663 $new_field = '';
664 foreach ($empty_row as $content_row_val) {
665 $new_field .= '<td align="center">' . $content_row_val . '</td>';
668 <script type="text/javascript">
669 // <![CDATA[
670 var odd_row = <?php echo $odd_row; ?>;
672 function addField() {
673 var new_fields = document.getElementById('added_fields').value;
674 var new_field_container = document.getElementById('table_columns');
675 var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';
676 var i = 0;
677 for (i = 0; i < new_fields; i++) {
678 if (odd_row) {
679 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
680 } else {
681 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
683 odd_row = ! odd_row;
686 return true;
688 // ]]>
689 </script>
690 <?php
694 if ($action == 'tbl_create.php') {
696 <table>
697 <tr valign="top">
698 <th><?php echo $strTableComments; ?>:&nbsp;</th>
699 <td width="25">&nbsp;</td>
700 <th><?php echo $strStorageEngine; ?>:
701 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
702 </th>
703 <td width="25">&nbsp;</td>
704 <th><?php echo $strCollation ;?>:&nbsp;</th>
705 </tr>
706 <tr><td><input type="text" name="comment" size="40" maxlength="80"
707 value="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
708 class="textfield" />
709 </td>
710 <td width="25">&nbsp;</td>
711 <td>
712 <?php
713 echo PMA_StorageEngine::getHtmlSelect('tbl_type', null,
714 (isset($_REQUEST['tbl_type']) ? $_REQUEST['tbl_type'] : null));
716 </td>
717 <td width="25">&nbsp;</td>
718 <td>
719 <?php
720 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation',
721 null, (isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null), false, 3);
723 </td>
724 </tr>
725 <?php
726 if (PMA_Partition::havePartitioning()) {
728 <tr valign="top">
729 <th><?php echo $strPartitionDefinition; ?>:&nbsp;<?php echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?>
730 </th>
731 </tr>
732 <tr>
733 <td>
734 <textarea name="partition_definition" id="partitiondefinition"
735 cols="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
736 rows="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
737 dir="<?php echo $GLOBALS['text_dir'];?>"><?php echo (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : ''); ?></textarea>
738 </td>
739 </tr>
740 <?php
743 </table>
744 <br />
745 <?php
746 } // end if ($action == 'tbl_create.php')
749 <fieldset class="tblFooters">
750 <input type="submit" name="do_save_data" value="<?php echo $strSave; ?>"
751 onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
752 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
753 <?php echo $GLOBALS['strOr']; ?>
754 <?php echo sprintf($strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
755 <input type="submit" name="submit_num_fields"
756 value="<?php echo $GLOBALS['strGo']; ?>"
757 <?php /* onclick="if (addField()) return false;" */ ?>
758 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)"
760 <?php } ?>
761 </fieldset>
763 </form>
765 <center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>