Merge pull request #574 from scnakandala/refac_tbl_columns_definitions
Refac tbl columns definitions
This commit is contained in:
commit
eec1426f3b
@ -80,53 +80,30 @@ if (isset($field_fulltext) && is_array($field_fulltext)) {
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $num_fields; $i++) {
|
||||
for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
|
||||
if (! empty($regenerate)) {
|
||||
list($row, $submit_length, $submit_attribute,
|
||||
list($columnMeta, $submit_length, $submit_attribute,
|
||||
$submit_default_current_timestamp, $comments_map, $mime_map)
|
||||
= PMA_handleRegeneration(
|
||||
isset($available_mime) ? $mime_map : null,
|
||||
$comments_map, $mime_map
|
||||
);
|
||||
} 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;
|
||||
}
|
||||
} elseif (isset($fields_meta[$columnNumber])) {
|
||||
$columnMeta = PMA_getColumnMetaForDefault(
|
||||
$fields_meta[$columnNumber],
|
||||
isset($analyzed_sql[0]['create_table_fields']
|
||||
[$fields_meta[$columnNumber]['Field']]['default_value'])
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($row['Type'])) {
|
||||
$extracted_columnspec = PMA_Util::extractColumnSpec($row['Type']);
|
||||
if (isset($columnMeta['Type'])) {
|
||||
$extracted_columnspec = PMA_Util::extractColumnSpec($columnMeta['Type']);
|
||||
if ($extracted_columnspec['type'] == 'bit') {
|
||||
$row['Default']
|
||||
= PMA_Util::convertBitDefaultValue($row['Default']);
|
||||
$columnMeta['Default']
|
||||
= PMA_Util::convertBitDefaultValue($columnMeta['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
|
||||
@ -135,30 +112,23 @@ for ($i = 0; $i < $num_fields; $i++) {
|
||||
|
||||
// old column name
|
||||
if ($is_backup) {
|
||||
if (isset($row['Field'])) {
|
||||
$_form_params['field_orig[' . $i . ']'] = $row['Field'];
|
||||
if (isset($columnMeta['Field'])) {
|
||||
$_form_params['field_orig[' . $columnNumber . ']']
|
||||
= $columnMeta['Field'];
|
||||
} else {
|
||||
$_form_params['field_orig[' . $i . ']'] = '';
|
||||
$_form_params['field_orig[' . $columnNumber . ']'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// column name
|
||||
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset)
|
||||
. '"' . ' type="text" name="field_name[' . $i . ']"'
|
||||
. ' maxlength="64" class="textfield" title="' . __('Column') . '"'
|
||||
. ' size="10"'
|
||||
. ' value="' . (isset($row['Field']) ? htmlspecialchars($row['Field']) : '')
|
||||
. '"' . ' />';
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForColumnName(
|
||||
$columnNumber, $ci, $ci_offset, isset($columnMeta) ? $columnMeta : null
|
||||
);
|
||||
$ci++;
|
||||
|
||||
// column type
|
||||
$select_id = 'field_' . $i . '_' . ($ci - $ci_offset);
|
||||
$content_cells[$i][$ci] = '<select class="column_type" name="field_type[' .
|
||||
$i . ']"' .' id="' . $select_id . '">';
|
||||
|
||||
if (empty($row['Type'])) {
|
||||
if (empty($columnMeta['Type'])) {
|
||||
// creating a column
|
||||
$row['Type'] = '';
|
||||
$columnMeta['Type'] = '';
|
||||
$type = '';
|
||||
$length = '';
|
||||
} else {
|
||||
@ -181,342 +151,114 @@ for ($i = 0; $i < $num_fields; $i++) {
|
||||
// rtrim the type, for cases like "float unsigned"
|
||||
$type = rtrim($type);
|
||||
$type_upper = strtoupper($type);
|
||||
|
||||
$content_cells[$i][$ci]
|
||||
.= PMA_Util::getSupportedDatatypes(true, $type_upper);
|
||||
$content_cells[$i][$ci] .= ' </select>';
|
||||
|
||||
// column type
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForColumnType(
|
||||
$columnNumber, $ci, $ci_offset, $type_upper
|
||||
);
|
||||
|
||||
$ci++;
|
||||
|
||||
// old column length
|
||||
if ($is_backup) {
|
||||
$_form_params['field_length_orig[' . $i . ']'] = $length;
|
||||
$_form_params['field_length_orig[' . $columnNumber . ']'] = $length;
|
||||
}
|
||||
|
||||
// column length
|
||||
$length_to_display = $length;
|
||||
|
||||
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset)
|
||||
. '"' . ' type="text" name="field_length[' . $i . ']" size="'
|
||||
. $length_values_input_size . '"' . ' value="' . htmlspecialchars(
|
||||
$length_to_display
|
||||
)
|
||||
. '"'
|
||||
. ' class="textfield" />'
|
||||
. '<p class="enum_notice" id="enum_notice_' . $i . '_' . ($ci - $ci_offset)
|
||||
. '">';
|
||||
$content_cells[$i][$ci] .= __('ENUM or SET data too long?')
|
||||
. '<a href="#" class="open_enum_editor"> '
|
||||
. __('Get more editing space') . '</a>'
|
||||
. '</p>';
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForColumnLength(
|
||||
$columnNumber, $ci, $ci_offset, $length_values_input_size, $length
|
||||
);
|
||||
$ci++;
|
||||
|
||||
// column default
|
||||
|
||||
// old column default
|
||||
if ($is_backup) {
|
||||
$_form_params['field_default_orig[' . $i . ']']
|
||||
= (isset($row['Default']) ? $row['Default'] : '');
|
||||
$_form_params['field_default_orig[' . $columnNumber . ']']
|
||||
= (isset($columnMeta['Default']) ? $columnMeta['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',
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForColumnDefault(
|
||||
$columnNumber, $ci, $ci_offset,
|
||||
isset($type_upper) ? $type_upper : null,
|
||||
isset($default_current_timestamp) ? $default_current_timestamp : null,
|
||||
isset($columnMeta) ? $columnMeta : null
|
||||
);
|
||||
|
||||
// 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_Util::convertBitDefaultValue($row['DefaultValue']);
|
||||
}
|
||||
|
||||
$content_cells[$i][$ci] = '<select name="field_default_type[' . $i
|
||||
. ']" id="field_' . $i . '_' . ($ci - $ci_offset)
|
||||
. '" class="default_type">';
|
||||
foreach ($default_options as $key => $value) {
|
||||
$content_cells[$i][$ci] .= '<option value="' . $key . '"';
|
||||
// is only set when we go back to edit a field's structure
|
||||
if (isset($row['DefaultType']) && $row['DefaultType'] == $key) {
|
||||
$content_cells[$i][$ci] .= ' selected="selected"';
|
||||
}
|
||||
$content_cells[$i][$ci] .= ' >' . $value . '</option>';
|
||||
}
|
||||
$content_cells[$i][$ci] .= '</select>';
|
||||
$content_cells[$i][$ci] .= '<br />';
|
||||
$content_cells[$i][$ci] .= '<input type="text"'
|
||||
. ' name="field_default_value[' . $i . ']" size="12"'
|
||||
. ' value="' . (isset($row['DefaultValue'])
|
||||
? htmlspecialchars($row['DefaultValue'])
|
||||
: '') . '"'
|
||||
. ' class="textfield default_value" />';
|
||||
$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
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForColumnCollation(
|
||||
$columnNumber, $ci, $ci_offset, $columnMeta
|
||||
);
|
||||
unset($tmp_collation);
|
||||
$ci++;
|
||||
|
||||
// column attribute
|
||||
$content_cells[$i][$ci] = '<select style="font-size: 70%;"'
|
||||
. ' name="field_attribute[' . $i . ']"'
|
||||
. ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
|
||||
|
||||
$attribute = '';
|
||||
if (isset($extracted_columnspec)) {
|
||||
$attribute = $extracted_columnspec['attribute'];
|
||||
}
|
||||
|
||||
if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
|
||||
$attribute = 'on update CURRENT_TIMESTAMP';
|
||||
}
|
||||
|
||||
if (isset($submit_attribute) && $submit_attribute != false) {
|
||||
$attribute = $submit_attribute;
|
||||
}
|
||||
|
||||
// here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having the
|
||||
// NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
|
||||
// the latter.
|
||||
if (PMA_MYSQL_INT_VERSION < 50025
|
||||
&& isset($row['Field'])
|
||||
&& isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
|
||||
&& $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
|
||||
&& $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true
|
||||
) {
|
||||
$row['Null'] = '';
|
||||
}
|
||||
|
||||
// MySQL 4.1.2+ TIMESTAMP options
|
||||
// (if on_update_current_timestamp is set, then it's TRUE)
|
||||
if (isset($row['Field'])
|
||||
&& isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])
|
||||
) {
|
||||
$attribute = 'on update CURRENT_TIMESTAMP';
|
||||
}
|
||||
if ((isset($row['Field'])
|
||||
&& isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
|
||||
|| (isset($submit_default_current_timestamp)
|
||||
&& $submit_default_current_timestamp)
|
||||
) {
|
||||
$default_current_timestamp = true;
|
||||
} else {
|
||||
$default_current_timestamp = false;
|
||||
}
|
||||
|
||||
$attribute_types = $GLOBALS['PMA_Types']->getAttributes();
|
||||
$cnt_attribute_types = count($attribute_types);
|
||||
for ($j = 0; $j < $cnt_attribute_types; $j++) {
|
||||
$content_cells[$i][$ci]
|
||||
.= ' <option value="' . $attribute_types[$j] . '"';
|
||||
if (strtoupper($attribute) == strtoupper($attribute_types[$j])) {
|
||||
$content_cells[$i][$ci] .= ' selected="selected"';
|
||||
}
|
||||
$content_cells[$i][$ci] .= '>' . $attribute_types[$j] . '</option>';
|
||||
}
|
||||
|
||||
$content_cells[$i][$ci] .= '</select>';
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForColumnAttribute(
|
||||
$columnNumber, $ci, $ci_offset,
|
||||
isset($extracted_columnspec) ? $extracted_columnspec : null,
|
||||
isset($columnMeta) ? $columnMeta : null,
|
||||
isset($submit_attribute) ? $submit_attribute : null,
|
||||
isset($analyzed_sql) ? $analyzed_sql : null,
|
||||
isset($submit_default_current_timestamp)
|
||||
? $submit_default_current_timestamp : null
|
||||
);
|
||||
$ci++;
|
||||
|
||||
// column NULL
|
||||
$content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
|
||||
. ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
|
||||
|
||||
if (! empty($row['Null'])
|
||||
&& $row['Null'] != 'NO'
|
||||
&& $row['Null'] != 'NOT NULL'
|
||||
) {
|
||||
$content_cells[$i][$ci] .= ' checked="checked"';
|
||||
}
|
||||
|
||||
$content_cells[$i][$ci] .= ' type="checkbox" value="NULL" class="allow_null"/>';
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForColumnNull(
|
||||
$columnNumber, $ci, $ci_offset, isset($columnMeta) ? $columnMeta : null
|
||||
);
|
||||
$ci++;
|
||||
|
||||
// column indexes
|
||||
// See my other comment about removing this 'if'.
|
||||
// See my other comment about this 'if'.
|
||||
if (!$is_backup) {
|
||||
$content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
|
||||
. ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
|
||||
$content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
|
||||
|
||||
$content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="'
|
||||
. __('Primary') . '"';
|
||||
if (isset($row['Key']) && $row['Key'] == 'PRI') {
|
||||
$content_cells[$i][$ci] .= ' selected="selected"';
|
||||
}
|
||||
$content_cells[$i][$ci] .= '>PRIMARY</option>';
|
||||
|
||||
$content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="'
|
||||
. __('Unique') . '"';
|
||||
if (isset($row['Key']) && $row['Key'] == 'UNI') {
|
||||
$content_cells[$i][$ci] .= ' selected="selected"';
|
||||
}
|
||||
$content_cells[$i][$ci] .= '>UNIQUE</option>';
|
||||
|
||||
$content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="'
|
||||
. __('Index') . '"';
|
||||
if (isset($row['Key']) && $row['Key'] == 'MUL') {
|
||||
$content_cells[$i][$ci] .= ' selected="selected"';
|
||||
}
|
||||
$content_cells[$i][$ci] .= '>INDEX</option>';
|
||||
|
||||
if (!PMA_DRIZZLE) {
|
||||
$content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="'
|
||||
. __('Fulltext') . '"';
|
||||
if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
|
||||
$content_cells[$i][$ci] .= ' selected="selected"';
|
||||
}
|
||||
$content_cells[$i][$ci] .= '>FULLTEXT</option>';
|
||||
}
|
||||
|
||||
$content_cells[$i][$ci] .= '</select>';
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForColumnIndexes(
|
||||
$columnNumber, $ci, $ci_offset, $columnMeta
|
||||
);
|
||||
$ci++;
|
||||
} // end if ($action ==...)
|
||||
|
||||
// column auto_increment
|
||||
$content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
|
||||
. ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
|
||||
|
||||
if (isset($row['Extra']) && strtolower($row['Extra']) == 'auto_increment') {
|
||||
$content_cells[$i][$ci] .= ' checked="checked"';
|
||||
}
|
||||
|
||||
$content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForColumnAutoIncrement(
|
||||
$columnNumber, $ci, $ci_offset, $columnMeta
|
||||
);
|
||||
$ci++;
|
||||
|
||||
// column comments
|
||||
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset)
|
||||
. '"' . ' type="text" name="field_comments[' . $i . ']" size="12"'
|
||||
. ' value="' . (isset($row['Field'])
|
||||
&& is_array($comments_map)
|
||||
&& isset($comments_map[$row['Field']])
|
||||
? htmlspecialchars($comments_map[$row['Field']])
|
||||
: '') . '"'
|
||||
. ' class="textfield" />';
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForColumnComment(
|
||||
$columnNumber, $ci, $ci_offset, isset($columnMeta) ? $columnMeta : null,
|
||||
$comments_map
|
||||
);
|
||||
$ci++;
|
||||
|
||||
// move column
|
||||
if (isset($fields_meta)) {
|
||||
$content_cells[$i][$ci] = '<select id="field_' . $i . '_'
|
||||
. ($ci - $ci_offset) . '"' . ' name="field_move_to[' . $i
|
||||
. ']" size="1" width="5em">'
|
||||
. '<option value="" selected="selected"> </option>';
|
||||
|
||||
// find index of current column
|
||||
$current_index = 0;
|
||||
for ($mi = 0, $cols = count($move_columns); $mi < $cols; $mi++) {
|
||||
if ($move_columns[$mi]->name == $row['Field']) {
|
||||
$current_index = $mi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$content_cells[$i][$ci] .= '<option value="-first"'
|
||||
. ($current_index == 0 ? ' disabled="disabled"' : '')
|
||||
. '>' . __('first') . '</option>';
|
||||
|
||||
for ($mi = 0, $cols = count($move_columns); $mi < $cols; $mi++) {
|
||||
$content_cells[$i][$ci] .=
|
||||
'<option value="' . htmlspecialchars($move_columns[$mi]->name) . '"'
|
||||
. (($current_index == $mi || $current_index == $mi + 1)
|
||||
? ' disabled="disabled"'
|
||||
: '')
|
||||
.'>'
|
||||
. sprintf(
|
||||
__('after %s'),
|
||||
PMA_Util::backquote(
|
||||
htmlspecialchars(
|
||||
$move_columns[$mi]->name
|
||||
)
|
||||
)
|
||||
)
|
||||
. '</option>';
|
||||
}
|
||||
|
||||
$content_cells[$i][$ci] .= '</select>';
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForMoveColumn(
|
||||
$columnNumber, $ci, $ci_offset, $move_columns, $columnMeta
|
||||
);
|
||||
$ci++;
|
||||
}
|
||||
|
||||
// column MIME-types
|
||||
if ($cfgRelation['mimework']
|
||||
&& $GLOBALS['cfg']['BrowseMIME']
|
||||
&& $cfgRelation['commwork']
|
||||
) {
|
||||
$content_cells[$i][$ci] = '<select id="field_' . $i . '_'
|
||||
. ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
|
||||
$content_cells[$i][$ci] .= ' <option value=""> </option>';
|
||||
|
||||
if (is_array($available_mime['mimetype'])) {
|
||||
foreach ($available_mime['mimetype'] as $mimekey => $mimetype) {
|
||||
$checked = (isset($row['Field'])
|
||||
&& isset($mime_map[$row['Field']]['mimetype'])
|
||||
&& ($mime_map[$row['Field']]['mimetype']
|
||||
== str_replace('/', '_', $mimetype))
|
||||
? 'selected '
|
||||
: '');
|
||||
$content_cells[$i][$ci] .= ' <option value="'
|
||||
. str_replace('/', '_', $mimetype) . '" ' . $checked . '>'
|
||||
. htmlspecialchars($mimetype) . '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
$content_cells[$i][$ci] .= '</select>';
|
||||
// Column Mime-type
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForMimeType(
|
||||
$columnNumber, $ci, $ci_offset, $available_mime, $columnMeta, $mime_map
|
||||
);
|
||||
$ci++;
|
||||
|
||||
$content_cells[$i][$ci] = '<select id="field_' . $i . '_'
|
||||
. ($ci - $ci_offset) . '" size="1" name="field_transformation['
|
||||
. $i . ']">';
|
||||
$content_cells[$i][$ci] .= ' <option value="" title="' . __('None')
|
||||
. '"></option>';
|
||||
if (is_array($available_mime['transformation'])) {
|
||||
foreach ($available_mime['transformation'] as $mimekey => $transform) {
|
||||
$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 '
|
||||
: '';
|
||||
$tooltip = PMA_getTransformationDescription(
|
||||
$available_mime['transformation_file'][$mimekey], false
|
||||
);
|
||||
$content_cells[$i][$ci] .= '<option value="'
|
||||
. $available_mime['transformation_file'][$mimekey] . '" '
|
||||
. $checked . ' title="' . htmlspecialchars($tooltip) . '">'
|
||||
. htmlspecialchars($transform) . '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
$content_cells[$i][$ci] .= '</select>';
|
||||
// Column Browser transformation
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForBrowserTransformation(
|
||||
$columnNumber, $ci, $ci_offset, $available_mime, $columnMeta, $mime_map
|
||||
);
|
||||
$ci++;
|
||||
|
||||
$val = isset($row['Field'])
|
||||
&& isset($mime_map[$row['Field']]['transformation_options'])
|
||||
? htmlspecialchars($mime_map[$row['Field']]['transformation_options'])
|
||||
: '';
|
||||
$content_cells[$i][$ci] = '<input id="field_' . $i . '_'
|
||||
. ($ci - $ci_offset) . '"' . ' type="text" '
|
||||
. 'name="field_transformation_options[' . $i . ']"'
|
||||
. ' size="16" class="textfield"'
|
||||
. ' value="' . $val . '"'
|
||||
. ' />';
|
||||
//$ci++;
|
||||
// column Transformation options
|
||||
$content_cells[$columnNumber][$ci] = PMA_getHtmlForTransformationOption(
|
||||
$columnNumber, $ci, $ci_offset, isset($columnMeta) ? $columnMeta : null,
|
||||
isset($mime_map) ? $mime_map : null
|
||||
);
|
||||
}
|
||||
} // end for
|
||||
|
||||
|
||||
@ -261,15 +261,15 @@ function PMA_getHtmlForTableCreateOrAddField($action, $form_params, $content_cel
|
||||
/**
|
||||
* Function to get header cells
|
||||
*
|
||||
* @param bool $is_backup whether backup or not
|
||||
* @param array $fields_meta fields meta data
|
||||
* @param bool $mimework whether mimework or not
|
||||
* @param string $db current database
|
||||
* @param string $table current table
|
||||
* @param bool $is_backup whether backup or not
|
||||
* @param array $columnMeta column meta data
|
||||
* @param bool $mimework whether mimework or not
|
||||
* @param string $db current database
|
||||
* @param string $table current table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_getHeaderCells($is_backup, $fields_meta, $mimework, $db, $table)
|
||||
function PMA_getHeaderCells($is_backup, $columnMeta, $mimework, $db, $table)
|
||||
{
|
||||
$header_cells = array();
|
||||
$header_cells[] = __('Name');
|
||||
@ -306,7 +306,7 @@ function PMA_getHeaderCells($is_backup, $fields_meta, $mimework, $db, $table)
|
||||
$header_cells[] = '<abbr title="AUTO_INCREMENT">A_I</abbr>';
|
||||
$header_cells[] = __('Comments');
|
||||
|
||||
if (isset($fields_meta)) {
|
||||
if (isset($columnMeta)) {
|
||||
$header_cells[] = __('Move column');
|
||||
}
|
||||
|
||||
@ -366,97 +366,102 @@ function PMA_getMoveColumns($db, $table)
|
||||
/**
|
||||
* Function to get row data for regenerating previous when error occured.
|
||||
*
|
||||
* @param int $columnNumber coulmn number
|
||||
* @param array $submit_fulltext submit full text
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_getRowDataForRegeneration($submit_fulltext)
|
||||
function PMA_getRowDataForRegeneration($columnNumber, $submit_fulltext)
|
||||
{
|
||||
$row['Field'] = isset($_REQUEST['field_name'][$i])
|
||||
? $_REQUEST['field_name'][$i]
|
||||
$columnMeta['Field'] = isset($_REQUEST['field_name'][$columnNumber])
|
||||
? $_REQUEST['field_name'][$columnNumber]
|
||||
: false;
|
||||
$row['Type'] = isset($_REQUEST['field_type'][$i])
|
||||
? $_REQUEST['field_type'][$i]
|
||||
$columnMeta['Type'] = isset($_REQUEST['field_type'][$columnNumber])
|
||||
? $_REQUEST['field_type'][$columnNumber]
|
||||
: false;
|
||||
$row['Collation'] = isset($_REQUEST['field_collation'][$i])
|
||||
? $_REQUEST['field_collation'][$i]
|
||||
$columnMeta['Collation'] = isset($_REQUEST['field_collation'][$columnNumber])
|
||||
? $_REQUEST['field_collation'][$columnNumber]
|
||||
: '';
|
||||
$row['Null'] = isset($_REQUEST['field_null'][$i])
|
||||
? $_REQUEST['field_null'][$i]
|
||||
$columnMeta['Null'] = isset($_REQUEST['field_null'][$columnNumber])
|
||||
? $_REQUEST['field_null'][$columnNumber]
|
||||
: '';
|
||||
|
||||
if (isset($_REQUEST['field_key'][$i])
|
||||
&& $_REQUEST['field_key'][$i] == 'primary_' . $i
|
||||
if (isset($_REQUEST['field_key'][$columnNumber])
|
||||
&& $_REQUEST['field_key'][$columnNumber] == 'primary_' . $columnNumber
|
||||
) {
|
||||
$row['Key'] = 'PRI';
|
||||
} elseif (isset($_REQUEST['field_key'][$i])
|
||||
&& $_REQUEST['field_key'][$i] == 'index_' . $i
|
||||
$columnMeta['Key'] = 'PRI';
|
||||
} elseif (isset($_REQUEST['field_key'][$columnNumber])
|
||||
&& $_REQUEST['field_key'][$columnNumber] == 'index_' . $columnNumber
|
||||
) {
|
||||
$row['Key'] = 'MUL';
|
||||
} elseif (isset($_REQUEST['field_key'][$i])
|
||||
&& $_REQUEST['field_key'][$i] == 'unique_' . $i
|
||||
$columnMeta['Key'] = 'MUL';
|
||||
} elseif (isset($_REQUEST['field_key'][$columnNumber])
|
||||
&& $_REQUEST['field_key'][$columnNumber] == 'unique_' . $columnNumber
|
||||
) {
|
||||
$row['Key'] = 'UNI';
|
||||
} elseif (isset($_REQUEST['field_key'][$i])
|
||||
&& $_REQUEST['field_key'][$i] == 'fulltext_' . $i
|
||||
$columnMeta['Key'] = 'UNI';
|
||||
} elseif (isset($_REQUEST['field_key'][$columnNumber])
|
||||
&& $_REQUEST['field_key'][$columnNumber] == 'fulltext_' . $columnNumber
|
||||
) {
|
||||
$row['Key'] = 'FULLTEXT';
|
||||
$columnMeta['Key'] = 'FULLTEXT';
|
||||
} else {
|
||||
$row['Key'] = '';
|
||||
$columnMeta['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]
|
||||
: '';
|
||||
$columnMeta['DefaultType']
|
||||
= isset($_REQUEST['field_default_type'][$columnNumber])
|
||||
? $_REQUEST['field_default_type'][$columnNumber]
|
||||
: 'NONE';
|
||||
$columnMeta['DefaultValue']
|
||||
= isset($_REQUEST['field_default_value'][$columnNumber])
|
||||
? $_REQUEST['field_default_value'][$columnNumber]
|
||||
: '';
|
||||
|
||||
switch ($row['DefaultType']) {
|
||||
switch ($columnMeta['DefaultType']) {
|
||||
case 'NONE' :
|
||||
$row['Default'] = null;
|
||||
$columnMeta['Default'] = null;
|
||||
break;
|
||||
case 'USER_DEFINED' :
|
||||
$row['Default'] = $row['DefaultValue'];
|
||||
$columnMeta['Default'] = $columnMeta['DefaultValue'];
|
||||
break;
|
||||
case 'NULL' :
|
||||
case 'CURRENT_TIMESTAMP' :
|
||||
$row['Default'] = $row['DefaultType'];
|
||||
$columnMeta['Default'] = $columnMeta['DefaultType'];
|
||||
break;
|
||||
}
|
||||
|
||||
$row['Extra']
|
||||
= (isset($_REQUEST['field_extra'][$i])
|
||||
? $_REQUEST['field_extra'][$i]
|
||||
$columnMeta['Extra']
|
||||
= (isset($_REQUEST['field_extra'][$columnNumber])
|
||||
? $_REQUEST['field_extra'][$columnNumber]
|
||||
: false);
|
||||
$row['Comment']
|
||||
= (isset($submit_fulltext[$i])
|
||||
&& ($submit_fulltext[$i] == $i)
|
||||
$columnMeta['Comment']
|
||||
= (isset($submit_fulltext[$columnNumber])
|
||||
&& ($submit_fulltext[$columnNumber] == $columnNumber)
|
||||
? 'FULLTEXT'
|
||||
: false);
|
||||
|
||||
return $row;
|
||||
return $columnMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get submit properties for regenerating previous when error occured.
|
||||
*
|
||||
* @param int $columnNumber coulmn number
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_getSubmitPropertiesForRegeneration()
|
||||
function PMA_getSubmitPropertiesForRegeneration($columnNumber)
|
||||
{
|
||||
$submit_length
|
||||
= (isset($_REQUEST['field_length'][$i])
|
||||
? $_REQUEST['field_length'][$i]
|
||||
= (isset($_REQUEST['field_length'][$columnNumber])
|
||||
? $_REQUEST['field_length'][$columnNumber]
|
||||
: false);
|
||||
$submit_attribute
|
||||
= (isset($_REQUEST['field_attribute'][$i])
|
||||
? $_REQUEST['field_attribute'][$i]
|
||||
= (isset($_REQUEST['field_attribute'][$columnNumber])
|
||||
? $_REQUEST['field_attribute'][$columnNumber]
|
||||
: false);
|
||||
|
||||
$submit_default_current_timestamp
|
||||
= (isset($_REQUEST['field_default_current_timestamp'][$i])
|
||||
= (isset($_REQUEST['field_default_current_timestamp'][$columnNumber])
|
||||
? true
|
||||
: false);
|
||||
|
||||
@ -469,42 +474,646 @@ function PMA_getSubmitPropertiesForRegeneration()
|
||||
* An error happened with previous inputs, so we will restore the data
|
||||
* to embed it once again in this form.
|
||||
*
|
||||
* @param int $columnNumber coulmn number
|
||||
* @param array $submit_fulltext submit full text
|
||||
* @param array $comments_map comments map
|
||||
* @param array $mime_map mime map
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_handleRegeneration($submit_fulltext, $comments_map, $mime_map)
|
||||
{
|
||||
$row = PMA_getRowDataForRegeneration(
|
||||
function PMA_handleRegeneration($columnNumber, $submit_fulltext, $comments_map,
|
||||
$mime_map
|
||||
) {
|
||||
$columnMeta = PMA_getRowDataForRegeneration(
|
||||
isset($submit_fulltext) ? $submit_fulltext : null
|
||||
);
|
||||
|
||||
list($submit_length, $submit_attribute, $submit_default_current_timestamp)
|
||||
= PMA_getSubmitPropertiesForRegeneration();
|
||||
|
||||
if (isset($_REQUEST['field_comments'][$i])) {
|
||||
$comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
|
||||
if (isset($_REQUEST['field_comments'][$columnNumber])) {
|
||||
$comments_map[$columnMeta['Field']]
|
||||
= $_REQUEST['field_comments'][$columnNumber];
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['field_mimetype'][$i])) {
|
||||
$mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
|
||||
if (isset($_REQUEST['field_mimetype'][$columnNumber])) {
|
||||
$mime_map[$columnMeta['Field']]['mimetype']
|
||||
= $_REQUEST['field_mimetype'][$columnNumber];
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['field_transformation'][$i])) {
|
||||
$mime_map[$row['Field']]['transformation']
|
||||
= $_REQUEST['field_transformation'][$i];
|
||||
if (isset($_REQUEST['field_transformation'][$columnNumber])) {
|
||||
$mime_map[$columnMeta['Field']]['transformation']
|
||||
= $_REQUEST['field_transformation'][$columnNumber];
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['field_transformation_options'][$i])) {
|
||||
$mime_map[$row['Field']]['transformation_options']
|
||||
= $_REQUEST['field_transformation_options'][$i];
|
||||
if (isset($_REQUEST['field_transformation_options'][$columnNumber])) {
|
||||
$mime_map[$columnMeta['Field']]['transformation_options']
|
||||
= $_REQUEST['field_transformation_options'][$columnNumber];
|
||||
}
|
||||
|
||||
return array(
|
||||
$row, $submit_length, $submit_attribute, $submit_default_current_timestamp,
|
||||
$comments_map, $mime_map
|
||||
$columnMeta, $submit_length, $submit_attribute,
|
||||
$submit_default_current_timestamp, $comments_map, $mime_map
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get row data for $columnMeta set
|
||||
*
|
||||
* @param array $columnMeta column meta
|
||||
* @param bool $isDefault whether the row value is default
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_getColumnMetaForDefault($columnMeta, $isDefault)
|
||||
{
|
||||
switch ($columnMeta['Default']) {
|
||||
case null:
|
||||
if ($columnMeta['Null'] == 'YES') {
|
||||
$columnMeta['DefaultType'] = 'NULL';
|
||||
$columnMeta['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 ($isDefault) {
|
||||
$columnMeta['DefaultType'] = 'USER_DEFINED';
|
||||
$columnMeta['DefaultValue'] = $columnMeta['Default'];
|
||||
} else {
|
||||
$columnMeta['DefaultType'] = 'NONE';
|
||||
$columnMeta['DefaultValue'] = '';
|
||||
}
|
||||
break;
|
||||
case 'CURRENT_TIMESTAMP':
|
||||
$columnMeta['DefaultType'] = 'CURRENT_TIMESTAMP';
|
||||
$columnMeta['DefaultValue'] = '';
|
||||
break;
|
||||
default:
|
||||
$columnMeta['DefaultType'] = 'USER_DEFINED';
|
||||
$columnMeta['DefaultValue'] = $columnMeta['Default'];
|
||||
break;
|
||||
}
|
||||
|
||||
return $columnMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the column name
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $columnMeta column meta
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnName($columnNumber, $ci, $ci_offset, $columnMeta)
|
||||
{
|
||||
$html = '<input id="field_' . $columnNumber . '_' . ($ci - $ci_offset)
|
||||
. '"' . ' type="text" name="field_name[' . $columnNumber . ']"'
|
||||
. ' maxlength="64" class="textfield" title="' . __('Column') . '"'
|
||||
. ' size="10"'
|
||||
. ' value="'
|
||||
. (isset($columnMeta['Field'])
|
||||
? htmlspecialchars($columnMeta['Field']) : '')
|
||||
. '"' . ' />';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the column type
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param string $type_upper type inuppercase
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnType($columnNumber, $ci, $ci_offset, $type_upper)
|
||||
{
|
||||
$select_id = 'field_' . $columnNumber . '_' . ($ci - $ci_offset);
|
||||
$html = '<select class="column_type" name="field_type[' .
|
||||
$columnNumber . ']"' .' id="' . $select_id . '">';
|
||||
$html .= PMA_Util::getSupportedDatatypes(true, $type_upper);
|
||||
$html .= ' </select>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for transformation option
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $columnMeta column meta
|
||||
* @param array $mime_map mime map
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForTransformationOption($columnNumber, $ci, $ci_offset,
|
||||
$columnMeta, $mime_map
|
||||
) {
|
||||
$val = isset($columnMeta['Field'])
|
||||
&& isset($mime_map[$columnMeta['Field']]['transformation_options'])
|
||||
? htmlspecialchars(
|
||||
$mime_map[$columnMeta['Field']]
|
||||
['transformation_options']
|
||||
)
|
||||
: '';
|
||||
|
||||
$html = '<input id="field_' . $columnNumber . '_'
|
||||
. ($ci - $ci_offset) . '"' . ' type="text" '
|
||||
. 'name="field_transformation_options[' . $columnNumber . ']"'
|
||||
. ' size="16" class="textfield"'
|
||||
. ' value="' . $val . '"'
|
||||
. ' />';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for mime type
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $available_mime available mime
|
||||
* @param array $columnMeta column meta
|
||||
* @param array $mime_map mime map
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForMimeType($columnNumber, $ci, $ci_offset,
|
||||
$available_mime, $columnMeta, $mime_map
|
||||
) {
|
||||
$html = '<select id="field_' . $columnNumber . '_'
|
||||
. ($ci - $ci_offset)
|
||||
. '" size="1" name="field_mimetype[' . $columnNumber . ']">';
|
||||
$html .= ' <option value=""> </option>';
|
||||
|
||||
if (is_array($available_mime['mimetype'])) {
|
||||
foreach ($available_mime['mimetype'] as $mimetype) {
|
||||
$checked = (isset($columnMeta['Field'])
|
||||
&& isset($mime_map[$columnMeta['Field']]['mimetype'])
|
||||
&& ($mime_map[$columnMeta['Field']]['mimetype']
|
||||
== str_replace('/', '_', $mimetype))
|
||||
? 'selected '
|
||||
: '');
|
||||
$html .= ' <option value="'
|
||||
. str_replace('/', '_', $mimetype) . '" ' . $checked . '>'
|
||||
. htmlspecialchars($mimetype) . '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '</select>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for browser transformation
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $available_mime available mime
|
||||
* @param array $columnMeta column meta
|
||||
* @param array $mime_map mime map
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForBrowserTransformation($columnNumber, $ci, $ci_offset,
|
||||
$available_mime, $columnMeta, $mime_map
|
||||
) {
|
||||
$html = '<select id="field_' . $columnNumber . '_'
|
||||
. ($ci - $ci_offset) . '" size="1" name="field_transformation['
|
||||
. $columnNumber . ']">';
|
||||
$html .= ' <option value="" title="' . __('None')
|
||||
. '"></option>';
|
||||
if (is_array($available_mime['transformation'])) {
|
||||
foreach ($available_mime['transformation'] as $mimekey => $transform) {
|
||||
$checked = isset($columnMeta['Field'])
|
||||
&& isset($mime_map[$columnMeta['Field']]['transformation'])
|
||||
&& preg_match(
|
||||
'@' . preg_quote(
|
||||
$available_mime['transformation_file'][$mimekey]
|
||||
) . '3?@i',
|
||||
$mime_map[$columnMeta['Field']]['transformation']
|
||||
)
|
||||
? 'selected '
|
||||
: '';
|
||||
$tooltip = PMA_getTransformationDescription(
|
||||
$available_mime['transformation_file'][$mimekey], false
|
||||
);
|
||||
$html .= '<option value="'
|
||||
. $available_mime['transformation_file'][$mimekey] . '" '
|
||||
. $checked . ' title="' . htmlspecialchars($tooltip) . '">'
|
||||
. htmlspecialchars($transform) . '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '</select>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for move column
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $move_columns move columns
|
||||
* @param array $columnMeta column meta
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForMoveColumn($columnNumber, $ci, $ci_offset, $move_columns,
|
||||
$columnMeta
|
||||
) {
|
||||
$html = '<select id="field_' . $columnNumber . '_'
|
||||
. ($ci - $ci_offset) . '"' . ' name="field_move_to[' . $columnNumber
|
||||
. ']" size="1" width="5em">'
|
||||
. '<option value="" selected="selected"> </option>';
|
||||
// find index of current column
|
||||
$current_index = 0;
|
||||
for ($mi = 0, $cols = count($move_columns); $mi < $cols; $mi++) {
|
||||
if ($move_columns[$mi]->name == $columnMeta['Field']) {
|
||||
$current_index = $mi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '<option value="-first"'
|
||||
. ($current_index == 0 ? ' disabled="disabled"' : '')
|
||||
. '>' . __('first') . '</option>';
|
||||
for ($mi = 0, $cols = count($move_columns); $mi < $cols; $mi++) {
|
||||
$html .=
|
||||
'<option value="' . htmlspecialchars($move_columns[$mi]->name) . '"'
|
||||
. (($current_index == $mi || $current_index == $mi + 1)
|
||||
? ' disabled="disabled"'
|
||||
: '')
|
||||
.'>'
|
||||
. sprintf(
|
||||
__('after %s'),
|
||||
PMA_Util::backquote(
|
||||
htmlspecialchars(
|
||||
$move_columns[$mi]->name
|
||||
)
|
||||
)
|
||||
)
|
||||
. '</option>';
|
||||
}
|
||||
|
||||
$html .= '</select>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for column comment
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $columnMeta column meta
|
||||
* @param array $comments_map comments map
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnComment($columnNumber, $ci, $ci_offset, $columnMeta,
|
||||
$comments_map
|
||||
) {
|
||||
$html = '<input id="field_' . $columnNumber . '_' . ($ci - $ci_offset)
|
||||
. '"' . ' type="text" name="field_comments[' . $columnNumber
|
||||
. ']" size="12"'
|
||||
. ' value="' . (isset($columnMeta['Field'])
|
||||
&& is_array($comments_map)
|
||||
&& isset($comments_map[$columnMeta['Field']])
|
||||
? htmlspecialchars($comments_map[$columnMeta['Field']])
|
||||
: '') . '"'
|
||||
. ' class="textfield" />';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function get html for column auto increment
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $columnMeta column meta
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnAutoIncrement($columnNumber, $ci, $ci_offset,
|
||||
$columnMeta
|
||||
) {
|
||||
$html = '<input name="field_extra[' . $columnNumber . ']"'
|
||||
. ' id="field_' . $columnNumber . '_' . ($ci - $ci_offset) . '"';
|
||||
if (isset($columnMeta['Extra'])
|
||||
&& strtolower($columnMeta['Extra']) == 'auto_increment'
|
||||
) {
|
||||
$html .= ' checked="checked"';
|
||||
}
|
||||
|
||||
$html .= ' type="checkbox" value="AUTO_INCREMENT" />';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the column indexes
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $columnMeta column meta
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnIndexes($columnNumber, $ci, $ci_offset, $columnMeta)
|
||||
{
|
||||
$html = '<select name="field_key[' . $columnNumber . ']"'
|
||||
. ' id="field_' . $columnNumber . '_' . ($ci - $ci_offset) . '">';
|
||||
$html .= '<option value="none_' . $columnNumber . '">---</option>';
|
||||
|
||||
$html .= PMA_getHtmlForIndexTypeOption(
|
||||
$columnNumber, $columnMeta, 'Primary', 'PRI'
|
||||
);
|
||||
$html .= PMA_getHtmlForIndexTypeOption(
|
||||
$columnNumber, $columnMeta, 'Unique', 'UNI'
|
||||
);
|
||||
$html .= PMA_getHtmlForIndexTypeOption(
|
||||
$columnNumber, $columnMeta, 'Index', 'MUL'
|
||||
);
|
||||
if (!PMA_DRIZZLE) {
|
||||
$html .= PMA_getHtmlForIndexTypeOption(
|
||||
$columnNumber, $columnMeta, 'Fulltext', 'FULLTEXT'
|
||||
);
|
||||
}
|
||||
|
||||
$html .= '</select>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the index options
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param array $columnMeta column meta
|
||||
* @param string $type index type
|
||||
* @param string $key column meta key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
function PMA_getHtmlForIndexTypeOption($columnNumber, $columnMeta, $type, $key)
|
||||
{
|
||||
$html = '<option value="' . strtolower($type) . '_' . $columnNumber
|
||||
. '" title="'
|
||||
. __($type) . '"';
|
||||
if (isset($columnMeta['Key']) && $columnMeta['Key'] == $key) {
|
||||
$html .= ' selected="selected"';
|
||||
}
|
||||
$html .= '>' . strtoupper($type) . '</option>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to get html for column null
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $columnMeta column meta
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnNull($columnNumber, $ci, $ci_offset, $columnMeta)
|
||||
{
|
||||
$html = '<input name="field_null[' . $columnNumber . ']"'
|
||||
. ' id="field_' . $columnNumber . '_' . ($ci - $ci_offset) . '"';
|
||||
if (! empty($columnMeta['Null'])
|
||||
&& $columnMeta['Null'] != 'NO'
|
||||
&& $columnMeta['Null'] != 'NOT NULL'
|
||||
) {
|
||||
$html .= ' checked="checked"';
|
||||
}
|
||||
|
||||
$html .= ' type="checkbox" value="NULL" class="allow_null"/>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for column attribute
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $extracted_columnspec extracted column
|
||||
* @param array $columnMeta column meta
|
||||
* @param bool $submit_attribute submit attribute
|
||||
* @param array $analyzed_sql analyzed sql
|
||||
* @param bool $submit_default_current_timestamp submit default current time stamp
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnAttribute($columnNumber, $ci, $ci_offset,
|
||||
$extracted_columnspec, $columnMeta, $submit_attribute, $analyzed_sql,
|
||||
$submit_default_current_timestamp
|
||||
) {
|
||||
$html = '<select style="font-size: 70%;"'
|
||||
. ' name="field_attribute[' . $columnNumber . ']"'
|
||||
. ' id="field_' . $columnNumber . '_' . ($ci - $ci_offset) . '">';
|
||||
|
||||
$attribute = '';
|
||||
if (isset($extracted_columnspec)) {
|
||||
$attribute = $extracted_columnspec['attribute'];
|
||||
}
|
||||
|
||||
if (isset($columnMeta['Extra'])
|
||||
&& $columnMeta['Extra'] == 'on update CURRENT_TIMESTAMP'
|
||||
) {
|
||||
$attribute = 'on update CURRENT_TIMESTAMP';
|
||||
}
|
||||
|
||||
if (isset($submit_attribute) && $submit_attribute != false) {
|
||||
$attribute = $submit_attribute;
|
||||
}
|
||||
|
||||
// here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having the
|
||||
// NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
|
||||
// the latter.
|
||||
$create_table_fields = $analyzed_sql[0]['create_table_fields'];
|
||||
if (PMA_MYSQL_INT_VERSION < 50025
|
||||
&& isset($columnMeta['Field'])
|
||||
&& isset($create_table_fields[$columnMeta['Field']]['type'])
|
||||
&& $create_table_fields[$columnMeta['Field']]['type'] == 'TIMESTAMP'
|
||||
&& $create_table_fields[$columnMeta['Field']]['timestamp_not_null'] == true
|
||||
) {
|
||||
$columnMeta['Null'] = '';
|
||||
}
|
||||
|
||||
// MySQL 4.1.2+ TIMESTAMP options
|
||||
// (if on_update_current_timestamp is set, then it's TRUE)
|
||||
if(isset($columnMeta['Field'])){
|
||||
$field = $create_table_fields[$columnMeta['Field']];
|
||||
}
|
||||
|
||||
if (isset($field)
|
||||
&& isset($field['on_update_current_timestamp'])
|
||||
) {
|
||||
$attribute = 'on update CURRENT_TIMESTAMP';
|
||||
}
|
||||
if ((isset($columnMeta['Field'])
|
||||
&& isset($field['default_current_timestamp']))
|
||||
|| (isset($submit_default_current_timestamp)
|
||||
&& $submit_default_current_timestamp)
|
||||
) {
|
||||
$default_current_timestamp = true;
|
||||
} else {
|
||||
$default_current_timestamp = false;
|
||||
}
|
||||
|
||||
$attribute_types = $GLOBALS['PMA_Types']->getAttributes();
|
||||
$cnt_attribute_types = count($attribute_types);
|
||||
for ($j = 0; $j < $cnt_attribute_types; $j++) {
|
||||
$html
|
||||
.= ' <option value="' . $attribute_types[$j] . '"';
|
||||
if (strtoupper($attribute) == strtoupper($attribute_types[$j])) {
|
||||
$html .= ' selected="selected"';
|
||||
}
|
||||
$html .= '>' . $attribute_types[$j] . '</option>';
|
||||
}
|
||||
|
||||
$html .= '</select>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for column collation
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param array $columnMeta column meta
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnCollation($columnNumber, $ci, $ci_offset, $columnMeta)
|
||||
{
|
||||
$tmp_collation
|
||||
= empty($columnMeta['Collation']) ? null : $columnMeta['Collation'];
|
||||
$html = PMA_generateCharsetDropdownBox(
|
||||
PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $columnNumber . ']',
|
||||
'field_' . $columnNumber . '_' . ($ci - $ci_offset), $tmp_collation, false
|
||||
);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function get html for column length
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param int $length_values_input_size length values input size
|
||||
* @param int $length_to_display length to disply
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnLength($columnNumber, $ci, $ci_offset,
|
||||
$length_values_input_size, $length_to_display
|
||||
) {
|
||||
$html = '<input id="field_' . $columnNumber . '_' . ($ci - $ci_offset)
|
||||
. '"' . ' type="text" name="field_length[' . $columnNumber . ']" size="'
|
||||
. $length_values_input_size . '"' . ' value="' . htmlspecialchars(
|
||||
$length_to_display
|
||||
)
|
||||
. '"'
|
||||
. ' class="textfield" />'
|
||||
. '<p class="enum_notice" id="enum_notice_' . $columnNumber . '_'
|
||||
. ($ci - $ci_offset)
|
||||
. '">';
|
||||
$html .= __('ENUM or SET data too long?')
|
||||
. '<a href="#" class="open_enum_editor"> '
|
||||
. __('Get more editing space') . '</a>'
|
||||
. '</p>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the default column
|
||||
*
|
||||
* @param int $columnNumber column number
|
||||
* @param int $ci cell index
|
||||
* @param int $ci_offset cell index offset
|
||||
* @param string $type_upper type upper
|
||||
* @param string $default_current_timestamp default current timestamp
|
||||
* @param array $columnMeta column meta
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function PMA_getHtmlForColumnDefault($columnNumber, $ci, $ci_offset, $type_upper,
|
||||
$default_current_timestamp, $columnMeta
|
||||
) {
|
||||
// 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($columnMeta['Default'])
|
||||
) {
|
||||
$columnMeta['Default'] = '';
|
||||
}
|
||||
|
||||
if ($type_upper == 'BIT') {
|
||||
$columnMeta['DefaultValue']
|
||||
= PMA_Util::convertBitDefaultValue($columnMeta['DefaultValue']);
|
||||
}
|
||||
|
||||
$html = '<select name="field_default_type[' . $columnNumber
|
||||
. ']" id="field_' . $columnNumber . '_' . ($ci - $ci_offset)
|
||||
. '" class="default_type">';
|
||||
foreach ($default_options as $key => $value) {
|
||||
$html .= '<option value="' . $key . '"';
|
||||
// is only set when we go back to edit a field's structure
|
||||
if (isset($columnMeta['DefaultType'])
|
||||
&& $columnMeta['DefaultType'] == $key
|
||||
) {
|
||||
$html .= ' selected="selected"';
|
||||
}
|
||||
$html .= ' >' . $value . '</option>';
|
||||
}
|
||||
$html .= '</select>';
|
||||
$html .= '<br />';
|
||||
$html .= '<input type="text"'
|
||||
. ' name="field_default_value[' . $columnNumber . ']" size="12"'
|
||||
. ' value="' . (isset($columnMeta['DefaultValue'])
|
||||
? htmlspecialchars($columnMeta['DefaultValue'])
|
||||
: '') . '"'
|
||||
. ' class="textfield default_value" />';
|
||||
|
||||
return $html;
|
||||
}
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user