forked from Public/pics
GenericTable: refactor order and pagination initalisation
This commit is contained in:
@@ -14,8 +14,8 @@ class ManageErrors extends HTMLController
|
||||
if (!Registry::get('user')->isAdmin())
|
||||
throw new NotAllowedException();
|
||||
|
||||
// Flushing, are we?
|
||||
if (isset($_POST['flush']) && Session::validateSession('get'))
|
||||
// Clearing, are we?
|
||||
if (isset($_POST['clear']) && Session::validateSession('get'))
|
||||
{
|
||||
ErrorLog::flush();
|
||||
header('Location: ' . BASEURL . '/manageerrors/');
|
||||
@@ -31,7 +31,7 @@ class ManageErrors extends HTMLController
|
||||
'method' => 'post',
|
||||
'class' => 'col-md-6 text-end',
|
||||
'buttons' => [
|
||||
'flush' => [
|
||||
'clear' => [
|
||||
'type' => 'submit',
|
||||
'caption' => 'Delete all',
|
||||
'class' => 'btn-danger',
|
||||
@@ -39,7 +39,7 @@ class ManageErrors extends HTMLController
|
||||
],
|
||||
],
|
||||
'columns' => [
|
||||
'id' => [
|
||||
'id_entry' => [
|
||||
'value' => 'id_entry',
|
||||
'header' => '#',
|
||||
'is_sortable' => true,
|
||||
@@ -95,19 +95,20 @@ class ManageErrors extends HTMLController
|
||||
],
|
||||
],
|
||||
],
|
||||
'start' => !empty($_GET['start']) ? (int) $_GET['start'] : 0,
|
||||
'sort_order' => !empty($_GET['order']) ? $_GET['order'] : '',
|
||||
'sort_direction' => !empty($_GET['dir']) ? $_GET['dir'] : '',
|
||||
'default_sort_order' => 'id_entry',
|
||||
'default_sort_direction' => 'down',
|
||||
'start' => $_GET['start'] ?? 0,
|
||||
'sort_order' => $_GET['order'] ?? '',
|
||||
'sort_direction' => $_GET['dir'] ?? '',
|
||||
'no_items_label' => "No errors to display -- we're all good!",
|
||||
'items_per_page' => 20,
|
||||
'index_class' => 'col-md-6',
|
||||
'base_url' => BASEURL . '/manageerrors/',
|
||||
'get_count' => 'ErrorLog::getCount',
|
||||
'get_data' => function($offset = 0, $limit = 20, $order = '', $direction = 'down') {
|
||||
if (!in_array($order, ['id_entry', 'file', 'line', 'time', 'ipaddress', 'id_user']))
|
||||
$order = 'id_entry';
|
||||
'get_data' => function($offset, $limit, $order, $direction) {
|
||||
assert(in_array($order, ['id_entry', 'file', 'line', 'time', 'ipaddress', 'id_user']));
|
||||
|
||||
$data = Registry::get('db')->queryAssocs('
|
||||
return Registry::get('db')->queryAssocs('
|
||||
SELECT *
|
||||
FROM log_errors
|
||||
ORDER BY {raw:order}
|
||||
@@ -117,12 +118,6 @@ class ManageErrors extends HTMLController
|
||||
'offset' => $offset,
|
||||
'limit' => $limit,
|
||||
]);
|
||||
|
||||
return [
|
||||
'rows' => $data,
|
||||
'order' => $order,
|
||||
'direction' => $direction,
|
||||
];
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user