aboutsummaryrefslogtreecommitdiffstats
path: root/core/include/home.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/include/home.php')
-rw-r--r--core/include/home.php31
1 files changed, 15 insertions, 16 deletions
diff --git a/core/include/home.php b/core/include/home.php
index 76c9287..bc73bef 100644
--- a/core/include/home.php
+++ b/core/include/home.php
@@ -1,23 +1,21 @@
<?php
#===============================================================================
-# Get instances
+# Get repositories
#===============================================================================
-$Database = Application::getDatabase();
-$Language = Application::getLanguage();
+$PostRepository = Application::getRepository('Post');
+$UserRepository = Application::getRepository('User');
-$execSQL = 'SELECT id FROM %s ORDER BY '.Application::get('POST.LIST_SORT').' LIMIT '.Application::get('POST.LIST_SIZE');
-$Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
-
-$postIDs = $Statement->fetchAll($Database::FETCH_COLUMN);
+#===============================================================================
+# Get paginated post list
+#===============================================================================
+$posts = $PostRepository->getPaginated(
+ Application::get('POST.LIST_SORT'),
+ Application::get('POST.LIST_SIZE')
+);
-foreach($postIDs as $postID) {
- try {
- $Post = Post\Factory::build($postID);
- $User = User\Factory::build($Post->get('user'));
- $templates[] = generatePostItemTemplate($Post, $User);
- }
- catch(Post\Exception $Exception){}
- catch(User\Exception $Exception){}
+foreach($posts as $Post) {
+ $User = $UserRepository->find($Post->get('user'));
+ $templates[] = generatePostItemTemplate($Post, $User);
}
#===============================================================================
@@ -35,7 +33,8 @@ $MainTemplate = Template\Factory::build('main');
$MainTemplate->set('HTML', $HomeTemplate);
$MainTemplate->set('HEAD', [
'NAME' => Application::get('BLOGMETA.HOME'),
- 'DESC' => Application::get('BLOGMETA.NAME').' – '.Application::get('BLOGMETA.DESC'),
+ 'DESC' => Application::get('BLOGMETA.NAME').' – '
+ .Application::get('BLOGMETA.DESC'),
'PERM' => Application::getURL()
]);