Rewrote the Pagination handler.
This commit is contained in:
parent
02adfa1f4f
commit
d3f9c299af
38 changed files with 135 additions and 147 deletions
public-legacy
|
@ -32,13 +32,13 @@ if($categoryInfo->isLink) {
|
|||
return;
|
||||
}
|
||||
|
||||
$forumPagination = new Pagination($msz->forumCtx->topics->countTopics(
|
||||
$forumPagination = Pagination::fromInput($msz->forumCtx->topics->countTopics(
|
||||
categoryInfo: $categoryInfo,
|
||||
global: true,
|
||||
deleted: $perms->check(Perm::F_POST_DELETE_ANY) ? null : false
|
||||
), 20);
|
||||
|
||||
if(!$forumPagination->hasValidOffset())
|
||||
if(!$forumPagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$children = [];
|
||||
|
|
|
@ -101,18 +101,18 @@ $topicPosts = $topicInfo->postsCount;
|
|||
if($canDeleteAny)
|
||||
$topicPosts += $topicInfo->deletedPostsCount;
|
||||
|
||||
$topicPagination = new Pagination($topicPosts, 10, 'page');
|
||||
|
||||
if(isset($preceedingPostCount))
|
||||
$topicPagination->setPage((int)floor($preceedingPostCount / $topicPagination->getRange()), true);
|
||||
$pagination = Pagination::fromPage($topicPosts, (int)floor($preceedingPostCount / 10), 10, 0);
|
||||
else
|
||||
$pagination = Pagination::fromInput($topicPosts, 10, 'page');
|
||||
|
||||
if(!$topicPagination->hasValidOffset())
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$postInfos = $msz->forumCtx->posts->getPosts(
|
||||
topicInfo: $topicInfo,
|
||||
deleted: $perms->check(Perm::F_POST_DELETE_ANY) ? null : false,
|
||||
pagination: $topicPagination,
|
||||
pagination: $pagination,
|
||||
);
|
||||
|
||||
if(empty($postInfos))
|
||||
|
@ -163,7 +163,7 @@ Template::render('forum.topic', [
|
|||
'category_info' => $categoryInfo,
|
||||
'topic_posts' => $posts,
|
||||
'can_reply' => $canReply,
|
||||
'topic_pagination' => $topicPagination,
|
||||
'topic_pagination' => $pagination,
|
||||
'topic_can_delete' => $canDelete,
|
||||
'topic_can_delete_any' => $canDeleteAny,
|
||||
'topic_can_nuke_or_restore' => $canNukeOrRestore,
|
||||
|
|
|
@ -9,8 +9,8 @@ if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|||
if(!$msz->authInfo->getPerms('global')->check(Perm::G_CL_CHANGES_MANAGE))
|
||||
Template::throwError(403);
|
||||
|
||||
$pagination = new Pagination($msz->changelog->countChanges(), 30);
|
||||
if(!$pagination->hasValidOffset())
|
||||
$pagination = Pagination::fromInput($msz->changelog->countChanges(), 30);
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$changeInfos = $msz->changelog->getChanges(pagination: $pagination);
|
||||
|
|
|
@ -31,8 +31,8 @@ if(filter_input(INPUT_GET, 'm') === 'explode') {
|
|||
return;
|
||||
}
|
||||
|
||||
$pagination = new Pagination($msz->forumCtx->topicRedirects->countTopicRedirects(), 20);
|
||||
if(!$pagination->hasValidOffset())
|
||||
$pagination = Pagination::fromInput($msz->forumCtx->topicRedirects->countTopicRedirects(), 20);
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$redirs = $msz->forumCtx->topicRedirects->getTopicRedirects(pagination: $pagination);
|
||||
|
|
|
@ -9,9 +9,8 @@ if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|||
if(!$msz->authInfo->getPerms('global')->check(Perm::G_LOGS_VIEW))
|
||||
Template::throwError(403);
|
||||
|
||||
$pagination = new Pagination($msz->auditLog->countLogs(), 50);
|
||||
|
||||
if(!$pagination->hasValidOffset())
|
||||
$pagination = Pagination::fromInput($msz->auditLog->countLogs(), 50);
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$logs = iterator_to_array($msz->auditLog->getLogs(pagination: $pagination));
|
||||
|
|
|
@ -7,9 +7,8 @@ if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|||
if(!$msz->authInfo->getPerms('global')->check(Perm::G_NEWS_CATEGORIES_MANAGE))
|
||||
Template::throwError(403);
|
||||
|
||||
$pagination = new Pagination($msz->news->countCategories(), 15);
|
||||
|
||||
if(!$pagination->hasValidOffset())
|
||||
$pagination = Pagination::fromInput($msz->news->countCategories(), 15);
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$categories = $msz->news->getCategories(pagination: $pagination);
|
||||
|
|
|
@ -7,12 +7,12 @@ if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|||
if(!$msz->authInfo->getPerms('global')->check(Perm::G_NEWS_POSTS_MANAGE))
|
||||
Template::throwError(403);
|
||||
|
||||
$pagination = new Pagination($msz->news->countPosts(
|
||||
$pagination = Pagination::fromInput($msz->news->countPosts(
|
||||
includeScheduled: true,
|
||||
includeDeleted: true
|
||||
), 15);
|
||||
|
||||
if(!$pagination->hasValidOffset())
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$posts = $msz->news->getPosts(
|
||||
|
|
|
@ -19,9 +19,8 @@ if(filter_has_var(INPUT_GET, 'u')) {
|
|||
}
|
||||
}
|
||||
|
||||
$pagination = new Pagination($msz->usersCtx->bans->countBans(userInfo: $filterUser), 10);
|
||||
|
||||
if(!$pagination->hasValidOffset())
|
||||
$pagination = Pagination::fromInput($msz->usersCtx->bans->countBans(userInfo: $filterUser), 10);
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$banList = [];
|
||||
|
|
|
@ -9,9 +9,8 @@ if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|||
if(!$msz->authInfo->getPerms('user')->check(Perm::U_USERS_MANAGE))
|
||||
Template::throwError(403);
|
||||
|
||||
$pagination = new Pagination($msz->usersCtx->users->countUsers(), 30);
|
||||
|
||||
if(!$pagination->hasValidOffset())
|
||||
$pagination = Pagination::fromInput($msz->usersCtx->users->countUsers(), 30);
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$userList = [];
|
||||
|
|
|
@ -19,9 +19,8 @@ if(filter_has_var(INPUT_GET, 'u')) {
|
|||
}
|
||||
}
|
||||
|
||||
$pagination = new Pagination($msz->usersCtx->modNotes->countNotes(userInfo: $filterUser), 10);
|
||||
|
||||
if(!$pagination->hasValidOffset())
|
||||
$pagination = Pagination::fromInput($msz->usersCtx->modNotes->countNotes(userInfo: $filterUser), 10);
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$notes = [];
|
||||
|
|
|
@ -8,9 +8,8 @@ if(!$msz->authInfo->getPerms('user')->check(Perm::U_ROLES_MANAGE))
|
|||
Template::throwError(403);
|
||||
|
||||
$roles = $msz->usersCtx->roles;
|
||||
$pagination = new Pagination($roles->countRoles(), 10);
|
||||
|
||||
if(!$pagination->hasValidOffset())
|
||||
$pagination = Pagination::fromInput($roles->countRoles(), 10);
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$rolesAll = [];
|
||||
|
|
|
@ -19,9 +19,8 @@ if(filter_has_var(INPUT_GET, 'u')) {
|
|||
}
|
||||
}
|
||||
|
||||
$pagination = new Pagination($msz->usersCtx->warnings->countWarnings(userInfo: $filterUser), 10);
|
||||
|
||||
if(!$pagination->hasValidOffset())
|
||||
$pagination = Pagination::fromInput($msz->usersCtx->warnings->countWarnings(userInfo: $filterUser), 10);
|
||||
if(!$pagination->validOffset)
|
||||
Template::throwError(404);
|
||||
|
||||
$warnList = [];
|
||||
|
|
|
@ -76,7 +76,7 @@ $canManageUsers = $msz->authInfo->getPerms('user')->check(Perm::U_USERS_MANAGE);
|
|||
$deleted = $canManageUsers ? null : false;
|
||||
|
||||
$rolesAll = $msz->usersCtx->roles->getRoles(hidden: false);
|
||||
$pagination = new Pagination($msz->usersCtx->users->countUsers(roleInfo: $roleInfo, deleted: $deleted), 15);
|
||||
$pagination = Pagination::fromInput($msz->usersCtx->users->countUsers(roleInfo: $roleInfo, deleted: $deleted), 15);
|
||||
|
||||
$userList = [];
|
||||
$userInfos = $msz->usersCtx->users->getUsers(
|
||||
|
|
|
@ -10,8 +10,8 @@ $currentUser = $msz->authInfo->userInfo;
|
|||
if($currentUser === null)
|
||||
Template::throwError(401);
|
||||
|
||||
$loginHistoryPagination = new Pagination($msz->authCtx->loginAttempts->countAttempts(userInfo: $currentUser), 5, 'hp');
|
||||
$accountLogPagination = new Pagination($msz->auditLog->countLogs(userInfo: $currentUser), 10, 'ap');
|
||||
$loginHistoryPagination = Pagination::fromInput($msz->authCtx->loginAttempts->countAttempts(userInfo: $currentUser), 5, 'hp');
|
||||
$accountLogPagination = Pagination::fromInput($msz->auditLog->countLogs(userInfo: $currentUser), 10, 'ap');
|
||||
|
||||
$loginHistory = iterator_to_array($msz->authCtx->loginAttempts->getAttempts(userInfo: $currentUser, pagination: $loginHistoryPagination));
|
||||
$auditLogs = iterator_to_array($msz->auditLog->getLogs(userInfo: $currentUser, pagination: $accountLogPagination));
|
||||
|
|
|
@ -42,7 +42,7 @@ while($_SERVER['REQUEST_METHOD'] === 'POST' && CSRF::validateRequest()) {
|
|||
} else break;
|
||||
}
|
||||
|
||||
$pagination = new Pagination($msz->authCtx->sessions->countSessions(userInfo: $currentUser), 10);
|
||||
$pagination = Pagination::fromInput($msz->authCtx->sessions->countSessions(userInfo: $currentUser), 10);
|
||||
|
||||
$sessionList = [];
|
||||
$sessionInfos = $msz->authCtx->sessions->getSessions(userInfo: $currentUser, pagination: $pagination);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue