$db, ); if ($action == 'tbl_create.php') { $_form_params['reload'] = 1; } elseif ($action == 'tbl_addfield.php') { $_form_params['field_where'] = $_REQUEST['field_where']; $_form_params['after_field'] = $_REQUEST['after_field']; $_form_params['table'] = $table; } else { $_form_params['table'] = $table; } if (isset($num_fields)) { $_form_params['orig_num_fields'] = $num_fields; } if (isset($_REQUEST['field_where'])) { $_form_params['orig_field_where'] = $_REQUEST['field_where']; } if (isset($_REQUEST['after_field'])) { $_form_params['orig_after_field'] = $_REQUEST['after_field']; } if (isset($selected) && is_array($selected)) { foreach ($selected as $o_fld_nr => $o_fld_val) { $_form_params['selected[' . $o_fld_nr . ']'] = $o_fld_val; if (! isset($true_selected)) { $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val; } } if (isset($true_selected) && is_array($true_selected)) { foreach ($true_selected as $o_fld_nr => $o_fld_val) { $_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val; } } } elseif (isset($_REQUEST['field'])) { $_form_params['orig_field'] = $_REQUEST['field']; if (isset($orig_field)) { $_form_params['true_selected[]'] = $orig_field; } else { $_form_params['true_selected[]'] = $_REQUEST['field']; } } $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php'); $header_cells = array(); $content_cells = array(); $header_cells[] = __('Name'); $header_cells[] = __('Type') . PMA_showMySQLDocu('SQL-Syntax', 'data-types'); $header_cells[] = __('Length/Values') . PMA_showHint(__('If column type is "enum" or "set", please enter the values using this format: \'a\',\'b\',\'c\'...
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\').')); $header_cells[] = __('Default') . PMA_showHint(__('For default values, please enter just a single value, without backslash escaping or quotes, using this format: a')); $header_cells[] = __('Collation'); $header_cells[] = __('Attributes'); $header_cells[] = __('Null'); // We could remove this 'if' and let the key information be shown and // editable. However, for this to work, tbl_alter must be modified to use the // key fields, as tbl_addfield does. if (!$is_backup) { $header_cells[] = __('Index'); } $header_cells[] = 'A_I'; require_once './libraries/transformations.lib.php'; $cfgRelation = PMA_getRelationsParam(); $comments_map = array(); $mime_map = array(); $available_mime = array(); $comments_map = PMA_getComments($db, $table); $header_cells[] = __('Comments'); if (isset($fields_meta)) { // for moving, load all available column names $move_columns_sql_query = 'SELECT * FROM ' . PMA_backquote($table); $move_columns_sql_result = PMA_DBI_try_query($move_columns_sql_query); $move_columns = PMA_DBI_get_fields_meta($move_columns_sql_result); unset($move_columns_sql_query, $move_columns_sql_result); $header_cells[] = __('Move column'); } if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) { $mime_map = PMA_getMIME($db, $table); $available_mime = PMA_getAvailableMIMEtypes(); $hint = '
' . sprintf( __('For a list of available transformation options and their MIME type transformations, click on %stransformation descriptions%s'), '', '' ); $header_cells[] = __('MIME type'); $header_cells[] = __('Browser transformation'); $header_cells[] = __('Transformation options') . PMA_showHint(__('Please enter the values for transformation options using this format: \'a\', 100, b,\'c\'...
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); } // workaround for field_fulltext, because its submitted indizes contain // the index as a value, not a key. Inserted here for easier maintaineance // and less code to change in existing files. if (isset($field_fulltext) && is_array($field_fulltext)) { foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) { $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey; } } for ($i = 0; $i < $num_fields; $i++) { if (! empty($regenerate)) { // An error happened with previous inputs, so we will restore the data // to embed it once again in this form. $row['Field'] = isset($_REQUEST['field_name'][$i]) ? $_REQUEST['field_name'][$i] : false; $row['Type'] = isset($_REQUEST['field_type'][$i]) ? $_REQUEST['field_type'][$i] : false; $row['Collation'] = isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : ''; $row['Null'] = isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : ''; if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i ) { $row['Key'] = 'PRI'; } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i ) { $row['Key'] = 'MUL'; } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i ) { $row['Key'] = 'UNI'; } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i ) { $row['Key'] = 'FULLTEXT'; } else { $row['Key'] = ''; } // put None in the drop-down for Default, when someone adds a field $row['DefaultType'] = isset($_REQUEST['field_default_type'][$i]) ? $_REQUEST['field_default_type'][$i] : 'NONE'; $row['DefaultValue'] = isset($_REQUEST['field_default_value'][$i]) ? $_REQUEST['field_default_value'][$i] : ''; switch ($row['DefaultType']) { case 'NONE' : $row['Default'] = null; break; case 'USER_DEFINED' : $row['Default'] = $row['DefaultValue']; break; case 'NULL' : case 'CURRENT_TIMESTAMP' : $row['Default'] = $row['DefaultType']; break; } $row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false); $row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : false); $submit_length = (isset($_REQUEST['field_length'][$i]) ? $_REQUEST['field_length'][$i] : false); $submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ? $_REQUEST['field_attribute'][$i] : false); $submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ? true : false); if (isset($_REQUEST['field_comments'][$i])) { $comments_map[$row['Field']] = $_REQUEST['field_comments'][$i]; } if (isset($_REQUEST['field_mimetype'][$i])) { $mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i]; } if (isset($_REQUEST['field_transformation'][$i])) { $mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i]; } if (isset($_REQUEST['field_transformation_options'][$i])) { $mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i]; } } elseif (isset($fields_meta[$i])) { $row = $fields_meta[$i]; switch ($row['Default']) { case null: if ($row['Null'] == 'YES') { $row['DefaultType'] = 'NULL'; $row['DefaultValue'] = ''; // SHOW FULL COLUMNS does not report the case // when there is a DEFAULT value which is empty so we need to use the // results of SHOW CREATE TABLE } elseif (isset($row) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']] ['default_value']) ) { $row['DefaultType'] = 'USER_DEFINED'; $row['DefaultValue'] = $row['Default']; } else { $row['DefaultType'] = 'NONE'; $row['DefaultValue'] = ''; } break; case 'CURRENT_TIMESTAMP': $row['DefaultType'] = 'CURRENT_TIMESTAMP'; $row['DefaultValue'] = ''; break; default: $row['DefaultType'] = 'USER_DEFINED'; $row['DefaultValue'] = $row['Default']; break; } } if (isset($row['Type'])) { $extracted_columnspec = PMA_extractColumnSpec($row['Type']); if ($extracted_columnspec['type'] == 'bit') { $row['Default'] = PMA_convertBitDefaultValue($row['Default']); } } // Cell index: If certain fields get left out, the counter shouldn't change. $ci = 0; // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset // has to be incremented ($ci_offset++) $ci_offset = -1; // old column name if ($is_backup) { if (! empty($true_selected[$i])) { $_form_params['field_orig[' . $i . ']'] = $true_selected[$i]; } elseif (isset($row['Field'])) { $_form_params['field_orig[' . $i . ']'] = $row['Field']; } else { $_form_params['field_orig[' . $i . ']'] = ''; } } // column name $content_cells[$i][$ci] = ''; $ci++; // column type $select_id = 'field_' . $i . '_' . ($ci - $ci_offset); $content_cells[$i][$ci] = ''; $ci++; // old column length if ($is_backup) { $_form_params['field_length_orig[' . $i . ']'] = $length; } // column length $length_to_display = $length; $content_cells[$i][$ci] = '' . '

