rfe #2127987 warn when session.gc_maxlifetime is less than cookie validity
[phpmyadmin/last10db.git] / libraries / tbl_properties.inc.php
blobff8ad78b8be2feaf77be7ff43677f79a2f3f534b
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">A_I</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 $row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ? $_REQUEST['field_default_type'][$i] : 'USER_DEFINED');
179 $row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ? $_REQUEST['field_default_value'][$i] : '');
181 switch ($row['DefaultType']) {
182 case 'NONE' :
183 $row['Default'] = null;
184 break;
185 case 'USER_DEFINED' :
186 $row['Default'] = $row['DefaultValue'];
187 break;
188 case 'NULL' :
189 case 'CURRENT_TIMESTAMP' :
190 $row['Default'] = $row['DefaultType'];
191 break;
194 $row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false);
195 $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : false);
197 $submit_length = (isset($_REQUEST['field_length'][$i]) ? $_REQUEST['field_length'][$i] : false);
198 $submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ? $_REQUEST['field_attribute'][$i] : false);
200 $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ? true : false);
202 if (isset($_REQUEST['field_comments'][$i])) {
203 $comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
206 if (isset($_REQUEST['field_mimetype'][$i])) {
207 $mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
210 if (isset($_REQUEST['field_transformation'][$i])) {
211 $mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i];
214 if (isset($_REQUEST['field_transformation_options'][$i])) {
215 $mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i];
218 } elseif (isset($fields_meta[$i])) {
219 $row = $fields_meta[$i];
220 switch ($row['Default']) {
221 case null:
222 if ($row['Null'] == 'YES') {
223 $row['DefaultType'] = 'NULL';
224 } else {
225 $row['DefaultType'] = 'NONE';
227 $row['DefaultValue'] = '';
228 break;
229 case 'CURRENT_TIMESTAMP':
230 $row['DefaultType'] = 'CURRENT_TIMESTAMP';
231 $row['DefaultValue'] = '';
232 break;
233 default:
234 $row['DefaultType'] = 'USER_DEFINED';
235 $row['DefaultValue'] = $row['Default'];
236 break;
240 if (isset($row['Type'])) {
241 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
242 if ($extracted_fieldspec['type'] == 'bit') {
243 $row['Default'] = PMA_printable_bit_value($row['Default'], $extracted_fieldspec['spec_in_brackets']);
246 // Cell index: If certain fields get left out, the counter shouldn't change.
247 $ci = 0;
248 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
249 // has to be incremented ($ci_offset++)
250 $ci_offset = -1;
252 // old column name
253 if ($is_backup) {
254 if (! empty($true_selected[$i])) {
255 $_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
256 } elseif (isset($row['Field'])) {
257 $_form_params['field_orig[' . $i . ']'] = $row['Field'];
258 } else {
259 $_form_params['field_orig[' . $i . ']'] = '';
263 // column name
264 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
265 . ' type="text" name="field_name[' . $i . ']"'
266 . ' maxlength="64" class="textfield" title="' . $strField . '"'
267 . ' size="' . ($GLOBALS['cfg']['DefaultPropDisplay'] == 'horizontal' ? '10' : '30') . '"'
268 . ' value="' . (isset($row['Field']) ? htmlspecialchars($row['Field']) : '') . '"'
269 . ' />';
270 $ci++;
272 // column type
273 $content_cells[$i][$ci] = '<select name="field_type[' . $i . ']"'
274 .' id="field_' . $i . '_' . ($ci - $ci_offset) . '" >';
276 if (empty($row['Type'])) {
277 // creating a column
278 $row['Type'] = '';
279 $type = '';
280 } else {
281 $type = $row['Type'];
284 if (! empty($row['Type'])) {
285 $type = $extracted_fieldspec['type'];
286 if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
287 $length = $extracted_fieldspec['spec_in_brackets'];
288 } else {
289 // strip the "BINARY" attribute, except if we find "BINARY(" because
290 // this would be a BINARY or VARBINARY field type
291 $type = preg_replace('@BINARY([^\(])@i', '', $type);
292 $type = preg_replace('@ZEROFILL@i', '', $type);
293 $type = preg_replace('@UNSIGNED@i', '', $type);
294 $length = $extracted_fieldspec['spec_in_brackets'];
295 } // end if else
296 } else {
297 // creating a column
298 $length = '';
301 // some types, for example longtext, are reported as
302 // "longtext character set latin7" when their charset and / or collation
303 // differs from the ones of the corresponding database.
304 $tmp = strpos($type, 'character set');
305 if ($tmp) {
306 $type = substr($type, 0, $tmp - 1);
309 if (isset($submit_length) && $submit_length != false) {
310 $length = $submit_length;
313 // rtrim the type, for cases like "float unsigned"
314 $type = rtrim($type);
315 $type_upper = strtoupper($type);
317 foreach ($cfg['ColumnTypes'] as $col_goup => $column_type) {
318 if (is_array($column_type)) {
319 $content_cells[$i][$ci] .= '<optgroup label="' . htmlspecialchars($col_goup) . '">';
320 foreach ($column_type as $col_group_type) {
321 $content_cells[$i][$ci] .= '<option value="'. $col_group_type . '"';
322 if ($type_upper == strtoupper($col_group_type)) {
323 $content_cells[$i][$ci] .= ' selected="selected"';
325 $content_cells[$i][$ci] .= '>' . $col_group_type . '</option>';
327 $content_cells[$i][$ci] .= '</optgroup>';
328 continue;
331 $content_cells[$i][$ci] .= '<option value="'. $column_type . '"';
332 if ($type_upper == strtoupper($column_type)) {
333 $content_cells[$i][$ci] .= ' selected="selected"';
335 $content_cells[$i][$ci] .= '>' . $column_type . '</option>';
336 } // end for
338 $content_cells[$i][$ci] .= ' </select>';
339 $ci++;
341 // old column length
342 if ($is_backup) {
343 $_form_params['field_length_orig[' . $i . ']'] = $length;
346 // column length
347 if (isset($extracted_fieldspec) && ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type'])) {
348 $binary = 0;
349 $unsigned = 0;
350 $zerofill = 0;
351 $length_to_display = htmlspecialchars($length);
352 } else {
353 $length_to_display = $length;
354 $binary = false;
355 $unsigned = stristr($row['Type'], 'unsigned');
356 $zerofill = stristr($row['Type'], 'zerofill');
359 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
360 . ' type="text" name="field_length[' . $i . ']" size="' . $length_values_input_size . '"'
361 . ' value="' . htmlspecialchars($length_to_display) . '"'
362 . ' class="textfield" />';
363 $ci++;
365 // column default
367 * having NULL enabled does not implicit having Default with NULL
369 if (isset($row)
370 && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
371 $row['Default'] = 'NULL';
375 // old column default
376 if ($is_backup) {
377 $_form_params['field_default_orig[' . $i . ']'] =
378 (isset($row['Default']) ? $row['Default'] : '');
381 // here we put 'NONE' as the default value of drop-down; otherwise
382 // users would have problems if they forget to enter the default
383 // value (example, for an INT)
384 $default_options = array(
385 'NONE' => $strNone,
386 'USER_DEFINED' => $strAsDefined,
387 'NULL' => 'NULL',
388 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
391 // for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
392 if ($type_upper == 'TIMESTAMP'
393 && $default_current_timestamp
394 && isset($row['Default'])) {
395 $row['Default'] = '';
398 $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">';
399 foreach ($default_options as $key => $value) {
400 $content_cells[$i][$ci] .= '<option value="' . $key . '"';
401 // is only set when we go back to edit a field's structure
402 if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
403 $content_cells[$i][$ci] .= ' selected="selected"';
405 $content_cells[$i][$ci] .= ' >' . $value . '</option>';
407 $content_cells[$i][$ci] .= '</select>';
408 $content_cells[$i][$ci] .= '<br />';
409 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
410 . ' type="text" name="field_default_value[' . $i . ']" size="12"'
411 . ' value="' . (isset($row['DefaultValue']) ? htmlspecialchars($row['DefaultValue']) : '') . '"'
412 . ' class="textfield" />';
413 $ci++;
415 // column collation
416 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
417 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
418 PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']',
419 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
420 unset($tmp_collation);
421 $ci++;
423 // column attribute
424 $content_cells[$i][$ci] = '<select style="font-size: 70%;"'
425 . ' name="field_attribute[' . $i . ']"'
426 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
428 $attribute = '';
429 if ($binary) {
430 $attribute = 'BINARY';
432 if ($unsigned) {
433 $attribute = 'UNSIGNED';
435 if ($zerofill) {
436 $attribute = 'UNSIGNED ZEROFILL';
438 if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
439 $attribute = 'on update CURRENT_TIMESTAMP';
442 if (isset($submit_attribute) && $submit_attribute != false) {
443 $attribute = $submit_attribute;
446 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
447 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
448 // the latter.
449 if (PMA_MYSQL_INT_VERSION < 50025
450 && isset($row['Field'])
451 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
452 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
453 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
454 $row['Null'] = '';
457 // MySQL 4.1.2+ TIMESTAMP options
458 // (if on_update_current_timestamp is set, then it's TRUE)
459 if (isset($row['Field'])
460 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
461 $attribute = 'on update CURRENT_TIMESTAMP';
463 if ((isset($row['Field'])
464 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
465 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
466 $default_current_timestamp = true;
467 } else {
468 $default_current_timestamp = false;
471 $cnt_attribute_types = count($cfg['AttributeTypes']);
472 for ($j = 0; $j < $cnt_attribute_types; $j++) {
473 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
474 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
475 $content_cells[$i][$ci] .= ' selected="selected"';
477 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
480 $content_cells[$i][$ci] .= '</select>';
481 $ci++;
483 // column NULL
484 $content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
485 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
487 if (! empty($row['Null']) && $row['Null'] != 'NO' && $row['Null'] != 'NOT NULL') {
488 $content_cells[$i][$ci] .= ' checked="checked"';
491 $content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
492 $ci++;
494 // column indexes
495 // lem9: See my other comment about removing this 'if'.
496 if (!$is_backup) {
497 $content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
498 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
499 $content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
501 $content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . $strPrimary . '"';
502 if (isset($row['Key']) && $row['Key'] == 'PRI') {
503 $content_cells[$i][$ci] .= ' selected="selected"';
505 $content_cells[$i][$ci] .= '>PRIMARY</option>';
507 $content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . $strUnique . '"';
508 if (isset($row['Key']) && $row['Key'] == 'UNI') {
509 $content_cells[$i][$ci] .= ' selected="selected"';
511 $content_cells[$i][$ci] .= '>UNIQUE</option>';
513 $content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . $strIndex . '"';
514 if (isset($row['Key']) && $row['Key'] == 'MUL') {
515 $content_cells[$i][$ci] .= ' selected="selected"';
517 $content_cells[$i][$ci] .= '>INDEX</option>';
519 $content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . $strIdxFulltext . '"';
520 if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
521 $content_cells[$i][$ci] .= ' selected="selected"';
523 $content_cells[$i][$ci] .= '>FULLTEXT</option>';
525 $content_cells[$i][$ci] .= '</select>';
526 $ci++;
527 } // end if ($action ==...)
529 // column auto_increment
530 $content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
531 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
533 if (isset($row['Extra']) && $row['Extra'] == 'auto_increment') {
534 $content_cells[$i][$ci] .= ' checked="checked"';
537 $content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
538 $ci++;
540 // column comments
541 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
542 . ' type="text" name="field_comments[' . $i . ']" size="12"'
543 . ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
544 . ' class="textfield" />';
545 $ci++;
547 // column MIME-types
548 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
549 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
550 $content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>';
552 if (is_array($available_mime['mimetype'])) {
553 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
554 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
555 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
559 $content_cells[$i][$ci] .= '</select>';
560 $ci++;
562 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
563 $content_cells[$i][$ci] .= ' <option value="" title="' . $strNone . '"></option>';
564 if (is_array($available_mime['transformation'])) {
565 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
566 $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 ' : '');
567 $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
568 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()');
569 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
573 $content_cells[$i][$ci] .= '</select>';
574 $ci++;
576 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
577 . ' type="text" name="field_transformation_options[' . $i . ']"'
578 . ' size="16" class="textfield"'
579 . ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
580 . ' />';
581 //$ci++;
583 } // end for
585 if ($cfg['CtrlArrowsMoving']) {
587 <script src="./js/keyhandler.js" type="text/javascript"></script>
588 <script type="text/javascript">
589 // <![CDATA[
590 var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
591 document.onkeydown = onKeyDownArrowsHandler;
592 // ]]>
593 </script>
594 <?php
598 <form method="post" action="<?php echo $action; ?>">
599 <?php
600 echo PMA_generate_common_hidden_inputs($_form_params);
601 unset($_form_params);
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">';
608 if ($display_type == 'horizontal') {
610 <tr>
611 <?php foreach ($header_cells as $header_val) { ?>
612 <th><?php echo $header_val; ?></th>
613 <?php } ?>
614 </tr>
615 <?php
617 $odd_row = true;
618 foreach ($content_cells as $content_row) {
619 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
620 $odd_row = ! $odd_row;
622 if (is_array($content_row)) {
623 foreach ($content_row as $content_row_val) {
625 <td align="center"><?php echo $content_row_val; ?></td>
626 <?php
629 echo '</tr>';
631 } else {
632 $i = 0;
633 $odd_row = true;
634 foreach ($header_cells as $header_val) {
635 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
636 $odd_row = ! $odd_row;
638 <th><?php echo $header_val; ?></th>
639 <?php
640 foreach ($content_cells as $content_cell) {
641 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
643 <td><?php echo $content_cell[$i]; ?></td>
644 <?php
647 echo '</tr>';
648 $i++;
652 </table>
653 <br />
654 <?php
658 * needs to be finished
661 if ($display_type == 'horizontal') {
662 $new_field = '';
663 foreach ($empty_row as $content_row_val) {
664 $new_field .= '<td align="center">' . $content_row_val . '</td>';
667 <script type="text/javascript">
668 // <![CDATA[
669 var odd_row = <?php echo $odd_row; ?>;
671 function addField() {
672 var new_fields = document.getElementById('added_fields').value;
673 var new_field_container = document.getElementById('table_columns');
674 var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';
675 var i = 0;
676 for (i = 0; i < new_fields; i++) {
677 if (odd_row) {
678 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
679 } else {
680 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
682 odd_row = ! odd_row;
685 return true;
687 // ]]>
688 </script>
689 <?php
693 if ($action == 'tbl_create.php') {
695 <table>
696 <tr valign="top">
697 <th><?php echo $strTableComments; ?>:&nbsp;</th>
698 <td width="25">&nbsp;</td>
699 <th><?php echo $strStorageEngine; ?>:
700 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
701 </th>
702 <td width="25">&nbsp;</td>
703 <th><?php echo $strCollation ;?>:&nbsp;</th>
704 </tr>
705 <tr><td><input type="text" name="comment" size="40" maxlength="80"
706 value="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
707 class="textfield" />
708 </td>
709 <td width="25">&nbsp;</td>
710 <td>
711 <?php
712 echo PMA_StorageEngine::getHtmlSelect('tbl_type', null,
713 (isset($_REQUEST['tbl_type']) ? $_REQUEST['tbl_type'] : null));
715 </td>
716 <td width="25">&nbsp;</td>
717 <td>
718 <?php
719 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation',
720 null, (isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null), false, 3);
722 </td>
723 </tr>
724 <?php
725 if (PMA_Partition::havePartitioning()) {
727 <tr valign="top">
728 <th><?php echo $strPartitionDefinition; ?>:&nbsp;<?php echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?>
729 </th>
730 </tr>
731 <tr>
732 <td>
733 <textarea name="partition_definition" id="partitiondefinition"
734 cols="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
735 rows="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
736 dir="<?php echo $GLOBALS['text_dir'];?>"><?php echo (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : ''); ?></textarea>
737 </td>
738 </tr>
739 <?php
742 </table>
743 <br />
744 <?php
745 } // end if ($action == 'tbl_create.php')
748 <fieldset class="tblFooters">
749 <input type="submit" name="do_save_data" value="<?php echo $strSave; ?>"
750 onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
751 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
752 <?php echo $GLOBALS['strOr']; ?>
753 <?php echo sprintf($strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
754 <input type="submit" name="submit_num_fields"
755 value="<?php echo $GLOBALS['strGo']; ?>"
756 <?php /* onclick="if (addField()) return false;" */ ?>
757 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)"
759 <?php } ?>
760 </fieldset>
762 </form>
764 <center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>