aboutsummaryrefslogtreecommitdiffstats
path: root/core/include/feed
diff options
context:
space:
mode:
Diffstat (limited to 'core/include/feed')
-rw-r--r--core/include/feed/main.php100
1 files changed, 48 insertions, 52 deletions
diff --git a/core/include/feed/main.php b/core/include/feed/main.php
index 84f3edb..59be3d1 100644
--- a/core/include/feed/main.php
+++ b/core/include/feed/main.php
@@ -11,73 +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 * FROM %s ORDER BY {$POST['FEED_SORT']} LIMIT {$POST['FEED_SIZE']}";
- $Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
+ $execSQL = "SELECT * FROM %s ORDER BY {$POST['FEED_SORT']} LIMIT {$POST['FEED_SIZE']}";
+ $Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
- while($Attribute = $Statement->fetchObject('Post\Attribute')) {
- try {
- $Post = Post\Factory::buildByAttribute($Attribute);
- $User = User\Factory::build($Post->attr('user'));
+ while($Attribute = $Statement->fetchObject('Post\Attribute')) {
+ try {
+ $Post = Post\Factory::buildByAttribute($Attribute);
+ $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 * FROM %s ORDER BY {$PAGE['FEED_SORT']} LIMIT {$PAGE['FEED_SIZE']}";
- $Statement = $Database->query(sprintf($execSQL, Page\Attribute::TABLE));
+#===============================================================================
+# Page feed
+#===============================================================================
+if(!isset($param) OR $param !== 'post') {
+ $PAGE['FEED_SORT'] = Application::get('PAGE.FEED_SORT');
+ $PAGE['FEED_SIZE'] = Application::get('PAGE.FEED_SIZE');
- while($Attribute = $Statement->fetchObject('Page\Attribute')) {
- try {
- $Page = Page\Factory::buildByAttribute($Attribute);
- $User = User\Factory::build($Page->attr('user'));
+ $execSQL = "SELECT * FROM %s ORDER BY {$PAGE['FEED_SORT']} LIMIT {$PAGE['FEED_SIZE']}";
+ $Statement = $Database->query(sprintf($execSQL, Page\Attribute::TABLE));
- $ItemTemplate = Template\Factory::build('feed/item_page');
- $ItemTemplate->set('PAGE', generateItemTemplateData($Page));
- $ItemTemplate->set('USER', generateItemTemplateData($User));
+ while($Attribute = $Statement->fetchObject('Page\Attribute')) {
+ try {
+ $Page = Page\Factory::buildByAttribute($Attribute);
+ $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());
-}
-?> \ No newline at end of file
+$FeedTemplate = Template\Factory::build('feed/main');
+$FeedTemplate->set('FEED', [
+ 'TYPE' => $param ?? NULL,
+ 'LIST' => [
+ 'POSTS' => $posts ?? [],
+ 'PAGES' => $pages ?? [],
+ ]
+]);
+
+echo $FeedTemplate;