Combine possible sort inputs to one in sortQuery, output limitQuery

pull/2077/head
digital-gnome 2017-12-15 08:45:49 -05:00
parent ce0a8c4486
commit c0fcfe6eb6
3 changed files with 21 additions and 9 deletions

View File

@ -1036,9 +1036,18 @@ function monitorLimitSql() {
return( $midSql );
}
function parseSort( $saveToSession=false, $querySep='&' ) {
global $sortQuery, $sortColumn, $sortOrder; // Outputs
function parseSort( $saveToSession=false, $querySep='&' ) {
global $sortQuery, $sortColumn, $sortOrder, $limitQuery; // Outputs
if (isset($_REQUEST['filter']['Query']['sort_field'])) { //Handle both new and legacy filter passing
$_REQUEST['sort_field'] = $_REQUEST['filter']['Query']['sort_field'];
}
if (isset($_REQUEST['filter']['Query']['sort_asc'])) {
$_REQUEST['sort_asc'] = $_REQUEST['filter']['Query']['sort_asc'];
}
if (isset($_REQUEST['filter']['Query']['limit'])) {
$_REQUEST['limit'] = $_REQUEST['filter']['Query']['limit'];
}
if ( empty($_REQUEST['sort_field']) ) {
$_REQUEST['sort_field'] = ZM_WEB_EVENT_SORT_FIELD;
$_REQUEST['sort_asc'] = (ZM_WEB_EVENT_SORT_ORDER == 'asc');
@ -1101,6 +1110,9 @@ function parseSort( $saveToSession=false, $querySep='&' ) {
$_SESSION['sort_field'] = validHtmlStr($_REQUEST['sort_field']);
$_SESSION['sort_asc'] = validHtmlStr($_REQUEST['sort_asc']);
}
if ($_REQUEST['limit'] != '') {
$limitQuery = "&limit=".$_REQUEST['limit'];
}
}
function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) {

View File

@ -182,9 +182,9 @@ function getNavBarHTML($reload = null) {
global $view;
global $filterQuery;
global $sortQuery;
global $limit;
global $limitQuery;
if (!sortQuery) {
if (!$sortQuery) {
parseSort();
}
if (!$filterQuery) {
@ -235,7 +235,7 @@ if ( ZM_OPT_X10 && canView( 'Devices' ) ) { ?>
<li><a href="?view=devices">Devices</a></li>
<?php } ?>
<li><a href="?view=groups"<?php echo $view=='groups'?' class="selected"':''?>><?php echo translate('Groups') ?></a></li>
<li><a href="?view=filter<?php echo $filterQuery.$sortQuery."&limit=".$limit ?>"<?php echo $view=='filter'?' class="selected"':''?>><?php echo translate('Filters') ?></a></li>
<li><a href="?view=filter<?php echo $filterQuery.$sortQuery.$limitQuery ?>"<?php echo $view=='filter'?' class="selected"':''?>><?php echo translate('Filters') ?></a></li>
<?php
if ( canView( 'Stream' ) ) {

View File

@ -84,12 +84,12 @@ if ( !empty($page) ) {
}
$maxShortcuts = 5;
$pagination = getPagination( $pages, $page, $maxShortcuts, $filterQuery.$sortQuery.'&amp;limit='.$limit );
$pagination = getPagination( $pages, $page, $maxShortcuts, $filterQuery.$sortQuery.$limitQuery );
$focusWindow = true;
if ($_POST) {
header("Location: " . $_SERVER['REQUEST_URI'].htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).'&limit='.$limit.'&page='.$page);
header("Location: " . $_SERVER['REQUEST_URI'].htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).$limitQuery.'&page='.$page);
exit();
}
@ -116,11 +116,11 @@ if ( $pagination ) {
if ( $pages > 1 ) {
if ( !empty($page) ) {
?>
<a href="?view=<?php echo $view ?>&amp;page=0<?php echo $filterQuery ?><?php echo $sortQuery ?>&amp;limit=<?php echo $limit ?>"><?php echo translate('ViewAll') ?></a>
<a href="?view=<?php echo $view ?>&amp;page=0<?php echo $filterQuery ?><?php echo $sortQuery.$limitQuery ?>"><?php echo translate('ViewAll') ?></a>
<?php
} else {
?>
<a href="?view=<?php echo $view ?>&amp;page=1<?php echo $filterQuery ?><?php echo $sortQuery ?>&amp;limit=<?php echo $limit ?>"><?php echo translate('ViewPaged') ?></a>
<a href="?view=<?php echo $view ?>&amp;page=1<?php echo $filterQuery ?><?php echo $sortQuery.$limitQuery ?>"><?php echo translate('ViewPaged') ?></a>
<?php
}
}