[+] реализована пагинация на уровне объекта запроса

This commit is contained in:
rsgrinko committed 2023-07-24 22:55:47 +03:00
1 parent bcc5d4227b
commit 236fd45afa
6 files changed
+27 -8

No files matched your search

+1 -1
View File
@@ -211,7 +211,7 @@ body {
position: absolute;
left: 100%;
top: 50%;
border-right-color: #eeeeee;
border-right-color: #00abff;
border-width: 9px;
margin-top: -9px;
transform: rotate(180deg);
+10 -1
View File
@@ -21,6 +21,7 @@
namespace Core;
use Core\Helpers\Pagination;
use Core\Helpers\Registry;
use Core\Helpers\SystemFunctions;
use Core\Models\{Posts, User};
@@ -45,6 +46,7 @@
$currentPage = explode('::', Registry::get('currentPage'))[1];
return [
'salt' => md5(random_int(1, 999999) . random_int(1, 999999) . random_int(1, 999999) . random_int(1, 999999)),
'currentPage' => $currentPage,
'executionTime' => $delta . ' cek.',
'isAuthorized' => User::isAuthorized(),
@@ -141,7 +143,14 @@
public static function users()
{
self::render('users.twig');
Pagination::execute($_REQUEST['page'], User::getAllCount(), PAGINATION_LIMIT);
$limit = Pagination::getLimit();
$limit= '0, 10';
$arUsers = User::getUsers($limit);
foreach($arUsers as $key => $user) {
unset($arUsers[$key]['password']);
}
self::render('users.twig', ['users' => $arUsers]);
}
/**
+7 -2
View File
@@ -53,9 +53,14 @@
*
* @return void
*/
public static function route(string $pattern, $callback)
public static function route(string $pattern, $callback, bool $usePagination = false)
{
$pattern = '/^' . str_replace('/', '\/', $pattern) . '$/';
$pattern = str_replace('/', '\/', $pattern);
if ($usePagination) {
$pattern = '/(^' . $pattern . '$)|(^' . $pattern . '\/page\/(\d+))$/';
} else {
$pattern = '/^' . $pattern . '$/';
}
self::$routes[$pattern] = $callback;
}
+2 -2
View File
@@ -23,7 +23,7 @@
use Core\Models\Router;
Router::route('/', '\Core\App::index');
Router::route('/test', '\Core\App::test');
Router::route('/test', '\Core\App::test', true);
Router::route('/info', '\Core\App::info');
Router::route('/login', '\Core\App::login');
@@ -52,7 +52,7 @@
Router::route('/test/(\d+)', '\Core\App::test');
// Router::route('/test/(\d+)', '\Core\App::test');
+1 -1
View File
@@ -2,7 +2,7 @@
<html>
<head>
<title>{% block title %}Delta Framework{% endblock %}</title>
<link href="/assets/css/style.css" rel="stylesheet">
<link href="/assets/css/style.css?{{ salt }}" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
+6 -1
View File
@@ -4,5 +4,10 @@
{% block main %}
<h1>Список пользователей</h1>
<p>This is sample text!</p>
<p>
<ul>{% for user in users %}
<li>{{ user.login }}</li>
{% endfor %}
</ul>
</p>
{% endblock %}