Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-01-08 13:56:26 +01:00
commit 529a974fe8
4 changed files with 144 additions and 120 deletions

View File

@ -2064,6 +2064,30 @@ function PMA_previewSQL($form)
});
}
/**
* check for reserved keyword column name
*
* @param jQuery Object $form Form
*
* @returns true|false
*/
function PMA_checkReservedWordColumns($form) {
var is_confirmed = true;
$.ajax({
type: 'POST',
url: "tbl_structure.php",
data: $form.serialize() + '&reserved_word_check=1',
success: function (data) {
if (typeof data.success != 'undefined' && data.success === true) {
is_confirmed = confirm(data.message);
}
},
async:false
});
return is_confirmed;
}
// This event only need to be fired once after the initial page load
$(function () {
/**
@ -2474,73 +2498,75 @@ AJAX.registerOnload('functions.js', function () {
*/
if (checkTableEditForm($form[0], $form.find('input[name=orig_num_fields]').val())) {
PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize() + "&do_save_data=1", function (data) {
if (typeof data !== 'undefined' && data.success === true) {
$('#properties_message')
.removeClass('error')
.html('');
PMA_ajaxShowMessage(data.message);
// Only if the create table dialog (distinct panel) exists
if ($("#create_table_dialog").length > 0) {
$("#create_table_dialog").dialog("close").remove();
}
$('#tableslistcontainer').before(data.formatted_sql);
if (PMA_checkReservedWordColumns($form)) {
PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
//User wants to submit the form
$.post($form.attr('action'), $form.serialize() + "&do_save_data=1", function (data) {
if (typeof data !== 'undefined' && data.success === true) {
$('#properties_message')
.removeClass('error')
.html('');
PMA_ajaxShowMessage(data.message);
// Only if the create table dialog (distinct panel) exists
if ($("#create_table_dialog").length > 0) {
$("#create_table_dialog").dialog("close").remove();
}
$('#tableslistcontainer').before(data.formatted_sql);
/**
* @var tables_table Object referring to the <tbody> element that holds the list of tables
*/
var tables_table = $("#tablesForm").find("tbody").not("#tbl_summary_row");
// this is the first table created in this db
if (tables_table.length === 0) {
PMA_commonActions.refreshMain(
PMA_commonParams.get('opendb_url')
);
/**
* @var tables_table Object referring to the <tbody> element that holds the list of tables
*/
var tables_table = $("#tablesForm").find("tbody").not("#tbl_summary_row");
// this is the first table created in this db
if (tables_table.length === 0) {
PMA_commonActions.refreshMain(
PMA_commonParams.get('opendb_url')
);
} else {
/**
* @var curr_last_row Object referring to the last <tr> element in {@link tables_table}
*/
var curr_last_row = $(tables_table).find('tr:last');
/**
* @var curr_last_row_index_string String containing the index of {@link curr_last_row}
*/
var curr_last_row_index_string = $(curr_last_row).find('input:checkbox').attr('id').match(/\d+/)[0];
/**
* @var curr_last_row_index Index of {@link curr_last_row}
*/
var curr_last_row_index = parseFloat(curr_last_row_index_string);
/**
* @var new_last_row_index Index of the new row to be appended to {@link tables_table}
*/
var new_last_row_index = curr_last_row_index + 1;
/**
* @var new_last_row_id String containing the id of the row to be appended to {@link tables_table}
*/
var new_last_row_id = 'checkbox_tbl_' + new_last_row_index;
data.new_table_string = data.new_table_string.replace(/checkbox_tbl_/, new_last_row_id);
//append to table
$(data.new_table_string)
.appendTo(tables_table);
//Sort the table
$(tables_table).PMA_sort_table('th');
// Adjust summary row
PMA_adjustTotals();
}
//Refresh navigation as a new table has been added
PMA_reloadNavigation();
} else {
/**
* @var curr_last_row Object referring to the last <tr> element in {@link tables_table}
*/
var curr_last_row = $(tables_table).find('tr:last');
/**
* @var curr_last_row_index_string String containing the index of {@link curr_last_row}
*/
var curr_last_row_index_string = $(curr_last_row).find('input:checkbox').attr('id').match(/\d+/)[0];
/**
* @var curr_last_row_index Index of {@link curr_last_row}
*/
var curr_last_row_index = parseFloat(curr_last_row_index_string);
/**
* @var new_last_row_index Index of the new row to be appended to {@link tables_table}
*/
var new_last_row_index = curr_last_row_index + 1;
/**
* @var new_last_row_id String containing the id of the row to be appended to {@link tables_table}
*/
var new_last_row_id = 'checkbox_tbl_' + new_last_row_index;
data.new_table_string = data.new_table_string.replace(/checkbox_tbl_/, new_last_row_id);
//append to table
$(data.new_table_string)
.appendTo(tables_table);
//Sort the table
$(tables_table).PMA_sort_table('th');
// Adjust summary row
PMA_adjustTotals();
PMA_ajaxShowMessage(
'<div class="error">' + data.error + '</div>',
false
);
}
//Refresh navigation as a new table has been added
PMA_reloadNavigation();
} else {
PMA_ajaxShowMessage(
'<div class="error">' + data.error + '</div>',
false
);
}
}); // end $.post()
}); // end $.post()
}
} // end if (checkTableEditForm() )
}); // end create table form (save)

