Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-08-17 19:37:30 +02:00
commit 31875e2730
14 changed files with 136 additions and 131 deletions

View File

@ -308,7 +308,7 @@ $response->addHTML(
PMA_getHtmlBodyForTableSummary(
$num_tables, $server_slave_status, $db_is_system_schema, $sum_entries,
$db_collation, $is_show_stats, $sum_size, $overhead_size, $create_time_all,
$update_time_all, $check_time_all, $approx_rows
$update_time_all, $check_time_all, isset($approx_rows) ? $approx_rows : false
)
);
$response->addHTML('</table>');

View File

@ -1878,6 +1878,56 @@ function PMA_ajaxRemoveMessage($this_msgbox)
}
}
/**
* Requests SQL for previewing before executing.
*
* @param jQuery Object $form Form containing query data
*
* @return void
*/
function PMA_previewSQL($form)
{
var form_url = $form.attr('action');
var form_data = $form.serialize() +
'&do_save_data=1' +
'&preview_sql=1' +
'&ajax_request=1';
$.ajax({
type: 'POST',
url: form_url,
data: form_data,
success: function (response) {
if (response.success) {
var $dialog_content = $('<div/>')
.append(response.sql_data);
var button_options = {};
button_options[PMA_messages.strClose] = function () {
$(this).dialog('close');
};
var $response_dialog = $dialog_content.dialog({
minWidth: 550,
maxHeight: 400,
modal: true,
buttons: button_options,
title: PMA_messages.strPreviewSQL,
close: function () {
$(this).remove();
},
open: function () {
// Pretty SQL printing.
PMA_highlightSQL($(this));
}
});
} else {
PMA_ajaxShowMessage(response.message);
}
},
error: function () {
PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest);
}
});
}
// This event only need to be fired once after the initial page load
$(function () {
/**
@ -3658,16 +3708,14 @@ AJAX.registerOnload('functions.js', function () {
cache: false,
type: 'POST',
data: {
favorite_tables: (window.localStorage.favorite_tables
!== undefined)
favorite_tables: (window.localStorage.favorite_tables !== undefined)
? window.localStorage.favorite_tables
: ''
},
success: function (data) {
// Update localStorage.
if (window.localStorage !== undefined) {
window.localStorage.favorite_tables
= data.favorite_tables;
window.localStorage.favorite_tables = data.favorite_tables;
}
$('#pma_favorite_list').html(data.list);
}
@ -4411,56 +4459,6 @@ function checkNumberOfFields() {
return true;
}
/**
* Requests SQL for previewing before executing.
*
* @param jQuery Object $form Form containing query data
*
* @return void
*/
function PMA_previewSQL($form)
{
var form_url = $form.attr('action');
var form_data = $form.serialize() +
'&do_save_data=1' +
'&preview_sql=1' +
'&ajax_request=1';
$.ajax({
type: 'POST',
url: form_url,
data: form_data,
success: function (response) {
if (response.success) {
var $dialog_content = $('<div/>')
.append(response.sql_data);
var button_options = {};
button_options[PMA_messages.strClose] = function () {
$(this).dialog('close');
};
var $response_dialog = $dialog_content.dialog({
minWidth: 550,
maxHeight: 400,
modal: true,
buttons: button_options,
title: PMA_messages.strPreviewSQL,
close: function () {
$(this).remove();
},
open: function () {
// Pretty SQL printing.
PMA_highlightSQL($(this));
}
});
} else {
PMA_ajaxShowMessage(response.message);
}
},
error: function () {
PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest);
}
});
}
/**
* Ignore the displayed php errors.
* Simply removes the displayed errors.

View File

@ -270,6 +270,55 @@ function verificationsAfterFieldChange(urlField, multi_edit, theType)
}
/* End of fields validation*/
/**
* Applies the selected function to all rows to be inserted.
*
* @param string currId Current ID of the row
* @param string functionName Name of the function
* @param bool copySalt Whether to copy salt or not
* @param string salt Salt value
* @param object targetRows Target rows
*
* @return void
*/
function applyFunctionToAllRows(currId, functionName, copySalt, salt, targetRows)
{
targetRows.each(function () {
var currentRowNum = /\d/.exec($(this).find("input[name*='fields_name']").attr("name"));
// Append the function select list.
var targetSelectList = $(this).find("select[name*='funcs[multi_edit]']");
if (targetSelectList.attr("id") === currId) {
return;
}
targetSelectList.find("option").filter(function () {
return $(this).text() === functionName;
}).attr("selected","selected");
// Handle salt field.
if (functionName === 'AES_ENCRYPT' || functionName === 'AES_DECRYPT') {
if ($("#salt_" + targetSelectList.attr("id")).length === 0) {
// Get hash value.
var hashed_value = targetSelectList.attr("name").match(/\[multi\_edit\]\[\d\]\[(.*)\]/);
//To generate the textbox that can take the salt
var new_salt_box = "<br><input type=text name=salt[multi_edit][" + currentRowNum + "][" + hashed_value[1] + "]" +
" id=salt_" + targetSelectList.attr("id") + " placeholder='" + PMA_messages.strEncryptionKey + "'>";
targetSelectList.parent().next("td").next("td").find("input[name*='fields']").after(new_salt_box);
}
if (copySalt) {
$("#salt_" + targetSelectList.attr("id")).attr("value", salt);
}
} else {
var id = targetSelectList.attr("id");
if ($("#salt_" + id).length) {
$("#salt_" + id).remove();
}
}
});
}
/**
* Unbind all event handlers before tearing down a page
@ -672,48 +721,3 @@ function changeValueFieldType(elem, searchIndex)
$("#fieldID_" + searchIndex).removeAttr('multiple');
}
}
function applyFunctionToAllRows(currId, functionName, copySalt, salt, targetRows)
{
targetRows.each(function () {
var currentRowNum = /\d/.exec($(this).find("input[name*='fields_name']").attr("name"));
/* // Ignore the rows whose insert_ignore_* checkbox is checked.
var insert_ignore = $(this).closest("table.insertRowTable").prevAll("input[name*='insert_ignore']");
if (insert_ignore.length) {
if ($(insert_ignore).attr("checked")) {
return;
}
} */
// Append the function select list.
var targetSelectList = $(this).find("select[name*='funcs[multi_edit]']");
if (targetSelectList.attr("id") === currId) {
return;
}
targetSelectList.find("option").filter(function () {
return $(this).text() === functionName;
}).attr("selected","selected");
// Handle salt field.
if (functionName === 'AES_ENCRYPT' || functionName === 'AES_DECRYPT') {
if ($("#salt_" + targetSelectList.attr("id")).length === 0) {
// Get hash value.
var hashed_value = targetSelectList.attr("name").match(/\[multi\_edit\]\[\d\]\[(.*)\]/);
//To generate the textbox that can take the salt
var new_salt_box = "<br><input type=text name=salt[multi_edit][" + currentRowNum + "][" + hashed_value[1] + "]" +
" id=salt_" + targetSelectList.attr("id") + " placeholder='" + PMA_messages.strEncryptionKey + "'>";
targetSelectList.parent().next("td").next("td").find("input[name*='fields']").after(new_salt_box);
}
if (copySalt) {
$("#salt_" + targetSelectList.attr("id")).attr("value", salt);
}
} else {
var id = targetSelectList.attr("id");
if ($("#salt_" + id).length) {
$("#salt_" + id).remove();
}
}
});
}

