diff options
author | Thomas Lange <code@nerdmind.de> | 2021-06-17 22:00:39 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-06-17 22:00:39 +0200 |
commit | 5555624546ea48d6327700f32b80848e0662dc90 (patch) | |
tree | 47d61fb756a6cb008aaf33586d292fcfe43da2a1 /core/include/feed/main.php | |
parent | 91d8a28c664afa5378735bcd0efe068dd74d589f (diff) | |
parent | 0a2614cb69fc732c2115ef2f0c356f39f602d311 (diff) | |
download | blog-optimization.tar.gz blog-optimization.tar.xz blog-optimization.zip |
Merge branch 'master' into 'optimization'optimization
Diffstat (limited to 'core/include/feed/main.php')
-rw-r--r-- | core/include/feed/main.php | 100 |
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; |