rfe Pagination for GIS visualization

Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
Madhura Jayaratne 2015-03-06 11:27:50 +05:30
parent 3de6ee1b0a
commit 5a0ffa30fd
6 changed files with 58 additions and 44 deletions

View File

@ -2,6 +2,7 @@ phpMyAdmin - ChangeLog
======================
4.5.0.0 (not yet released)
+ rfe Pagination for GIS visualization
4.4.0.0 (not yet released)
+ rfe #1553 InnoDB presently supports one FULLTEXT index creation at a time

View File

@ -395,11 +395,6 @@ AJAX.registerOnload('tbl_chart.js', function () {
*
*/
$(document).on('submit', "#tblchartform", function (event) {
if (!checkFormElementInRange(this, 'session_max_rows', PMA_messages.strNotValidRowNumber, 1) ||
!checkFormElementInRange(this, 'pos', PMA_messages.strNotValidRowNumber, 0 - 1)
) {
return false;
}
var $form = $(this);
if (codemirror_editor) {

View File

@ -4581,6 +4581,47 @@ class PMA_Util
return $html;
}
/**
* Function to get html for the start row and number of rows panel
*
* @param string $sql_query sql query
*
* @return string html
*/
public static function getStartAndNumberOfRowsPanel($sql_query)
{
$html = '<fieldset><div>';
$pos = isset($_REQUEST['pos']) ? $_REQUEST['pos'] : $_SESSION['tmpval']['pos'];
$html .= '<label for="pos">' . __('Start row:') . '</label>'
. '<input type="number" name="pos" min="0" required="required"'
. ' value="' . htmlspecialchars($pos) . '" />';
if (isset($_REQUEST['session_max_rows'])) {
$rows = $_REQUEST['session_max_rows'];
} else {
if ($_SESSION['tmpval']['max_rows'] != 'all') {
$rows = $_SESSION['tmpval']['max_rows'];
} else {
$rows = $GLOBALS['cfg']['MaxRows'];
}
}
$html .= '<label for="session_max_rows">'
. __('Number of rows:')
. '</label>'
. '<input type="number" name="session_max_rows" min="1"'
. ' value="' . htmlspecialchars($rows) . '" required="required" />';
$html .= '<input type="submit" name="submit" class="Go"'
. ' value="' . __('Go') . '" />'
. '<input type="hidden" name="sql_query"'
. ' value="' . htmlspecialchars($sql_query) . '" />';
$html .= '</div></fieldset>';
return $html;
}
}
?>

View File

@ -271,38 +271,6 @@ function PMA_getHtmlForAlternativeDataFormat($keys, $fields_meta, $numeric_types
return $htmlString;
}
/**
* Function to get html for the start row and number of rows options
*
* @param string $sql_query sql query
*
* @return string
*/
function PMA_getHtmlForStartAndNumberOfRowsOptions($sql_query)
{
$htmlString = '<p style="clear:both;">&nbsp;</p>'
. '<fieldset>'
. '<div>'
. '<label for="pos">' . __('Start row:') . '</label>'
. '<input type="text" name="pos" size="3" value="'
. $_SESSION['tmpval']['pos'] . '" />'
. '<label for="session_max_rows">'
. __('Number of rows:') . '</label>'
. '<input type="text" name="session_max_rows" size="3" value="'
. (($_SESSION['tmpval']['max_rows'] != 'all')
? $_SESSION['tmpval']['max_rows']
: $GLOBALS['cfg']['MaxRows'])
. '" />'
. '<input type="submit" name="submit" class="Go" value="' . __('Go')
. '" />'
. '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($sql_query) . '" />'
. '</div>'
. '</fieldset>';
return $htmlString;
}
/**
* Function to get html for the chart area div
*
@ -370,7 +338,7 @@ function PMA_getHtmlForTableChartDisplay($url_query, $url_params, $keys,
$htmlString .= PMA_getHtmlForAlternativeDataFormat(
$keys, $fields_meta, $numeric_types, $xaxis
);
$htmlString .= PMA_getHtmlForStartAndNumberOfRowsOptions($sql_query);
$htmlString .= PMA_Util::getStartAndNumberOfRowsPanel($sql_query);
$htmlString .= PMA_getHtmlForChartAreaDiv();

View File

@ -39,9 +39,20 @@ function PMA_GIS_modifyQuery($sql_query, $visualizationSettings)
. PMA_Util::backquote($visualizationSettings['spatialColumn'])
. ') AS ' . PMA_Util::backquote('srid') . ' ';
$pos = isset($_REQUEST['pos']) ? $_REQUEST['pos'] : $_SESSION['tmpval']['pos'];
if (isset($_REQUEST['session_max_rows'])) {
$rows = $_REQUEST['session_max_rows'];
} else {
if ($_SESSION['tmpval']['max_rows'] != 'all') {
$rows = $_SESSION['tmpval']['max_rows'];
} else {
$rows = $GLOBALS['cfg']['MaxRows'];
}
}
// Append the original query as the inner query
$modified_query .= 'FROM (' . $sql_query . ') AS '
. PMA_Util::backquote('temp_gis');
. PMA_Util::backquote('temp_gis') . ' LIMIT '
. $pos . ', ' . $rows;
return $modified_query;
}
@ -222,14 +233,12 @@ function PMA_getHtmlForGisVisualization(
);
$html .= '<input type="hidden" name="displayVisualization" value="redraw">';
$html .= '<input type="hidden" name="sql_query" value="';
$html .= htmlspecialchars($sql_query) . '" />';
$html .= '</form>';
if (! $GLOBALS['PMA_Config']->isHttps()) {
$isSelected = isset($visualizationSettings['choice']) ? true : false;
$html .= PMA_getHtmlForUseOpenStreetMaps($isSelected);
}
$html .= PMA_Util::getStartAndNumberOfRowsPanel($sql_query);
$html .= '</form>';
$html .= '<div class="pma_quick_warp" style="width: 50px; position: absolute;'
. ' right: 0; top: 0; cursor: pointer;">';

View File

@ -259,7 +259,7 @@ class PMA_TblChartTest extends PHPUnit_Framework_TestCase
$html
);
$this->assertContains(
PMA_getHtmlForStartAndNumberOfRowsOptions($sql_query),
PMA_Util::getStartAndNumberOfRowsPanel($sql_query),
$html
);
$this->assertContains(