Merge remote-tracking branch 'origin/master'
This commit is contained in:
28
js/sql.js
28
js/sql.js
@@ -784,6 +784,10 @@ $(document).ready(function() {
|
||||
* @var relation_fields Array containing the name/value pairs of relational fields
|
||||
*/
|
||||
var relation_fields = {};
|
||||
/**
|
||||
* @var relational_display string 'K' if relational key, 'D' if relational display column
|
||||
*/
|
||||
var relational_display = $("#relational_display_K").attr('checked') ? 'K' : 'D';
|
||||
/**
|
||||
* @var transform_fields Array containing the name/value pairs for transformed fields
|
||||
*/
|
||||
@@ -800,15 +804,16 @@ $(document).ready(function() {
|
||||
|
||||
var need_to_post = false;
|
||||
|
||||
var new_clause='';
|
||||
var prev_index=-1;
|
||||
var new_clause = '';
|
||||
var prev_index = -1;
|
||||
|
||||
$input_siblings.each(function() {
|
||||
/** @lends jQuery */
|
||||
/**
|
||||
* @var this_field Object referring to this field (<td>)
|
||||
*/
|
||||
var $this_field = $(this);
|
||||
var $this_field = $(this);
|
||||
|
||||
/**
|
||||
* @var field_name String containing the name of this field.
|
||||
* @see getFieldName()
|
||||
@@ -861,7 +866,7 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
if(where_clause.indexOf(field_name) > prev_index){
|
||||
new_clause += '`'+window.parent.table+'`.'+'`' + field_name + "` = '"+this_field_params[field_name].replace(/'/g,"''")+"'"+' AND ';
|
||||
new_clause += '`' + window.parent.table + '`.' + '`' + field_name + "` = '" + this_field_params[field_name].replace(/'/g,"''") + "'" + ' AND ';
|
||||
}
|
||||
if (this_field_params[field_name] != $this_field.data('original_data')) {
|
||||
sql_query += ' `' + field_name + "`='" + this_field_params[field_name].replace(/'/g, "''") + "' , ";
|
||||
@@ -876,8 +881,8 @@ $(document).ready(function() {
|
||||
|
||||
//Remove the last ',' appended in the above loop
|
||||
sql_query = sql_query.replace(/,\s$/, '');
|
||||
new_clause=new_clause.substring(0,new_clause.length-5);
|
||||
new_clause=PMA_urlencode(new_clause);
|
||||
new_clause = new_clause.substring(0, new_clause.length-5);
|
||||
new_clause = PMA_urlencode(new_clause);
|
||||
sql_query += ' WHERE ' + PMA_urldecode(where_clause);
|
||||
/**
|
||||
* @var rel_fields_list String, url encoded representation of {@link relations_fields}
|
||||
@@ -890,8 +895,8 @@ $(document).ready(function() {
|
||||
var transform_fields_list = $.param(transform_fields);
|
||||
|
||||
// if inline_edit is successful, we need to go back to default view
|
||||
var $del_hide=$(this).parent();
|
||||
var $chg_submit=$(this);
|
||||
var $del_hide = $(this).parent();
|
||||
var $chg_submit = $(this);
|
||||
|
||||
if (need_to_post) {
|
||||
// Make the Ajax post after setting all parameters
|
||||
@@ -909,6 +914,7 @@ $(document).ready(function() {
|
||||
'rel_fields_list' : rel_fields_list,
|
||||
'do_transformations' : transformation_fields,
|
||||
'transform_fields_list' : transform_fields_list,
|
||||
'relational_display' : relational_display,
|
||||
'goto' : 'sql.php',
|
||||
'submit_type' : 'save'
|
||||
};
|
||||
@@ -917,10 +923,10 @@ $(document).ready(function() {
|
||||
if(data.success == true) {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
if(disp_mode == 'vertical') {
|
||||
$this_td.parents('tbody').find('tr').find('.where_clause:nth('+this_td_index+')').attr('value',new_clause);
|
||||
$this_td.parents('tbody').find('tr').find('.where_clause:nth(' + this_td_index + ')').attr('value', new_clause);
|
||||
}
|
||||
else {
|
||||
$this_td.parent('tr').find('.where_clause').attr('value',new_clause);
|
||||
$this_td.parent('tr').find('.where_clause').attr('value', new_clause);
|
||||
}
|
||||
// remove possible previous feedback message
|
||||
$('#result_query').remove();
|
||||
@@ -1026,7 +1032,7 @@ function PMA_unInlineEditRow($del_hide, $chg_submit, $this_td, $input_siblings,
|
||||
if (typeof data.relations != 'undefined') {
|
||||
$.each(data.relations, function(key, value) {
|
||||
if(key == field_name) {
|
||||
new_html = $(value).append(new_value);
|
||||
new_html = $(value);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
|
41
sql.php
41
sql.php
@@ -654,6 +654,34 @@ if (0 == $num_rows || $is_affected) {
|
||||
foreach( $rel_fields as $rel_field => $rel_field_value) {
|
||||
|
||||
$where_comparison = "='" . $rel_field_value . "'";
|
||||
$display_field = PMA_getDisplayField($map[$rel_field]['foreign_db'], $map[$rel_field]['foreign_table']);
|
||||
|
||||
// Field to display from the foreign table?
|
||||
if (isset($display_field) && strlen($display_field)) {
|
||||
$dispsql = 'SELECT ' . PMA_backquote($display_field)
|
||||
. ' FROM ' . PMA_backquote($map[$rel_field]['foreign_db'])
|
||||
. '.' . PMA_backquote($map[$rel_field]['foreign_table'])
|
||||
. ' WHERE ' . PMA_backquote($map[$rel_field]['foreign_field'])
|
||||
. $where_comparison;
|
||||
$dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
|
||||
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
|
||||
list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
|
||||
} else {
|
||||
//$dispval = __('Link not found');
|
||||
}
|
||||
@PMA_DBI_free_result($dispresult);
|
||||
} else {
|
||||
$dispval = '';
|
||||
} // end if... else...
|
||||
|
||||
if ('K' == $_SESSION['tmp_user_values']['relational_display']) {
|
||||
// user chose "relational key" in the display options, so
|
||||
// the title contains the display field
|
||||
$title = (! empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
|
||||
} else {
|
||||
$title = ' title="' . htmlspecialchars($rel_field_value) . '"';
|
||||
}
|
||||
|
||||
$_url_params = array(
|
||||
'db' => $map[$rel_field]['foreign_db'],
|
||||
'table' => $map[$rel_field]['foreign_table'],
|
||||
@@ -663,9 +691,18 @@ if (0 == $num_rows || $is_affected) {
|
||||
. ' WHERE ' . PMA_backquote($map[$rel_field]['foreign_field'])
|
||||
. $where_comparison
|
||||
);
|
||||
$output = '<a href="sql.php' . PMA_generate_common_url($_url_params) . '"' . $title . '>';
|
||||
|
||||
$extra_data['relations'][$rel_field] = '<a href="sql.php' . PMA_generate_common_url($_url_params) . '">';
|
||||
$extra_data['relations'][$rel_field] .= '</a>';
|
||||
if ('D' == $_SESSION['tmp_user_values']['relational_display']) {
|
||||
// user chose "relational display field" in the
|
||||
// display options, so show display field in the cell
|
||||
$output .= (!empty($dispval)) ? htmlspecialchars($dispval) : '';
|
||||
} else {
|
||||
// otherwise display data in the cell
|
||||
$output .= htmlspecialchars($rel_field_value);
|
||||
}
|
||||
$output .= '</a>';
|
||||
$extra_data['relations'][$rel_field] = $output;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user