Permalink
Browse files

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

  • Loading branch information...
madhuracj committed Apr 29, 2012
2 parents b327bba + afaa480 commit b91c8cd097e57a065eeab203621dad2671728462
Showing with 112 additions and 85 deletions.
  1. +30 −4 js/tbl_structure.js
  2. +24 −17 libraries/export/htmlword.php
  3. +47 −61 libraries/export/texytext.php
  4. +8 −2 tbl_alter.php
  5. +3 −1 tbl_create.php
View
@@ -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,14 +653,14 @@ $(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();
} else if ($(".error").length != 0) {
$(".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);
});
}
@@ -201,10 +201,20 @@ function PMA_getTableDefStandIn($db, $view, $crlf)
$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 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comme
$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 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
* 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']);
@@ -177,7 +177,7 @@ function PMA_getTableDefStandIn($db, $view, $crlf)
* 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 @@ function PMA_getTableDefStandIn($db, $view, $crlf)
$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 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comme
$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 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comme
}
$text_output .= "\n";
- } // end while
+ } // end foreach
return $text_output;
} // end of the 'PMA_getTableDef()' function
@@ -465,5 +410,46 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
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
@@ -39,7 +39,7 @@
/**
* 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 ($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
@@ -108,7 +108,9 @@
? $_REQUEST['field_comments'][$i]
: '',
$field_primary,
- $i
+ $i,
+ '',
+ ''
);
$query .= ', ';

0 comments on commit b91c8cd

Please sign in to comment.