Merge remote-tracking branch 'origin/QA_4_1' into QA_4_1

This commit is contained in:
Weblate 2014-02-28 21:11:54 +01:00
commit 9b7fccd1c3
4 changed files with 44 additions and 34 deletions

View File

@ -40,11 +40,12 @@ $db_search = new PMA_DbSearch($GLOBALS['db']);
if ( $GLOBALS['is_ajax_request'] != true) {
include 'libraries/db_info.inc.php';
}
$response->addHTML('<div id="searchresults">');
// Main search form has been submitted, get results
if (isset($_REQUEST['submit_search'])) {
$response->addHTML($db_search->getSearchResults());
} else {
$response->addHTML('<div id="searchresults"></div>');
}
// If we are in an Ajax request, we need to exit after displaying all the HTML
@ -53,5 +54,9 @@ if ($GLOBALS['is_ajax_request'] == true && empty($_REQUEST['ajax_page_request'])
}
// Display the search form
$response->addHTML('<div id="togglesearchresultsdiv">'
. '<a id="togglesearchresultlink"></a></div>'
. '<br class="clearfloat" />');
$response->addHTML($db_search->getSelectionForm($url_params));
$response->addHTML($db_search->_getResultDivs());
?>

View File

@ -44,15 +44,21 @@ function loadResult(result_path, table_name, link)
/** Load the browse results to the page */
$("#table-info").show();
$('#table-link').attr({"href" : 'sql.php?' + link }).text(table_name);
var url = result_path + " #sqlqueryresults";
$('#browse-results').load(url, null, function () {
$('html, body')
.animate({
scrollTop: $("#browse-results").offset().top
}, 1000);
PMA_ajaxRemoveMessage($msg);
PMA_makegrid($('#table_results')[0], true, true, true, true);
}).show();
var url = result_path + "#sqlqueryresults";
$.get(url, {'ajax_request': true, 'is_js_confirmed': true}, function (data) {
if (data.success) {
$('#browse-results').html(data.message);
$('html, body')
.animate({
scrollTop: $("#browse-results").offset().top
}, 1000);
PMA_ajaxRemoveMessage($msg);
PMA_makegrid($('#table_results')[0], true, true, true, true);
$('#browse-results').show();
} else {
PMA_ajaxShowMessage(data.error, false);
}
});
});
}
@ -69,7 +75,6 @@ function deleteResult(result_path, msg)
$(function () {
/** Hides the results shown by the browse criteria */
$("#table-info").hide();
$('#browse-results').hide();
$('#sqlqueryform').hide();
$('#togglequerybox').hide();
/** Conformation message for deletion */
@ -77,13 +82,16 @@ function deleteResult(result_path, msg)
var $msg = PMA_ajaxShowMessage(PMA_messages.strDeleting, false);
/** Load the deleted option to the page*/
$('#sqlqueryform').html('');
var url = result_path + " #result_query, #sqlqueryform";
$('#browse-results').load(url, function () {
var url = result_path + "#result_query, #sqlqueryform";
$.get(url, {'ajax_request': true, 'is_js_confirmed': true},
function (data) {
if (data.success) {
$('#sqlqueryform').html(data.sql_query);
/** Refresh the search results after the deletion */
document.getElementById('buttonGo').click();
$('#togglequerybox').html(PMA_messages.strHideQueryBox);
/** Show the results of the deletion option */
$('#browse-results').show();
$('#browse-results').hide();
$('#sqlqueryform').show();
$('#togglequerybox').show();
$('html, body')
@ -91,7 +99,10 @@ function deleteResult(result_path, msg)
scrollTop: $("#browse-results").offset().top
}, 1000);
PMA_ajaxRemoveMessage($msg);
});
} else {
PMA_ajaxShowMessage(data.error, false);
}
});
}
});
}
@ -111,12 +122,10 @@ AJAX.registerOnload('db_search.js', function () {
/**
* Prepare a div containing a link for toggle the search results
*/
$('<div id="togglesearchresultsdiv"><a id="togglesearchresultlink"></a></div>')
.insertAfter('#searchresults')
$('#togglesearchresultsdiv')
/** don't show it until we have results on-screen */
.hide();
$('<br class="clearfloat" />').insertAfter("#togglesearchresultsdiv").show();
/**
* Changing the displayed text according to
* the hide/show criteria in search result forms
@ -139,8 +148,7 @@ AJAX.registerOnload('db_search.js', function () {
* Prepare a div containing a link for toggle the search form,
* otherwise it's incorrectly displayed after a couple of clicks
*/
$('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>')
.insertAfter('#db_search_form')
$('#togglesearchformdiv')
.hide(); // don't show it until we have results on-screen
/**

View File

@ -342,7 +342,7 @@ class PMA_DbSearch
if ($res_cnt > 0) {
$this_url_params['sql_query'] = $newsearchsqls['select_columns'];
$browse_result_path = 'sql.php' . PMA_URL_getCommon($this_url_params);
$html_output .= '<td><a name="browse_search" href="'
$html_output .= '<td><a name="browse_search" class="ajax" href="'
. $browse_result_path . '" onclick="loadResult(\''
. $browse_result_path . '\',\'' . $each_table . '\',\''
. PMA_URL_getCommon($GLOBALS['db'], $each_table) . '\''
@ -350,7 +350,7 @@ class PMA_DbSearch
. __('Browse') . '</a></td>';
$this_url_params['sql_query'] = $newsearchsqls['delete'];
$delete_result_path = 'sql.php' . PMA_URL_getCommon($this_url_params);
$html_output .= '<td><a name="delete_search" href="'
$html_output .= '<td><a name="delete_search" class="ajax" href="'
. $delete_result_path . '" onclick="deleteResult(\''
. $delete_result_path . '\' , \''
. sprintf(
@ -465,7 +465,8 @@ class PMA_DbSearch
. __('Go') . '" id="buttonGo" />';
$html_output .= '</fieldset>';
$html_output .= '</form>';
$html_output .= $this->_getResultDivs();
$html_output .= '<div id="togglesearchformdiv">'
. '<a id="togglesearchformlink"></a></div>';
return $html_output;
}
@ -475,7 +476,7 @@ class PMA_DbSearch
*
* @return string div tags
*/
private function _getResultDivs()
public function _getResultDivs()
{
$html_output = '<!-- These two table-image and table-link elements display'
. ' the table name in browse search results -->';

View File

@ -153,14 +153,16 @@ class PMA_DbSearch_Test extends PHPUnit_Framework_TestCase
),
true,
'<tr class="noclick odd"><td>2 matches in <strong>table1</strong>'
. '</td><td><a name="browse_search" href="sql.php?db=pma&amp;table'
. '</td><td><a name="browse_search" class="ajax" '
. 'href="sql.php?db=pma&amp;table'
. '=table1&amp;goto=db_sql.php&amp;pos=0&amp;is_js_confirmed=0&amp;'
. 'sql_query=column1&amp;server=0&amp;lang=en&amp;token=token" '
. 'onclick="loadResult(\'sql.php?db=pma&amp;table=table1&amp;goto='
. 'db_sql.php&amp;pos=0&amp;is_js_confirmed=0&amp;sql_query=column1'
. '&amp;server=0&amp;lang=en&amp;token=token\',\'table1\',\'db=pma'
. '&amp;table=table1&amp;server=0&amp;lang=en&amp;token=token\');'
. 'return false;" >Browse</a></td><td><a name="delete_search" href'
. 'return false;" >Browse</a></td><td>'
. '<a name="delete_search" class="ajax" href'
. '="sql.php?db=pma&amp;table=table1&amp;goto=db_sql.php&amp;pos=0'
. '&amp;is_js_confirmed=0&amp;sql_query=column2&amp;server=0&amp;'
. 'lang=en&amp;token=token" onclick="deleteResult(\'sql.php?db=pma'
@ -225,14 +227,8 @@ class PMA_DbSearch_Test extends PHPUnit_Framework_TestCase
. '<input type="text" name="criteriaColumnName" size="60"value="" />'
. '</td></tr></table></fieldset><fieldset class="tblFooters"><input '
. 'type="submit" name="submit_search" value="Go" id="buttonGo" />'
. '</fieldset></form><!-- These two table-image and table-link elements '
. 'display the table name in browse search results --><div id="table-'
. 'info"><a class="item" id="table-link" ></a></div><div id="browse-'
. 'results"><!-- this browse-results div is used to load the browse and '
. 'delete results in the db search --></div><br class="clearfloat" />'
. '<div id="sqlqueryform"><!-- this sqlqueryform div is used to load '
. 'the delete form in the db search --></div><!-- toggle query box '
. 'link--><a id="togglequerybox"></a>',
. '</fieldset></form><div id="togglesearchformdiv">'
. '<a id="togglesearchformlink"></a></div>',
$this->object->getSelectionForm($url_params)
);
}