diff options
author | Thomas Lange <code@nerdmind.de> | 2017-04-11 07:13:13 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2017-04-11 07:13:13 +0200 |
commit | 85e48b669f65933d5376f9214219c7e5eb10a9e7 (patch) | |
tree | 5a08463dc9d770d98442e1c9f8d65044cdd9f1ff /core/include/feed | |
parent | dd0433cf81fe5329b694a148191f09e427d4a56c (diff) | |
download | blog-85e48b669f65933d5376f9214219c7e5eb10a9e7.tar.gz blog-85e48b669f65933d5376f9214219c7e5eb10a9e7.tar.xz blog-85e48b669f65933d5376f9214219c7e5eb10a9e7.zip |
The system directory has been moved to a non-public directory. After the commit e33c245d910e55b8cab407a03e669470509a705d, it is no longer necessary that the directory is publicly accessible via HTTP because all requests are running through the router.v1.2
Diffstat (limited to 'core/include/feed')
-rw-r--r-- | core/include/feed/main.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/core/include/feed/main.php b/core/include/feed/main.php new file mode 100644 index 0000000..671f5c7 --- /dev/null +++ b/core/include/feed/main.php @@ -0,0 +1,77 @@ +<?php +#=============================================================================== +# Get instances +#=============================================================================== +$Database = Application::getDatabase(); +$Language = Application::getLanguage(); + +#=============================================================================== +# HEADER: Content-Type for XML document +#=============================================================================== +HTTP::responseHeader(HTTP::HEADER_CONTENT_TYPE, HTTP::CONTENT_TYPE_XML); + +#=============================================================================== +# TRY: Template\Exception +#=============================================================================== +try { + if(!isset($param) OR $param !== 'page') { + $execSQL = 'SELECT id FROM %s ORDER BY '.Application::get('POST.FEED_SORT').' LIMIT '.Application::get('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')); + + $ItemTemplate = Template\Factory::build('feed/item_post'); + $ItemTemplate->set('POST', generatePostItemData($Post)); + $ItemTemplate->set('USER', generateUserItemData($User)); + + $posts[] = $ItemTemplate; + } + + catch(Post\Exception $Exception){} + catch(User\Exception $Exception){} + } + } + + if(!isset($param) OR $param !== 'post') { + $execSQL = 'SELECT id FROM %s ORDER BY '.Application::get('PAGE.FEED_SORT').' LIMIT '.Application::get('PAGE.FEED_SIZE'); + $pageIDs = $Database->query(sprintf($execSQL, Page\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN); + + foreach($pageIDs as $pageID) { + try { + $Page = Page\Factory::build($pageID); + $User = User\Factory::build($Page->attr('user')); + + $ItemTemplate = Template\Factory::build('feed/item_page'); + $ItemTemplate->set('PAGE', generatePageItemData($Page)); + $ItemTemplate->set('USER', generateUserItemData($User)); + + $pages[] = $ItemTemplate; + } + + catch(Page\Exception $Exception){} + catch(User\Exception $Exception){} + } + } + + $FeedTemplate = Template\Factory::build('feed/main'); + $FeedTemplate->set('FEED', [ + 'TYPE' => $param ?? NULL, + 'LIST' => [ + 'POSTS' => $posts ?? [], + 'PAGES' => $pages ?? [], + ] + ]); + + echo $FeedTemplate; +} + +#=============================================================================== +# CATCH: Template\Exception +#=============================================================================== +catch(Template\Exception $Exception) { + Application::exit($Exception->getMessage()); +} +?>
\ No newline at end of file |