bug #2063100 Unknown column Event_priv
[phpmyadmin/crack.git] / libraries / tbl_properties.inc.php
blobd36f3019c85fea0c4e3afcc2cf346de20beece82
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 */
9 if (! defined('PHPMYADMIN')) {
10 exit;
13 /**
14 * Check parameters
16 require_once './libraries/common.inc.php';
17 PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
20 // Get available character sets and storage engines
21 require_once './libraries/mysql_charsets.lib.php';
22 require_once './libraries/StorageEngine.class.php';
24 /**
25 * Class for partition management
27 require_once './libraries/Partition.class.php';
29 if (is_int($cfg['DefaultPropDisplay'])) {
30 if ($num_fields <= $cfg['DefaultPropDisplay']) {
31 $display_type = 'vertical';
32 } else {
33 $display_type = 'horizontal';
35 } else {
36 $display_type = $cfg['DefaultPropDisplay'];
39 $_form_params = array(
40 'db' => $db,
41 'table' => $table,
44 if ($action == 'tbl_create.php') {
45 $_form_params['reload'] = 1;
46 } elseif ($action == 'tbl_addfield.php') {
47 $_form_params['field_where'] = $_REQUEST['field_where'];
48 $_form_params['after_field'] = $_REQUEST['after_field'];
51 if (isset($num_fields)) {
52 $_form_params['orig_num_fields'] = $num_fields;
55 if (isset($_REQUEST['field_where'])) {
56 $_form_params['orig_field_where'] = $_REQUEST['field_where'];
59 if (isset($_REQUEST['after_field'])) {
60 $_form_params['orig_after_field'] = $_REQUEST['after_field'];
63 if (isset($selected) && is_array($selected)) {
64 foreach ($selected as $o_fld_nr => $o_fld_val) {
65 $_form_params['selected[' . $o_fld_nr . ']'] = $o_fld_val;
66 if (! isset($true_selected)) {
67 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
71 if (isset($true_selected) && is_array($true_selected)) {
72 foreach ($true_selected as $o_fld_nr => $o_fld_val) {
73 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
76 } elseif (isset($_REQUEST['field'])) {
77 $_form_params['orig_field'] = $_REQUEST['field'];
78 if (isset($orig_field)) {
79 $_form_params['true_selected[]'] = $orig_field;
80 } else {
81 $_form_params['true_selected[]'] = $_REQUEST['field'];
85 $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
87 $header_cells = array();
88 $content_cells = array();
90 $header_cells[] = $strField;
91 $header_cells[] = $strType
92 . ($GLOBALS['cfg']['ReplaceHelpImg']
93 ? PMA_showMySQLDocu('SQL-Syntax', 'data-types')
94 : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'data-types')
95 . '</span>');
96 $header_cells[] = $strLengthSet . PMA_showHint($strSetEnumVal);
97 $header_cells[] = $strDefault . PMA_showHint($strDefaultValueHelp);
98 $header_cells[] = $strCollation;
99 $header_cells[] = $strAttr;
100 $header_cells[] = $strNull;
102 // lem9: We could remove this 'if' and let the key information be shown and
103 // editable. However, for this to work, tbl_alter must be modified to use the
104 // key fields, as tbl_addfield does.
106 if (!$is_backup) {
107 $header_cells[] = $strIndex;
110 $header_cells[] = '<abbr title="AUTO_INCREMENT">A_I</abbr>';
112 require_once './libraries/relation.lib.php';
113 require_once './libraries/transformations.lib.php';
114 $cfgRelation = PMA_getRelationsParam();
116 $comments_map = array();
117 $mime_map = array();
118 $available_mime = array();
120 $comments_map = PMA_getComments($db, $table);
121 $header_cells[] = $strComments;
123 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
124 $mime_map = PMA_getMIME($db, $table);
125 $available_mime = PMA_getAvailableMIMEtypes();
127 $hint = '<br />' .
128 sprintf($strMIME_transformation_note,
129 '<a href="transformation_overview.php?'
130 . PMA_generate_common_url($db, $table) . '" target="_blank">',
131 '</a>');
134 $header_cells[] = $strMIME_MIMEtype;
135 $header_cells[] = $strMIME_transformation;
136 $header_cells[] = $strMIME_transformation_options
137 . PMA_showHint($strMIME_transformation_options_note . $hint);
140 // garvin: workaround for field_fulltext, because its submitted indizes contain
141 // the index as a value, not a key. Inserted here for easier maintaineance
142 // and less code to change in existing files.
143 if (isset($field_fulltext) && is_array($field_fulltext)) {
144 foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
145 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
149 for ($i = 0; $i < $num_fields; $i++) {
150 if (! empty($regenerate)) {
151 // An error happened with previous inputs, so we will restore the data
152 // to embed it once again in this form.
154 $row['Field'] = (isset($_REQUEST['field_name'][$i]) ? $_REQUEST['field_name'][$i] : false);
155 $row['Type'] = (isset($_REQUEST['field_type'][$i]) ? $_REQUEST['field_type'][$i] : false);
156 $row['Collation'] = (isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '');
157 $row['Null'] = (isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : '');
159 if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i) {
160 $row['Key'] = 'PRI';
161 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i) {
162 $row['Key'] = 'MUL';
163 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i) {
164 $row['Key'] = 'UNI';
165 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i) {
166 $row['Key'] = 'FULLTEXT';
167 } else {
168 $row['Key'] = '';
171 $row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ? $_REQUEST['field_default_type'][$i] : 'USER_DEFINED');
172 $row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ? $_REQUEST['field_default_value'][$i] : '');
174 switch ($row['DefaultType']) {
175 case 'NONE' :
176 $row['Default'] = null;
177 break;
178 case 'USER_DEFINED' :
179 $row['Default'] = $row['DefaultValue'];
180 break;
181 case 'NULL' :
182 case 'CURRENT_TIMESTAMP' :
183 $row['Default'] = $row['DefaultType'];
184 break;
187 $row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false);
188 $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : false);
190 $submit_length = (isset($_REQUEST['field_length'][$i]) ? $_REQUEST['field_length'][$i] : false);
191 $submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ? $_REQUEST['field_attribute'][$i] : false);
193 $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ? true : false);
195 if (isset($_REQUEST['field_comments'][$i])) {
196 $comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
199 if (isset($_REQUEST['field_mimetype'][$i])) {
200 $mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
203 if (isset($_REQUEST['field_transformation'][$i])) {
204 $mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i];
207 if (isset($_REQUEST['field_transformation_options'][$i])) {
208 $mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i];
211 } elseif (isset($fields_meta[$i])) {
212 $row = $fields_meta[$i];
213 switch ($row['Default']) {
214 case null:
215 if ($row['Null'] == 'YES') {
216 $row['DefaultType'] = 'NULL';
217 } else {
218 $row['DefaultType'] = 'NONE';
220 $row['DefaultValue'] = '';
221 break;
222 case 'CURRENT_TIMESTAMP':
223 $row['DefaultType'] = 'CURRENT_TIMESTAMP';
224 $row['DefaultValue'] = '';
225 break;
226 default:
227 $row['DefaultType'] = 'USER_DEFINED';
228 $row['DefaultValue'] = $row['Default'];
229 break;
233 if (isset($row['Type'])) {
234 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
235 if ($extracted_fieldspec['type'] == 'bit') {
236 $row['Default'] = PMA_printable_bit_value($row['Default'], $extracted_fieldspec['spec_in_brackets']);
239 // Cell index: If certain fields get left out, the counter shouldn't change.
240 $ci = 0;
241 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
242 // has to be incremented ($ci_offset++)
243 $ci_offset = -1;
245 // old column name
246 if ($is_backup) {
247 if (! empty($true_selected[$i])) {
248 $_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
249 } elseif (isset($row['Field'])) {
250 $_form_params['field_orig[' . $i . ']'] = $row['Field'];
251 } else {
252 $_form_params['field_orig[' . $i . ']'] = '';
256 // column name
257 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
258 . ' type="text" name="field_name[' . $i . ']"'
259 . ' maxlength="64" class="textfield" title="' . $strField . '"'
260 . ' size="' . ($GLOBALS['cfg']['DefaultPropDisplay'] == 'horizontal' ? '10' : '30') . '"'
261 . ' value="' . (isset($row['Field']) ? htmlspecialchars($row['Field']) : '') . '"'
262 . ' />';
263 $ci++;
265 // column type
266 $content_cells[$i][$ci] = '<select name="field_type[' . $i . ']"'
267 .' id="field_' . $i . '_' . ($ci - $ci_offset) . '" >';
269 if (empty($row['Type'])) {
270 // creating a column
271 $row['Type'] = '';
272 $type = '';
273 } else {
274 $type = $row['Type'];
277 if (! empty($row['Type'])) {
278 $type = $extracted_fieldspec['type'];
279 if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
280 $length = $extracted_fieldspec['spec_in_brackets'];
281 } else {
282 // strip the "BINARY" attribute, except if we find "BINARY(" because
283 // this would be a BINARY or VARBINARY field type
284 $type = preg_replace('@BINARY([^\(])@i', '', $type);
285 $type = preg_replace('@ZEROFILL@i', '', $type);
286 $type = preg_replace('@UNSIGNED@i', '', $type);
287 $length = $extracted_fieldspec['spec_in_brackets'];
288 } // end if else
289 } else {
290 // creating a column
291 $length = '';
294 // some types, for example longtext, are reported as
295 // "longtext character set latin7" when their charset and / or collation
296 // differs from the ones of the corresponding database.
297 $tmp = strpos($type, 'character set');
298 if ($tmp) {
299 $type = substr($type, 0, $tmp - 1);
302 if (isset($submit_length) && $submit_length != false) {
303 $length = $submit_length;
306 // rtrim the type, for cases like "float unsigned"
307 $type = rtrim($type);
308 $type_upper = strtoupper($type);
310 foreach ($cfg['ColumnTypes'] as $col_goup => $column_type) {
311 if (is_array($column_type)) {
312 $content_cells[$i][$ci] .= '<optgroup label="' . htmlspecialchars($col_goup) . '">';
313 foreach ($column_type as $col_group_type) {
314 $content_cells[$i][$ci] .= '<option value="'. $col_group_type . '"';
315 if ($type_upper == strtoupper($col_group_type)) {
316 $content_cells[$i][$ci] .= ' selected="selected"';
318 $content_cells[$i][$ci] .= '>' . $col_group_type . '</option>';
320 $content_cells[$i][$ci] .= '</optgroup>';
321 continue;
324 $content_cells[$i][$ci] .= '<option value="'. $column_type . '"';
325 if ($type_upper == strtoupper($column_type)) {
326 $content_cells[$i][$ci] .= ' selected="selected"';
328 $content_cells[$i][$ci] .= '>' . $column_type . '</option>';
329 } // end for
331 $content_cells[$i][$ci] .= ' </select>';
332 $ci++;
334 // old column length
335 if ($is_backup) {
336 $_form_params['field_length_orig[' . $i . ']'] = $length;
339 // column length
340 if (isset($extracted_fieldspec) && ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type'])) {
341 $binary = 0;
342 $unsigned = 0;
343 $zerofill = 0;
344 $length_to_display = htmlspecialchars($length);
345 } else {
346 $length_to_display = $length;
347 $binary = false;
348 $unsigned = stristr($row['Type'], 'unsigned');
349 $zerofill = stristr($row['Type'], 'zerofill');
352 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
353 . ' type="text" name="field_length[' . $i . ']" size="8"'
354 . ' value="' . htmlspecialchars($length_to_display) . '"'
355 . ' class="textfield" />';
356 $ci++;
358 // column default
360 * having NULL enabled does not implicit having Default with NULL
362 if (isset($row)
363 && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
364 $row['Default'] = 'NULL';
368 // old column default
369 if ($is_backup) {
370 $_form_params['field_default_orig[' . $i . ']'] =
371 (isset($row['Default']) ? $row['Default'] : '');
374 // here we put 'NONE' as the default value of drop-down; otherwise
375 // users would have problems if they forget to enter the default
376 // value (example, for an INT)
377 $default_options = array(
378 'NONE' => $strNone,
379 'USER_DEFINED' => $strAsDefined,
380 'NULL' => 'NULL',
381 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
384 // for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
385 if ($type_upper == 'TIMESTAMP'
386 && $default_current_timestamp
387 && isset($row['Default'])) {
388 $row['Default'] = '';
391 $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">';
392 foreach ($default_options as $key => $value) {
393 $content_cells[$i][$ci] .= '<option value="' . $key . '"';
394 // is only set when we go back to edit a field's structure
395 if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
396 $content_cells[$i][$ci] .= ' selected="selected"';
398 $content_cells[$i][$ci] .= ' >' . $value . '</option>';
400 $content_cells[$i][$ci] .= '</select>';
401 $content_cells[$i][$ci] .= '<br />';
402 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
403 . ' type="text" name="field_default_value[' . $i . ']" size="12"'
404 . ' value="' . (isset($row['DefaultValue']) ? htmlspecialchars($row['DefaultValue']) : '') . '"'
405 . ' class="textfield" />';
406 $ci++;
408 // column collation
409 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
410 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
411 PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']',
412 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
413 unset($tmp_collation);
414 $ci++;
416 // column attribute
417 $content_cells[$i][$ci] = '<select style="font-size: 70%;"'
418 . ' name="field_attribute[' . $i . ']"'
419 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
421 $attribute = '';
422 if ($binary) {
423 $attribute = 'BINARY';
425 if ($unsigned) {
426 $attribute = 'UNSIGNED';
428 if ($zerofill) {
429 $attribute = 'UNSIGNED ZEROFILL';
431 if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
432 $attribute = 'on update CURRENT_TIMESTAMP';
435 if (isset($submit_attribute) && $submit_attribute != false) {
436 $attribute = $submit_attribute;
439 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
440 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
441 // the latter.
442 if (PMA_MYSQL_INT_VERSION < 50025
443 && isset($row['Field'])
444 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
445 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
446 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
447 $row['Null'] = '';
450 // MySQL 4.1.2+ TIMESTAMP options
451 // (if on_update_current_timestamp is set, then it's TRUE)
452 if (isset($row['Field'])
453 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
454 $attribute = 'on update CURRENT_TIMESTAMP';
456 if ((isset($row['Field'])
457 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
458 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
459 $default_current_timestamp = true;
460 } else {
461 $default_current_timestamp = false;
464 $cnt_attribute_types = count($cfg['AttributeTypes']);
465 for ($j = 0; $j < $cnt_attribute_types; $j++) {
466 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
467 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
468 $content_cells[$i][$ci] .= ' selected="selected"';
470 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
473 $content_cells[$i][$ci] .= '</select>';
474 $ci++;
476 // column NULL
477 $content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
478 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
480 if (! empty($row['Null']) && $row['Null'] != 'NO' && $row['Null'] != 'NOT NULL') {
481 $content_cells[$i][$ci] .= ' checked="checked"';
484 $content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
485 $ci++;
487 // column indexes
488 // lem9: See my other comment about removing this 'if'.
489 if (!$is_backup) {
490 $content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
491 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
492 $content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
494 $content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . $strPrimary . '"';
495 if (isset($row['Key']) && $row['Key'] == 'PRI') {
496 $content_cells[$i][$ci] .= ' selected="selected"';
498 $content_cells[$i][$ci] .= '>PRIMARY</option>';
500 $content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . $strUnique . '"';
501 if (isset($row['Key']) && $row['Key'] == 'UNI') {
502 $content_cells[$i][$ci] .= ' selected="selected"';
504 $content_cells[$i][$ci] .= '>UNIQUE</option>';
506 $content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . $strIndex . '"';
507 if (isset($row['Key']) && $row['Key'] == 'MUL') {
508 $content_cells[$i][$ci] .= ' selected="selected"';
510 $content_cells[$i][$ci] .= '>INDEX</option>';
512 $content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . $strIdxFulltext . '"';
513 if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
514 $content_cells[$i][$ci] .= ' selected="selected"';
516 $content_cells[$i][$ci] .= '>FULLTEXT</option>';
518 $content_cells[$i][$ci] .= '</select>';
519 $ci++;
520 } // end if ($action ==...)
522 // column auto_increment
523 $content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
524 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
526 if (isset($row['Extra']) && $row['Extra'] == 'auto_increment') {
527 $content_cells[$i][$ci] .= ' checked="checked"';
530 $content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
531 $ci++;
533 // column comments
534 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
535 . ' type="text" name="field_comments[' . $i . ']" size="12"'
536 . ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
537 . ' class="textfield" />';
538 $ci++;
540 // column MIME-types
541 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
542 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
543 $content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>';
545 if (is_array($available_mime['mimetype'])) {
546 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
547 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
548 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
552 $content_cells[$i][$ci] .= '</select>';
553 $ci++;
555 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
556 $content_cells[$i][$ci] .= ' <option value="" title="' . $strNone . '"></option>';
557 if (is_array($available_mime['transformation'])) {
558 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
559 $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 ' : '');
560 $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
561 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()');
562 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
566 $content_cells[$i][$ci] .= '</select>';
567 $ci++;
569 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
570 . ' type="text" name="field_transformation_options[' . $i . ']"'
571 . ' size="16" class="textfield"'
572 . ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
573 . ' />';
574 //$ci++;
576 } // end for
578 if ($cfg['CtrlArrowsMoving']) {
580 <script src="./js/keyhandler.js" type="text/javascript"></script>
581 <script type="text/javascript">
582 // <![CDATA[
583 var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
584 document.onkeydown = onKeyDownArrowsHandler;
585 // ]]>
586 </script>
587 <?php
591 <form method="post" action="<?php echo $action; ?>">
592 <?php
593 echo PMA_generate_common_hidden_inputs($_form_params);
594 unset($_form_params);
596 if (is_array($content_cells) && is_array($header_cells)) {
597 // last row is for javascript insert
598 //$empty_row = array_pop($content_cells);
600 echo '<table id="table_columns">';
601 if ($display_type == 'horizontal') {
603 <tr>
604 <?php foreach ($header_cells as $header_val) { ?>
605 <th><?php echo $header_val; ?></th>
606 <?php } ?>
607 </tr>
608 <?php
610 $odd_row = true;
611 foreach ($content_cells as $content_row) {
612 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
613 $odd_row = ! $odd_row;
615 if (is_array($content_row)) {
616 foreach ($content_row as $content_row_val) {
618 <td align="center"><?php echo $content_row_val; ?></td>
619 <?php
622 echo '</tr>';
624 } else {
625 $i = 0;
626 $odd_row = true;
627 foreach ($header_cells as $header_val) {
628 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
629 $odd_row = ! $odd_row;
631 <th><?php echo $header_val; ?></th>
632 <?php
633 foreach ($content_cells as $content_cell) {
634 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
636 <td><?php echo $content_cell[$i]; ?></td>
637 <?php
640 echo '</tr>';
641 $i++;
645 </table>
646 <br />
647 <?php
651 * needs to be finished
654 if ($display_type == 'horizontal') {
655 $new_field = '';
656 foreach ($empty_row as $content_row_val) {
657 $new_field .= '<td align="center">' . $content_row_val . '</td>';
660 <script type="text/javascript">
661 // <![CDATA[
662 var odd_row = <?php echo $odd_row; ?>;
664 function addField() {
665 var new_fields = document.getElementById('added_fields').value;
666 var new_field_container = document.getElementById('table_columns');
667 var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';
668 var i = 0;
669 for (i = 0; i < new_fields; i++) {
670 if (odd_row) {
671 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
672 } else {
673 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
675 odd_row = ! odd_row;
678 return true;
680 // ]]>
681 </script>
682 <?php
686 if ($action == 'tbl_create.php') {
688 <table>
689 <tr valign="top">
690 <th><?php echo $strTableComments; ?>:&nbsp;</th>
691 <td width="25">&nbsp;</td>
692 <th><?php echo $strStorageEngine; ?>:
693 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
694 </th>
695 <td width="25">&nbsp;</td>
696 <th><?php echo $strCollation ;?>:&nbsp;</th>
697 </tr>
698 <tr><td><input type="text" name="comment" size="40" maxlength="80"
699 value="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
700 class="textfield" />
701 </td>
702 <td width="25">&nbsp;</td>
703 <td>
704 <?php
705 echo PMA_StorageEngine::getHtmlSelect('tbl_type', null,
706 (isset($_REQUEST['tbl_type']) ? $_REQUEST['tbl_type'] : null));
708 </td>
709 <td width="25">&nbsp;</td>
710 <td>
711 <?php
712 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation',
713 null, (isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null), false, 3);
715 </td>
716 </tr>
717 <?php
718 if (PMA_Partition::havePartitioning()) {
720 <tr valign="top">
721 <th><?php echo $strPartitionDefinition; ?>:&nbsp;<?php echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?>
722 </th>
723 </tr>
724 <tr>
725 <td>
726 <textarea name="partition_definition" id="partitiondefinition"
727 cols="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
728 rows="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
729 dir="<?php echo $GLOBALS['text_dir'];?>"><?php echo (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : ''); ?></textarea>
730 </td>
731 </tr>
732 <?php
735 </table>
736 <br />
737 <?php
738 } // end if ($action == 'tbl_create.php')
741 <fieldset class="tblFooters">
742 <input type="submit" name="do_save_data" value="<?php echo $strSave; ?>"
743 onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
744 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
745 <?php echo $GLOBALS['strOr']; ?>
746 <?php echo sprintf($strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
747 <input type="submit" name="submit_num_fields"
748 value="<?php echo $GLOBALS['strGo']; ?>"
749 <?php /* onclick="if (addField()) return false;" */ ?>
750 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)"
752 <?php } ?>
753 </fieldset>
755 </form>
757 <center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>