diff --git a/htdocs/sql/libraries/tbl_properties.inc.php b/htdocs/sql/libraries/tbl_properties.inc.php new file mode 100755 --- /dev/null +++ b/htdocs/sql/libraries/tbl_properties.inc.php @@ -0,0 +1,728 @@ + + + + = 40102) { + ?> + + + +
+ + + + + + + + + + + + $o_fld_val) { + ?> + + + + $o_fld_val) { + ?> + + + + " /> + ' . PMA_showMySQLDocu('SQL-Syntax', 'data-types') . ''); +$header_cells[] = $strLengthSet . '1'; +if (PMA_MYSQL_INT_VERSION >= 40100) { + $header_cells[] = $strCollation; +} +$header_cells[] = $strAttr; +$header_cells[] = $strNull; +$header_cells[] = $strDefault . '2'; +$header_cells[] = $strExtra; + + + +// lem9: 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[] = $cfg['PropertiesIconic'] ? '' . $strPrimary . '' : $strPrimary; + $header_cells[] = $cfg['PropertiesIconic'] ? '' . $strIndex . '' : $strIndex; + $header_cells[] = $cfg['PropertiesIconic'] ? '' . $strUnique . '' : $strUnique; + $header_cells[] = '---'; + $header_cells[] = $cfg['PropertiesIconic'] ? '' . $strIdxFulltext . '' : $strIdxFulltext; +} + +require_once './libraries/relation.lib.php'; +require_once './libraries/transformations.lib.php'; +$cfgRelation = PMA_getRelationsParam(); + +$comments_map = array(); +$mime_map = array(); +$available_mime = array(); + +if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) { + $comments_map = PMA_getComments($db, $table); + $header_cells[] = $strComments; + + if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) { + $mime_map = PMA_getMIME($db, $table); + $available_mime = PMA_getAvailableMIMEtypes(); + + $header_cells[] = $strMIME_MIMEtype; + $header_cells[] = $strMIME_transformation; + $header_cells[] = $strMIME_transformation_options . '3'; + } +} + +// garvin: 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++) { + $submit_null = FALSE; + if (isset($regenerate) && $regenerate == TRUE) { + // An error happened with previous inputs, so we will restore the data + // to embed it once again in this form. + + $row['Field'] = (isset($field_name) && isset($field_name[$i]) ? $field_name[$i] : FALSE); + $row['Type'] = (isset($field_type) && isset($field_type[$i]) ? $field_type[$i] : FALSE); + if (PMA_MYSQL_INT_VERSION >= 40100) { + $row['Collation'] = (isset($field_collation) && isset($field_collation[$i]) ? $field_collation[$i] : ''); + } + $row['Null'] = (isset($field_null) && isset($field_null[$i]) ? $field_null[$i] : ''); + if (isset($field_type[$i]) && $row['Null'] == '') { + $submit_null = TRUE; + } + + if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) { + $row['Key'] = 'PRI'; + } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) { + $row['Key'] = 'MUL'; + } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) { + $row['Key'] = 'UNI'; + } else { + $row['Key'] = ''; + } + + $row['Default'] = (isset($field_default) && isset($field_default[$i]) ? $field_default[$i] : FALSE); + $row['Extra'] = (isset($field_extra) && isset($field_extra[$i]) ? $field_extra[$i] : FALSE); + $row['Comment'] = (isset($submit_fulltext) && isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE); + + $submit_length = (isset($field_length) && isset($field_length[$i]) ? $field_length[$i] : FALSE); + $submit_attribute = (isset($field_attribute) && isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE); + + $submit_default_current_timestamp = (isset($field_default_current_timestamp) && isset($field_default_current_timestamp[$i]) ? TRUE : FALSE); + + if (isset($field_comments) && isset($field_comments[$i])) { + $comments_map[$row['Field']] = $field_comments[$i]; + } + + if (isset($field_mimetype) && isset($field_mimetype[$i])) { + $mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i]; + } + + if (isset($field_transformation) && isset($field_transformation[$i])) { + $mime_map[$row['Field']]['transformation'] = $field_transformation[$i]; + } + + if (isset($field_transformation_options) && isset($field_transformation_options[$i])) { + $mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i]; + } + + } elseif (isset($fields_meta) && isset($fields_meta[$i])) { + $row = $fields_meta[$i]; + } + + if (isset($row) && isset($row['Type'])) { + $type_and_length = PMA_extract_type_length($row['Type']); + if ($type_and_length['type'] == 'bit') { + $row['Default'] = PMA_printable_bit_value($row['Default'], $type_and_length['length']); + } + } + + // Cell index: If certain fields get left out, the counter shouldn't chage. + $ci = 0; + // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset + // has to be incremented ($ci_offset++) + $ci_offset = -1; + + if ($is_backup) { + $backup_field = (isset($true_selected) && isset($true_selected[$i]) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : '')); + $content_cells[$i][$ci] = "\n" . '' . "\n"; + } else { + $content_cells[$i][$ci] = ''; + } + + $content_cells[$i][$ci] .= "\n" . ''; + $ci++; + $content_cells[$i][$ci] = ''; + $ci++; + + if ($is_backup) { + $content_cells[$i][$ci] = "\n" . ''; + } else { + $content_cells[$i][$ci] = ''; + } + + if (preg_match('@^(set|enum)$@i', $type)) { + $binary = 0; + $unsigned = 0; + $zerofill = 0; + $length_to_display = htmlspecialchars($length); + } else { + $length_to_display = $length; + if (!preg_match('@BINARY[\(]@i', $row['Type']) && PMA_MYSQL_INT_VERSION < 40100) { + $binary = stristr($row['Type'], 'binary'); + } else { + $binary = FALSE; + } + $unsigned = stristr($row['Type'], 'unsigned'); + $zerofill = stristr($row['Type'], 'zerofill'); + } + + $content_cells[$i][$ci] .= "\n" . '' . "\n"; + $ci++; + + if (PMA_MYSQL_INT_VERSION >= 40100) { + $tmp_collation = empty($row['Collation']) ? null : $row['Collation']; + $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[]', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, FALSE); + unset($tmp_collation); + $ci++; + } + + $content_cells[$i][$ci] = ''; + $ci++; + + $content_cells[$i][$ci] = ''; + $ci++; + + if (isset($row) + && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') { + $row['Default'] = 'NULL'; + } + + if ($is_backup) { + $content_cells[$i][$ci] = "\n" . ''; + } else { + $content_cells[$i][$ci] = "\n"; + } + + // for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value + if (PMA_MYSQL_INT_VERSION >= 40102 + && $type_upper == 'TIMESTAMP' + && $default_current_timestamp + && isset($row) + && isset($row['Default'])) { + $row['Default'] = ''; + } + + $content_cells[$i][$ci] .= ''; + if (PMA_MYSQL_INT_VERSION >= 40102) { + if ($type_upper == 'TIMESTAMP') { + $tmp_display_type = 'block'; + } else { + $tmp_display_type = 'none'; + $default_current_timestamp = FALSE; + } + $content_cells[$i][$ci] .= '
CURRENT_TIMESTAMP
'; + } + $ci++; + + $content_cells[$i][$ci] = ''; + $ci++; + + + // lem9: See my other comment about removing this 'if'. + if (!$is_backup) { + if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') { + $checked_primary = ' checked="checked"'; + } else { + $checked_primary = ''; + } + if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') { + $checked_index = ' checked="checked"'; + } else { + $checked_index = ''; + } + if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') { + $checked_unique = ' checked="checked"'; + } else { + $checked_unique = ''; + } + if (empty($checked_primary) + && empty($checked_index) + && empty($checked_unique)) { + $checked_none = ' checked="checked"'; + } else { + $checked_none = ''; + } + + if ((isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) { + $checked_fulltext = ' checked="checked"'; + } else { + $checked_fulltext = ''; + } + + $content_cells[$i][$ci] = "\n" . ''; + $ci++; + + $content_cells[$i][$ci] = "\n" . ''; + $ci++; + + $content_cells[$i][$ci] = "\n" . ''; + $ci++; + + $content_cells[$i][$ci] = "\n" . ''; + $ci++; + + $content_cells[$i][$ci] = ''; + $ci++; + } // end if ($action ==...) + + // garvin: comments + if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) { + $content_cells[$i][$ci] = ''; + $ci++; + } + + // garvin: MIME-types + if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) { + $content_cells[$i][$ci] = ''; + $ci++; + + $content_cells[$i][$ci] = ''; + $ci++; + + $content_cells[$i][$ci] = ''; + //$ci++; + } +} // end for + +if (is_array($content_cells) && is_array($header_cells)) { + // last row is for javascript insert + $empty_row = array_pop($content_cells); + + echo ''; + if ($display_type == 'horizontal') { + ?> + + + + + + '; + $odd_row = ! $odd_row; + + if (is_array($content_row)) { + foreach ($content_row as $content_row_val) { + ?> + + '; + } + } else { + $i = 0; + $odd_row = true; + foreach ($header_cells as $header_val) { + echo ''; + $odd_row = ! $odd_row; + ?> + + + + '; + $i++; + } + } + ?> +
+
+ ' . $content_row_val . ''; + } + ?> + + + + + + + + = 40100) { + echo ' ' . "\n" + . ' ' . "\n"; + } + ?> + + + + + = 40100) { + echo ' ' . "\n" + . ' ' . "\n"; + } + ?> + +
  +  ' . $strCollation . ': 
+   + +  ' . "\n" + . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, (isset($tbl_collation) ? $tbl_collation : null), FALSE, 3) + . '
+
+ + +
+ + + + '); ?> + + onclick="return checkFormElementInRange(this.form, 'added_fields', '', 1)" + /> + +
+ +
+ +
+

1

+

2

+ 3 ' . $strMIME_transformation_options_note . '

'; + echo '

'; + printf($strMIME_transformation_note, + '', + ''); + echo '

'; +} +?> +
+ +