Use template for _getAdditionalFieldsForTableNavigation

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
Maurício Meneghini Fauth 2017-11-17 15:09:18 -02:00
parent dba5237520
commit 1852c2c4da
3 changed files with 29 additions and 29 deletions

View File

@ -1098,30 +1098,16 @@ class Results
* Prepare fields for table navigation
* Number of rows
*
* @param string $html_sql_query the sql encoded by htmlspecialchars()
* @param string $sqlQuery the sql encoded by htmlspecialchars()
*
* @return string $additional_fields_html html content
* @return string html content
*
* @access private
*
* @see _getTableNavigation()
*/
private function _getAdditionalFieldsForTableNavigation(
$html_sql_query
) {
$additional_fields_html = '';
$additional_fields_html .= '<input type="hidden" name="sql_query" '
. 'value="' . $html_sql_query . '" />'
. '<input type="hidden" name="goto" value="' . $this->__get('goto')
. '" />'
. '<input type="hidden" name="pos" size="3" value="'
// Do not change the position when changing the number of rows
. $_SESSION['tmpval']['pos'] . '" />'
. '<input type="hidden" name="is_browse_distinct" value="'
. $this->__get('is_browse_distinct') . '" />' ;
private function _getAdditionalFieldsForTableNavigation($sqlQuery)
{
$numberOfRowsPlaceholder = null;
if ($_SESSION['tmpval']['max_rows'] == self::ALL_ROWS) {
$numberOfRowsPlaceholder = __('All');
@ -1134,17 +1120,17 @@ class Results
'250' => 250,
'500' => 500
);
$additional_fields_html .= __('Number of rows:') . ' ';
$additional_fields_html .= Util::getDropdown(
'session_max_rows', $numberOfRowsChoices,
$_SESSION['tmpval']['max_rows'], '',
'autosubmit', $numberOfRowsPlaceholder
);
return $additional_fields_html;
} // end of the '_getAdditionalFieldsForTableNavigation()' function
return Template::get('display/results/additional_fields')->render([
'goto' => $this->__get('goto'),
'is_browse_distinct' => $this->__get('is_browse_distinct'),
'sql_query' => $sqlQuery,
'number_of_rows_choices' => $numberOfRowsChoices,
'number_of_rows_placeholder' => $numberOfRowsPlaceholder,
'pos' => $_SESSION['tmpval']['pos'],
'max_rows' => $_SESSION['tmpval']['max_rows'],
]);
}
/**
* Get the headers of the results table, for all of the columns

View File

@ -0,0 +1,14 @@
<input type="hidden" name="sql_query" value="{{ sql_query|raw }}" />
<input type="hidden" name="goto" value="{{ goto }}" />
{# Do not change the position when changing the number of rows #}
<input type="hidden" name="pos" size="3" value="{{ pos }}" />
<input type="hidden" name="is_browse_distinct" value="{{ is_browse_distinct }}" />
{% trans 'Number of rows:' %}
{{ Util_getDropdown(
'session_max_rows',
number_of_rows_choices,
max_rows,
'',
'autosubmit',
number_of_rows_placeholder
) }}

View File

@ -1,7 +1,7 @@
<td>
<form action="sql.php" method="post">
{{ Url_getHiddenInputs(db, table) }}
<input type="hidden" name="sql_query" value="{{ html_sql_query }}" />
<input type="hidden" name="sql_query" value="{{ html_sql_query|raw }}" />
<input type="hidden" name="pos" value="0" />
<input type="hidden" name="is_browse_distinct" value="{{ is_browse_distinct }}" />
<input type="hidden" name="session_max_rows" value="{{ not showing_all ? 'all' : max_rows }}" />