aboutsummaryrefslogtreecommitdiffstats
path: root/core/include/page
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-06-14 20:03:19 +0200
committerThomas Lange <code@nerdmind.de>2021-06-14 20:03:19 +0200
commit78fcc20190121d487a2e6cf1fca53b66df67dc3a (patch)
treeb9b0dc3da8afc923fbac80ade147305cb7079e3f /core/include/page
parentd453ba414803832bb4e4f9ae5eddec7ae3f60205 (diff)
downloadblog-78fcc20190121d487a2e6cf1fca53b66df67dc3a.tar.gz
blog-78fcc20190121d487a2e6cf1fca53b66df67dc3a.tar.xz
blog-78fcc20190121d487a2e6cf1fca53b66df67dc3a.zip
Remove more redundant try/catch blocks
Remove all try/catch blocks where the exception handling did not differ from the exception handler already defined by "set_exception_handler".
Diffstat (limited to 'core/include/page')
-rw-r--r--core/include/page/list.php65
-rw-r--r--core/include/page/main.php52
2 files changed, 46 insertions, 71 deletions
diff --git a/core/include/page/list.php b/core/include/page/list.php
index 6bda9cf..0165116 100644
--- a/core/include/page/list.php
+++ b/core/include/page/list.php
@@ -30,48 +30,39 @@ if(Application::get('PAGE.SINGLE_REDIRECT') === TRUE AND $count === '1') {
HTTP::redirect($Page->getURL());
}
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $execSQL = "SELECT id FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
- $pageIDs = $Database->query(sprintf($execSQL, Page\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
+$execSQL = "SELECT id FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_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'));
+foreach($pageIDs as $pageID) {
+ try {
+ $Page = Page\Factory::build($pageID);
+ $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());
-}
+$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 6086345..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,10 +77,3 @@ catch(Page\Exception $Exception) {
Application::error404();
}
}
-
-#===============================================================================
-# CATCH: User\Exception
-#===============================================================================
-catch(User\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}