do not remove the BINARY attribute in drop-down
[phpmyadmin/crack.git] / libraries / tbl_properties.inc.php
blob80afd04b3e3ae6ff68d88e84795f0360de654d92
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 */
8 /**
9 * Check parameters
11 require_once './libraries/common.inc.php';
12 PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
15 // Get available character sets and storage engines
16 require_once './libraries/mysql_charsets.lib.php';
17 require_once './libraries/StorageEngine.class.php';
19 if (is_int($cfg['DefaultPropDisplay'])) {
20 if ($num_fields <= $cfg['DefaultPropDisplay']) {
21 $display_type = 'vertical';
22 } else {
23 $display_type = 'horizontal';
25 } else {
26 $display_type = $cfg['DefaultPropDisplay'];
29 if ($cfg['CtrlArrowsMoving']) {
31 <script src="./js/keyhandler.js" type="text/javascript"></script>
32 <script type="text/javascript">
33 // <![CDATA[
34 var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
35 document.onkeydown = onKeyDownArrowsHandler;
36 // ]]>
37 </script>
38 <?php
40 // here, the div_x_7 represents a div id which contains
41 // the default CURRENT TIMESTAMP checkbox and label
42 // and, field_x_7a represents the checkbox itself
44 if (PMA_MYSQL_INT_VERSION >= 40102) {
46 <script type="text/javascript">
47 // <![CDATA[
48 function display_field_options(field_type, i) {
49 if (field_type == 'TIMESTAMP') {
50 getElement('div_' + i + '_7').style.display = 'block';
51 } else {
52 getElement('div_' + i + '_7').style.display = 'none';
53 getElement('field_' + i + '_7a').checked = false;
55 return true;
57 // ]]>
58 </script>
59 <?php } ?>
61 <form method="post" action="<?php echo $action; ?>">
62 <?php
63 echo PMA_generate_common_hidden_inputs($db, $table);
64 if ($action == 'tbl_create.php') {
66 <input type="hidden" name="reload" value="1" />
67 <?php
68 } elseif ($action == 'tbl_addfield.php') {
70 <input type="hidden" name="field_where" value="<?php echo $field_where; ?>" />
71 <input type="hidden" name="after_field" value="<?php echo PMA_sanitize($after_field); ?>" />
72 <?php
75 if (isset($num_fields)) {
77 <input type="hidden" name="orig_num_fields" value="<?php echo $num_fields; ?>" />
78 <?php
81 if (isset($field_where)) {
83 <input type="hidden" name="orig_field_where" value="<?php echo $field_where; ?>" />
84 <?php
87 if (isset($after_field)) {
89 <input type="hidden" name="orig_after_field" value="<?php echo PMA_sanitize($after_field); ?>" />
90 <?php
93 if (isset($selected) && is_array($selected)) {
94 foreach ($selected AS $o_fld_nr => $o_fld_val) {
96 <input type="hidden" name="selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
97 <?php
98 if (!isset($true_selected)) {
100 <input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
101 <?php
106 if (isset($true_selected) && is_array($true_selected)) {
107 foreach ($true_selected AS $o_fld_nr => $o_fld_val) {
109 <input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
110 <?php
114 } elseif (isset($field)) {
116 <input type="hidden" name="orig_field" value="<?php echo urlencode($field); ?>" />
117 <input type="hidden" name="true_selected[] value="<?php echo (isset($orig_field) ? $orig_field : urlencode($field)); ?>" />
118 <?php
121 $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
123 $header_cells = array();
124 $content_cells = array();
126 $header_cells[] = $strField;
127 $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>');
128 $header_cells[] = $strLengthSet . '<sup>1</sup>';
129 if (PMA_MYSQL_INT_VERSION >= 40100) {
130 $header_cells[] = $strCollation;
132 $header_cells[] = $strAttr;
133 $header_cells[] = $strNull;
134 $header_cells[] = $strDefault . '<sup>2</sup>';
135 $header_cells[] = $strExtra;
139 // lem9: We could remove this 'if' and let the key information be shown and
140 // editable. However, for this to work, tbl_alter must be modified to use the
141 // key fields, as tbl_addfield does.
143 if (!$is_backup) {
144 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_primary.png" width="16" height="16" alt="' . $strPrimary . '" title="' . $strPrimary . '" />' : $strPrimary;
145 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_index.png" width="16" height="16" alt="' . $strIndex . '" title="' . $strIndex . '" />' : $strIndex;
146 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_unique.png" width="16" height="16" alt="' . $strUnique . '" title="' . $strUnique . '" />' : $strUnique;
147 $header_cells[] = '---';
148 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_ftext.png" width="16" height="16" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' : $strIdxFulltext;
151 require_once './libraries/relation.lib.php';
152 require_once './libraries/transformations.lib.php';
153 $cfgRelation = PMA_getRelationsParam();
155 $comments_map = array();
156 $mime_map = array();
157 $available_mime = array();
159 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
160 $comments_map = PMA_getComments($db, $table);
161 $header_cells[] = $strComments;
163 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
164 $mime_map = PMA_getMIME($db, $table);
165 $available_mime = PMA_getAvailableMIMEtypes();
167 $header_cells[] = $strMIME_MIMEtype;
168 $header_cells[] = $strMIME_transformation;
169 $header_cells[] = $strMIME_transformation_options . '<sup>3</sup>';
173 // garvin: workaround for field_fulltext, because its submitted indizes contain
174 // the index as a value, not a key. Inserted here for easier maintaineance
175 // and less code to change in existing files.
176 if (isset($field_fulltext) && is_array($field_fulltext)) {
177 foreach ($field_fulltext AS $fulltext_nr => $fulltext_indexkey) {
178 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
182 for ($i = 0 ; $i <= $num_fields; $i++) {
183 $submit_null = FALSE;
184 if (isset($regenerate) && $regenerate == TRUE) {
185 // An error happened with previous inputs, so we will restore the data
186 // to embed it once again in this form.
188 $row['Field'] = (isset($field_name) && isset($field_name[$i]) ? $field_name[$i] : FALSE);
189 $row['Type'] = (isset($field_type) && isset($field_type[$i]) ? $field_type[$i] : FALSE);
190 if (PMA_MYSQL_INT_VERSION >= 40100) {
191 $row['Collation'] = (isset($field_collation) && isset($field_collation[$i]) ? $field_collation[$i] : '');
193 $row['Null'] = (isset($field_null) && isset($field_null[$i]) ? $field_null[$i] : '');
194 if (isset($field_type[$i]) && $row['Null'] == '') {
195 $submit_null = TRUE;
198 if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) {
199 $row['Key'] = 'PRI';
200 } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) {
201 $row['Key'] = 'MUL';
202 } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) {
203 $row['Key'] = 'UNI';
204 } else {
205 $row['Key'] = '';
208 $row['Default'] = (isset($field_default) && isset($field_default[$i]) ? $field_default[$i] : FALSE);
209 $row['Extra'] = (isset($field_extra) && isset($field_extra[$i]) ? $field_extra[$i] : FALSE);
210 $row['Comment'] = (isset($submit_fulltext) && isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE);
212 $submit_length = (isset($field_length) && isset($field_length[$i]) ? $field_length[$i] : FALSE);
213 $submit_attribute = (isset($field_attribute) && isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE);
215 $submit_default_current_timestamp = (isset($field_default_current_timestamp) && isset($field_default_current_timestamp[$i]) ? TRUE : FALSE);
217 if (isset($field_comments) && isset($field_comments[$i])) {
218 $comments_map[$row['Field']] = $field_comments[$i];
221 if (isset($field_mimetype) && isset($field_mimetype[$i])) {
222 $mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i];
225 if (isset($field_transformation) && isset($field_transformation[$i])) {
226 $mime_map[$row['Field']]['transformation'] = $field_transformation[$i];
229 if (isset($field_transformation_options) && isset($field_transformation_options[$i])) {
230 $mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i];
233 } elseif (isset($fields_meta) && isset($fields_meta[$i])) {
234 $row = $fields_meta[$i];
237 if (isset($row) && isset($row['Type'])) {
238 $type_and_length = PMA_extract_type_length($row['Type']);
239 if ($type_and_length['type'] == 'bit') {
240 $row['Default'] = PMA_printable_bit_value($row['Default'], $type_and_length['length']);
244 // Cell index: If certain fields get left out, the counter shouldn't chage.
245 $ci = 0;
246 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
247 // has to be incremented ($ci_offset++)
248 $ci_offset = -1;
250 if ($is_backup) {
251 $backup_field = (isset($true_selected) && isset($true_selected[$i]) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : ''));
252 $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_orig[]" value="' . $backup_field . '" />' . "\n";
253 } else {
254 $content_cells[$i][$ci] = '';
257 $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 . '" />';
258 $ci++;
259 $content_cells[$i][$ci] = '<select name="field_type[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '" ';
260 if (PMA_MYSQL_INT_VERSION >= 40102) {
261 $content_cells[$i][$ci] .= 'onchange="display_field_options(this.options[this.selectedIndex].value,' . $i .')" ';
263 $content_cells[$i][$ci] .= '>' . "\n";
265 if (empty($row['Type'])) {
266 $row['Type'] = '';
267 $type = '';
268 } else {
269 $type = $row['Type'];
271 // set or enum types: slashes single quotes inside options
272 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
273 $type = $tmp[1];
274 $length = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
275 } else {
276 // strip the "BINARY" attribute, except if we find "BINARY(" because
277 // this would be a BINARY or VARBINARY field type
278 $type = preg_replace('@BINARY([^\(])@i', '', $type);
279 $type = preg_replace('@ZEROFILL@i', '', $type);
280 $type = preg_replace('@UNSIGNED@i', '', $type);
282 $type_and_length = PMA_extract_type_length($type);
283 $type = $type_and_length['type'];
284 $length = $type_and_length['length'];
285 unset($type_and_length);
286 } // end if else
288 // some types, for example longtext, are reported as
289 // "longtext character set latin7" when their charset and / or collation
290 // differs from the ones of the corresponding database.
291 if (PMA_MYSQL_INT_VERSION >= 40100) {
292 $tmp = strpos($type, 'character set');
293 if ($tmp) {
294 $type = substr($type, 0, $tmp-1);
298 if (isset($submit_length) && $submit_length != FALSE) {
299 $length = $submit_length;
302 // rtrim the type, for cases like "float unsigned"
303 $type = rtrim($type);
304 $type_upper = strtoupper($type);
306 $cnt_column_types = count($cfg['ColumnTypes']);
307 for ($j = 0; $j < $cnt_column_types; $j++) {
308 $content_cells[$i][$ci] .= ' <option value="'. $cfg['ColumnTypes'][$j] . '"';
309 if ($type_upper == strtoupper($cfg['ColumnTypes'][$j])) {
310 $content_cells[$i][$ci] .= ' selected="selected"';
312 $content_cells[$i][$ci] .= '>' . $cfg['ColumnTypes'][$j] . '</option>' . "\n";
313 } // end for
315 $content_cells[$i][$ci] .= ' </select>';
316 $ci++;
318 if ($is_backup) {
319 $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_length_orig[]" value="' . urlencode($length) . '" />';
320 } else {
321 $content_cells[$i][$ci] = '';
324 if (preg_match('@^(set|enum)$@i', $type)) {
325 $binary = 0;
326 $unsigned = 0;
327 $zerofill = 0;
328 $length_to_display = htmlspecialchars($length);
329 } else {
330 $length_to_display = $length;
331 if (!preg_match('@BINARY[\(]@i', $row['Type']) && PMA_MYSQL_INT_VERSION < 40100) {
332 $binary = stristr($row['Type'], 'binary');
333 } else {
334 $binary = FALSE;
336 $unsigned = stristr($row['Type'], 'unsigned');
337 $zerofill = stristr($row['Type'], 'zerofill');
340 $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";
341 $ci++;
343 if (PMA_MYSQL_INT_VERSION >= 40100) {
344 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
345 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[]', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, FALSE);
346 unset($tmp_collation);
347 $ci++;
350 $content_cells[$i][$ci] = '<select style="font-size: 70%;" name="field_attribute[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">' . "\n";
352 $attribute = '';
353 if ($binary) {
354 $attribute = 'BINARY';
356 if ($unsigned) {
357 $attribute = 'UNSIGNED';
359 if ($zerofill) {
360 $attribute = 'UNSIGNED ZEROFILL';
363 if (isset($submit_attribute) && $submit_attribute != FALSE) {
364 $attribute = $submit_attribute;
367 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
368 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
369 // the latter.
370 if (isset($row['Field'])
371 && isset($analyzed_sql[0])
372 && isset($analyzed_sql[0]['create_table_fields'])
373 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
374 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
375 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
376 $row['Null'] = '';
379 // MySQL 4.1.2+ TIMESTAMP options
380 // (if on_update_current_timestamp is set, then it's TRUE)
381 if (isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
382 $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
384 if ((isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
385 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
386 $default_current_timestamp = TRUE;
387 } else {
388 $default_current_timestamp = FALSE;
391 // Dynamically add ON UPDATE CURRENT_TIMESTAMP to the possible attributes
392 if (PMA_MYSQL_INT_VERSION >= 40102 && !in_array('ON UPDATE CURRENT_TIMESTAMP', $cfg['AttributeTypes'])) {
393 $cfg['AttributeTypes'][] = 'ON UPDATE CURRENT_TIMESTAMP';
397 $cnt_attribute_types = count($cfg['AttributeTypes']);
398 for ($j = 0;$j < $cnt_attribute_types; $j++) {
399 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
400 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
401 $content_cells[$i][$ci] .= ' selected="selected"';
403 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n";
406 $content_cells[$i][$ci] .= '</select>';
407 $ci++;
409 $content_cells[$i][$ci] = '<select name="field_null[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
411 if ((!isset($row) || empty($row['Null']) || $row['Null'] == 'NO' || $row['Null'] == 'NOT NULL') && $submit_null == FALSE) {
412 $content_cells[$i][$ci] .= "\n";
413 $content_cells[$i][$ci] .= ' <option value="NOT NULL" selected="selected" >not null</option>' . "\n";
414 $content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n";
415 } else {
416 $content_cells[$i][$ci] .= "\n";
417 $content_cells[$i][$ci] .= ' <option value="" selected="selected" >null</option>' . "\n";
418 $content_cells[$i][$ci] .= ' <option value="NOT NULL">not null</option>' . "\n";
421 $content_cells[$i][$ci] .= "\n" . '</select>';
422 $ci++;
424 if (isset($row)
425 && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
426 $row['Default'] = 'NULL';
429 if ($is_backup) {
430 $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_default_orig[]" size="8" value="' . (isset($row) && isset($row['Default']) ? urlencode($row['Default']) : '') . '" />';
431 } else {
432 $content_cells[$i][$ci] = "\n";
435 // for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
436 if (PMA_MYSQL_INT_VERSION >= 40102
437 && $type_upper == 'TIMESTAMP'
438 && $default_current_timestamp
439 && isset($row)
440 && isset($row['Default'])) {
441 $row['Default'] = '';
444 $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" />';
445 if (PMA_MYSQL_INT_VERSION >= 40102) {
446 if ($type_upper == 'TIMESTAMP') {
447 $tmp_display_type = 'block';
448 } else {
449 $tmp_display_type = 'none';
450 $default_current_timestamp = FALSE;
452 $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 . ']"';
453 if ($default_current_timestamp) {
454 $content_cells[$i][$ci] .= ' checked="checked" ';
456 $content_cells[$i][$ci] .= ' /><label for="field_' . $i . '_' . ($ci - $ci_offset) . 'a" style="font-size: 70%;">CURRENT_TIMESTAMP</label></div>';
458 $ci++;
460 $content_cells[$i][$ci] = '<select name="field_extra[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
462 if (!isset($row) || empty($row['Extra'])) {
463 $content_cells[$i][$ci] .= "\n";
464 $content_cells[$i][$ci] .= '<option value="">&nbsp;</option>' . "\n";
465 $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
466 } else {
467 $content_cells[$i][$ci] .= "\n";
468 $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
469 $content_cells[$i][$ci] .= '<option value="">&nbsp;</option>' . "\n";
472 $content_cells[$i][$ci] .= "\n" . '</select>';
473 $ci++;
476 // lem9: See my other comment about removing this 'if'.
477 if (!$is_backup) {
478 if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
479 $checked_primary = ' checked="checked"';
480 } else {
481 $checked_primary = '';
483 if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
484 $checked_index = ' checked="checked"';
485 } else {
486 $checked_index = '';
488 if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
489 $checked_unique = ' checked="checked"';
490 } else {
491 $checked_unique = '';
493 if (empty($checked_primary)
494 && empty($checked_index)
495 && empty($checked_unique)) {
496 $checked_none = ' checked="checked"';
497 } else {
498 $checked_none = '';
501 if ((isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
502 $checked_fulltext = ' checked="checked"';
503 } else {
504 $checked_fulltext = '';
507 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="primary_' . $i . '"' . $checked_primary . ' title="' . $strPrimary . '" />';
508 $ci++;
510 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="index_' . $i . '"' . $checked_index . ' title="' . $strIndex . '" />';
511 $ci++;
513 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="unique_' . $i . '"' . $checked_unique . ' title="' . $strUnique . '" />';
514 $ci++;
516 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="none_' . $i . '"' . $checked_none . ' title="---" />';
517 $ci++;
519 $content_cells[$i][$ci] = '<input type="checkbox" name="field_fulltext[]" value="' . $i . '"' . $checked_fulltext . ' title="' . $strIdxFulltext . '" />';
520 $ci++;
521 } // end if ($action ==...)
523 // garvin: comments
524 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
525 $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" />';
526 $ci++;
529 // garvin: MIME-types
530 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
531 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[]">' . "\n";
532 $content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>' . "\n";
534 if (is_array($available_mime['mimetype'])) {
535 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
536 $checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
537 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
541 $content_cells[$i][$ci] .= '</select>';
542 $ci++;
544 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[]">' . "\n";
545 $content_cells[$i][$ci] .= ' <option value="" title="' . $strNone . '"></option>' . "\n";
546 if (is_array($available_mime['transformation'])) {
547 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
548 $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 ' : '');
549 $tooltip = 'strTransformation_' . strtolower(preg_replace('@(\.inc\.php3?)$@', '', $available_mime['transformation_file'][$mimekey]));
550 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()');
551 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>' . "\n";
555 $content_cells[$i][$ci] .= '</select>';
556 $ci++;
558 $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" />';
559 //$ci++;
561 } // end for
563 if (is_array($content_cells) && is_array($header_cells)) {
564 // last row is for javascript insert
565 $empty_row = array_pop($content_cells);
567 echo '<table id="table_columns">';
568 if ($display_type == 'horizontal') {
570 <tr>
571 <?php foreach ($header_cells as $header_val) { ?>
572 <th><?php echo $header_val; ?></th>
573 <?php } ?>
574 </tr>
575 <?php
577 $odd_row = true;
578 foreach ($content_cells as $content_row) {
579 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
580 $odd_row = ! $odd_row;
582 if (is_array($content_row)) {
583 foreach ($content_row as $content_row_val) {
585 <td align="center"><?php echo $content_row_val; ?></td>
586 <?php
589 echo '</tr>';
591 } else {
592 $i = 0;
593 $odd_row = true;
594 foreach ($header_cells as $header_val) {
595 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
596 $odd_row = ! $odd_row;
598 <th><?php echo $header_val; ?></th>
599 <?php
600 foreach ($content_cells as $content_cell) {
601 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
603 <td><?php echo $content_cell[$i]; ?></td>
604 <?php
607 echo '</tr>';
608 $i++;
612 </table>
613 <br />
614 <?php
618 * needs to be finished
621 if ($display_type == 'horizontal') {
622 $new_field = '';
623 foreach ($empty_row as $content_row_val) {
624 $new_field .= '<td align="center">' . $content_row_val . '</td>';
627 <script type="text/javascript">
628 // <![CDATA[
629 var odd_row = <?php echo $odd_row; ?>;
631 function addField() {
632 var new_fields = document.getElementById('added_fields').value;
633 var new_field_container = document.getElementById('table_columns');
634 var new_field = '<?php echo preg_replace('�\s+�', ' ', preg_replace('�\'�', '\\\'', $new_field)); ?>';
635 var i = 0;
636 for (i = 0; i < new_fields; i++) {
637 if (odd_row) {
638 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
639 } else {
640 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
642 odd_row = ! odd_row;
645 return true;
647 // ]]>
648 </script>
649 <?php
653 if ($action == 'tbl_create.php') {
655 <table>
656 <tr valign="top">
657 <th><?php echo $strTableComments; ?>:&nbsp;</th>
658 <td width="25">&nbsp;</td>
659 <th><?php echo $strStorageEngine; ?>:&nbsp;<?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
660 </th>
661 <?php
662 if (PMA_MYSQL_INT_VERSION >= 40100) {
663 echo ' <td width="25">&nbsp;</td>' . "\n"
664 . ' <th>' . $strCollation . ':&nbsp;</th>' . "\n";
667 </tr>
668 <tr><td><input type="text" name="comment" size="40" maxlength="80"
669 value="<?php echo (isset($comment) ? $comment : ''); ?>"
670 class="textfield" />
671 </td>
672 <td width="25">&nbsp;</td>
673 <td>
674 <?php echo PMA_StorageEngine::getHtmlSelect('tbl_type', null, (isset($GLOBALS['tbl_type']) ? $GLOBALS['tbl_type'] : null)); ?>
675 </td>
676 <?php
677 if (PMA_MYSQL_INT_VERSION >= 40100) {
678 echo ' <td width="25">&nbsp;</td>' . "\n"
679 . ' <td>' . "\n"
680 . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, (isset($tbl_collation) ? $tbl_collation : null), FALSE, 3)
681 . ' </td>' . "\n";
684 </tr>
685 </table>
686 <br />
687 <?php
688 } // end if ($action == 'tbl_create.php')
691 <fieldset class="tblFooters">
692 <input type="submit" name="do_save_data" value="<?php echo $strSave; ?>" onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
693 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
694 <?php echo $GLOBALS['strOr']; ?>
695 <?php echo sprintf($strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
696 <input type="submit" name="submit_num_fields"
697 value="<?php echo $GLOBALS['strGo']; ?>"
698 <?php /* onclick="if (addField()) return false;" */ ?>
699 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)"
701 <?php } ?>
702 </fieldset>
704 </form>
706 <div class="notice">
707 <p> <a name="footnoote_setenumval"><sup>1</sup></a> <?php echo $strSetEnumVal; ?></p>
708 <p> <a name="footnoote_defaultvalue"><sup>2</sup></a> <?php echo $strDefaultValueHelp; ?></p>
709 <?php
710 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
711 echo '<p> <a name="footnoote_mime"><sup>3</sup></a> ' . $strMIME_transformation_options_note . '</p>';
712 echo '<p> ';
713 printf($strMIME_transformation_note,
714 '<a href="transformation_overview.php?'
715 . PMA_generate_common_url($db, $table) . '" target="_blank">',
716 '</a>');
717 echo '</p>';
720 </div>
722 <center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>