Translation update done using Pootle.
[phpmyadmin/ammaryasirr.git] / libraries / tbl_properties.inc.php
blob3a4bf96503453666db24894d472244cbdce111c2
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 } else {
293 $type = $row['Type'];
296 if (! empty($row['Type'])) {
297 $type = $extracted_fieldspec['type'];
298 if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
299 $length = $extracted_fieldspec['spec_in_brackets'];
300 } else {
301 $type = $extracted_fieldspec['print_type'];
302 $length = $extracted_fieldspec['spec_in_brackets'];
303 } // end if else
304 } else {
305 // creating a column
306 $length = '';
309 // some types, for example longtext, are reported as
310 // "longtext character set latin7" when their charset and / or collation
311 // differs from the ones of the corresponding database.
312 $tmp = strpos($type, 'character set');
313 if ($tmp) {
314 $type = substr($type, 0, $tmp - 1);
317 if (isset($submit_length) && $submit_length != false) {
318 $length = $submit_length;
321 // rtrim the type, for cases like "float unsigned"
322 $type = rtrim($type);
323 $type_upper = strtoupper($type);
325 $content_cells[$i][$ci] .= PMA_getSupportedDatatypes(true, $type_upper);
326 $content_cells[$i][$ci] .= ' </select>';
327 $ci++;
329 // old column length
330 if ($is_backup) {
331 $_form_params['field_length_orig[' . $i . ']'] = $length;
334 // column length
335 $length_to_display = $length;
337 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
338 . ' type="text" name="field_length[' . $i . ']" size="' . $length_values_input_size . '"'
339 . ' value="' . htmlspecialchars($length_to_display) . '"'
340 . ' class="textfield" />'
341 . '<p class="enum_notice" id="enum_notice_' . $i . '_' . ($ci - $ci_offset) . '">';
342 $content_cells[$i][$ci] .= __('ENUM or SET data too long?')
343 . '<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"> '
344 . __('Get more editing space') . '</a></p>';
345 $ci++;
347 // column default
349 * having NULL enabled does not implicit having Default with NULL
351 if (isset($row)
352 && ! isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
353 $row['Default'] = 'NULL';
357 // old column default
358 if ($is_backup) {
359 $_form_params['field_default_orig[' . $i . ']'] =
360 (isset($row['Default']) ? $row['Default'] : '');
363 // here we put 'NONE' as the default value of drop-down; otherwise
364 // users would have problems if they forget to enter the default
365 // value (example, for an INT)
366 $default_options = array(
367 'NONE' => _pgettext('for default', 'None'),
368 'USER_DEFINED' => __('As defined:'),
369 'NULL' => 'NULL',
370 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
373 // for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value
374 if ($type_upper == 'TIMESTAMP'
375 && ! empty($default_current_timestamp)
376 && isset($row['Default'])) {
377 $row['Default'] = '';
380 if ($type_upper == 'BIT') {
381 $row['DefaultValue'] = PMA_convert_bit_default_value($row['DefaultValue']);
384 $content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">';
385 foreach ($default_options as $key => $value) {
386 $content_cells[$i][$ci] .= '<option value="' . $key . '"';
387 // is only set when we go back to edit a field's structure
388 if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
389 $content_cells[$i][$ci] .= ' selected="selected"';
391 $content_cells[$i][$ci] .= ' >' . $value . '</option>';
393 $content_cells[$i][$ci] .= '</select>';
394 $content_cells[$i][$ci] .= '<br />';
395 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
396 . ' type="text" name="field_default_value[' . $i . ']" size="12"'
397 . ' value="' . (isset($row['DefaultValue']) ? htmlspecialchars($row['DefaultValue']) : '') . '"'
398 . ' class="textfield" />';
399 $ci++;
401 // column collation
402 $tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
403 $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
404 PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']',
405 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
406 unset($tmp_collation);
407 $ci++;
409 // column attribute
410 $content_cells[$i][$ci] = '<select style="font-size: 70%;"'
411 . ' name="field_attribute[' . $i . ']"'
412 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
414 $attribute = '';
415 if (isset($extracted_fieldspec)) {
416 $attribute = $extracted_fieldspec['attribute'];
419 if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
420 $attribute = 'on update CURRENT_TIMESTAMP';
423 if (isset($submit_attribute) && $submit_attribute != false) {
424 $attribute = $submit_attribute;
427 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
428 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
429 // the latter.
430 if (PMA_MYSQL_INT_VERSION < 50025
431 && isset($row['Field'])
432 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
433 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
434 && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
435 $row['Null'] = '';
438 // MySQL 4.1.2+ TIMESTAMP options
439 // (if on_update_current_timestamp is set, then it's TRUE)
440 if (isset($row['Field'])
441 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
442 $attribute = 'on update CURRENT_TIMESTAMP';
444 if ((isset($row['Field'])
445 && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
446 || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
447 $default_current_timestamp = true;
448 } else {
449 $default_current_timestamp = false;
452 $cnt_attribute_types = count($cfg['AttributeTypes']);
453 for ($j = 0; $j < $cnt_attribute_types; $j++) {
454 $content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
455 if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
456 $content_cells[$i][$ci] .= ' selected="selected"';
458 $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
461 $content_cells[$i][$ci] .= '</select>';
462 $ci++;
464 // column NULL
465 $content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
466 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
468 if (! empty($row['Null']) && $row['Null'] != 'NO' && $row['Null'] != 'NOT NULL') {
469 $content_cells[$i][$ci] .= ' checked="checked"';
472 $content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
473 $ci++;
475 // column indexes
476 // See my other comment about removing this 'if'.
477 if (!$is_backup) {
478 $content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
479 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
480 $content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
482 $content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . __('Primary') . '"';
483 if (isset($row['Key']) && $row['Key'] == 'PRI') {
484 $content_cells[$i][$ci] .= ' selected="selected"';
486 $content_cells[$i][$ci] .= '>PRIMARY</option>';
488 $content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . __('Unique') . '"';
489 if (isset($row['Key']) && $row['Key'] == 'UNI') {
490 $content_cells[$i][$ci] .= ' selected="selected"';
492 $content_cells[$i][$ci] .= '>UNIQUE</option>';
494 $content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . __('Index') . '"';
495 if (isset($row['Key']) && $row['Key'] == 'MUL') {
496 $content_cells[$i][$ci] .= ' selected="selected"';
498 $content_cells[$i][$ci] .= '>INDEX</option>';
500 $content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . __('Fulltext') . '"';
501 if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
502 $content_cells[$i][$ci] .= ' selected="selected"';
504 $content_cells[$i][$ci] .= '>FULLTEXT</option>';
506 $content_cells[$i][$ci] .= '</select>';
507 $ci++;
508 } // end if ($action ==...)
510 // column auto_increment
511 $content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
512 . ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
514 if (isset($row['Extra']) && strtolower($row['Extra']) == 'auto_increment') {
515 $content_cells[$i][$ci] .= ' checked="checked"';
518 $content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
519 $ci++;
521 // column comments
522 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
523 . ' type="text" name="field_comments[' . $i . ']" size="12"'
524 . ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
525 . ' class="textfield" />';
526 $ci++;
528 // column MIME-types
529 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
530 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
531 $content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>';
533 if (is_array($available_mime['mimetype'])) {
534 foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
535 $checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
536 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
540 $content_cells[$i][$ci] .= '</select>';
541 $ci++;
543 $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
544 $content_cells[$i][$ci] .= ' <option value="" title="' . __('None') . '"></option>';
545 if (is_array($available_mime['transformation'])) {
546 foreach ($available_mime['transformation'] AS $mimekey => $transform) {
547 $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 ' : '');
548 $tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
549 $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 . '()');
550 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
554 $content_cells[$i][$ci] .= '</select>';
555 $ci++;
557 $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
558 . ' type="text" name="field_transformation_options[' . $i . ']"'
559 . ' size="16" class="textfield"'
560 . ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
561 . ' />';
562 //$ci++;
564 } // end for
567 <script src="./js/keyhandler.js" type="text/javascript"></script>
568 <script type="text/javascript">
569 // <![CDATA[
570 var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
571 document.onkeydown = onKeyDownArrowsHandler;
572 // ]]>
573 </script>
575 <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"' : ''); ?>>
576 <?php
577 echo PMA_generate_common_hidden_inputs($_form_params);
578 unset($_form_params);
579 if ($action == 'tbl_create.php') {
581 <table>
582 <tr valign="top">
583 <th><?php echo __('Table name'); ?>:&nbsp;</th>
584 </tr>
585 <tr><td><input type="text" name="table" size="40" maxlength="80"
586 value="<?php echo (isset($_REQUEST['table']) ? htmlspecialchars($_REQUEST['table']) : ''); ?>"
587 class="textfield" />
588 </td>
589 <td>
590 <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
591 <?php echo sprintf(__('Add %s column(s)'), '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
592 <input type="submit" name="submit_num_fields" value="<?php echo __('Go'); ?>"
593 onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)"
595 <?php } ?>
596 </td>
597 </tr>
598 </table>
599 <?php
603 if (is_array($content_cells) && is_array($header_cells)) {
604 // last row is for javascript insert
605 //$empty_row = array_pop($content_cells);
607 echo '<table id="table_columns" class="noclick">';
608 echo '<caption class="tblHeaders">' . __('Structure') . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE') . '</caption>';
610 if ($display_type == 'horizontal') {
612 <tr>
613 <?php foreach ($header_cells as $header_val) { ?>
614 <th><?php echo $header_val; ?></th>
615 <?php } ?>
616 </tr>
617 <?php
619 $odd_row = true;
620 foreach ($content_cells as $content_row) {
621 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
622 $odd_row = ! $odd_row;
624 if (is_array($content_row)) {
625 foreach ($content_row as $content_row_val) {
627 <td align="center"><?php echo $content_row_val; ?></td>
628 <?php
631 echo '</tr>';
633 } else {
634 $i = 0;
635 $odd_row = true;
636 foreach ($header_cells as $header_val) {
637 echo '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
638 $odd_row = ! $odd_row;
640 <th><?php echo $header_val; ?></th>
641 <?php
642 foreach ($content_cells as $content_cell) {
643 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
645 <td><?php echo $content_cell[$i]; ?></td>
646 <?php
649 echo '</tr>';
650 $i++;
654 </table>
655 <br />
656 <?php
660 * needs to be finished
663 if ($display_type == 'horizontal') {
664 $new_field = '';
665 foreach ($empty_row as $content_row_val) {
666 $new_field .= '<td align="center">' . $content_row_val . '</td>';
669 <script type="text/javascript">
670 // <![CDATA[
671 var odd_row = <?php echo $odd_row; ?>;
673 function addField()
675 var new_fields = document.getElementById('added_fields').value;
676 var new_field_container = document.getElementById('table_columns');
677 var new_field = '<?php echo preg_replace('|\s+|', ' ', preg_replace('|\'|', '\\\'', $new_field)); ?>';
678 var i = 0;
679 for (i = 0; i < new_fields; i++) {
680 if (odd_row) {
681 new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
682 } else {
683 new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
685 odd_row = ! odd_row;
688 return true;
690 // ]]>
691 </script>
692 <?php
696 if ($action == 'tbl_create.php') {
698 <table>
699 <tr valign="top">
700 <th><?php echo __('Table comments'); ?>:&nbsp;</th>
701 <td width="25">&nbsp;</td>
702 <th><?php echo __('Storage Engine'); ?>:
703 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
704 </th>
705 <td width="25">&nbsp;</td>
706 <th><?php echo __('Collation') ;?>:&nbsp;</th>
707 </tr>
708 <tr><td><input type="text" name="comment" size="40" maxlength="80"
709 value="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
710 class="textfield" />
711 </td>
712 <td width="25">&nbsp;</td>
713 <td>
714 <?php
715 echo PMA_StorageEngine::getHtmlSelect('tbl_type', null,
716 (isset($_REQUEST['tbl_type']) ? $_REQUEST['tbl_type'] : null));
718 </td>
719 <td width="25">&nbsp;</td>
720 <td>
721 <?php
722 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation',
723 null, (isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null), false, 3);
725 </td>
726 </tr>
727 <?php
728 if (PMA_Partition::havePartitioning()) {
730 <tr valign="top">
731 <th><?php echo __('PARTITION definition'); ?>:&nbsp;<?php echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?>
732 </th>
733 </tr>
734 <tr>
735 <td>
736 <textarea name="partition_definition" id="partitiondefinition"
737 cols="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
738 rows="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
739 dir="<?php echo $GLOBALS['text_dir'];?>"><?php echo (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : ''); ?></textarea>
740 </td>
741 </tr>
742 <?php
745 </table>
746 <br />
747 <?php
748 } // end if ($action == 'tbl_create.php')
751 <fieldset class="tblFooters">
752 <input type="submit" name="do_save_data" value="<?php echo __('Save'); ?>" />
753 </fieldset>
754 <div id="properties_message"></div>
755 </form>
757 <div id="enum_editor">
758 <a class="close_enum_editor"><?php echo __('Close'); ?></a>
759 <h3><?php printf(__('Values for the column "%s"'), isset($row['Field']) ? htmlspecialchars($row['Field']) : ""); ?></h3>
760 <p><?php echo __('Enter each value in a separate field.'); ?></p>
761 <div id="values"></div>
762 <p><a class="add_value"><?php echo __('+ Add a value'); ?></a></p>
763 <input type="submit" value="<?php echo __('Go'); ?>" /> <a class="cancel_enum_editor"><?php echo __('Cancel'); ?></a>
764 </div>
766 <div id="popup_background"></div>