Merge branch 'master' of github.com:phpmyadmin/phpmyadmin

This commit is contained in:
Madhura Jayaratne 2012-04-29 22:48:33 +05:30
commit b91c8cd097
5 changed files with 112 additions and 85 deletions

View File

@ -403,8 +403,31 @@ $(function() {
buttons: button_options_error
}); // end dialog options
} else {
// sort the fields table
var $fields_table = $("table#tablestructure tbody");
// remove all existing rows and remember them
var $rows = $fields_table.find("tr").remove();
// loop through the correct order
for (var i in data.columns) {
var the_column = data.columns[i];
var $the_row
= $rows
.find("input:checkbox[value=" + the_column + "]")
.closest("tr");
// append the row for this column to the table
$fields_table.append($the_row);
}
var $firstrow = $fields_table.find("tr").eq(0);
// Adjust the row numbers and colors
for (var $row = $firstrow; $row.length > 0; $row = $row.next()) {
$row
.find('td:nth-child(2)')
.text($row.index() + 1)
.end()
.removeClass("odd even")
.addClass($row.index() % 2 == 0 ? "odd" : "even");
}
PMA_ajaxShowMessage(data.message);
reloadFieldForm();
$this.dialog('close');
}
});
@ -630,6 +653,7 @@ $(function() {
if ($form.hasClass('ajax')) {
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
PMA_ajaxShowMessage();
$.post($form.attr('action'), $form.serialize()+"&do_save_data=Save", function(data) {
if ($("#sqlqueryresults").length != 0) {
$("#sqlqueryresults").remove();
@ -637,7 +661,6 @@ $(function() {
$(".error").remove();
}
if (data.success == true) {
PMA_ajaxShowMessage(data.message);
$("<div id='sqlqueryresults'></div>").insertAfter("#floating_menubar");
$("#sqlqueryresults").html(data.sql_query);
$("#result_query .notice").remove();
@ -648,7 +671,7 @@ $(function() {
$("#add_columns").dialog("close").remove();
}
/*Reload the field form*/
reloadFieldForm();
reloadFieldForm(data.message);
} else {
var $temp_div = $("<div id='temp_div'><div>").append(data);
var $error = $temp_div.find(".error code").addClass("error");
@ -668,7 +691,7 @@ $(function() {
/**
* Reload fields table
*/
function reloadFieldForm() {
function reloadFieldForm(message) {
$.post($("#fieldsForm").attr('action'), $("#fieldsForm").serialize()+"&ajax_request=true", function(form_data) {
var $temp_div = $("<div id='temp_div'><div>").append(form_data);
$("#fieldsForm").replaceWith($temp_div.find("#fieldsForm"));
@ -679,6 +702,9 @@ function reloadFieldForm() {
$table_clone = false;
$("div.replace_in_more").hide(); // fix "more" dropdown
moreOptsMenuResize();
setTimeout(function() {
PMA_ajaxShowMessage(message);
}, 500);
});
}

View File

@ -201,10 +201,20 @@ if (isset($plugin_list)) {
$schema_insert .= '<td class="print"><strong>' . __('Default') . '</strong></td>';
$schema_insert .= '</tr>';
/**
* Get the unique keys in the table
*/
$unique_keys = array();
$keys = PMA_DBI_get_table_indexes($db, $table);
foreach ($keys as $key) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
$columns = PMA_DBI_get_columns($db, $view);
foreach ($columns as $column) {
$schema_insert .= PMA_formatOneColumnDefinition($column);
$schema_insert .= PMA_formatOneColumnDefinition($column, $unique_keys);
$schema_insert .= '</tr>';
}
@ -295,8 +305,18 @@ if (isset($plugin_list)) {
$schema_insert .= '</tr>';
$columns = PMA_DBI_get_columns($db, $table);
/**
* Get the unique keys in the table
*/
$unique_keys = array();
$keys = PMA_DBI_get_table_indexes($db, $table);
foreach ($keys as $key) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
foreach ($columns as $column) {
$schema_insert .= PMA_formatOneColumnDefinition($column);
$schema_insert .= PMA_formatOneColumnDefinition($column, $unique_keys);
$field_name = $column['Field'];
if ($do_relation && $have_rel) {
@ -407,28 +427,15 @@ if (isset($plugin_list)) {
* Formats the definition for one column
*
* @param array $column info about this column
* @param array $unique_keys unique keys of the table
*
* @return string Formatted column definition
*
* @access public
*/
function PMA_formatOneColumnDefinition(
$column
$column, $unique_keys
) {
/**
* Get the unique keys in the table
*/
$unique_keys = array();
$keys = PMA_DBI_get_table_indexes($db, $table);
foreach ($keys as $key) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
/**
* Formats the definition
*/
$definition = '<tr class="print-category">';
$extracted_columnspec = PMA_extractColumnSpec($column['Type']);
$type = htmlspecialchars($extracted_columnspec['print_type']);

View File

@ -177,7 +177,7 @@ if (isset($plugin_list)) {
* Get the unique keys in the table
*/
$unique_keys = array();
$keys = PMA_DBI_get_table_indexes($db, $table);
$keys = PMA_DBI_get_table_indexes($db, $view);
foreach ($keys as $key) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
@ -202,39 +202,11 @@ if (isset($plugin_list)) {
$text_output .= '|' . __('Default');
$text_output .= "\n|------\n";
$columns = PMA_DBI_get_columns($db, $table);
$columns = PMA_DBI_get_columns($db, $view);
foreach ($columns as $column) {
$extracted_columnspec = PMA_extractColumnSpec($column['Type']);
$type = $extracted_columnspec['print_type'];
if (empty($type)) {
$type = '&nbsp;';
}
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
}
}
$fmt_pre = '';
$fmt_post = '';
if (in_array($column['Field'], $unique_keys)) {
$fmt_pre = '**' . $fmt_pre;
$fmt_post = $fmt_post . '**';
}
if ($column['Key']=='PRI') {
$fmt_pre = '//' . $fmt_pre;
$fmt_post = $fmt_post . '//';
}
$text_output .= '|' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post;
$text_output .= '|' . htmlspecialchars($type);
$text_output .= '|' . (($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes'));
$text_output .= '|' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '');
$field_name = $column['Field'];
$text_output .= PMA_formatOneColumnDefinition($column, $unique_keys);
$text_output .= "\n";
} // end while
} // end foreach
return $text_output;
}
@ -333,34 +305,7 @@ if (isset($plugin_list)) {
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$extracted_columnspec = PMA_extractColumnSpec($column['Type']);
$type = $extracted_columnspec['print_type'];
if (empty($type)) {
$type = '&nbsp;';
}
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
}
}
$fmt_pre = '';
$fmt_post = '';
if (in_array($column['Field'], $unique_keys)) {
$fmt_pre = '**' . $fmt_pre;
$fmt_post = $fmt_post . '**';
}
if ($column['Key']=='PRI') {
$fmt_pre = '//' . $fmt_pre;
$fmt_post = $fmt_post . '//';
}
$text_output .= '|' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post;
$text_output .= '|' . htmlspecialchars($type);
$text_output .= '|' . (($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes'));
$text_output .= '|' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '');
$text_output .= PMA_formatOneColumnDefinition($column, $unique_keys);
$field_name = $column['Field'];
if ($do_relation && $have_rel) {
@ -374,7 +319,7 @@ if (isset($plugin_list)) {
}
$text_output .= "\n";
} // end while
} // end foreach
return $text_output;
} // end of the 'PMA_getTableDef()' function
@ -465,5 +410,46 @@ if (isset($plugin_list)) {
return PMA_exportOutputHandler($dump);
}
/**
* Formats the definition for one column
*
* @param array $column info about this column
* @param array $unique_keys unique keys for this table
*
* @return string Formatted column definition
*
* @access public
*/
function PMA_formatOneColumnDefinition(
$column, $unique_keys
) {
$extracted_columnspec = PMA_extractColumnSpec($column['Type']);
$type = $extracted_columnspec['print_type'];
if (empty($type)) {
$type = '&nbsp;';
}
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
}
}
$fmt_pre = '';
$fmt_post = '';
if (in_array($column['Field'], $unique_keys)) {
$fmt_pre = '**' . $fmt_pre;
$fmt_post = $fmt_post . '**';
}
if ($column['Key']=='PRI') {
$fmt_pre = '//' . $fmt_pre;
$fmt_post = $fmt_post . '//';
}
$definition = '|' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post;
$definition .= '|' . htmlspecialchars($type);
$definition .= '|' . (($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes'));
$definition .= '|' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '');
return $definition;
}
}
?>

View File

@ -39,7 +39,7 @@ $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
/**
* Moving columns
*/
if (isset($_REQUEST['move_columns'])
if (isset($_REQUEST['move_columns'])
&& is_array($_REQUEST['move_columns'])
&& $GLOBALS['is_ajax_request']) {
/*
@ -127,7 +127,13 @@ if (isset($_REQUEST['move_columns'])
if ($tmp_error) {
PMA_ajaxResponse(PMA_Message::error($tmp_error), false);
}
PMA_ajaxResponse(PMA_Message::success(__('The columns have been moved successfully.')), true);
PMA_ajaxResponse(
PMA_Message::success(__('The columns have been moved successfully.')),
true,
array(
'columns' => $column_names
)
);
}
/**

View File

@ -108,7 +108,9 @@ if (isset($_REQUEST['do_save_data'])) {
? $_REQUEST['field_comments'][$i]
: '',
$field_primary,
$i
$i,
'',
''
);
$query .= ', ';