fix pagination back links
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Froxlor\UI;
|
namespace Froxlor\UI;
|
||||||
|
|
||||||
|
use Froxlor\Settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of the Froxlor project.
|
* This file is part of the Froxlor project.
|
||||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
@@ -115,7 +117,7 @@ class Collection
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare pagination
|
// Prepare pagination
|
||||||
$this->pagination = new Pagination($this->userinfo, $sortableColumns, $this->count());
|
$this->pagination = new Pagination($sortableColumns, $this->count(), (int) Settings::Get('panel.paging'));
|
||||||
$this->params = array_merge($this->params, $this->pagination->getApiCommandParams());
|
$this->params = array_merge($this->params, $this->pagination->getApiCommandParams());
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Froxlor\UI;
|
namespace Froxlor\UI;
|
||||||
|
|
||||||
use Froxlor\Settings;
|
use Froxlor\Settings;
|
||||||
@@ -47,12 +48,11 @@ class Pagination
|
|||||||
/**
|
/**
|
||||||
* Create new pagination object to search/filter, limit and sort Api-listing() calls
|
* Create new pagination object to search/filter, limit and sort Api-listing() calls
|
||||||
*
|
*
|
||||||
* @param array $userinfo
|
|
||||||
* @param array $fields
|
* @param array $fields
|
||||||
* @param int $total_entries
|
* @param int $total_entries
|
||||||
* @param int $perPage
|
* @param int $perPage
|
||||||
*/
|
*/
|
||||||
public function __construct(array $userinfo, array $fields = array(), int $total_entries = 0, int $perPage = 20)
|
public function __construct(array $fields = array(), int $total_entries = 0, int $perPage = 20)
|
||||||
{
|
{
|
||||||
$this->fields = $fields;
|
$this->fields = $fields;
|
||||||
$this->entries = $total_entries;
|
$this->entries = $total_entries;
|
||||||
@@ -72,7 +72,7 @@ class Pagination
|
|||||||
if (isset($_REQUEST['searchfield']) && isset($fields[$_REQUEST['searchfield']])) {
|
if (isset($_REQUEST['searchfield']) && isset($fields[$_REQUEST['searchfield']])) {
|
||||||
$this->searchfield = $_REQUEST['searchfield'];
|
$this->searchfield = $_REQUEST['searchfield'];
|
||||||
}
|
}
|
||||||
if (! empty($this->searchtext) && ! empty($this->searchfield)) {
|
if (!empty($this->searchtext) && !empty($this->searchfield)) {
|
||||||
$this->addSearch($this->searchtext, $this->searchfield);
|
$this->addSearch($this->searchtext, $this->searchfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ class Pagination
|
|||||||
*/
|
*/
|
||||||
public function addOrderBy($field = null, $order = 'ASC'): Pagination
|
public function addOrderBy($field = null, $order = 'ASC'): Pagination
|
||||||
{
|
{
|
||||||
if (! isset($this->data['sql_orderby'])) {
|
if (!isset($this->data['sql_orderby'])) {
|
||||||
$this->data['sql_orderby'] = array();
|
$this->data['sql_orderby'] = array();
|
||||||
}
|
}
|
||||||
$this->data['sql_orderby'][$field] = $order;
|
$this->data['sql_orderby'][$field] = $order;
|
||||||
@@ -155,7 +155,7 @@ class Pagination
|
|||||||
*/
|
*/
|
||||||
public function addSearch(string $searchtext = null, string $field = null, string $operator = null): Pagination
|
public function addSearch(string $searchtext = null, string $field = null, string $operator = null): Pagination
|
||||||
{
|
{
|
||||||
if (! isset($this->data['sql_search'])) {
|
if (!isset($this->data['sql_search'])) {
|
||||||
$this->data['sql_search'] = array();
|
$this->data['sql_search'] = array();
|
||||||
}
|
}
|
||||||
$this->data['sql_search'][$field] = [
|
$this->data['sql_search'][$field] = [
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{% macro paging(pagination) %}
|
{% macro paging(pagination) %}
|
||||||
{% if pagination.last_page > 1 %}
|
{% if pagination.last_page > 1 %}
|
||||||
<div class="card-footer border-top">
|
<div class="card-footer border-top">
|
||||||
{% if pagination.current_page >= pagination.last_page %}
|
{% if pagination.current_page > 2 %}
|
||||||
<a href="?s={{ s }}&page={{ page }}&action={{ action }}&pageno=1">«</a>
|
<a href="?s={{ s }}&page={{ page }}&action={{ action }}&pageno=1">«</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if pagination.current_page >= pagination.last_page %}
|
{% if pagination.current_page > 1 %}
|
||||||
<a href="?s={{ s }}&page={{ page }}&action={{ action }}&pageno={{ pagination.current_page - 1 }}">‹</a>
|
<a href="?s={{ s }}&page={{ page }}&action={{ action }}&pageno={{ pagination.current_page - 1 }}">‹</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if pagination.current_page < pagination.last_page %}
|
{% if pagination.current_page < pagination.last_page %}
|
||||||
|
|||||||
Reference in New Issue
Block a user