Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThilina Buddika <thilinaabeyrathna@gmail.com>2012-05-14 08:51:38 +0400
committerThilina Buddika <thilinaabeyrathna@gmail.com>2012-05-14 08:51:38 +0400
commit23b95543c5310d92b2ddd1734778eba041496c76 (patch)
tree5718c08e16985cee730aff792f80074e8bf41afb /tbl_change.php
parentb1b57f7131b2dc0e740df5d3d9639a9551721c18 (diff)
parent791c08bef3f08b1f0c13681799c72dd89948b6eb (diff)
code improvement in tbl_change
Diffstat (limited to 'tbl_change.php')
-rw-r--r--tbl_change.php362
1 files changed, 6 insertions, 356 deletions
diff --git a/tbl_change.php b/tbl_change.php
index f097feff90..21983fe85b 100644
--- a/tbl_change.php
+++ b/tbl_change.php
@@ -382,6 +382,7 @@ foreach ($rows as $row_id => $vrow) {
} else {
$data = $column['Default'];
}
+
if ($column['True_Type'] == 'bit') {
$special_chars = PMA_convert_bit_default_value($column['Default']);
} else {
@@ -427,362 +428,11 @@ foreach ($rows as $row_id => $vrow) {
// Will be used by js/tbl_change.js to set the default value
// for the "Continue insertion" feature
echo '<span class="default_value hide">' . $special_chars . '</span>';
- if ($foreignData['foreign_link'] == true) {
- echo $backup_field . "\n";
- ?>
- <input type="hidden" name="fields_type<?php echo $column_name_appendix; ?>"
- value="foreign" />
- <input type="text" name="fields<?php echo $column_name_appendix; ?>"
- class="textfield" <?php echo $unnullify_trigger; ?>
- tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
- id="field_<?php echo ($idindex); ?>_3"
- value="<?php echo htmlspecialchars($data); ?>" />
- <a class="hide foreign_values_anchor" target="_blank" onclick="window.open(this.href, 'foreigners', 'width=640,height=240,scrollbars=yes,resizable=yes'); return false;" href="browse_foreigners.php?<?php echo PMA_generate_common_url($db, $table); ?>&amp;field=<?php echo PMA_escapeJsString(urlencode($column['Field']) . $rownumber_param); ?>"><?php echo str_replace("'", "\'", $titles['Browse']); ?></a>
- <?php
- } elseif (is_array($foreignData['disp_row'])) {
- echo $backup_field . "\n";
- ?>
- <input type="hidden" name="fields_type<?php echo $column_name_appendix; ?>"
- value="foreign" />
- <select name="fields<?php echo $column_name_appendix; ?>"
- <?php echo $unnullify_trigger; ?>
- class="textfield"
- tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
- id="field_<?php echo ($idindex); ?>_3">
- <?php echo PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $data, $cfg['ForeignKeyMaxLimit']); ?>
- </select>
- <?php
- // still needed? :
- unset($foreignData['disp_row']);
- } elseif ($cfg['LongtextDoubleTextarea'] && strstr($column['pma_type'], 'longtext')) {
- ?>
- &nbsp;</td>
- </tr>
- <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
- <td colspan="5" class="right">
- <?php echo $backup_field . "\n"; ?>
- <textarea name="fields<?php echo $column_name_appendix; ?>"
- rows="<?php echo ($cfg['TextareaRows']*2); ?>"
- cols="<?php echo ($cfg['TextareaCols']*2); ?>"
- dir="<?php echo $text_dir; ?>"
- id="field_<?php echo ($idindex); ?>_3"
- <?php echo $unnullify_trigger; ?>
- tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
- ><?php echo $special_chars_encoded; ?>
- </textarea>
- <?php
- } elseif (strstr($column['pma_type'], 'text')) {
- echo $backup_field . "\n";
- ?>
- <textarea name="fields<?php echo $column_name_appendix; ?>"
- rows="<?php echo $cfg['TextareaRows']; ?>"
- cols="<?php echo $cfg['TextareaCols']; ?>"
- dir="<?php echo $text_dir; ?>"
- id="field_<?php echo ($idindex); ?>_3"
- <?php echo $unnullify_trigger; ?>
- tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
- ><?php echo $special_chars_encoded; ?>
- </textarea>
- <?php
- echo "\n";
- if (strlen($special_chars) > 32000) {
- echo " </td>\n";
- echo ' <td>' . __('Because of its length,<br /> this column might not be editable');
- }
- } elseif ($column['pma_type'] == 'enum') {
- if (! isset($table_fields[$i]['values'])) {
- $table_fields[$i]['values'] = array();
- foreach ($extracted_columnspec['enum_set_values'] as $val) {
- // Removes automatic MySQL escape format
- $val = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $val));
- $table_fields[$i]['values'][] = array(
- 'plain' => $val,
- 'html' => htmlspecialchars($val),
- );
- }
- }
- $column_enum_values = $table_fields[$i]['values'];
- ?>
- <input type="hidden" name="fields_type<?php echo $column_name_appendix; ?>" value="enum" />
- <input type="hidden" name="fields<?php echo $column_name_appendix; ?>" value="" />
- <?php
- echo "\n" . ' ' . $backup_field . "\n";
-
- // show dropdown or radio depend on length
- if (strlen($column['Type']) > 20) {
- ?>
- <select name="fields<?php echo $column_name_appendix; ?>"
- <?php echo $unnullify_trigger; ?>
- class="textfield"
- tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
- id="field_<?php echo ($idindex); ?>_3">
- <option value="">&nbsp;</option>
- <?php
- echo "\n";
-
- foreach ($column_enum_values as $enum_value) {
- echo ' ';
- echo '<option value="' . $enum_value['html'] . '"';
- if ($data == $enum_value['plain']
- || ($data == ''
- && (! isset($where_clause) || $column['Null'] != 'YES')
- && isset($column['Default'])
- && $enum_value['plain'] == $column['Default'])
- ) {
- echo ' selected="selected"';
- }
- echo '>' . $enum_value['html'] . '</option>' . "\n";
- } // end for
-
- ?>
- </select>
- <?php
- } else {
- $j = 0;
- foreach ($column_enum_values as $enum_value) {
- echo ' ';
- echo '<input type="radio" name="fields' . $column_name_appendix . '"';
- echo ' class="textfield"';
- echo ' value="' . $enum_value['html'] . '"';
- echo ' id="field_' . ($idindex) . '_3_' . $j . '"';
- echo $unnullify_trigger;
- if ($data == $enum_value['plain']
- || ($data == ''
- && (! isset($where_clause) || $column['Null'] != 'YES')
- && isset($column['Default'])
- && $enum_value['plain'] == $column['Default'])
- ) {
- echo ' checked="checked"';
- }
- echo ' tabindex="' . ($tabindex + $tabindex_for_value) . '" />';
- echo '<label for="field_' . $idindex . '_3_' . $j . '">'
- . $enum_value['html'] . '</label>' . "\n";
- $j++;
- } // end for
- } // end else
- } elseif ($column['pma_type'] == 'set') {
- if (! isset($table_fields[$i]['values'])) {
- $table_fields[$i]['values'] = array();
- foreach ($extracted_columnspec['enum_set_values'] as $val) {
- $table_fields[$i]['values'][] = array(
- 'plain' => $val,
- 'html' => htmlspecialchars($val),
- );
- }
- $table_fields[$i]['select_size'] = min(4, count($table_fields[$i]['values']));
- }
- $column_set_values = $table_fields[$i]['values'];
- $select_size = $table_fields[$i]['select_size'];
-
- $vset = array_flip(explode(',', $data));
- echo $backup_field . "\n";
- ?>
- <input type="hidden" name="fields_type<?php echo $column_name_appendix; ?>" value="set" />
- <select name="fields<?php echo $column_name_appendix . '[]'; ?>"
- class="textfield"
- size="<?php echo $select_size; ?>"
- multiple="multiple" <?php echo $unnullify_trigger; ?>
- tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
- id="field_<?php echo ($idindex); ?>_3">
- <?php
- foreach ($column_set_values as $column_set_value) {
- echo ' ';
- echo '<option value="' . $column_set_value['html'] . '"';
- if (isset($vset[$column_set_value['plain']])) {
- echo ' selected="selected"';
- }
- echo '>' . $column_set_value['html'] . '</option>' . "\n";
- } // end for
- ?>
- </select>
- <?php
- // We don't want binary data destroyed
- } elseif ($column['is_binary'] || $column['is_blob']) {
- if (($cfg['ProtectBinary'] && $column['is_blob'])
- || ($cfg['ProtectBinary'] == 'all' && $column['is_binary'])
- || ($cfg['ProtectBinary'] == 'noblob' && !$column['is_blob'])
- ) {
- echo __('Binary - do not edit');
- if (isset($data)) {
- $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
- echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
- unset($data_size);
- }
- ?>
- <input type="hidden" name="fields_type<?php echo $column_name_appendix; ?>" value="protected" />
- <input type="hidden" name="fields<?php echo $column_name_appendix; ?>" value="" />
- <?php
- } elseif ($column['is_blob']) {
- echo "\n";
- echo $backup_field . "\n";
- ?>
- <textarea name="fields<?php echo $column_name_appendix; ?>"
- rows="<?php echo $cfg['TextareaRows']; ?>"
- cols="<?php echo $cfg['TextareaCols']; ?>"
- dir="<?php echo $text_dir; ?>"
- id="field_<?php echo ($idindex); ?>_3"
- <?php echo $unnullify_trigger; ?>
- tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
- ><?php echo $special_chars_encoded; ?></textarea>
- <?php
-
- } else {
- // field size should be at least 4 and max $cfg['LimitChars']
- $columnsize = min(max($column['len'], 4), $cfg['LimitChars']);
- echo "\n";
- echo $backup_field . "\n";
- ?>
- <input type="text" name="fields<?php echo $column_name_appendix; ?>"
- value="<?php echo $special_chars; ?>" size="<?php echo $columnsize; ?>"
- class="textfield" <?php echo $unnullify_trigger; ?>
- tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
- id="field_<?php echo ($idindex); ?>_3" />
- <?php
- } // end if...elseif...else
-
- // Upload choice (only for BLOBs because the binary
- // attribute does not imply binary contents)
- // (displayed whatever value the ProtectBinary has)
-
- if ($is_upload && $column['is_blob']) {
- echo '<br />';
- echo '<input type="file" name="fields_upload' . $vkey . '[' . $column['Field_md5'] . ']" class="textfield" id="field_' . $idindex . '_3" size="10" ' . $unnullify_trigger . '/>&nbsp;';
-
- // find maximum upload size, based on field type
- /**
- * @todo with functions this is not so easy, as you can basically
- * process any data with function like MD5
- */
- $max_field_sizes = array(
- 'tinyblob' => '256',
- 'blob' => '65536',
- 'mediumblob' => '16777216',
- 'longblob' => '4294967296'); // yeah, really
-
- $this_field_max_size = $max_upload_size; // from PHP max
- if ($this_field_max_size > $max_field_sizes[$column['pma_type']]) {
- $this_field_max_size = $max_field_sizes[$column['pma_type']];
- }
- echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n";
- // do not generate here the MAX_FILE_SIZE, because we should
- // put only one in the form to accommodate the biggest field
- if ($this_field_max_size > $biggest_max_file_size) {
- $biggest_max_file_size = $this_field_max_size;
- }
- }
-
- if (!empty($cfg['UploadDir'])) {
- $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']));
- if ($files === false) {
- echo ' <font color="red">' . __('Error') . '</font><br />' . "\n";
- echo ' ' . __('The directory you set for upload work cannot be reached') . "\n";
- } elseif (!empty($files)) {
- echo "<br />\n";
- echo ' <i>' . __('Or') . '</i>' . ' ' . __('web server upload directory') . ':<br />' . "\n";
- echo ' <select size="1" name="fields_uploadlocal' . $vkey . '[' . $column['Field_md5'] . ']">' . "\n";
- echo ' <option value="" selected="selected"></option>' . "\n";
- echo $files;
- echo ' </select>' . "\n";
- }
- } // end if (web-server upload directory)
- // end elseif (binary or blob)
- } elseif (! in_array($column['pma_type'], $no_support_types)) {
- // ignore this column to avoid changing it
- if ($column['is_char']) {
- $columnsize = $extracted_columnspec['spec_in_brackets'];
- if ($columnsize > $cfg['MaxSizeForInputField']) {
- /**
- * This case happens for CHAR or VARCHAR columns which have
- * a size larger than the maximum size for input field.
- */
- $cfg['CharEditing'] = 'textarea';
- }
- } else {
- /**
- * This case happens for example for INT or DATE columns;
- * in these situations, the value returned in $column['len']
- * seems appropriate.
- */
- $columnsize = $column['len'];
- }
- $columnsize = min(max($columnsize, $cfg['MinSizeForInputField']), $cfg['MaxSizeForInputField']);
- echo $backup_field . "\n";
- if ($column['is_char']
- && ($cfg['CharEditing'] == 'textarea'
- || strpos($data, "\n") !== false)
- ) {
- echo "\n";
- $cfg['CharEditing'] = $default_char_editing;
- ?>
- <textarea class="char" name="fields<?php echo $column_name_appendix; ?>"
- rows="<?php echo $cfg['CharTextareaRows']; ?>"
- cols="<?php echo $cfg['CharTextareaCols']; ?>"
- dir="<?php echo $text_dir; ?>"
- id="field_<?php echo ($idindex); ?>_3"
- <?php echo $unnullify_trigger; ?>
- tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
- ><?php echo $special_chars_encoded; ?></textarea>
- <?php
- } else {
- $the_class = 'textfield';
- if ($column['pma_type'] == 'date') {
- $the_class .= ' datefield';
- } elseif ($column['pma_type'] == 'datetime'
- || substr($column['pma_type'], 0, 9) == 'timestamp'
- ) {
- $the_class .= ' datetimefield';
- }
- ?>
- <input type="text" name="fields<?php echo $column_name_appendix; ?>"
- value="<?php echo $special_chars; ?>" size="<?php echo $columnsize; ?>"
- class="<?php echo $the_class; ?>" <?php echo $unnullify_trigger; ?>
- tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
- id="field_<?php echo ($idindex); ?>_3" />
- <?php
- if ($column['Extra'] == 'auto_increment') {
- ?>
- <input type="hidden" name="auto_increment<?php echo $column_name_appendix; ?>" value="1" />
- <?php
- } // end if
- if (substr($column['pma_type'], 0, 9) == 'timestamp') {
- ?>
- <input type="hidden" name="fields_type<?php echo $column_name_appendix; ?>" value="timestamp" />
- <?php
- }
- if (substr($column['pma_type'], 0, 8) == 'datetime') {
- ?>
- <input type="hidden" name="fields_type<?php echo $column_name_appendix; ?>" value="datetime" />
- <?php
- }
- if ($column['True_Type'] == 'bit') {
- ?>
- <input type="hidden" name="fields_type<?php echo $column_name_appendix; ?>" value="bit" />
- <?php
- }
- if ($column['pma_type'] == 'date'
- || $column['pma_type'] == 'datetime'
- || substr($column['pma_type'], 0, 9) == 'timestamp'
- ) {
- // the _3 suffix points to the date field
- // the _2 suffix points to the corresponding NULL checkbox
- // in dateFormat, 'yy' means the year with 4 digits
- }
- }
- }
- if (in_array($column['pma_type'], $gis_data_types)) {
- $data_val = isset($vrow[$column['Field']]) ? $vrow[$column['Field']] : '';
- $_url_params = array(
- 'field' => $column['Field_title'],
- 'value' => $data_val,
- );
- if ($column['pma_type'] != 'geometry') {
- $_url_params = $_url_params + array('gis_data[gis_type]' => strtoupper($column['pma_type']));
- }
- $edit_str = PMA_getIcon('b_edit.png', __('Edit/Insert'));
- echo '<span class="open_gis_editor">';
- echo PMA_linkOrButton('#', $edit_str, array(), false, false, '_blank');
- echo '</span>';
- }
+
+ echo PMA_getValueColumn($column, $backup_field, $column_name_appendix, $unnullify_trigger,
+ $tabindex, $tabindex_for_value, $idindex, $data,$special_chars, $foreignData, $odd_row,
+ $paramTableDbArray,$rownumber_param, $titles, $text_dir, $special_chars_encoded, $vkey,$is_upload,
+ $biggest_max_file_size, $default_char_editing, $no_support_types, $gis_data_types, $extracted_columnspec);
?>
</td>
</tr>