View File

@ -311,11 +311,10 @@ AJAX.registerOnload('tbl_select.js', function () {
button_options[PMA_messages.strGo] = function () {
var min_value = $('#min_value').val();
var max_value = $('#max_value').val();
var final_value = '';
if (min_value.length && max_value.length) {
var final_value = min_value + ', ' +
final_value = min_value + ', ' +
max_value;
} else {
final_value = '';
}
var $target_field = $source_select.closest('tr')
.find('[name*="criteriaValues"]');

View File

@ -268,9 +268,9 @@ AJAX.registerOnload('tbl_structure.js', function () {
var question = $.sprintf(PMA_messages.strDoYouReally, 'ALTER TABLE `' + escapeHtml(curr_table_name) + '` ADD PRIMARY KEY(`' + escapeHtml(curr_column_name) + '`);');
$(this).PMA_confirm(question, $(this).attr('href'), function (url) {
var $msg = PMA_ajaxShowMessage(PMA_messages.strAddingPrimaryKey, false);
$.get(url
, {'is_js_confirmed' : 1, 'ajax_request' : true, 'index_change' : true}
, function (data) {
$.get(url,
{'is_js_confirmed' : 1, 'ajax_request' : true, 'index_change' : true},
function (data) {
if (data.success === true) {
PMA_ajaxRemoveMessage($msg);
$(this).remove();
@ -317,9 +317,9 @@ AJAX.registerOnload('tbl_structure.js', function () {
var question = $.sprintf(PMA_messages.strDoYouReally, 'ALTER TABLE `' + escapeHtml(curr_table_name) + '` ADD INDEX(`' + escapeHtml(curr_column_name) + '`);');
$(this).PMA_confirm(question, $(this).attr('href'), function (url) {
var $msg = PMA_ajaxShowMessage(PMA_messages.strAddingIndex, false);
$.get(url
, {'is_js_confirmed' : 1, 'ajax_request' : true, 'index_change' : true}
, function (data) {
$.get(url,
{'is_js_confirmed' : 1, 'ajax_request' : true, 'index_change' : true},
function (data) {
if (data.success === true) {
PMA_ajaxRemoveMessage($msg);
if ($('#result_query').length) {
@ -361,9 +361,9 @@ AJAX.registerOnload('tbl_structure.js', function () {
var question = $.sprintf(PMA_messages.strDoYouReally, 'ALTER TABLE `' + escapeHtml(curr_table_name) + '` ADD UNIQUE(`' + escapeHtml(curr_column_name) + '`);');
$(this).PMA_confirm(question, $(this).attr('href'), function (url) {
var $msg = PMA_ajaxShowMessage(PMA_messages.strAddingUnique, false);
$.get(url
, {'is_js_confirmed' : 1, 'ajax_request' : true, 'index_change' : true}
, function (data) {
$.get(url,
{'is_js_confirmed' : 1, 'ajax_request' : true, 'index_change' : true},
function (data) {
if (data.success === true) {
PMA_ajaxRemoveMessage($msg);
if ($('#result_query').length) {

View File

@ -1381,6 +1381,7 @@ function PMA_handleSimulateDMLRequest()
// Only single-table queries accepted.
$table_references = PMA_getTableReferences($analyzed_sql_results);
$table_references = $table_references ? $table_references : '';
if (preg_match('/JOIN/i', $table_references)) {
$error = $error_msg;
break;
@ -1393,7 +1394,7 @@ function PMA_handleSimulateDMLRequest()
}
// Get the matched rows for the query.
$result = PMA_getMatchedRows($sql_query, $analyzed_sql_results);
$result = PMA_getMatchedRows($analyzed_sql_results);
if (! $error = $GLOBALS['dbi']->getError()) {
$sql_data[] = $result;
} else {
@ -1413,12 +1414,11 @@ function PMA_handleSimulateDMLRequest()
/**
* Find the matching rows for UPDATE/DELETE query.
*
* @param string $query SQL query
* @param array $analyzed_sql_results Analyzed SQL results from parser.
* @param array $analyzed_sql_results Analyzed SQL results from parser.
*
* @return mixed
*/
function PMA_getMatchedRows($query, $analyzed_sql_results = array())
function PMA_getMatchedRows($analyzed_sql_results = array())
{
// Get the query type.
$query_type = (isset($analyzed_sql_results['analyzed_sql'][0]['querytype']))
@ -1841,7 +1841,7 @@ function PMA_checkIfRollbackPossible($sql_query)
// Get table_references from the query.
$table_references = PMA_getTableReferences($analyzed_sql_results);
$table_references = $table_references ? $table_references : '';
// Get table names from table_references.
$tables = PMA_getTableNamesFromTableReferences($table_references);

View File

@ -84,7 +84,7 @@ if (! empty($submit_mult)
exit;
break;
case 'show_create':
$show_create = PMA_getHtmlShowCreate($db, $selected);
$show_create = PMA_getHtmlShowCreate($GLOBALS['db'], $selected);
// Send response to client.
$response = PMA_Response::getInstance();
$response->addJSON('message', $show_create);
@ -99,7 +99,10 @@ if (! empty($submit_mult)
break;
case 'make_consistent_with_central_list':
include_once 'libraries/central_columns.lib.php';
$centralColsError = PMA_makeConsistentWithList($db, $selected);
$centralColsError = PMA_makeConsistentWithList(
$GLOBALS['db'],
$selected
);
break;
} // end switch
}
@ -112,7 +115,7 @@ if (! empty($submit_mult)
$centralColsError
)
= PMA_getDataForSubmitMult(
$submit_mult, $db, $table,
$submit_mult, $GLOBALS['db'], $table,
$selected, $action
);
//update the existing variables

View File

@ -180,6 +180,7 @@ function PMA_getHtmlBodyForTableSummary($num_tables, $server_slave_status,
$row_count_sum = PMA_Util::formatNumber($sum_entries, 0);
// If a table shows approximate rows count, display update-all-real-count anchor.
$row_sum_url = array();
if (isset($approx_rows)) {
$row_sum_url = array(
'ajax_request' => true,
@ -2824,8 +2825,8 @@ function PMA_checkFavoriteTable($db, $current_table)
* Get HTML for favorite anchor.
*
* @param string $db current database
* @param string $current_table current table
* @param string $titles titles
* @param array $current_table current table
* @param array $titles titles
*
* @return string The html output
*/

View File

@ -162,8 +162,8 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
isset($submit_default_current_timestamp)
? $submit_default_current_timestamp : null,
$comments_map, isset($fields_meta) ? $fields_meta : null, $is_backup,
isset($move_columns) ? $move_columns : null, $cfgRelation,
isset($available_mime) ? $available_mime : null,
isset($move_columns) ? $move_columns : array(), $cfgRelation,
isset($available_mime) ? $available_mime : array(),
isset($mime_map) ? $mime_map : array()
);
} // end for

View File

@ -701,7 +701,9 @@ function PMA_getHtmlForMimeType($columnNumber, $ci, $ci_offset,
. '" size="1" name="field_mimetype[' . $columnNumber . ']">';
$html .= ' <option value="">&nbsp;</option>';
if (is_array($available_mime['mimetype'])) {
if (isset($available_mime['mimetype'])
&& is_array($available_mime['mimetype'])
) {
foreach ($available_mime['mimetype'] as $mimetype) {
$checked = (isset($columnMeta['Field'])
&& isset($mime_map[$columnMeta['Field']]['mimetype'])
@ -743,7 +745,7 @@ function PMA_getHtmlForTransformation($columnNumber, $ci, $ci_offset,
. '[' . $columnNumber . ']">';
$html .= ' <option value="" title="' . __('None')
. '"></option>';
if (is_array($available_mime[$type])) {
if (isset($available_mime[$type]) && is_array($available_mime[$type])) {
foreach ($available_mime[$type] as $mimekey => $transform) {
$checked = isset($columnMeta['Field'])
&& isset($mime_map[$columnMeta['Field']][$type])

View File

@ -289,7 +289,6 @@ function PMA_getHtmlForInternalRelationRow($save_row, $i, $odd_row,
$html_output .= '<td>';
$foreign_db = false;
$foreign_table = false;
$foreign_column = false;
@ -531,7 +530,6 @@ function PMA_getHtmlForForeignKeyRow($one_key, $odd_row, $columns, $i,
. '</a>';
$html_output .= '</td>';
$html_output .= '<td>';
$foreign_db = false;
$foreign_table = false;
$foreign_column = false;

View File

@ -59,7 +59,7 @@ if (! empty($goto)) {
if (! isset($err_url)) {
$err_url = (! empty($back) ? $back : $goto)
. '?' . PMA_URL_getCommon($db)
. '?' . PMA_URL_getCommon($GLOBALS['db'])
. ((strpos(' ' . $goto, 'db_') != 1 && strlen($table))
? '&amp;table=' . urlencode($table)
: ''

View File

@ -153,7 +153,7 @@ $columns = $GLOBALS['dbi']->getColumns($db, $table);
// common form
$html_output .= PMA_getHtmlForCommonForm(
$db, $table, $columns, $cfgRelation, $tbl_storage_engine,
isset($existrel) ? $existrel : null,
isset($existrel) ? $existrel : array(),
isset($existrel_foreign) ? $existrel_foreign['foreign_keys_data'] : null,
$options_array
);

View File

@ -418,7 +418,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
'analyzed_sql' => $analyzed_sql
);
$simulated_data = PMA_getMatchedRows($sql_query, $analyzed_sql_results);
$simulated_data = PMA_getMatchedRows($analyzed_sql_results);
// URL to matched rows.
$_url_params = array(