Fix typos (bug #1597137).
[phpmyadmin/last10db.git] / libraries / tbl_properties.inc.php
blobc72f24ef29d6667adc472c03528b20ed5691f508
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4 // Check parameters
6 require_once('./libraries/common.lib.php');
7 PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
10 // Get available character sets and storage engines
11 require_once('./libraries/mysql_charsets.lib.php');
12 require_once('./libraries/storage_engines.lib.php');
14 if (is_int($cfg['DefaultPropDisplay'])) {
15 if ($num_fields <= $cfg['DefaultPropDisplay']) {
16 $display_type = 'vertical';
17 } else {
18 $display_type = 'horizontal';
20 } else {
21 $display_type = $cfg['DefaultPropDisplay'];
24 if ($cfg['CtrlArrowsMoving']) {
26 <script src="./js/keyhandler.js" type="text/javascript" language="javascript"></script>
27 <script type="text/javascript" language="javascript">
28 <!--
29 var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
30 document.onkeydown = onKeyDownArrowsHandler;
31 // -->
32 </script>
33 <?php
35 // here, the div_x_7 represents a div id which contains
36 // the default CURRENT TIMESTAMP checkbox and label
37 // and, field_x_7a represents the checkbox itself
39 if (PMA_MYSQL_INT_VERSION >= 40102) {
41 <script type="text/javascript" language="javascript">
42 <!--
43 function display_field_options(field_type, i) {
44 if (field_type == 'TIMESTAMP') {
45 getElement('div_' + i + '_7').style.display = 'block';
46 } else {
47 getElement('div_' + i + '_7').style.display = 'none';
48 getElement('field_' + i + '_7a').checked = false;
50 return true;
52 // -->
53 </script>
54 <?php } ?>
56 <form method="post" action="<?php echo $action; ?>">
57 <?php
58 echo PMA_generate_common_hidden_inputs($db, $table);
59 if ($action == 'tbl_create.php') {
61 <input type="hidden" name="reload" value="1" />
62 <?php
63 } elseif ($action == 'tbl_addfield.php') {
65 <input type="hidden" name="field_where" value="<?php echo $field_where; ?>" />
66 <input type="hidden" name="after_field" value="<?php echo $after_field; ?>" />
67 <?php
70 if (isset($num_fields)) {
72 <input type="hidden" name="orig_num_fields" value="<?php echo $num_fields; ?>" />
73 <?php
76 if (isset($field_where)) {
78 <input type="hidden" name="orig_field_where" value="<?php echo $field_where; ?>" />
79 <?php
82 if (isset($after_field)) {
84 <input type="hidden" name="orig_after_field" value="<?php echo $after_field; ?>" />
85 <?php
88 if (isset($selected) && is_array($selected)) {
89 foreach ($selected AS $o_fld_nr => $o_fld_val) {
91 <input type="hidden" name="selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
92 <?php
93 if (!isset($true_selected)) {
95 <input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
96 <?php
101 if (isset($true_selected) && is_array($true_selected)) {
102 foreach ($true_selected AS $o_fld_nr => $o_fld_val) {
104 <input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
105 <?php
109 } elseif (isset($field)) {
111 <input type="hidden" name="orig_field" value="<?php echo urlencode($field); ?>" />
112 <input type="hidden" name="true_selected[] value="<?php echo (isset($orig_field) ? $orig_field : urlencode($field)); ?>" />
113 <?php
116 $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
118 $header_cells = array();
119 $content_cells = array();
121 $header_cells[] = $strField;
122 $header_cells[] = $strType . ($GLOBALS['cfg']['ReplaceHelpImg'] ? PMA_showMySQLDocu('SQL-Syntax', 'data-types') : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'data-types') . '</span>');
123 $header_cells[] = $strLengthSet . '<sup>1</sup>';
124 if (PMA_MYSQL_INT_VERSION >= 40100) {
125 $header_cells[] = $strCollation;
127 $header_cells[] = $strAttr;
128 $header_cells[] = $strNull;
129 $header_cells[] = $strDefault . '<sup>2</sup>';
130 $header_cells[] = $strExtra;
134 // lem9: We could remove this 'if' and let the key information be shown and
135 // editable. However, for this to work, tbl_alter must be modified to use the
136 // key fields, as tbl_addfield does.
138 if (!$is_backup) {
139 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_primary.png" width="16" height="16" alt="' . $strPrimary . '" title="' . $strPrimary . '" />' : $strPrimary;
140 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_index.png" width="16" height="16" alt="' . $strIndex . '" title="' . $strIndex . '" />' : $strIndex;
141 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_unique.png" width="16" height="16" alt="' . $strUnique . '" title="' . $strUnique . '" />' : $strUnique;
142 $header_cells[] = '---';
143 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_ftext.png" width="16" height="16" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' : $strIdxFulltext;
146 require_once('./libraries/relation.lib.php');
147 require_once('./libraries/transformations.lib.php');
148 $cfgRelation = PMA_getRelationsParam();
150 $comments_map = array();
151 $mime_map = array();
152 $available_mime = array();
154 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
155 $comments_map = PMA_getComments($db, $table);
156 $header_cells[] = $strComments;
158 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
159 $mime_map = PMA_getMIME($db, $table);
160 $available_mime = PMA_getAvailableMIMEtypes();
162 $header_cells[] = $strMIME_MIMEtype;
163 $header_cells[] = $strMIME_transformation;
164 $header_cells[] = $strMIME_transformation_options . '<sup>3</sup>';
168 // garvin: workaround for field_fulltext, because its submitted indizes contain
169 // the index as a value, not a key. Inserted here for easier maintaineance
170 // and less code to change in existing files.
171 if (isset($field_fulltext) && is_array($field_fulltext)) {
172 foreach ($field_fulltext AS $fulltext_nr => $fulltext_indexkey) {
173 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
177 for ( $i = 0 ; $i <= $num_fields; $i++ ) {
178 $submit_null = FALSE;
179 if (isset($regenerate) && $regenerate == TRUE) {
180 // An error happened with previous inputs, so we will restore the data
181 // to embed it once again in this form.
183 $row['Field'] = (isset($field_name) && isset($field_name[$i]) ? $field_name[$i] : FALSE);
184 $row['Type'] = (isset($field_type) && isset($field_type[$i]) ? $field_type[$i] : FALSE);
185 if (PMA_MYSQL_INT_VERSION >= 40100) {
186 $row['Collation'] = (isset($field_collation) && isset($field_collation[$i]) ? $field_collation[$i] : '');
188 $row['Null'] = (isset($field_null) && isset($field_null[$i]) ? $field_null[$i] : '');
189 if (isset($field_type[$i]) && $row['Null'] == '') {
190 $submit_null = TRUE;
193 if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) {
194 $row['Key'] = 'PRI';
195 } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) {
196 $row['Key'] = 'MUL';
197 } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) {
198 $row['Key'] = 'UNI';
199 } else {
200 $row['Key'] = '';
203 $row['Default'] = (isset($field_default) && isset($field_default[$i]) ? $field_default[$i] : FALSE);
204 $row['Extra'] = (isset($field_extra) && isset($field_extra[$i]) ? $field_extra[$i] : FALSE);
205 $row['Comment'] = (isset($submit_fulltext) && isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE);
207 $submit_length = (isset($field_length) && isset($field_length[$i]) ? $field_length[$i] : FALSE);
208 $submit_attribute = (isset($field_attribute) && isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE);
210 $submit_default_current_timestamp = (isset($field_default_current_timestamp) && isset($field_default_current_timestamp[$i]) ? TRUE : FALSE);
212 if (isset($field_comments) && isset($field_comments[$i])) {
213 $comments_map[$row['Field']] = $field_comments[$i];
216 if (isset($field_mimetype) && isset($field_mimetype[$i])) {
217 $mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i];
220 if (isset($field_transformation) && isset($field_transformation[$i])) {
221 $mime_map[$row['Field']]['transformation'] = $field_transformation[$i];
224 if (isset($field_transformation_options) && isset($field_transformation_options[$i])) {
225 $mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i];
228 } elseif (isset($fields_meta) && isset($fields_meta[$i])) {
229 $row = $fields_meta[$i];
232 // Cell index: If certain fields get left out, the counter shouldn't chage.
233 $ci = 0;
234 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
235 // has to be incremented ($ci_offset++)
236 $ci_offset = -1;
238 if ($is_backup) {
239 $backup_field = (isset($true_selected) && isset($true_selected[$i]) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : ''));
240 $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_orig[]" value="' . $backup_field . '" />' . "\n";
241 } else {
242 $content_cells[$i][$ci] = '';
245 $content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_name[]" size="10" maxlength="64" value="' . (isset($row) && isset($row['Field']) ? str_replace('"', '&quot;', $row['Field']) : '') . '" class="textfield" title="' . $strField . '" />';
246 $ci++;
247 $content_cells[$i][$ci] = '<select name="field_type[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '" ';
248 if (PMA_MYSQL_INT_VERSION >= 40102) {
249 $content_cells[$i][$ci] .= 'onchange="display_field_options(this.options[this.selectedIndex].value,' . $i .')" ';
251 $content_cells[$i][$ci] .= '>' . "\n";
253 if (empty($row['Type'])) {
254 $row['Type'] = '';
255 $type = '';
256 } else {
257 $type = $row['Type'];
259 // set or enum types: slashes single quotes inside options
260 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
261 $type = $tmp[1];
262 $length = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
263 } else {
264 // strip the "BINARY" attribute, except if we find "BINARY(" because
265 // this would be a BINARY or VARBINARY field type
266 $type = preg_replace('@BINARY([^\(])@i', '', $type);
267 $type = preg_replace('@ZEROFILL@i', '', $type);
268 $type = preg_replace('@UNSIGNED@i', '', $type);
270 if (strpos($type, '(')) {
271 $length = chop(substr($type, (strpos($type, '(') + 1), (strpos($type, ')') - strpos($type, '(') - 1)));
272 $type = chop(substr($type, 0, strpos($type, '(')));
273 } else {
274 $length = '';
276 } // end if else
278 // some types, for example longtext, are reported as
279 // "longtext character set latin7" when their charset and / or collation
280 // differs from the ones of the corresponding database.
281 if (PMA_MYSQL_INT_VERSION >= 40100) {
282 $tmp = strpos($type, 'character set');
283 if ($tmp) {
284 $type = substr($type, 0, $tmp-1);
288 if (isset($submit_length) && $submit_length != FALSE) {
289 $length = $submit_length;
292 // rtrim the type, for cases like "float unsigned"
293 $type = rtrim($type);
294 $type_upper = strtoupper($type);
296 $cnt_column_types = count($cfg['ColumnTypes']);
297 for ($j = 0; $j < $cnt_column_types; $j++) {
298 $content_cells[$i][$ci] .= ' <option value="'. $cfg['ColumnTypes'][$j] . '"';
299 if ($type_upper == strtoupper($cfg['ColumnTypes'][$j])) {
300 $content_cells[$i][$ci] .= ' selected="selected"';
302 $content_cells[$i][$ci] .= '>' . $cfg['ColumnTypes'][$j] . '</option>' . "\n";
303 } // end for
305 $content_cells[$i][$ci] .= ' </select>';
306 $ci++;
308 if ($is_backup) {
309 $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_length_orig[]" value="' . urlencode($length) . '" />';
310 } else {
311 $content_cells[$i][$ci] = '';
314 if (preg_match('@^(set|enum)$@i', $type)) {
315 $binary = 0;
316 $unsigned = 0;
317 $zerofill = 0;
318 $length_to_display = htmlspecialchars($length);
319 } else {
320 $length_to_display = $length;
321 if (!preg_match('@BINARY[\(]@i', $row['Type']) && PMA_MYSQL_INT_VERSION < 40100) {
322 $binary = stristr($row['Type'], 'binary');
323 } else {
324 $binary = FALSE;
326 $unsigned = stristr($row['Type'], 'unsigned');
327 $zerofill = stristr($row['Type'], 'zerofill');
330 $content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_length[]" size="8" value="' . str_replace('"', '&quot;', $length_to_display) . '" class="textfield" />' . "\n";
331 $ci++;
333 if (PMA_MYSQL_INT_VERSION >= 40100) {
334 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
335 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[]', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, FALSE);
336 unset($tmp_collation);
337 $ci++;
340 $content_cells[$i][$ci] = '<select style="font-size: 70%;" name="field_attribute[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">' . "\n";
342 $attribute = '';
343 if ($binary) {
344 $attribute = 'BINARY';
346 if ($unsigned) {
347 $attribute = 'UNSIGNED';
349 if ($zerofill) {
350 $attribute = 'UNSIGNED ZEROFILL';
353 if (isset($submit_attribute) && $submit_attribute != FALSE) {
354 $attribute = $submit_attribute;
357 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
358 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
359 // the latter.
360 if (isset($row['Field'])
361 && isset($analyzed_sql[0])
362 && isset($analyzed_sql[0]['create_table_fields'])
363 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
364 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
365 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
366 $row['Null'] = '';
369 // MySQL 4.1.2+ TIMESTAMP options
370 // (if on_update_current_timestamp is set, then it's TRUE)
371 if (isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
372 $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
374 if ((isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
375 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp) ) {
376 $default_current_timestamp = TRUE;
377 } else {
378 $default_current_timestamp = FALSE;
381 // Dynamically add ON UPDATE CURRENT_TIMESTAMP to the possible attributes
382 if (PMA_MYSQL_INT_VERSION >= 40102 && !in_array('ON UPDATE CURRENT_TIMESTAMP', $cfg['AttributeTypes'])) {
383 $cfg['AttributeTypes'][] = 'ON UPDATE CURRENT_TIMESTAMP';
387 $cnt_attribute_types = count($cfg['AttributeTypes']);
388 for ($j = 0;$j < $cnt_attribute_types; $j++) {
389 if (PMA_MYSQL_INT_VERSION >= 40100 && $cfg['AttributeTypes'][$j] == 'BINARY') {
390 continue;
392 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
393 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
394 $content_cells[$i][$ci] .= ' selected="selected"';
396 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n";
399 $content_cells[$i][$ci] .= '</select>';
400 $ci++;
402 $content_cells[$i][$ci] = '<select name="field_null[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
404 if ((!isset($row) || empty($row['Null']) || $row['Null'] == 'NO' || $row['Null'] == 'NOT NULL') && $submit_null == FALSE) {
405 $content_cells[$i][$ci] .= "\n";
406 $content_cells[$i][$ci] .= ' <option value="NOT NULL" selected="selected" >not null</option>' . "\n";
407 $content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n";
408 } else {
409 $content_cells[$i][$ci] .= "\n";
410 $content_cells[$i][$ci] .= ' <option value="" selected="selected" >null</option>' . "\n";
411 $content_cells[$i][$ci] .= ' <option value="NOT NULL">not null</option>' . "\n";
414 $content_cells[$i][$ci] .= "\n" . '</select>';
415 $ci++;
417 if (isset($row)
418 && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
419 $row['Default'] = 'NULL';
422 if ($is_backup) {
423 $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_default_orig[]" size="8" value="' . (isset($row) && isset($row['Default']) ? urlencode($row['Default']) : '') . '" />';
424 } else {
425 $content_cells[$i][$ci] = "\n";
428 // for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
429 if (PMA_MYSQL_INT_VERSION >= 40102
430 && $type_upper == 'TIMESTAMP'
431 && $default_current_timestamp
432 && isset($row)
433 && isset($row['Default'])) {
434 $row['Default'] = '';
437 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_default[]" size="12" value="' . (isset($row) && isset($row['Default']) ? str_replace('"', '&quot;', $row['Default']) : '') . '" class="textfield" />';
438 if (PMA_MYSQL_INT_VERSION >= 40102) {
439 if ($type_upper == 'TIMESTAMP') {
440 $tmp_display_type = 'block';
441 } else {
442 $tmp_display_type = 'none';
443 $default_current_timestamp = FALSE;
445 $content_cells[$i][$ci] .= '<br /><div id="div_' . $i . '_' . ($ci - $ci_offset) . '" style="white-space: nowrap; display: ' . $tmp_display_type . '"><input id="field_' . $i . '_' . ($ci - $ci_offset) . 'a" type="checkbox" name="field_default_current_timestamp[' . $i . ']"';
446 if ($default_current_timestamp) {
447 $content_cells[$i][$ci] .= ' checked="checked" ';
449 $content_cells[$i][$ci] .= ' /><label for="field_' . $i . '_' . ($ci - $ci_offset) . 'a" style="font-size: 70%;">CURRENT_TIMESTAMP</label></div>';
451 $ci++;
453 $content_cells[$i][$ci] = '<select name="field_extra[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
455 if (!isset($row) || empty($row['Extra'])) {
456 $content_cells[$i][$ci] .= "\n";
457 $content_cells[$i][$ci] .= '<option value=""></option>' . "\n";
458 $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
459 } else {
460 $content_cells[$i][$ci] .= "\n";
461 $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
462 $content_cells[$i][$ci] .= '<option value=""></option>' . "\n";
465 $content_cells[$i][$ci] .= "\n" . '</select>';
466 $ci++;
469 // lem9: See my other comment about removing this 'if'.
470 if (!$is_backup) {
471 if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
472 $checked_primary = ' checked="checked"';
473 } else {
474 $checked_primary = '';
476 if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
477 $checked_index = ' checked="checked"';
478 } else {
479 $checked_index = '';
481 if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
482 $checked_unique = ' checked="checked"';
483 } else {
484 $checked_unique = '';
486 if (empty($checked_primary)
487 && empty($checked_index)
488 && empty($checked_unique)) {
489 $checked_none = ' checked="checked"';
490 } else {
491 $checked_none = '';
494 if ((isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
495 $checked_fulltext = ' checked="checked"';
496 } else {
497 $checked_fulltext = '';
500 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="primary_' . $i . '"' . $checked_primary . ' title="' . $strPrimary . '" />';
501 $ci++;
503 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="index_' . $i . '"' . $checked_index . ' title="' . $strIndex . '" />';
504 $ci++;
506 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="unique_' . $i . '"' . $checked_unique . ' title="' . $strUnique . '" />';
507 $ci++;
509 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="none_' . $i . '"' . $checked_none . ' title="---" />';
510 $ci++;
512 $content_cells[$i][$ci] = '<input type="checkbox" name="field_fulltext[]" value="' . $i . '"' . $checked_fulltext . ' title="' . $strIdxFulltext . '" />';
513 $ci++;
514 } // end if ($action ==...)
516 // garvin: comments
517 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
518 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_comments[]" size="12" value="' . (isset($row) && isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '" class="textfield" />';
519 $ci++;
522 // garvin: MIME-types
523 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
524 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[]">' . "\n";
525 $content_cells[$i][$ci] .= ' <option value=""></option>' . "\n";
526 $content_cells[$i][$ci] .= ' <option value="auto">auto-detect</option>' . "\n";
528 if (is_array($available_mime['mimetype'])) {
529 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
530 $checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
531 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
535 $content_cells[$i][$ci] .= '</select>';
536 $ci++;
538 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[]">' . "\n";
539 $content_cells[$i][$ci] .= ' <option value="" title="' . $strNone . '"></option>' . "\n";
540 if (is_array($available_mime['transformation'])) {
541 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
542 $checked = (isset($row) && 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 ' : '');
543 $tooltip = 'strTransformation_' . strtolower(preg_replace('@(\.inc\.php3?)$@', '', $available_mime['transformation_file'][$mimekey]));
544 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()');
545 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>' . "\n";
549 $content_cells[$i][$ci] .= '</select>';
550 $ci++;
552 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_transformation_options[]" size="16" value="' . (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '" class="textfield" />';
553 //$ci++;
555 } // end for
557 if ( is_array( $content_cells ) && is_array( $header_cells ) ) {
558 // last row is for javascript insert
559 $empty_row = array_pop( $content_cells );
561 echo '<table id="table_columns">';
562 if ( $display_type == 'horizontal' ) {
564 <tr>
565 <?php foreach ( $header_cells as $header_val ) { ?>
566 <th><?php echo $header_val; ?></th>
567 <?php } ?>
568 </tr>
569 <?php
571 $odd_row = true;
572 foreach ( $content_cells as $content_row ) {
573 echo '<tr class="' . ( $odd_row ? 'odd' : 'even' ) . ' noclick">';
574 $odd_row = ! $odd_row;
576 if ( is_array( $content_row ) ) {
577 foreach ($content_row as $content_row_val) {
579 <td align="center"><?php echo $content_row_val; ?></td>
580 <?php
583 echo '</tr>';
585 } else {
586 $i = 0;
587 $odd_row = true;
588 foreach ( $header_cells as $header_val ) {
589 echo '<tr class="' . ( $odd_row ? 'odd' : 'even' ) . ' noclick">';
590 $odd_row = ! $odd_row;
592 <th><?php echo $header_val; ?></th>
593 <?php
594 foreach ( $content_cells as $content_cell ) {
595 if ( isset( $content_cell[$i] ) && $content_cell[$i] != '' ) {
597 <td><?php echo $content_cell[$i]; ?></td>
598 <?php
601 echo '</tr>';
602 $i++;
606 </table>
607 <br />
608 <?php
612 * needs to be finished
615 if ( $display_type == 'horizontal' ) {
616 $new_field = '';
617 foreach ( $empty_row as $content_row_val ) {
618 $new_field .= '<td align="center">' . $content_row_val . '</td>';
621 <script type="text/javascript" language="javascript">
622 <!--
623 var odd_row = <?php echo $odd_row; ?>;
625 function addField() {
626 var new_fields = document.getElementById('added_fields').value;
627 var new_field_container = document.getElementById('table_columns');
628 var new_field = '<?php echo preg_replace( '�\s+�', ' ', preg_replace( '�\'�', '\\\'', $new_field ) ); ?>';
629 var i = 0;
630 for ( i = 0; i < new_fields; i++ ) {
631 if ( odd_row ) {
632 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
633 } else {
634 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
636 odd_row = ! odd_row;
639 return true;
641 // -->
642 </script>
643 <?php
647 if ($action == 'tbl_create.php') {
649 <table>
650 <tr valign="top">
651 <th><?php echo $strTableComments; ?>:&nbsp;</th>
652 <td width="25">&nbsp;</td>
653 <th><?php echo $strStorageEngine; ?>:&nbsp;<?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
654 </th>
655 <?php
656 if ( PMA_MYSQL_INT_VERSION >= 40100 ) {
657 echo ' <td width="25">&nbsp;</td>' . "\n"
658 . ' <th>' . $strCollation . ':&nbsp;</th>' . "\n";
661 </tr>
662 <tr><td><input type="text" name="comment" size="40" maxlength="80"
663 value="<?php echo (isset($comment) ? $comment : ''); ?>"
664 class="textfield" />
665 </td>
666 <td width="25">&nbsp;</td>
667 <td>
668 <?php echo PMA_generateEnginesDropdown('tbl_type', null, FALSE, (isset($GLOBALS['tbl_type']) ? $GLOBALS['tbl_type'] : null), 3); ?>
669 </td>
670 <?php
671 if ( PMA_MYSQL_INT_VERSION >= 40100 ) {
672 echo ' <td width="25">&nbsp;</td>' . "\n"
673 . ' <td>' . "\n"
674 . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, (isset($tbl_collation) ? $tbl_collation : null), FALSE, 3)
675 . ' </td>' . "\n";
678 </tr>
679 </table>
680 <br />
681 <?php
682 } // end if ($action == 'tbl_create.php')
685 <fieldset class="tblFooters">
686 <input type="submit" name="do_save_data" value="<?php echo $strSave; ?>" onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
687 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
688 <?php echo $GLOBALS['strOr']; ?>
689 <?php echo sprintf( $strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />' ); ?>
690 <input type="submit" name="submit_num_fields"
691 value="<?php echo $GLOBALS['strGo']; ?>"
692 <?php /* onclick="if ( addField() ) return false;" */ ?>
693 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)"
695 <?php } ?>
696 </fieldset>
698 </form>
700 <div class="notice">
701 <p> <a name="footnoote_setenumval"><sup>1</sup></a> <?php echo $strSetEnumVal; ?></p>
702 <p> <a name="footnoote_defaultvalue"><sup>2</sup></a> <?php echo $strDefaultValueHelp; ?></p>
703 <?php
704 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
705 echo '<p> <a name="footnoote_mime"><sup>3</sup></a> ' . $strMIME_transformation_options_note . '</p>';
706 echo '<p> ';
707 printf( $strMIME_transformation_note,
708 '<a href="transformation_overview.php?'
709 . PMA_generate_common_url($db, $table) . '" target="_blank">',
710 '</a>' );
711 echo '</p>';
714 </div>
716 <center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>