'; $content_cells[$i][$ci] .= __('ENUM or SET data too long?') . ' ' . __('Get more editing space') . '' . '

'; $ci++; // column default // old column default if ($is_backup) { $_form_params['field_default_orig[' . $i . ']'] = (isset($row['Default']) ? $row['Default'] : ''); } // here we put 'NONE' as the default value of drop-down; otherwise // users would have problems if they forget to enter the default // value (example, for an INT) $default_options = array( 'NONE' => _pgettext('for default', 'None'), 'USER_DEFINED' => __('As defined:'), 'NULL' => 'NULL', 'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP', ); // for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value if ($type_upper == 'TIMESTAMP' && ! empty($default_current_timestamp) && isset($row['Default']) ) { $row['Default'] = ''; } if ($type_upper == 'BIT') { $row['DefaultValue'] = PMA_convertBitDefaultValue($row['DefaultValue']); } $content_cells[$i][$ci] = ''; $content_cells[$i][$ci] .= '
'; $content_cells[$i][$ci] .= ''; $ci++; // column collation $tmp_collation = empty($row['Collation']) ? null : $row['Collation']; $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox( PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false ); unset($tmp_collation); $ci++; // column attribute $content_cells[$i][$ci] = ''; $ci++; // column NULL $content_cells[$i][$ci] = ''; $content_cells[$i][$ci] .= ''; $content_cells[$i][$ci] .= '