diff options
Diffstat (limited to 'core/include/post')
-rw-r--r-- | core/include/post/list.php | 66 | ||||
-rw-r--r-- | core/include/post/main.php | 53 |
2 files changed, 46 insertions, 73 deletions
diff --git a/core/include/post/list.php b/core/include/post/list.php index 6ade592..68183c7 100644 --- a/core/include/post/list.php +++ b/core/include/post/list.php @@ -30,49 +30,39 @@ if(Application::get('POST.SINGLE_REDIRECT') === TRUE AND $count === '1') { HTTP::redirect($Post->getURL()); } -#=============================================================================== -# TRY: Template\Exception -#=============================================================================== -try { - $execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}"; - $Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE)); +$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_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 = generatePostItemTemplate($Post, $User); + $ItemTemplate = generatePostItemTemplate($Post, $User); - $posts[] = $ItemTemplate; - } - catch(Post\Exception $Exception){} - catch(User\Exception $Exception){} + $posts[] = $ItemTemplate; } - - $ListTemplate = Template\Factory::build('post/list'); - $ListTemplate->set('PAGINATION', [ - 'THIS' => $currentSite, - 'LAST' => $lastSite, - 'HTML' => generatePostNaviTemplate($currentSite) - ]); - $ListTemplate->set('LIST', [ - 'POSTS' => $posts ?? [] - ]); - - $MainTemplate = Template\Factory::build('main'); - $MainTemplate->set('HTML', $ListTemplate); - $MainTemplate->set('HEAD', [ - 'NAME' => $Language->text('title_post_overview', $currentSite) - ]); - - echo $MainTemplate; + catch(Post\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 +$ListTemplate = Template\Factory::build('post/list'); +$ListTemplate->set('PAGINATION', [ + 'THIS' => $currentSite, + 'LAST' => $lastSite, + 'HTML' => generatePostNaviTemplate($currentSite) +]); +$ListTemplate->set('LIST', [ + 'POSTS' => $posts ?? [] +]); + +$MainTemplate = Template\Factory::build('main'); +$MainTemplate->set('HTML', $ListTemplate); +$MainTemplate->set('HEAD', [ + 'NAME' => $Language->text('title_post_overview', $currentSite) +]); + +echo $MainTemplate; diff --git a/core/include/post/main.php b/core/include/post/main.php index aa5dc50..8c65740 100644 --- a/core/include/post/main.php +++ b/core/include/post/main.php @@ -6,7 +6,7 @@ $Database = Application::getDatabase(); $Language = Application::getLanguage(); #=============================================================================== -# TRY: Post\Exception, User\Exception +# TRY: Post\Exception #=============================================================================== try { if(Application::get('POST.SLUG_URLS')) { @@ -36,36 +36,27 @@ try { } catch(Post\Exception $Exception){} #=============================================================================== - # TRY: Template\Exception + # Build document #=============================================================================== - try { - $PostTemplate = Template\Factory::build('post/main'); - $PostTemplate->set('POST', $post_data); - $PostTemplate->set('USER', $user_data); - - $MainTemplate = Template\Factory::build('main'); - $MainTemplate->set('HTML', $PostTemplate); - $MainTemplate->set('HEAD', [ - 'NAME' => $post_data['ATTR']['NAME'], - 'DESC' => description($post_data['BODY']['HTML'](), Application::get('POST.DESCRIPTION_SIZE')), - 'PERM' => $post_data['URL'], - 'OG_IMAGES' => $post_data['FILE']['LIST'] - ]); + $PostTemplate = Template\Factory::build('post/main'); + $PostTemplate->set('POST', $post_data); + $PostTemplate->set('USER', $user_data); - # Get access to the current item data from main template - $MainTemplate->set('TYPE', 'POST'); - $MainTemplate->set('POST', $post_data); - $MainTemplate->set('USER', $user_data); + $MainTemplate = Template\Factory::build('main'); + $MainTemplate->set('HTML', $PostTemplate); + $MainTemplate->set('HEAD', [ + 'NAME' => $post_data['ATTR']['NAME'], + 'DESC' => description($post_data['BODY']['HTML'](), Application::get('POST.DESCRIPTION_SIZE')), + 'PERM' => $post_data['URL'], + 'OG_IMAGES' => $post_data['FILE']['LIST'] + ]); - echo $MainTemplate; - } + # Get access to the current item data from main template + $MainTemplate->set('TYPE', 'POST'); + $MainTemplate->set('POST', $post_data); + $MainTemplate->set('USER', $user_data); - #=============================================================================== - # CATCH: Template\Exception - #=============================================================================== - catch(Template\Exception $Exception) { - Application::exit($Exception->getMessage()); - } + echo $MainTemplate; } #=============================================================================== @@ -86,11 +77,3 @@ catch(Post\Exception $Exception) { Application::error404(); } } - -#=============================================================================== -# CATCH: User\Exception -#=============================================================================== -catch(User\Exception $Exception) { - Application::exit($Exception->getMessage()); -} -?>
\ No newline at end of file |