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/page | |
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/page')
-rw-r--r-- | core/include/page/list.php | 66 | ||||
-rw-r--r-- | core/include/page/main.php | 53 |
2 files changed, 46 insertions, 73 deletions
diff --git a/core/include/page/list.php b/core/include/page/list.php index 656d01a..2bb2639 100644 --- a/core/include/page/list.php +++ b/core/include/page/list.php @@ -30,49 +30,39 @@ if(Application::get('PAGE.SINGLE_REDIRECT') === TRUE AND $count === '1') { HTTP::redirect($Page->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, Page\Attribute::TABLE)); +$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}"; +$Statement = $Database->query(sprintf($execSQL, Page\Attribute::TABLE)); - while($Attribute = $Statement->fetchObject('Page\Attribute')) { - try { - $Page = Page\Factory::buildByAttribute($Attribute); - $User = User\Factory::build($Page->attr('user')); +while($Attribute = $Statement->fetchObject('Page\Attribute')) { + try { + $Page = Page\Factory::buildByAttribute($Attribute); + $User = User\Factory::build($Page->attr('user')); - $ItemTemplate = generatePageItemTemplate($Page, $User); + $ItemTemplate = generatePageItemTemplate($Page, $User); - $pages[] = $ItemTemplate; - } - catch(Page\Exception $Exception){} - catch(User\Exception $Exception){} + $pages[] = $ItemTemplate; } - - $ListTemplate = Template\Factory::build('page/list'); - $ListTemplate->set('PAGINATION', [ - 'THIS' => $currentSite, - 'LAST' => $lastSite, - 'HTML' => generatePageNaviTemplate($currentSite) - ]); - $ListTemplate->set('LIST', [ - 'PAGES' => $pages ?? [] - ]); - - $MainTemplate = Template\Factory::build('main'); - $MainTemplate->set('HTML', $ListTemplate); - $MainTemplate->set('HEAD', [ - 'NAME' => $Language->text('title_page_overview', $currentSite) - ]); - - echo $MainTemplate; + 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 +$ListTemplate = Template\Factory::build('page/list'); +$ListTemplate->set('PAGINATION', [ + 'THIS' => $currentSite, + 'LAST' => $lastSite, + 'HTML' => generatePageNaviTemplate($currentSite) +]); +$ListTemplate->set('LIST', [ + 'PAGES' => $pages ?? [] +]); + +$MainTemplate = Template\Factory::build('main'); +$MainTemplate->set('HTML', $ListTemplate); +$MainTemplate->set('HEAD', [ + 'NAME' => $Language->text('title_page_overview', $currentSite) +]); + +echo $MainTemplate; diff --git a/core/include/page/main.php b/core/include/page/main.php index 7f1aa02..955bb35 100644 --- a/core/include/page/main.php +++ b/core/include/page/main.php @@ -6,7 +6,7 @@ $Database = Application::getDatabase(); $Language = Application::getLanguage(); #=============================================================================== -# TRY: Page\Exception, User\Exception +# TRY: Page\Exception #=============================================================================== try { if(Application::get('PAGE.SLUG_URLS')) { @@ -36,36 +36,27 @@ try { } catch(Page\Exception $Exception){} #=============================================================================== - # TRY: Template\Exception + # Build document #=============================================================================== - try { - $PageTemplate = Template\Factory::build('page/main'); - $PageTemplate->set('PAGE', $page_data); - $PageTemplate->set('USER', $user_data); - - $MainTemplate = Template\Factory::build('main'); - $MainTemplate->set('HTML', $PageTemplate); - $MainTemplate->set('HEAD', [ - 'NAME' => $page_data['ATTR']['NAME'], - 'DESC' => description($page_data['BODY']['HTML'](), Application::get('PAGE.DESCRIPTION_SIZE')), - 'PERM' => $page_data['URL'], - 'OG_IMAGES' => $page_data['FILE']['LIST'] - ]); + $PageTemplate = Template\Factory::build('page/main'); + $PageTemplate->set('PAGE', $page_data); + $PageTemplate->set('USER', $user_data); - # Get access to the current item data from main template - $MainTemplate->set('TYPE', 'PAGE'); - $MainTemplate->set('PAGE', $page_data); - $MainTemplate->set('USER', $user_data); + $MainTemplate = Template\Factory::build('main'); + $MainTemplate->set('HTML', $PageTemplate); + $MainTemplate->set('HEAD', [ + 'NAME' => $page_data['ATTR']['NAME'], + 'DESC' => description($page_data['BODY']['HTML'](), Application::get('PAGE.DESCRIPTION_SIZE')), + 'PERM' => $page_data['URL'], + 'OG_IMAGES' => $page_data['FILE']['LIST'] + ]); - echo $MainTemplate; - } + # Get access to the current item data from main template + $MainTemplate->set('TYPE', 'PAGE'); + $MainTemplate->set('PAGE', $page_data); + $MainTemplate->set('USER', $user_data); - #=============================================================================== - # CATCH: Template\Exception - #=============================================================================== - catch(Template\Exception $Exception) { - Application::exit($Exception->getMessage()); - } + echo $MainTemplate; } #=============================================================================== @@ -86,11 +77,3 @@ catch(Page\Exception $Exception) { Application::error404(); } } - -#=============================================================================== -# CATCH: User\Exception -#=============================================================================== -catch(User\Exception $Exception) { - Application::exit($Exception->getMessage()); -} -?>
\ No newline at end of file |