aboutsummaryrefslogtreecommitdiffstats
path: root/admin/page/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/page/index.php')
-rw-r--r--admin/page/index.php29
1 files changed, 17 insertions, 12 deletions
diff --git a/admin/page/index.php b/admin/page/index.php
index 7527afa..63839a9 100644
--- a/admin/page/index.php
+++ b/admin/page/index.php
@@ -11,12 +11,19 @@ define('AUTHENTICATION', TRUE);
require '../../core/application.php';
#===============================================================================
+# Get repositories
+#===============================================================================
+$PageRepository = Application::getRepository('Page');
+$UserRepository = Application::getRepository('User');
+
+#===============================================================================
# Pagination
#===============================================================================
$site_size = Application::get('ADMIN.PAGE.LIST_SIZE');
$site_sort = Application::get('ADMIN.PAGE.LIST_SORT');
-$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', Page\Attribute::TABLE))->fetchColumn() / $site_size);
+$count = $PageRepository->getCount();
+$lastSite = ceil($count / $site_size);
$currentSite = HTTP::GET('site') ?? 1;
$currentSite = intval($currentSite);
@@ -26,19 +33,17 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
}
#===============================================================================
-# Fetch page IDs from database
+# Get paginated page list
#===============================================================================
-$execSQL = "SELECT id FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
-$pageIDs = $Database->query(sprintf($execSQL, Page\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
+$pages = $PageRepository->getPaginated(
+ $site_sort,
+ $site_size,
+ ($currentSite-1) * $site_size
+);
-foreach($pageIDs as $pageID) {
- try {
- $Page = Page\Factory::build($pageID);
- $User = User\Factory::build($Page->get('user'));
- $templates[] = generatePageItemTemplate($Page, $User);
- }
- catch(Page\Exception $Exception){}
- catch(User\Exception $Exception){}
+foreach($pages as $Page) {
+ $User = $UserRepository->find($Page->get('user'));
+ $templates[] = generatePageItemTemplate($Page, $User);
}
#===============================================================================