Bug: Live query chart always zero
[phpmyadmin/tyronm.git] / libraries / tbl_properties.inc.php
blobcdc2c553f7b9fa233e7543a87f5f703ca46d2487
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 * @package phpMyAdmin
8 */
9 if (! defined('PHPMYADMIN')) {
10 exit;
13 /**
14 * Check parameters
16 require_once './libraries/common.inc.php';
17 require_once './libraries/common.lib.php';
18 PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
21 // Get available character sets and storage engines
22 require_once './libraries/mysql_charsets.lib.php';
23 require_once './libraries/StorageEngine.class.php';
25 /**
26 * Class for partition management
28 require_once './libraries/Partition.class.php';
30 // load additional configuration variables
31 require_once './libraries/data_mysql.inc.php';
33 if (is_int($cfg['DefaultPropDisplay'])) {
34 if ($num_fields <= $cfg['DefaultPropDisplay']) {
35 $display_type = 'vertical';
36 } else {
37 $display_type = 'horizontal';
39 } else {
40 $display_type = $cfg['DefaultPropDisplay'];
43 if ('horizontal' == $display_type) {
44 $length_values_input_size = 8;
45 } else {
46 $length_values_input_size = 30;
49 $_form_params = array(
50 'db' => $db,
53 if ($action == 'tbl_create.php') {
54 $_form_params['reload'] = 1;
55 } elseif ($action == 'tbl_addfield.php') {
56 $_form_params['field_where'] = $_REQUEST['field_where'];
57 $_form_params['after_field'] = $_REQUEST['after_field'];
58 $_form_params['table'] = $table;
59 } else {
60 $_form_params['table'] = $table;
63 if (isset($num_fields)) {
64 $_form_params['orig_num_fields'] = $num_fields;
67 if (isset($_REQUEST['field_where'])) {
68 $_form_params['orig_field_where'] = $_REQUEST['field_where'];
71 if (isset($_REQUEST['after_field'])) {
72 $_form_params['orig_after_field'] = $_REQUEST['after_field'];
75 if (isset($selected) && is_array($selected)) {
76 foreach ($selected as $o_fld_nr => $o_fld_val) {
77 $_form_params['selected[' . $o_fld_nr . ']'] = $o_fld_val;
78 if (! isset($true_selected)) {
79 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
83 if (isset($true_selected) && is_array($true_selected)) {
84 foreach ($true_selected as $o_fld_nr => $o_fld_val) {
85 $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
88 } elseif (isset($_REQUEST['field'])) {
89 $_form_params['orig_field'] = $_REQUEST['field'];
90 if (isset($orig_field)) {
91 $_form_params['true_selected[]'] = $orig_field;
92 } else {
93 $_form_params['true_selected[]'] = $_REQUEST['field'];
97 $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
99 $header_cells = array();
100 $content_cells = array();
102 $header_cells[] = __('Name');
103 $header_cells[] = __('Type')
104 . ($GLOBALS['cfg']['ReplaceHelpImg']
105 ? PMA_showMySQLDocu('SQL-Syntax', 'data-types')
106 : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'data-types')
107 . '</span>');
108 $header_cells[] = __('Length/Values') . PMA_showHint(__('If column type is "enum" or "set", please enter the values using this format: \'a\',\'b\',\'c\'...<br />If you ever need to put a backslash ("\") or a single quote ("\'") amongst those values, precede it with a backslash (for example \'\\\\xyz\' or \'a\\\'b\').'));
109 $header_cells[] = __('Default') . PMA_showHint(__('For default values, please enter just a single value, without backslash escaping or quotes, using this format: a'));
110 $header_cells[] = __('Collation');
111 $header_cells[] = __('Attributes');
112 $header_cells[] = __('Null');
114 // We could remove this 'if' and let the key information be shown and
115 // editable. However, for this to work, tbl_alter must be modified to use the
116 // key fields, as tbl_addfield does.
118 if (!$is_backup) {
119 $header_cells[] = __('Index');
122 $header_cells[] = '<abbr title="AUTO_INCREMENT">' . ($display_type == 'horizontal' ? 'A_I' : 'AUTO_INCREMENT') . '</abbr>';
124 require_once './libraries/transformations.lib.php';
125 $cfgRelation = PMA_getRelationsParam();
127 $comments_map = array();
128 $mime_map = array();
129 $available_mime = array();
131 $comments_map = PMA_getComments($db, $table);
132 $header_cells[] = __('Comments');
134 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
135 $mime_map = PMA_getMIME($db, $table);
136 $available_mime = PMA_getAvailableMIMEtypes();
138 $hint = '<br />' .
139 sprintf(__('For a list of available transformation options and their MIME type transformations, click on %stransformation descriptions%s'),
140 '<a href="transformation_overview.php?'
141 . PMA_generate_common_url($db, $table) . '" target="_blank">',
142 '</a>');
145 $header_cells[] = __('MIME type');
146 $header_cells[] = __('Browser transformation');
147 $header_cells[] = __('Transformation options')
148 . PMA_showHint(__('Please enter the values for transformation options using this format: \'a\', 100, b,\'c\'...<br />If you ever need to put a backslash ("\") or a single quote ("\'") amongst those values, precede it with a backslash (for example \'\\\\xyz\' or \'a\\\'b\').') . $hint);
151 // workaround for field_fulltext, because its submitted indizes contain
152 // the index as a value, not a key. Inserted here for easier maintaineance
153 // and less code to change in existing files.
154 if (isset($field_fulltext) && is_array($field_fulltext)) {
155 foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
156 $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
160 for ($i = 0; $i < $num_fields; $i++) {
161 if (! empty($regenerate)) {
162 // An error happened with previous inputs, so we will restore the data
163 // to embed it once again in this form.
165 $row['Field'] = (isset($_REQUEST['field_name'][$i]) ? $_REQUEST['field_name'][$i] : false);
166 $row['Type'] = (isset($_REQUEST['field_type'][$i]) ? $_REQUEST['field_type'][$i] : false);
167 $row['Collation'] = (isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '');
168 $row['Null'] = (isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : '');
170 if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i) {
171 $row['Key'] = 'PRI';
172 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i) {
173 $row['Key'] = 'MUL';
174 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i) {
175 $row['Key'] = 'UNI';
176 } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i) {
177 $row['Key'] = 'FULLTEXT';
178 } else {
179 $row['Key'] = '';
182 // put None in the drop-down for Default, when someone adds a field
183 $row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ? $_REQUEST['field_default_type'][$i] : 'NONE');
184 $row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ? $_REQUEST['field_default_value'][$i] : '');
186 switch ($row['DefaultType']) {
187 case 'NONE' :
188 $row['Default'] = null;
189 break;
190 case 'USER_DEFINED' :
191 $row['Default'] = $row['DefaultValue'];
192 break;
193 case 'NULL' :
194 case 'CURRENT_TIMESTAMP' :
195 $row['Default'] = $row['DefaultType'];
196 break;
199 $row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false);
200 $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : false);
202 $submit_length = (isset($_REQUEST['field_length'][$i]) ? $_REQUEST['field_length'][$i] : false);
203 $submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ? $_REQUEST['field_attribute'][$i] : false);
205 $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ? true : false);
207 if (isset($_REQUEST['field_comments'][$i])) {
208 $comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
211 if (isset($_REQUEST['field_mimetype'][$i])) {
212 $mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
215 if (isset($_REQUEST['field_transformation'][$i])) {
216 $mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i];
219 if (isset($_REQUEST['field_transformation_options'][$i])) {
220 $mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i];
223 } elseif (isset($fields_meta[$i])) {
224 $row = $fields_meta[$i];
225 switch ($row['Default']) {
226 case null:
227 if ($row['Null'] == 'YES') {
228 $row['DefaultType'] = 'NULL';
229 $row['DefaultValue'] = '';
230 // SHOW FULL FIELDS does not report the case when there is a DEFAULT value
231 // which is empty so we need to use the results of SHOW CREATE TABLE
232 } elseif (isset($row) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_value'])) {
233 $row['DefaultType'] = 'USER_DEFINED';
234 $row['DefaultValue'] = $row['Default'];
235 } else {
236 $row['DefaultType'] = 'NONE';
237 $row['DefaultValue'] = '';
239 break;
240 case 'CURRENT_TIMESTAMP':
241 $row['DefaultType'] = 'CURRENT_TIMESTAMP';
242 $row['DefaultValue'] = '';
243 break;
244 default:
245 $row['DefaultType'] = 'USER_DEFINED';
246 $row['DefaultValue'] = $row['Default'];
247 break;
251 if (isset($row['Type'])) {
252 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
253 if ($extracted_fieldspec['type'] == 'bit') {
254 $row['Default'] = PMA_convert_bit_default_value($row['Default']);
257 // Cell index: If certain fields get left out, the counter shouldn't change.
258 $ci = 0;
259 // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
260 // has to be incremented ($ci_offset++)
261 $ci_offset = -1;
263 // old column name
264 if ($is_backup) {
265 if (! empty($true_selected[$i])) {
266 $_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
267 } elseif (isset($row['Field'])) {
268 $_form_params['field_orig[' . $i . ']'] = $row['Field'];
269 } else {
270 $_form_params['field_orig[' . $i . ']'] = '';
274 // column name
275 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
276 . ' type="text" name="field_name[' . $i . ']"'
277 . ' maxlength="64" class="textfield" title="' . __('Column') . '"'
278 . ' size="' . ($GLOBALS['cfg']['DefaultPropDisplay'] == 'horizontal' ? '10' : '30') . '"'
279 . ' value="' . (isset($row['Field']) ? htmlspecialchars($row['Field']) : '') . '"'
280 . ' />';
281 $ci++;
283 // column type
284 $select_id = 'field_' . $i . '_' . ($ci - $ci_offset);
285 $content_cells[$i][$ci] = '<select class="column_type" name="field_type[' . $i . ']"'
286 .' id="' . $select_id . '">';
288 if (empty($row['Type'])) {
289 // creating a column
290 $row['Type'] = '';
291 $type = '';
292 $length = '';
293 } else {
294 $type = $extracted_fieldspec['type'];
295 $length = $extracted_fieldspec['spec_in_brackets'];
298 // some types, for example longtext, are reported as
299 // "longtext character set latin7" when their charset and / or collation
300 // differs from the ones of the corresponding database.
301 $tmp = strpos($type, 'character set');
302 if ($tmp) {
303 $type = substr($type, 0, $tmp - 1);
306 if (isset($submit_length) && $submit_length != false) {
307 $length = $submit_length;
310 // rtrim the type, for cases like "float unsigned"
311 $type = rtrim($type);
312 $type_upper = strtoupper($type);
314 $content_cells[$i][$ci] .= PMA_getSupportedDatatypes(true, $type_upper);
315 $content_cells[$i][$ci] .= ' </select>';
316 $ci++;
318 // old column length
319 if ($is_backup) {
320 $_form_params['field_length_orig[' . $i . ']'] = $length;
323 // column length
324 $length_to_display = $length;
326 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
327 . ' type="text" name="field_length[' . $i . ']" size="' . $length_values_input_size . '"'
328 . ' value="' . htmlspecialchars($length_to_display) . '"'
329 . ' class="textfield" />'
330 . '<p class="enum_notice" id="enum_notice_' . $i . '_' . ($ci - $ci_offset) . '">';
331 $content_cells[$i][$ci] .= __('ENUM or SET data too long?')
332 . '<a onclick="return false;" href="enum_editor.php?' . PMA_generate_common_url() . '&amp;values=' . urlencode($length_to_display) . '&amp;field=' . (isset($row['Field']) ? urlencode($row['Field']) : "") . '" class="open_enum_editor" target="_blank"> '
333 . __('Get more editing space') . '</a></p>';
334 $ci++;
336 // column default
338 * having NULL enabled does not implicit having Default with NULL
340 if (isset($row)
341 && ! isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
342 $row['Default'] = 'NULL';
346 // old column default
347 if ($is_backup) {
348 $_form_params['field_default_orig[' . $i . ']'] =
349 (isset($row['Default']) ? $row['Default'] : '');
352 // here we put 'NONE' as the default value of drop-down; otherwise
353 // users would have problems if they forget to enter the default
354 // value (example, for an INT)
355 $default_options = array(
356 'NONE' => _pgettext('for default', 'None'),
357 'USER_DEFINED' => __('As defined:'),
358 'NULL' => 'NULL',
359 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
362 // for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value
363 if ($type_upper == 'TIMESTAMP'
364 && ! empty($default_current_timestamp)
365 && isset($row['Default'])) {
366 $row['Default'] = '';
369 if ($type_upper == 'BIT') {
370 $row['DefaultValue'] = PMA_convert_bit_default_value($row['DefaultValue']);
373 $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">';
374 foreach ($default_options as $key => $value) {
375 $content_cells[$i][$ci] .= '<option value="' . $key . '"';
376 // is only set when we go back to edit a field's structure
377 if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
378 $content_cells[$i][$ci] .= ' selected="selected"';
380 $content_cells[$i][$ci] .= ' >' . $value . '</option>';
382 $content_cells[$i][$ci] .= '</select>';
383 $content_cells[$i][$ci] .= '<br />';
384 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
385 . ' type="text" name="field_default_value[' . $i . ']" size="12"'
386 . ' value="' . (isset($row['DefaultValue']) ? htmlspecialchars($row['DefaultValue']) : '') . '"'
387 . ' class="textfield" />';
388 $ci++;
390 // column collation
391 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
392 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
393 PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']',
394 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
395 unset($tmp_collation);
396 $ci++;
398 // column attribute
399 $content_cells[$i][$ci] = '<select style="font-size: 70%;"'
400 . ' name="field_attribute[' . $i . ']"'
401 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
403 $attribute = '';
404 if (isset($extracted_fieldspec)) {
405 $attribute = $extracted_fieldspec['attribute'];
408 if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
409 $attribute = 'on update CURRENT_TIMESTAMP';
412 if (isset($submit_attribute) && $submit_attribute != false) {
413 $attribute = $submit_attribute;
416 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
417 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
418 // the latter.
419 if (PMA_MYSQL_INT_VERSION < 50025
420 && isset($row['Field'])
421 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
422 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
423 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
424 $row['Null'] = '';
427 // MySQL 4.1.2+ TIMESTAMP options
428 // (if on_update_current_timestamp is set, then it's TRUE)
429 if (isset($row['Field'])
430 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
431 $attribute = 'on update CURRENT_TIMESTAMP';
433 if ((isset($row['Field'])
434 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
435 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
436 $default_current_timestamp = true;
437 } else {
438 $default_current_timestamp = false;
441 $cnt_attribute_types = count($cfg['AttributeTypes']);
442 for ($j = 0; $j < $cnt_attribute_types; $j++) {
443 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
444 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
445 $content_cells[$i][$ci] .= ' selected="selected"';
447 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
450 $content_cells[$i][$ci] .= '</select>';
451 $ci++;
453 // column NULL
454 $content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
455 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
457 if (! empty($row['Null']) && $row['Null'] != 'NO' && $row['Null'] != 'NOT NULL') {
458 $content_cells[$i][$ci] .= ' checked="checked"';
461 $content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
462 $ci++;
464 // column indexes
465 // See my other comment about removing this 'if'.
466 if (!$is_backup) {
467 $content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
468 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
469 $content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
471 $content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . __('Primary') . '"';
472 if (isset($row['Key']) && $row['Key'] == 'PRI') {
473 $content_cells[$i][$ci] .= ' selected="selected"';
475 $content_cells[$i][$ci] .= '>PRIMARY</option>';
477 $content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . __('Unique') . '"';
478 if (isset($row['Key']) && $row['Key'] == 'UNI') {
479 $content_cells[$i][$ci] .= ' selected="selected"';
481 $content_cells[$i][$ci] .= '>UNIQUE</option>';
483 $content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . __('Index') . '"';
484 if (isset($row['Key']) && $row['Key'] == 'MUL') {
485 $content_cells[$i][$ci] .= ' selected="selected"';
487 $content_cells[$i][$ci] .= '>INDEX</option>';
489 $content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . __('Fulltext') . '"';
490 if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
491 $content_cells[$i][$ci] .= ' selected="selected"';
493 $content_cells[$i][$ci] .= '>FULLTEXT</option>';
495 $content_cells[$i][$ci] .= '</select>';
496 $ci++;
497 } // end if ($action ==...)
499 // column auto_increment
500 $content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
501 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
503 if (isset($row['Extra']) && strtolower($row['Extra']) == 'auto_increment') {
504 $content_cells[$i][$ci] .= ' checked="checked"';
507 $content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
508 $ci++;
510 // column comments
511 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
512 . ' type="text" name="field_comments[' . $i . ']" size="12"'
513 . ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
514 . ' class="textfield" />';
515 $ci++;
517 // column MIME-types
518 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
519 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
520 $content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>';
522 if (is_array($available_mime['mimetype'])) {
523 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
524 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
525 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
529 $content_cells[$i][$ci] .= '</select>';
530 $ci++;
532 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
533 $content_cells[$i][$ci] .= ' <option value="" title="' . __('None') . '"></option>';
534 if (is_array($available_mime['transformation'])) {
535 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
536 $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 ' : '');
537 $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
538 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', __('No description is available for this transformation.<br />Please ask the author what %s does.')), 'PMA_transformation_' . $tooltip . '()');
539 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
543 $content_cells[$i][$ci] .= '</select>';
544 $ci++;
546 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
547 . ' type="text" name="field_transformation_options[' . $i . ']"'
548 . ' size="16" class="textfield"'
549 . ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
550 . ' />';
551 //$ci++;
553 } // end for
556 <script src="./js/keyhandler.js" type="text/javascript"></script>
557 <script type="text/javascript">
558 // <![CDATA[
559 var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
560 document.onkeydown = onKeyDownArrowsHandler;
561 // ]]>
562 </script>
564 <form id="<?php echo ($action == 'tbl_create.php' ? 'create_table' : 'append_fields'); ?>_form" method="post" action="<?php echo $action; ?>" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : ''); ?>>
565 <?php
566 echo PMA_generate_common_hidden_inputs($_form_params);
567 unset($_form_params);
568 if ($action == 'tbl_create.php') {
570 <table>
571 <tr valign="top">
572 <th><?php echo __('Table name'); ?>:&nbsp;</th>
573 </tr>
574 <tr><td><input type="text" name="table" size="40" maxlength="80"
575 value="<?php echo (isset($_REQUEST['table']) ? htmlspecialchars($_REQUEST['table']) : ''); ?>"
576 class="textfield" />
577 </td>
578 <td>
579 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
580 <?php echo sprintf(__('Add %s column(s)'), '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
581 <input type="submit" name="submit_num_fields" value="<?php echo __('Go'); ?>"
582 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)"
584 <?php } ?>
585 </td>
586 </tr>
587 </table>
588 <?php
592 if (is_array($content_cells) && is_array($header_cells)) {
593 // last row is for javascript insert
594 //$empty_row = array_pop($content_cells);
596 echo '<table id="table_columns" class="noclick">';
597 echo '<caption class="tblHeaders">' . __('Structure') . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE') . '</caption>';
599 if ($display_type == 'horizontal') {
601 <tr>
602 <?php foreach ($header_cells as $header_val) { ?>
603 <th><?php echo $header_val; ?></th>
604 <?php } ?>
605 </tr>
606 <?php
608 $odd_row = true;
609 foreach ($content_cells as $content_row) {
610 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
611 $odd_row = ! $odd_row;
613 if (is_array($content_row)) {
614 foreach ($content_row as $content_row_val) {
616 <td align="center"><?php echo $content_row_val; ?></td>
617 <?php
620 echo '</tr>';
622 } else {
623 $i = 0;
624 $odd_row = true;
625 foreach ($header_cells as $header_val) {
626 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
627 $odd_row = ! $odd_row;
629 <th><?php echo $header_val; ?></th>
630 <?php
631 foreach ($content_cells as $content_cell) {
632 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
634 <td><?php echo $content_cell[$i]; ?></td>
635 <?php
638 echo '</tr>';
639 $i++;
643 </table>
644 <br />
645 <?php
649 * needs to be finished
652 if ($display_type == 'horizontal') {
653 $new_field = '';
654 foreach ($empty_row as $content_row_val) {
655 $new_field .= '<td align="center">' . $content_row_val . '</td>';
658 <script type="text/javascript">
659 // <![CDATA[
660 var odd_row = <?php echo $odd_row; ?>;
662 function addField()
664 var new_fields = document.getElementById('added_fields').value;
665 var new_field_container = document.getElementById('table_columns');
666 var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';
667 var i = 0;
668 for (i = 0; i < new_fields; i++) {
669 if (odd_row) {
670 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
671 } else {
672 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
674 odd_row = ! odd_row;
677 return true;
679 // ]]>
680 </script>
681 <?php
685 if ($action == 'tbl_create.php') {
687 <table>
688 <tr valign="top">
689 <th><?php echo __('Table comments'); ?>:&nbsp;</th>
690 <td width="25">&nbsp;</td>
691 <th><?php echo __('Storage Engine'); ?>:
692 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
693 </th>
694 <td width="25">&nbsp;</td>
695 <th><?php echo __('Collation') ;?>:&nbsp;</th>
696 </tr>
697 <tr><td><input type="text" name="comment" size="40" maxlength="80"
698 value="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
699 class="textfield" />
700 </td>
701 <td width="25">&nbsp;</td>
702 <td>
703 <?php
704 echo PMA_StorageEngine::getHtmlSelect('tbl_type', null,
705 (isset($_REQUEST['tbl_type']) ? $_REQUEST['tbl_type'] : null));
707 </td>
708 <td width="25">&nbsp;</td>
709 <td>
710 <?php
711 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation',
712 null, (isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null), false, 3);
714 </td>
715 </tr>
716 <?php
717 if (PMA_Partition::havePartitioning()) {
719 <tr valign="top">
720 <th><?php echo __('PARTITION definition'); ?>:&nbsp;<?php echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?>
721 </th>
722 </tr>
723 <tr>
724 <td>
725 <textarea name="partition_definition" id="partitiondefinition"
726 cols="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
727 rows="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
728 dir="<?php echo $GLOBALS['text_dir'];?>"><?php echo (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : ''); ?></textarea>
729 </td>
730 </tr>
731 <?php
734 </table>
735 <br />
736 <?php
737 } // end if ($action == 'tbl_create.php')
740 <fieldset class="tblFooters">
741 <input type="submit" name="do_save_data" value="<?php echo __('Save'); ?>" />
742 </fieldset>
743 <div id="properties_message"></div>
744 </form>
746 <div id="enum_editor">
747 <a class="close_enum_editor"><?php echo __('Close'); ?></a>
748 <h3><?php printf(__('Values for the column "%s"'), isset($row['Field']) ? htmlspecialchars($row['Field']) : ""); ?></h3>
749 <p><?php echo __('Enter each value in a separate field.'); ?></p>
750 <div id="values"></div>
751 <p><a class="add_value"><?php echo __('+ Add a value'); ?></a></p>
752 <input type="submit" value="<?php echo __('Go'); ?>" /> <a class="cancel_enum_editor"><?php echo __('Cancel'); ?></a>
753 </div>
755 <div id="popup_background"></div>