Fix for the Open in New Window in Patient/Client->Patients search gui, take 2.
[openemr.git] / phpmyadmin / libraries / tbl_properties.inc.php
blobe933ed32a4cac6ce77c43ba5a1f34e68f9c8c70f
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 */
7 if (! defined('PHPMYADMIN')) {
8 exit;
11 /**
12 * Check parameters
14 require_once './libraries/common.inc.php';
15 PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
18 // Get available character sets and storage engines
19 require_once './libraries/mysql_charsets.lib.php';
20 require_once './libraries/StorageEngine.class.php';
22 if (is_int($cfg['DefaultPropDisplay'])) {
23 if ($num_fields <= $cfg['DefaultPropDisplay']) {
24 $display_type = 'vertical';
25 } else {
26 $display_type = 'horizontal';
28 } else {
29 $display_type = $cfg['DefaultPropDisplay'];
32 if ($cfg['CtrlArrowsMoving']) {
34 <script src="./js/keyhandler.js" type="text/javascript"></script>
35 <script type="text/javascript">
36 // <![CDATA[
37 var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
38 document.onkeydown = onKeyDownArrowsHandler;
39 // ]]>
40 </script>
41 <?php
43 // here, the div_x_7 represents a div id which contains
44 // the default CURRENT TIMESTAMP checkbox and label
45 // and, field_x_7a represents the checkbox itself
47 if (PMA_MYSQL_INT_VERSION >= 40102) {
49 <script type="text/javascript">
50 // <![CDATA[
51 function display_field_options(field_type, i) {
52 if (field_type == 'TIMESTAMP') {
53 getElement('div_' + i + '_7').style.display = 'block';
54 } else {
55 getElement('div_' + i + '_7').style.display = 'none';
56 getElement('field_' + i + '_7a').checked = false;
58 return true;
60 // ]]>
61 </script>
62 <?php } ?>
64 <form method="post" action="<?php echo $action; ?>">
65 <?php
66 echo PMA_generate_common_hidden_inputs($db, $table);
67 if ($action == 'tbl_create.php') {
69 <input type="hidden" name="reload" value="1" />
70 <?php
71 } elseif ($action == 'tbl_addfield.php') {
73 <input type="hidden" name="field_where" value="<?php echo $field_where; ?>" />
74 <input type="hidden" name="after_field" value="<?php echo PMA_sanitize($after_field); ?>" />
75 <?php
78 if (isset($num_fields)) {
80 <input type="hidden" name="orig_num_fields" value="<?php echo $num_fields; ?>" />
81 <?php
84 if (isset($field_where)) {
86 <input type="hidden" name="orig_field_where" value="<?php echo $field_where; ?>" />
87 <?php
90 if (isset($after_field)) {
92 <input type="hidden" name="orig_after_field" value="<?php echo PMA_sanitize($after_field); ?>" />
93 <?php
96 if (isset($selected) && is_array($selected)) {
97 foreach ($selected AS $o_fld_nr => $o_fld_val) {
99 <input type="hidden" name="selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
100 <?php
101 if (!isset($true_selected)) {
103 <input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
104 <?php
109 if (isset($true_selected) && is_array($true_selected)) {
110 foreach ($true_selected AS $o_fld_nr => $o_fld_val) {
112 <input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
113 <?php
117 } elseif (isset($field)) {
119 <input type="hidden" name="orig_field" value="<?php echo urlencode($field); ?>" />
120 <input type="hidden" name="true_selected[] value="<?php echo (isset($orig_field) ? $orig_field : urlencode($field)); ?>" />
121 <?php
124 $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
126 $header_cells = array();
127 $content_cells = array();
129 $header_cells[] = $strField;
130 $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>');
131 $header_cells[] = $strLengthSet . '<sup>1</sup>';
132 if (PMA_MYSQL_INT_VERSION >= 40100) {
133 $header_cells[] = $strCollation;
135 $header_cells[] = $strAttr;
136 $header_cells[] = $strNull;
137 $header_cells[] = $strDefault . '<sup>2</sup>';
138 $header_cells[] = $strExtra;
142 // lem9: We could remove this 'if' and let the key information be shown and
143 // editable. However, for this to work, tbl_alter must be modified to use the
144 // key fields, as tbl_addfield does.
146 if (!$is_backup) {
147 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_primary.png" width="16" height="16" alt="' . $strPrimary . '" title="' . $strPrimary . '" />' : $strPrimary;
148 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_index.png" width="16" height="16" alt="' . $strIndex . '" title="' . $strIndex . '" />' : $strIndex;
149 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_unique.png" width="16" height="16" alt="' . $strUnique . '" title="' . $strUnique . '" />' : $strUnique;
150 $header_cells[] = '---';
151 $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_ftext.png" width="16" height="16" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' : $strIdxFulltext;
154 require_once './libraries/relation.lib.php';
155 require_once './libraries/transformations.lib.php';
156 $cfgRelation = PMA_getRelationsParam();
158 $comments_map = array();
159 $mime_map = array();
160 $available_mime = array();
162 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
163 $comments_map = PMA_getComments($db, $table);
164 $header_cells[] = $strComments;
166 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
167 $mime_map = PMA_getMIME($db, $table);
168 $available_mime = PMA_getAvailableMIMEtypes();
170 $header_cells[] = $strMIME_MIMEtype;
171 $header_cells[] = $strMIME_transformation;
172 $header_cells[] = $strMIME_transformation_options . '<sup>3</sup>';
176 // garvin: workaround for field_fulltext, because its submitted indizes contain
177 // the index as a value, not a key. Inserted here for easier maintaineance
178 // and less code to change in existing files.
179 if (isset($field_fulltext) && is_array($field_fulltext)) {
180 foreach ($field_fulltext AS $fulltext_nr => $fulltext_indexkey) {
181 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
185 for ($i = 0 ; $i <= $num_fields; $i++) {
186 $submit_null = FALSE;
187 if (isset($regenerate) && $regenerate == TRUE) {
188 // An error happened with previous inputs, so we will restore the data
189 // to embed it once again in this form.
191 $row['Field'] = (isset($field_name) && isset($field_name[$i]) ? $field_name[$i] : FALSE);
192 $row['Type'] = (isset($field_type) && isset($field_type[$i]) ? $field_type[$i] : FALSE);
193 if (PMA_MYSQL_INT_VERSION >= 40100) {
194 $row['Collation'] = (isset($field_collation) && isset($field_collation[$i]) ? $field_collation[$i] : '');
196 $row['Null'] = (isset($field_null) && isset($field_null[$i]) ? $field_null[$i] : '');
197 if (isset($field_type[$i]) && $row['Null'] == '') {
198 $submit_null = TRUE;
201 if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) {
202 $row['Key'] = 'PRI';
203 } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) {
204 $row['Key'] = 'MUL';
205 } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) {
206 $row['Key'] = 'UNI';
207 } else {
208 $row['Key'] = '';
211 $row['Default'] = (isset($field_default) && isset($field_default[$i]) ? $field_default[$i] : FALSE);
212 $row['Extra'] = (isset($field_extra) && isset($field_extra[$i]) ? $field_extra[$i] : FALSE);
213 $row['Comment'] = (isset($submit_fulltext) && isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE);
215 $submit_length = (isset($field_length) && isset($field_length[$i]) ? $field_length[$i] : FALSE);
216 $submit_attribute = (isset($field_attribute) && isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE);
218 $submit_default_current_timestamp = (isset($field_default_current_timestamp) && isset($field_default_current_timestamp[$i]) ? TRUE : FALSE);
220 if (isset($field_comments) && isset($field_comments[$i])) {
221 $comments_map[$row['Field']] = $field_comments[$i];
224 if (isset($field_mimetype) && isset($field_mimetype[$i])) {
225 $mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i];
228 if (isset($field_transformation) && isset($field_transformation[$i])) {
229 $mime_map[$row['Field']]['transformation'] = $field_transformation[$i];
232 if (isset($field_transformation_options) && isset($field_transformation_options[$i])) {
233 $mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i];
236 } elseif (isset($fields_meta) && isset($fields_meta[$i])) {
237 $row = $fields_meta[$i];
240 if (isset($row) && isset($row['Type'])) {
241 $type_and_length = PMA_extract_type_length($row['Type']);
242 if ($type_and_length['type'] == 'bit') {
243 $row['Default'] = PMA_printable_bit_value($row['Default'], $type_and_length['length']);
247 // Cell index: If certain fields get left out, the counter shouldn't chage.
248 $ci = 0;
249 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
250 // has to be incremented ($ci_offset++)
251 $ci_offset = -1;
253 if ($is_backup) {
254 $backup_field = (isset($true_selected) && isset($true_selected[$i]) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : ''));
255 $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_orig[]" value="' . $backup_field . '" />' . "\n";
256 } else {
257 $content_cells[$i][$ci] = '';
260 $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 . '" />';
261 $ci++;
262 $content_cells[$i][$ci] = '<select name="field_type[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '" ';
263 if (PMA_MYSQL_INT_VERSION >= 40102) {
264 $content_cells[$i][$ci] .= 'onchange="display_field_options(this.options[this.selectedIndex].value,' . $i .')" ';
266 $content_cells[$i][$ci] .= '>' . "\n";
268 if (empty($row['Type'])) {
269 $row['Type'] = '';
270 $type = '';
271 } else {
272 $type = $row['Type'];
274 // set or enum types: slashes single quotes inside options
275 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
276 $type = $tmp[1];
277 $length = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
278 } else {
279 // strip the "BINARY" attribute, except if we find "BINARY(" because
280 // this would be a BINARY or VARBINARY field type
281 $type = preg_replace('@BINARY([^\(])@i', '', $type);
282 $type = preg_replace('@ZEROFILL@i', '', $type);
283 $type = preg_replace('@UNSIGNED@i', '', $type);
285 $type_and_length = PMA_extract_type_length($type);
286 $type = $type_and_length['type'];
287 $length = $type_and_length['length'];
288 unset($type_and_length);
289 } // end if else
291 // some types, for example longtext, are reported as
292 // "longtext character set latin7" when their charset and / or collation
293 // differs from the ones of the corresponding database.
294 if (PMA_MYSQL_INT_VERSION >= 40100) {
295 $tmp = strpos($type, 'character set');
296 if ($tmp) {
297 $type = substr($type, 0, $tmp-1);
301 if (isset($submit_length) && $submit_length != FALSE) {
302 $length = $submit_length;
305 // rtrim the type, for cases like "float unsigned"
306 $type = rtrim($type);
307 $type_upper = strtoupper($type);
309 $cnt_column_types = count($cfg['ColumnTypes']);
310 for ($j = 0; $j < $cnt_column_types; $j++) {
311 $content_cells[$i][$ci] .= ' <option value="'. $cfg['ColumnTypes'][$j] . '"';
312 if ($type_upper == strtoupper($cfg['ColumnTypes'][$j])) {
313 $content_cells[$i][$ci] .= ' selected="selected"';
315 $content_cells[$i][$ci] .= '>' . $cfg['ColumnTypes'][$j] . '</option>' . "\n";
316 } // end for
318 $content_cells[$i][$ci] .= ' </select>';
319 $ci++;
321 if ($is_backup) {
322 $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_length_orig[]" value="' . urlencode($length) . '" />';
323 } else {
324 $content_cells[$i][$ci] = '';
327 if (preg_match('@^(set|enum)$@i', $type)) {
328 $binary = 0;
329 $unsigned = 0;
330 $zerofill = 0;
331 $length_to_display = htmlspecialchars($length);
332 } else {
333 $length_to_display = $length;
334 if (!preg_match('@BINARY[\(]@i', $row['Type']) && PMA_MYSQL_INT_VERSION < 40100) {
335 $binary = stristr($row['Type'], 'binary');
336 } else {
337 $binary = FALSE;
339 $unsigned = stristr($row['Type'], 'unsigned');
340 $zerofill = stristr($row['Type'], 'zerofill');
343 $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";
344 $ci++;
346 if (PMA_MYSQL_INT_VERSION >= 40100) {
347 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
348 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[]', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, FALSE);
349 unset($tmp_collation);
350 $ci++;
353 $content_cells[$i][$ci] = '<select style="font-size: 70%;" name="field_attribute[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">' . "\n";
355 $attribute = '';
356 if ($binary) {
357 $attribute = 'BINARY';
359 if ($unsigned) {
360 $attribute = 'UNSIGNED';
362 if ($zerofill) {
363 $attribute = 'UNSIGNED ZEROFILL';
365 if (isset($row['Extra']) && $row['Extra'] == 'ON UPDATE CURRENT_TIMESTAMP') {
366 $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
369 if (isset($submit_attribute) && $submit_attribute != FALSE) {
370 $attribute = $submit_attribute;
373 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
374 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
375 // the latter.
376 if (isset($row['Field'])
377 && isset($analyzed_sql[0])
378 && isset($analyzed_sql[0]['create_table_fields'])
379 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
380 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
381 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
382 $row['Null'] = '';
385 // MySQL 4.1.2+ TIMESTAMP options
386 // (if on_update_current_timestamp is set, then it's TRUE)
387 if (isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
388 $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
390 if ((isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
391 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
392 $default_current_timestamp = TRUE;
393 } else {
394 $default_current_timestamp = FALSE;
397 // Dynamically add ON UPDATE CURRENT_TIMESTAMP to the possible attributes
398 if (PMA_MYSQL_INT_VERSION >= 40102 && !in_array('ON UPDATE CURRENT_TIMESTAMP', $cfg['AttributeTypes'])) {
399 $cfg['AttributeTypes'][] = 'ON UPDATE CURRENT_TIMESTAMP';
403 $cnt_attribute_types = count($cfg['AttributeTypes']);
404 for ($j = 0;$j < $cnt_attribute_types; $j++) {
405 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
406 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
407 $content_cells[$i][$ci] .= ' selected="selected"';
409 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n";
412 $content_cells[$i][$ci] .= '</select>';
413 $ci++;
415 $content_cells[$i][$ci] = '<select name="field_null[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
417 if ((!isset($row) || empty($row['Null']) || $row['Null'] == 'NO' || $row['Null'] == 'NOT NULL') && $submit_null == FALSE) {
418 $content_cells[$i][$ci] .= "\n";
419 $content_cells[$i][$ci] .= ' <option value="NOT NULL" selected="selected" >not null</option>' . "\n";
420 $content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n";
421 } else {
422 $content_cells[$i][$ci] .= "\n";
423 $content_cells[$i][$ci] .= ' <option value="" selected="selected" >null</option>' . "\n";
424 $content_cells[$i][$ci] .= ' <option value="NOT NULL">not null</option>' . "\n";
427 $content_cells[$i][$ci] .= "\n" . '</select>';
428 $ci++;
430 if (isset($row)
431 && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
432 $row['Default'] = 'NULL';
435 if ($is_backup) {
436 $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_default_orig[]" size="8" value="' . (isset($row) && isset($row['Default']) ? urlencode($row['Default']) : '') . '" />';
437 } else {
438 $content_cells[$i][$ci] = "\n";
441 // for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
442 if (PMA_MYSQL_INT_VERSION >= 40102
443 && $type_upper == 'TIMESTAMP'
444 && $default_current_timestamp
445 && isset($row)
446 && isset($row['Default'])) {
447 $row['Default'] = '';
450 $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" />';
451 if (PMA_MYSQL_INT_VERSION >= 40102) {
452 if ($type_upper == 'TIMESTAMP') {
453 $tmp_display_type = 'block';
454 } else {
455 $tmp_display_type = 'none';
456 $default_current_timestamp = FALSE;
458 $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 . ']"';
459 if ($default_current_timestamp) {
460 $content_cells[$i][$ci] .= ' checked="checked" ';
462 $content_cells[$i][$ci] .= ' /><label for="field_' . $i . '_' . ($ci - $ci_offset) . 'a" style="font-size: 70%;">CURRENT_TIMESTAMP</label></div>';
464 $ci++;
466 $content_cells[$i][$ci] = '<select name="field_extra[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
468 if (!isset($row) || empty($row['Extra']) || $row['Extra'] != 'auto_increment') {
469 $content_cells[$i][$ci] .= "\n";
470 $content_cells[$i][$ci] .= '<option value="">&nbsp;</option>' . "\n";
471 $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
472 } else {
473 $content_cells[$i][$ci] .= "\n";
474 $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
475 $content_cells[$i][$ci] .= '<option value="">&nbsp;</option>' . "\n";
478 $content_cells[$i][$ci] .= "\n" . '</select>';
479 $ci++;
482 // lem9: See my other comment about removing this 'if'.
483 if (!$is_backup) {
484 if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
485 $checked_primary = ' checked="checked"';
486 } else {
487 $checked_primary = '';
489 if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
490 $checked_index = ' checked="checked"';
491 } else {
492 $checked_index = '';
494 if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
495 $checked_unique = ' checked="checked"';
496 } else {
497 $checked_unique = '';
499 if (empty($checked_primary)
500 && empty($checked_index)
501 && empty($checked_unique)) {
502 $checked_none = ' checked="checked"';
503 } else {
504 $checked_none = '';
507 if ((isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
508 $checked_fulltext = ' checked="checked"';
509 } else {
510 $checked_fulltext = '';
513 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="primary_' . $i . '"' . $checked_primary . ' title="' . $strPrimary . '" />';
514 $ci++;
516 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="index_' . $i . '"' . $checked_index . ' title="' . $strIndex . '" />';
517 $ci++;
519 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="unique_' . $i . '"' . $checked_unique . ' title="' . $strUnique . '" />';
520 $ci++;
522 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="none_' . $i . '"' . $checked_none . ' title="---" />';
523 $ci++;
525 $content_cells[$i][$ci] = '<input type="checkbox" name="field_fulltext[]" value="' . $i . '"' . $checked_fulltext . ' title="' . $strIdxFulltext . '" />';
526 $ci++;
527 } // end if ($action ==...)
529 // garvin: comments
530 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
531 $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" />';
532 $ci++;
535 // garvin: MIME-types
536 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
537 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[]">' . "\n";
538 $content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>' . "\n";
540 if (is_array($available_mime['mimetype'])) {
541 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
542 $checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
543 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
547 $content_cells[$i][$ci] .= '</select>';
548 $ci++;
550 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[]">' . "\n";
551 $content_cells[$i][$ci] .= ' <option value="" title="' . $strNone . '"></option>' . "\n";
552 if (is_array($available_mime['transformation'])) {
553 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
554 $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 ' : '');
555 $tooltip = 'strTransformation_' . strtolower(preg_replace('@(\.inc\.php3?)$@', '', $available_mime['transformation_file'][$mimekey]));
556 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()');
557 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>' . "\n";
561 $content_cells[$i][$ci] .= '</select>';
562 $ci++;
564 $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" />';
565 //$ci++;
567 } // end for
569 if (is_array($content_cells) && is_array($header_cells)) {
570 // last row is for javascript insert
571 $empty_row = array_pop($content_cells);
573 echo '<table id="table_columns">';
574 if ($display_type == 'horizontal') {
576 <tr>
577 <?php foreach ($header_cells as $header_val) { ?>
578 <th><?php echo $header_val; ?></th>
579 <?php } ?>
580 </tr>
581 <?php
583 $odd_row = true;
584 foreach ($content_cells as $content_row) {
585 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
586 $odd_row = ! $odd_row;
588 if (is_array($content_row)) {
589 foreach ($content_row as $content_row_val) {
591 <td align="center"><?php echo $content_row_val; ?></td>
592 <?php
595 echo '</tr>';
597 } else {
598 $i = 0;
599 $odd_row = true;
600 foreach ($header_cells as $header_val) {
601 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
602 $odd_row = ! $odd_row;
604 <th><?php echo $header_val; ?></th>
605 <?php
606 foreach ($content_cells as $content_cell) {
607 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
609 <td><?php echo $content_cell[$i]; ?></td>
610 <?php
613 echo '</tr>';
614 $i++;
618 </table>
619 <br />
620 <?php
624 * needs to be finished
627 if ($display_type == 'horizontal') {
628 $new_field = '';
629 foreach ($empty_row as $content_row_val) {
630 $new_field .= '<td align="center">' . $content_row_val . '</td>';
633 <script type="text/javascript">
634 // <![CDATA[
635 var odd_row = <?php echo $odd_row; ?>;
637 function addField() {
638 var new_fields = document.getElementById('added_fields').value;
639 var new_field_container = document.getElementById('table_columns');
640 var new_field = '<?php echo preg_replace('�\s+�', ' ', preg_replace('�\'�', '\\\'', $new_field)); ?>';
641 var i = 0;
642 for (i = 0; i < new_fields; i++) {
643 if (odd_row) {
644 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
645 } else {
646 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
648 odd_row = ! odd_row;
651 return true;
653 // ]]>
654 </script>
655 <?php
659 if ($action == 'tbl_create.php') {
661 <table>
662 <tr valign="top">
663 <th><?php echo $strTableComments; ?>:&nbsp;</th>
664 <td width="25">&nbsp;</td>
665 <th><?php echo $strStorageEngine; ?>:&nbsp;<?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
666 </th>
667 <?php
668 if (PMA_MYSQL_INT_VERSION >= 40100) {
669 echo ' <td width="25">&nbsp;</td>' . "\n"
670 . ' <th>' . $strCollation . ':&nbsp;</th>' . "\n";
673 </tr>
674 <tr><td><input type="text" name="comment" size="40" maxlength="80"
675 value="<?php echo (isset($comment) ? $comment : ''); ?>"
676 class="textfield" />
677 </td>
678 <td width="25">&nbsp;</td>
679 <td>
680 <?php echo PMA_StorageEngine::getHtmlSelect('tbl_type', null, (isset($GLOBALS['tbl_type']) ? $GLOBALS['tbl_type'] : null)); ?>
681 </td>
682 <?php
683 if (PMA_MYSQL_INT_VERSION >= 40100) {
684 echo ' <td width="25">&nbsp;</td>' . "\n"
685 . ' <td>' . "\n"
686 . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, (isset($tbl_collation) ? $tbl_collation : null), FALSE, 3)
687 . ' </td>' . "\n";
690 </tr>
691 </table>
692 <br />
693 <?php
694 } // end if ($action == 'tbl_create.php')
697 <fieldset class="tblFooters">
698 <input type="submit" name="do_save_data" value="<?php echo $strSave; ?>" onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
699 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
700 <?php echo $GLOBALS['strOr']; ?>
701 <?php echo sprintf($strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
702 <input type="submit" name="submit_num_fields"
703 value="<?php echo $GLOBALS['strGo']; ?>"
704 <?php /* onclick="if (addField()) return false;" */ ?>
705 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)"
707 <?php } ?>
708 </fieldset>
710 </form>
712 <div class="notice">
713 <p> <a name="footnoote_setenumval"><sup>1</sup></a> <?php echo $strSetEnumVal; ?></p>
714 <p> <a name="footnoote_defaultvalue"><sup>2</sup></a> <?php echo $strDefaultValueHelp; ?></p>
715 <?php
716 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
717 echo '<p> <a name="footnoote_mime"><sup>3</sup></a> ' . $strMIME_transformation_options_note . '</p>';
718 echo '<p> ';
719 printf($strMIME_transformation_note,
720 '<a href="transformation_overview.php?'
721 . PMA_generate_common_url($db, $table) . '" target="_blank">',
722 '</a>');
723 echo '</p>';
726 </div>
728 <center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>