aboutsummaryrefslogtreecommitdiffstats
path: root/core/include/feed/main.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/include/feed/main.php')
-rw-r--r--core/include/feed/main.php99
1 files changed, 48 insertions, 51 deletions
diff --git a/core/include/feed/main.php b/core/include/feed/main.php
index cd53fa0..765f296 100644
--- a/core/include/feed/main.php
+++ b/core/include/feed/main.php
@@ -11,72 +11,69 @@ $Language = Application::getLanguage();
HTTP::responseHeader(HTTP::HEADER_CONTENT_TYPE, HTTP::CONTENT_TYPE_XML);
#===============================================================================
-# TRY: Template\Exception
+# Post feed
#===============================================================================
-try {
- if(!isset($param) OR $param !== 'page') {
- $POST['FEED_SORT'] = Application::get('POST.FEED_SORT');
- $POST['FEED_SIZE'] = Application::get('POST.FEED_SIZE');
+if(!isset($param) OR $param !== 'page') {
+ $POST['FEED_SORT'] = Application::get('POST.FEED_SORT');
+ $POST['FEED_SIZE'] = Application::get('POST.FEED_SIZE');
- $execSQL = "SELECT id FROM %s ORDER BY {$POST['FEED_SORT']} LIMIT {$POST['FEED_SIZE']}";
- $postIDs = $Database->query(sprintf($execSQL, Post\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
+ $execSQL = "SELECT id FROM %s ORDER BY {$POST['FEED_SORT']} LIMIT {$POST['FEED_SIZE']}";
+ $postIDs = $Database->query(sprintf($execSQL, Post\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
- foreach($postIDs as $postID) {
- try {
- $Post = Post\Factory::build($postID);
- $User = User\Factory::build($Post->attr('user'));
+ foreach($postIDs as $postID) {
+ try {
+ $Post = Post\Factory::build($postID);
+ $User = User\Factory::build($Post->attr('user'));
- $ItemTemplate = Template\Factory::build('feed/item_post');
- $ItemTemplate->set('POST', generateItemTemplateData($Post));
- $ItemTemplate->set('USER', generateItemTemplateData($User));
+ $ItemTemplate = Template\Factory::build('feed/item_post');
+ $ItemTemplate->set('POST', generateItemTemplateData($Post));
+ $ItemTemplate->set('USER', generateItemTemplateData($User));
- $posts[] = $ItemTemplate;
- }
-
- catch(Post\Exception $Exception){}
- catch(User\Exception $Exception){}
+ $posts[] = $ItemTemplate;
}
- }
- if(!isset($param) OR $param !== 'post') {
- $PAGE['FEED_SORT'] = Application::get('PAGE.FEED_SORT');
- $PAGE['FEED_SIZE'] = Application::get('PAGE.FEED_SIZE');
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
+ }
+}
- $execSQL = "SELECT id FROM %s ORDER BY {$PAGE['FEED_SORT']} LIMIT {$PAGE['FEED_SIZE']}";
- $pageIDs = $Database->query(sprintf($execSQL, Page\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
+#===============================================================================
+# Page feed
+#===============================================================================
+if(!isset($param) OR $param !== 'post') {
+ $PAGE['FEED_SORT'] = Application::get('PAGE.FEED_SORT');
+ $PAGE['FEED_SIZE'] = Application::get('PAGE.FEED_SIZE');
- foreach($pageIDs as $pageID) {
- try {
- $Page = Page\Factory::build($pageID);
- $User = User\Factory::build($Page->attr('user'));
+ $execSQL = "SELECT id FROM %s ORDER BY {$PAGE['FEED_SORT']} LIMIT {$PAGE['FEED_SIZE']}";
+ $pageIDs = $Database->query(sprintf($execSQL, Page\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
- $ItemTemplate = Template\Factory::build('feed/item_page');
- $ItemTemplate->set('PAGE', generateItemTemplateData($Page));
- $ItemTemplate->set('USER', generateItemTemplateData($User));
+ foreach($pageIDs as $pageID) {
+ try {
+ $Page = Page\Factory::build($pageID);
+ $User = User\Factory::build($Page->attr('user'));
- $pages[] = $ItemTemplate;
- }
+ $ItemTemplate = Template\Factory::build('feed/item_page');
+ $ItemTemplate->set('PAGE', generateItemTemplateData($Page));
+ $ItemTemplate->set('USER', generateItemTemplateData($User));
- catch(Page\Exception $Exception){}
- catch(User\Exception $Exception){}
+ $pages[] = $ItemTemplate;
}
- }
-
- $FeedTemplate = Template\Factory::build('feed/main');
- $FeedTemplate->set('FEED', [
- 'TYPE' => $param ?? NULL,
- 'LIST' => [
- 'POSTS' => $posts ?? [],
- 'PAGES' => $pages ?? [],
- ]
- ]);
- echo $FeedTemplate;
+ catch(Page\Exception $Exception){}
+ catch(User\Exception $Exception){}
+ }
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+$FeedTemplate = Template\Factory::build('feed/main');
+$FeedTemplate->set('FEED', [
+ 'TYPE' => $param ?? NULL,
+ 'LIST' => [
+ 'POSTS' => $posts ?? [],
+ 'PAGES' => $pages ?? [],
+ ]
+]);
+
+echo $FeedTemplate;