View File

@ -108,31 +108,33 @@ AJAX.registerOnload('tbl_structure.js', function () {
if (checkTableEditForm($form[0], $form.find('input[name=orig_num_fields]').val())) {
// OK, form passed validation step
PMA_prepareForAjaxRequest($form);
//User wants to submit the form
$msg = PMA_ajaxShowMessage();
$.post($form.attr('action'), $form.serialize() + '&do_save_data=1', function (data) {
if ($(".sqlqueryresults").length !== 0) {
$(".sqlqueryresults").remove();
} else if ($(".error:not(.tab)").length !== 0) {
$(".error:not(.tab)").remove();
}
if (typeof data.success != 'undefined' && data.success === true) {
$("#page_content")
.empty()
.append(data.message)
.append(data.sql_query)
.show();
PMA_highlightSQL($('#page_content'));
$(".result_query .notice").remove();
reloadFieldForm();
$form.remove();
PMA_ajaxRemoveMessage($msg);
PMA_init_slider();
PMA_reloadNavigation();
} else {
PMA_ajaxShowMessage(data.error, false);
}
}); // end $.post()
if (PMA_checkReservedWordColumns($form)) {
//User wants to submit the form
$msg = PMA_ajaxShowMessage();
$.post($form.attr('action'), $form.serialize() + '&do_save_data=1', function (data) {
if ($(".sqlqueryresults").length !== 0) {
$(".sqlqueryresults").remove();
} else if ($(".error:not(.tab)").length !== 0) {
$(".error:not(.tab)").remove();
}
if (typeof data.success != 'undefined' && data.success === true) {
$("#page_content")
.empty()
.append(data.message)
.append(data.sql_query)
.show();
PMA_highlightSQL($('#page_content'));
$(".result_query .notice").remove();
reloadFieldForm();
$form.remove();
PMA_ajaxRemoveMessage($msg);
PMA_init_slider();
PMA_reloadNavigation();
} else {
PMA_ajaxShowMessage(data.error, false);
}
}); // end $.post()
}
}
}); // end change table button "do_save_data"

View File

@ -2118,7 +2118,7 @@ function PMA_getHtmlForActionsInTableStructure($type, $tbl_storage_engine,
);
}
$html_output .= PMA_getHtmlForDistinctValueAction($url_query, $row, $titles);
if (isset($GLOBALS['cfgRelation']['central_columnswork'])
if (isset($GLOBALS['cfgRelation']['central_columnswork'])
&& $GLOBALS['cfgRelation']['central_columnswork']
) {
$html_output .= '<li class="browse nowrap">';
@ -2763,33 +2763,6 @@ function PMA_getColumnsWithUniqueIndex($db ,$table)
return $columns_with_unique_index;
}
/**
* Check column names for MySQL reserved words
*
* @param string $db database name
* @param string $table tablename
*
* @return array $messages array of PMA_Messages
*/
function PMA_getReservedWordColumnNameMessages($db ,$table)
{
$messages = array();
if ($GLOBALS['cfg']['ReservedWordDisableWarning'] === false) {
$pma_table = new PMA_Table($table, $db);
$columns = $pma_table->getReservedColumnNames();
if (!empty($columns)) {
foreach ($columns as $column) {
$msg = PMA_message::notice(
__('The column name \'%s\' is a MySQL reserved keyword.')
);
$msg->addParam($column);
$messages[] = $msg;
}
}
}
return $messages;
}
/**
* Function to get the type of command for multiple field handling
*

View File

@ -38,6 +38,33 @@ if (isset($_REQUEST['move_columns'])
exit;
}
/**
* handle MySQL reserved words columns check
*/
if (isset($_REQUEST['reserved_word_check'])) {
$response = PMA_Response::getInstance();
if ($GLOBALS['cfg']['ReservedWordDisableWarning'] === false) {
$columns_names = $_REQUEST['field_name'];
$cols = "";
foreach ($columns_names as $column) {
if (PMA_SQP_isKeyWord($column)) {
$cols .= $column . ", ";
}
}
if ($cols == "") {
$response->isSuccess(false);
}
$response->addJSON(
'message', sprintf(
__('The column name(s) \'%s\' are MySQL reserved keyword.'),
trim($cols, ", ")
)
);
} else {
$response->isSuccess(false);
}
exit;
}
/**
* A click on Change has been made for one column
*/
@ -107,10 +134,6 @@ $url_query .= '&amp;goto=tbl_structure.php&amp;back=tbl_structure.php';
$url_params['goto'] = 'tbl_structure.php';
$url_params['back'] = 'tbl_structure.php';
// Check column names for MySQL reserved words
$reserved_word_column_messages = PMA_getReservedWordColumnNameMessages($db, $table);
$response->addHTML($reserved_word_column_messages);
/**
* Prepares the table structure display
*/