aboutsummaryrefslogtreecommitdiffstats
path: root/admin
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 /admin
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 'admin')
-rw-r--r--admin/auth.php37
-rw-r--r--admin/database.php35
-rw-r--r--admin/index.php108
-rw-r--r--admin/page/delete.php43
-rw-r--r--admin/page/index.php67
-rw-r--r--admin/page/insert.php59
-rw-r--r--admin/page/search.php25
-rw-r--r--admin/page/update.php59
-rw-r--r--admin/post/delete.php43
-rw-r--r--admin/post/index.php67
-rw-r--r--admin/post/insert.php59
-rw-r--r--admin/post/search.php25
-rw-r--r--admin/post/update.php59
-rw-r--r--admin/user/delete.php43
-rw-r--r--admin/user/index.php63
-rw-r--r--admin/user/insert.php43
-rw-r--r--admin/user/update.php37
17 files changed, 354 insertions, 518 deletions
diff --git a/admin/auth.php b/admin/auth.php
index cec8867..8c6d5a6 100644
--- a/admin/auth.php
+++ b/admin/auth.php
@@ -50,28 +50,19 @@ if(HTTP::issetPOST(['token' => Application::getSecurityToken()], 'username', 'pa
}
#===============================================================================
-# TRY: Template\Exception
+# Build document
#===============================================================================
-try {
- $AuthTemplate = Template\Factory::build('auth');
- $AuthTemplate->set('FORM', [
- 'INFO' => $messages ?? [],
- 'DATA' => [
- 'USERNAME' => HTTP::POST('username'),
- 'PASSWORD' => HTTP::POST('password'),
- ],
- 'TOKEN' => Application::getSecurityToken()
- ]);
+$AuthTemplate = Template\Factory::build('auth');
+$AuthTemplate->set('FORM', [
+ 'INFO' => $messages ?? [],
+ 'DATA' => [
+ 'USERNAME' => HTTP::POST('username'),
+ 'PASSWORD' => HTTP::POST('password'),
+ ],
+ 'TOKEN' => Application::getSecurityToken()
+]);
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', 'Authentication');
- $MainTemplate->set('HTML', $AuthTemplate);
- echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', 'Authentication');
+$MainTemplate->set('HTML', $AuthTemplate);
+echo $MainTemplate;
diff --git a/admin/database.php b/admin/database.php
index 14f34e1..78d47c1 100644
--- a/admin/database.php
+++ b/admin/database.php
@@ -26,26 +26,17 @@ if(HTTP::issetPOST(['token' => Application::getSecurityToken()], 'command')) {
}
#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $DatabaseTemplate = Template\Factory::build('database');
- $DatabaseTemplate->set('FORM', [
- 'INFO' => $messages ?? [],
- 'TOKEN' => Application::getSecurityToken(),
- 'RESULT' => implode(NULL, $result ?? []),
- 'COMMAND' => HTTP::POST('command'),
- ]);
+# Build document
+#===============================================================================
+$DatabaseTemplate = Template\Factory::build('database');
+$DatabaseTemplate->set('FORM', [
+ 'INFO' => $messages ?? [],
+ 'TOKEN' => Application::getSecurityToken(),
+ 'RESULT' => implode(NULL, $result ?? []),
+ 'COMMAND' => HTTP::POST('command'),
+]);
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', 'SQL');
- $MainTemplate->set('HTML', $DatabaseTemplate);
- echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', 'SQL');
+$MainTemplate->set('HTML', $DatabaseTemplate);
+echo $MainTemplate;
diff --git a/admin/index.php b/admin/index.php
index 6170021..788cee4 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -11,81 +11,61 @@ define('AUTHENTICATION', TRUE);
require '../core/application.php';
#===============================================================================
-# TRY: PDOException
+# Fetch last items and item count
#===============================================================================
-try {
- $execute = 'SELECT id FROM %s ORDER BY time_insert DESC LIMIT 1';
+$execute = 'SELECT id FROM %s ORDER BY time_insert DESC LIMIT 1';
+$LastPageStatement = $Database->query(sprintf($execute, Page\Attribute::TABLE));
+$LastPostStatement = $Database->query(sprintf($execute, Post\Attribute::TABLE));
+$LastUserStatement = $Database->query(sprintf($execute, User\Attribute::TABLE));
- $LastPageStatement = $Database->query(sprintf($execute, Page\Attribute::TABLE));
- $LastPostStatement = $Database->query(sprintf($execute, Post\Attribute::TABLE));
- $LastUserStatement = $Database->query(sprintf($execute, User\Attribute::TABLE));
+$execute = 'SELECT COUNT(*) FROM %s';
+$PageCountStatement = $Database->query(sprintf($execute, Page\Attribute::TABLE));
+$PostCountStatement = $Database->query(sprintf($execute, Post\Attribute::TABLE));
+$UserCountStatement = $Database->query(sprintf($execute, User\Attribute::TABLE));
- $execute = 'SELECT COUNT(*) FROM %s';
+try {
+ $LastPage = Page\Factory::build($LastPageStatement->fetchColumn());
+ $LastPageUser = User\Factory::build($LastPage->attr('user'));
- $PageCountStatement = $Database->query(sprintf($execute, Page\Attribute::TABLE));
- $PostCountStatement = $Database->query(sprintf($execute, Post\Attribute::TABLE));
- $UserCountStatement = $Database->query(sprintf($execute, User\Attribute::TABLE));
+ $PageItemTemplate = generatePageItemTemplate($LastPage, $LastPageUser);
}
-#===============================================================================
-# CATCH: PDOException
-#===============================================================================
-catch(PDOException $Exception) {
- exit($Exception->getMessage());
-}
+catch(Page\Exception $Exception){}
+catch(User\Exception $Exception){}
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
try {
- try {
- $LastPage = Page\Factory::build($LastPageStatement->fetchColumn());
- $LastPageUser = User\Factory::build($LastPage->attr('user'));
-
- $PageItemTemplate = generatePageItemTemplate($LastPage, $LastPageUser);
- }
-
- catch(Page\Exception $Exception){}
- catch(User\Exception $Exception){}
+ $LastPost = Post\Factory::build($LastPostStatement->fetchColumn());
+ $LastPostUser = User\Factory::build($LastPost->attr('user'));
- try {
- $LastPost = Post\Factory::build($LastPostStatement->fetchColumn());
- $LastPostUser = User\Factory::build($LastPost->attr('user'));
-
- $PostItemTemplate = generatePostItemTemplate($LastPost, $LastPostUser);
- }
-
- catch(Post\Exception $Exception){}
- catch(User\Exception $Exception){}
-
- try {
- $LastUser = User\Factory::build($LastUserStatement->fetchColumn());
- $UserItemTemplate = generateUserItemTemplate($LastUser);
- } catch(User\Exception $Exception){}
-
- $HomeTemplate = Template\Factory::build('home');
- $HomeTemplate->set('LAST', [
- 'PAGE' => $PageItemTemplate ?? FALSE,
- 'POST' => $PostItemTemplate ?? FALSE,
- 'USER' => $UserItemTemplate ?? FALSE,
-
- ]);
+ $PostItemTemplate = generatePostItemTemplate($LastPost, $LastPostUser);
+}
- $HomeTemplate->set('COUNT', [
- 'PAGE' => $PageCountStatement->fetchColumn(),
- 'POST' => $PostCountStatement->fetchColumn(),
- 'USER' => $UserCountStatement->fetchColumn(),
- ]);
+catch(Post\Exception $Exception){}
+catch(User\Exception $Exception){}
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', 'Dashboard');
- $MainTemplate->set('HTML', $HomeTemplate);
- echo $MainTemplate;
-}
+try {
+ $LastUser = User\Factory::build($LastUserStatement->fetchColumn());
+ $UserItemTemplate = generateUserItemTemplate($LastUser);
+} catch(User\Exception $Exception){}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+$HomeTemplate = Template\Factory::build('home');
+$HomeTemplate->set('LAST', [
+ 'PAGE' => $PageItemTemplate ?? FALSE,
+ 'POST' => $PostItemTemplate ?? FALSE,
+ 'USER' => $UserItemTemplate ?? FALSE,
+
+]);
+
+$HomeTemplate->set('COUNT', [
+ 'PAGE' => $PageCountStatement->fetchColumn(),
+ 'POST' => $PostCountStatement->fetchColumn(),
+ 'USER' => $UserCountStatement->fetchColumn(),
+]);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', 'Dashboard');
+$MainTemplate->set('HTML', $HomeTemplate);
+echo $MainTemplate;
diff --git a/admin/page/delete.php b/admin/page/delete.php
index 111910b..1406ece 100644
--- a/admin/page/delete.php
+++ b/admin/page/delete.php
@@ -28,33 +28,24 @@ try {
}
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- try {
- $FormTemplate = Template\Factory::build('page/form');
- $FormTemplate->set('HTML', $Page->getHTML());
- $FormTemplate->set('FORM', [
- 'TYPE' => 'DELETE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
-
- $DeleteTemplate = Template\Factory::build('page/delete');
- $DeleteTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_page_delete'));
- $MainTemplate->set('HTML', $DeleteTemplate);
- echo $MainTemplate;
- }
-
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $FormTemplate = Template\Factory::build('page/form');
+ $FormTemplate->set('HTML', $Page->getHTML());
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'DELETE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $DeleteTemplate = Template\Factory::build('page/delete');
+ $DeleteTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_page_delete'));
+ $MainTemplate->set('HTML', $DeleteTemplate);
+ echo $MainTemplate;
}
#===============================================================================
diff --git a/admin/page/index.php b/admin/page/index.php
index 584ba48..7c8b1a6 100644
--- a/admin/page/index.php
+++ b/admin/page/index.php
@@ -31,48 +31,39 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
$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);
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- 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;
}
-
- $PaginationTemplate = Template\Factory::build('pagination');
- $PaginationTemplate->set('THIS', $currentSite);
- $PaginationTemplate->set('LAST', $lastSite);
- $PaginationTemplate->set('HREF', Application::getAdminURL('page/?site=%d'));
-
- $ListTemplate = Template\Factory::build('page/index');
- $ListTemplate->set('LIST', [
- 'PAGES' => $pages ?? []
- ]);
-
- $ListTemplate->set('PAGINATION', [
- 'THIS' => $currentSite,
- 'LAST' => $lastSite,
- 'HTML' => $PaginationTemplate
- ]);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_page_overview', $currentSite));
- $MainTemplate->set('HTML', $ListTemplate);
- echo $MainTemplate;
+ catch(Page\Exception $Exception){}
+ catch(User\Exception $Exception){}
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+$PaginationTemplate = Template\Factory::build('pagination');
+$PaginationTemplate->set('THIS', $currentSite);
+$PaginationTemplate->set('LAST', $lastSite);
+$PaginationTemplate->set('HREF', Application::getAdminURL('page/?site=%d'));
+
+$ListTemplate = Template\Factory::build('page/index');
+$ListTemplate->set('LIST', [
+ 'PAGES' => $pages ?? []
+]);
+
+$ListTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $lastSite,
+ 'HTML' => $PaginationTemplate
+]);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_page_overview', $currentSite));
+$MainTemplate->set('HTML', $ListTemplate);
+echo $MainTemplate;
diff --git a/admin/page/insert.php b/admin/page/insert.php
index 4fc4d8b..ec903e7 100644
--- a/admin/page/insert.php
+++ b/admin/page/insert.php
@@ -37,42 +37,33 @@ if(HTTP::issetPOST('id', 'user', 'slug', 'name', 'body', 'argv', 'time_insert',
}
}
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
-
- foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
- $User = User\Factory::build($userID);
- $userAttributes[] = [
- 'ID' => $User->attr('id'),
- 'FULLNAME' => $User->attr('fullname'),
- 'USERNAME' => $User->attr('username'),
- ];
- }
-
- $FormTemplate = Template\Factory::build('page/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'INSERT',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'USER_LIST' => $userAttributes ?? [],
- 'TOKEN' => Application::getSecurityToken()
- ]);
+$userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
- $InsertTemplate = Template\Factory::build('page/insert');
- $InsertTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_page_insert'));
- $MainTemplate->set('HTML', $InsertTemplate);
- echo $MainTemplate;
+foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
+ $User = User\Factory::build($userID);
+ $userAttributes[] = [
+ 'ID' => $User->attr('id'),
+ 'FULLNAME' => $User->attr('fullname'),
+ 'USERNAME' => $User->attr('username'),
+ ];
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+$FormTemplate = Template\Factory::build('page/form');
+$FormTemplate->set('FORM', [
+ 'TYPE' => 'INSERT',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'USER_LIST' => $userAttributes ?? [],
+ 'TOKEN' => Application::getSecurityToken()
+]);
+
+$InsertTemplate = Template\Factory::build('page/insert');
+$InsertTemplate->set('HTML', $FormTemplate);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_page_insert'));
+$MainTemplate->set('HTML', $InsertTemplate);
+echo $MainTemplate;
diff --git a/admin/page/search.php b/admin/page/search.php
index e71a8b8..eb57a7c 100644
--- a/admin/page/search.php
+++ b/admin/page/search.php
@@ -29,23 +29,14 @@ if($search = HTTP::GET('q')) {
}
#===============================================================================
-# TRY: Template\Exception
+# Build document
#===============================================================================
-try {
- $SearchTemplate = Template\Factory::build('page/search');
- $SearchTemplate->set('QUERY', $search);
- $SearchTemplate->set('PAGES', $pages ?? []);
+$SearchTemplate = Template\Factory::build('page/search');
+$SearchTemplate->set('QUERY', $search);
+$SearchTemplate->set('PAGES', $pages ?? []);
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_page_search'));
- $MainTemplate->set('HTML', $SearchTemplate);
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_page_search'));
+$MainTemplate->set('HTML', $SearchTemplate);
- echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+echo $MainTemplate;
diff --git a/admin/page/update.php b/admin/page/update.php
index a7c9cd0..ba34a86 100644
--- a/admin/page/update.php
+++ b/admin/page/update.php
@@ -39,45 +39,36 @@ try {
}
}
- #===============================================================================
- # TRY: Template\Exception
- #===============================================================================
- try {
- $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
-
- foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
- $User = User\Factory::build($userID);
- $userAttributes[] = [
- 'ID' => $User->attr('id'),
- 'FULLNAME' => $User->attr('fullname'),
- 'USERNAME' => $User->attr('username'),
- ];
- }
-
- $FormTemplate = Template\Factory::build('page/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'UPDATE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'USER_LIST' => $userAttributes ?? [],
- 'TOKEN' => Application::getSecurityToken()
- ]);
+ $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
- $PageUpdateTemplate = Template\Factory::build('page/update');
- $PageUpdateTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_page_update'));
- $MainTemplate->set('HTML', $PageUpdateTemplate);
- echo $MainTemplate;
+ foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
+ $User = User\Factory::build($userID);
+ $userAttributes[] = [
+ 'ID' => $User->attr('id'),
+ 'FULLNAME' => $User->attr('fullname'),
+ 'USERNAME' => $User->attr('username'),
+ ];
}
#===============================================================================
- # CATCH: Template\Exception
+ # Build document
#===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $FormTemplate = Template\Factory::build('page/form');
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'UPDATE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'USER_LIST' => $userAttributes ?? [],
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $PageUpdateTemplate = Template\Factory::build('page/update');
+ $PageUpdateTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_page_update'));
+ $MainTemplate->set('HTML', $PageUpdateTemplate);
+ echo $MainTemplate;
}
#===============================================================================
diff --git a/admin/post/delete.php b/admin/post/delete.php
index 792b958..6da8a68 100644
--- a/admin/post/delete.php
+++ b/admin/post/delete.php
@@ -28,33 +28,24 @@ try {
}
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- try {
- $FormTemplate = Template\Factory::build('post/form');
- $FormTemplate->set('HTML', $Post->getHTML());
- $FormTemplate->set('FORM', [
- 'TYPE' => 'DELETE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
-
- $DeleteTemplate = Template\Factory::build('post/delete');
- $DeleteTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_post_delete'));
- $MainTemplate->set('HTML', $DeleteTemplate);
- echo $MainTemplate;
- }
-
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $FormTemplate = Template\Factory::build('post/form');
+ $FormTemplate->set('HTML', $Post->getHTML());
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'DELETE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $DeleteTemplate = Template\Factory::build('post/delete');
+ $DeleteTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_post_delete'));
+ $MainTemplate->set('HTML', $DeleteTemplate);
+ echo $MainTemplate;
}
#===============================================================================
diff --git a/admin/post/index.php b/admin/post/index.php
index 7793c9b..e18a634 100644
--- a/admin/post/index.php
+++ b/admin/post/index.php
@@ -31,48 +31,39 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
$execSQL = "SELECT id FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
$postIDs = $Database->query(sprintf($execSQL, Post\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- foreach($postIDs as $postID) {
- try {
- $Post = Post\Factory::build($postID);
- $User = User\Factory::build($Post->attr('user'));
+foreach($postIDs as $postID) {
+ try {
+ $Post = Post\Factory::build($postID);
+ $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;
}
-
- $PaginationTemplate = Template\Factory::build('pagination');
- $PaginationTemplate->set('THIS', $currentSite);
- $PaginationTemplate->set('LAST', $lastSite);
- $PaginationTemplate->set('HREF', Application::getAdminURL('post/?site=%d'));
-
- $ListTemplate = Template\Factory::build('post/index');
- $ListTemplate->set('LIST', [
- 'POSTS' => $posts ?? []
- ]);
-
- $ListTemplate->set('PAGINATION', [
- 'THIS' => $currentSite,
- 'LAST' => $lastSite,
- 'HTML' => $PaginationTemplate
- ]);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_post_overview', $currentSite));
- $MainTemplate->set('HTML', $ListTemplate);
- echo $MainTemplate;
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+$PaginationTemplate = Template\Factory::build('pagination');
+$PaginationTemplate->set('THIS', $currentSite);
+$PaginationTemplate->set('LAST', $lastSite);
+$PaginationTemplate->set('HREF', Application::getAdminURL('post/?site=%d'));
+
+$ListTemplate = Template\Factory::build('post/index');
+$ListTemplate->set('LIST', [
+ 'POSTS' => $posts ?? []
+]);
+
+$ListTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $lastSite,
+ 'HTML' => $PaginationTemplate
+]);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_post_overview', $currentSite));
+$MainTemplate->set('HTML', $ListTemplate);
+echo $MainTemplate;
diff --git a/admin/post/insert.php b/admin/post/insert.php
index 6916a61..6065c95 100644
--- a/admin/post/insert.php
+++ b/admin/post/insert.php
@@ -37,42 +37,33 @@ if(HTTP::issetPOST('id', 'user', 'slug', 'name', 'body', 'argv', 'time_insert',
}
}
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
-
- foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
- $User = User\Factory::build($userID);
- $userAttributes[] = [
- 'ID' => $User->attr('id'),
- 'FULLNAME' => $User->attr('fullname'),
- 'USERNAME' => $User->attr('username'),
- ];
- }
-
- $FormTemplate = Template\Factory::build('post/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'INSERT',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'USER_LIST' => $userAttributes ?? [],
- 'TOKEN' => Application::getSecurityToken()
- ]);
+$userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
- $InsertTemplate = Template\Factory::build('post/insert');
- $InsertTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_post_insert'));
- $MainTemplate->set('HTML', $InsertTemplate);
- echo $MainTemplate;
+foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
+ $User = User\Factory::build($userID);
+ $userAttributes[] = [
+ 'ID' => $User->attr('id'),
+ 'FULLNAME' => $User->attr('fullname'),
+ 'USERNAME' => $User->attr('username'),
+ ];
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+$FormTemplate = Template\Factory::build('post/form');
+$FormTemplate->set('FORM', [
+ 'TYPE' => 'INSERT',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'USER_LIST' => $userAttributes ?? [],
+ 'TOKEN' => Application::getSecurityToken()
+]);
+
+$InsertTemplate = Template\Factory::build('post/insert');
+$InsertTemplate->set('HTML', $FormTemplate);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_post_insert'));
+$MainTemplate->set('HTML', $InsertTemplate);
+echo $MainTemplate;
diff --git a/admin/post/search.php b/admin/post/search.php
index cd28322..8fe6a51 100644
--- a/admin/post/search.php
+++ b/admin/post/search.php
@@ -29,23 +29,14 @@ if($search = HTTP::GET('q')) {
}
#===============================================================================
-# TRY: Template\Exception
+# Build document
#===============================================================================
-try {
- $SearchTemplate = Template\Factory::build('post/search');
- $SearchTemplate->set('QUERY', $search);
- $SearchTemplate->set('POSTS', $posts ?? []);
+$SearchTemplate = Template\Factory::build('post/search');
+$SearchTemplate->set('QUERY', $search);
+$SearchTemplate->set('POSTS', $posts ?? []);
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_post_search'));
- $MainTemplate->set('HTML', $SearchTemplate);
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_post_search'));
+$MainTemplate->set('HTML', $SearchTemplate);
- echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+echo $MainTemplate;
diff --git a/admin/post/update.php b/admin/post/update.php
index 7b82bf4..d7778f8 100644
--- a/admin/post/update.php
+++ b/admin/post/update.php
@@ -39,45 +39,36 @@ try {
}
}
- #===============================================================================
- # TRY: Template\Exception
- #===============================================================================
- try {
- $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
-
- foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
- $User = User\Factory::build($userID);
- $userAttributes[] = [
- 'ID' => $User->attr('id'),
- 'FULLNAME' => $User->attr('fullname'),
- 'USERNAME' => $User->attr('username'),
- ];
- }
-
- $FormTemplate = Template\Factory::build('post/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'UPDATE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
- 'USER_LIST' => $userAttributes ?? [],
- 'TOKEN' => Application::getSecurityToken()
- ]);
+ $userIDs = $Database->query(sprintf('SELECT id FROM %s ORDER BY fullname ASC', User\Attribute::TABLE));
- $PostUpdateTemplate = Template\Factory::build('post/update');
- $PostUpdateTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_post_update'));
- $MainTemplate->set('HTML', $PostUpdateTemplate);
- echo $MainTemplate;
+ foreach($userIDs->fetchAll($Database::FETCH_COLUMN) as $userID) {
+ $User = User\Factory::build($userID);
+ $userAttributes[] = [
+ 'ID' => $User->attr('id'),
+ 'FULLNAME' => $User->attr('fullname'),
+ 'USERNAME' => $User->attr('username'),
+ ];
}
#===============================================================================
- # CATCH: Template\Exception
+ # Build document
#===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $FormTemplate = Template\Factory::build('post/form');
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'UPDATE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(), CASE_UPPER),
+ 'USER_LIST' => $userAttributes ?? [],
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $PostUpdateTemplate = Template\Factory::build('post/update');
+ $PostUpdateTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_post_update'));
+ $MainTemplate->set('HTML', $PostUpdateTemplate);
+ echo $MainTemplate;
}
#===============================================================================
diff --git a/admin/user/delete.php b/admin/user/delete.php
index 92aed0d..18a57cf 100644
--- a/admin/user/delete.php
+++ b/admin/user/delete.php
@@ -28,33 +28,24 @@ try {
}
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- try {
- $FormTemplate = Template\Factory::build('user/form');
- $FormTemplate->set('HTML', $User->getHTML());
- $FormTemplate->set('FORM', [
- 'TYPE' => 'DELETE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
-
- $DeleteTemplate = Template\Factory::build('user/delete');
- $DeleteTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_delete'));
- $MainTemplate->set('HTML', $DeleteTemplate);
- echo $MainTemplate;
- }
-
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $FormTemplate = Template\Factory::build('user/form');
+ $FormTemplate->set('HTML', $User->getHTML());
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'DELETE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
+
+ $DeleteTemplate = Template\Factory::build('user/delete');
+ $DeleteTemplate->set('HTML', $FormTemplate);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_user_delete'));
+ $MainTemplate->set('HTML', $DeleteTemplate);
+ echo $MainTemplate;
}
#===============================================================================
diff --git a/admin/user/index.php b/admin/user/index.php
index 223e83e..7d0cfa8 100644
--- a/admin/user/index.php
+++ b/admin/user/index.php
@@ -31,44 +31,35 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
$execSQL = "SELECT id FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
$userIDs = $Database->query(sprintf($execSQL, User\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN);
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- foreach($userIDs as $userID) {
- try {
- $User = User\Factory::build($userID);
- $ItemTemplate = generateUserItemTemplate($User);
-
- $users[] = $ItemTemplate;
- } catch(User\Exception $Exception){}
- }
-
- $PaginationTemplate = Template\Factory::build('pagination');
- $PaginationTemplate->set('THIS', $currentSite);
- $PaginationTemplate->set('LAST', $lastSite);
- $PaginationTemplate->set('HREF', Application::getAdminURL('user/?site=%d'));
-
- $ListTemplate = Template\Factory::build('user/index');
- $ListTemplate->set('LIST', [
- 'USERS' => $users ?? []
- ]);
+foreach($userIDs as $userID) {
+ try {
+ $User = User\Factory::build($userID);
+ $ItemTemplate = generateUserItemTemplate($User);
- $ListTemplate->set('PAGINATION', [
- 'THIS' => $currentSite,
- 'LAST' => $lastSite,
- 'HTML' => $PaginationTemplate
- ]);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_overview', $currentSite));
- $MainTemplate->set('HTML', $ListTemplate);
- echo $MainTemplate;
+ $users[] = $ItemTemplate;
+ } catch(User\Exception $Exception){}
}
#===============================================================================
-# CATCH: Template\Exception
+# Build document
#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+$PaginationTemplate = Template\Factory::build('pagination');
+$PaginationTemplate->set('THIS', $currentSite);
+$PaginationTemplate->set('LAST', $lastSite);
+$PaginationTemplate->set('HREF', Application::getAdminURL('user/?site=%d'));
+
+$ListTemplate = Template\Factory::build('user/index');
+$ListTemplate->set('LIST', [
+ 'USERS' => $users ?? []
+]);
+
+$ListTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $lastSite,
+ 'HTML' => $PaginationTemplate
+]);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_user_overview', $currentSite));
+$MainTemplate->set('HTML', $ListTemplate);
+echo $MainTemplate;
diff --git a/admin/user/insert.php b/admin/user/insert.php
index 0a50927..59b9444 100644
--- a/admin/user/insert.php
+++ b/admin/user/insert.php
@@ -40,29 +40,20 @@ if(HTTP::issetPOST('id', 'slug', 'username', 'password', 'fullname', 'mailaddr',
}
#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- $FormTemplate = Template\Factory::build('user/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'INSERT',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
-
- $InsertTemplate = Template\Factory::build('user/insert');
- $InsertTemplate->set('HTML', $FormTemplate);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_insert'));
- $MainTemplate->set('HTML', $InsertTemplate);
- echo $MainTemplate;
-}
-
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
-}
+# Build document
+#===============================================================================
+$FormTemplate = Template\Factory::build('user/form');
+$FormTemplate->set('FORM', [
+ 'TYPE' => 'INSERT',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+]);
+
+$InsertTemplate = Template\Factory::build('user/insert');
+$InsertTemplate->set('HTML', $FormTemplate);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('NAME', $Language->text('title_user_insert'));
+$MainTemplate->set('HTML', $InsertTemplate);
+echo $MainTemplate;
diff --git a/admin/user/update.php b/admin/user/update.php
index 49ec335..b9b5f08 100644
--- a/admin/user/update.php
+++ b/admin/user/update.php
@@ -42,32 +42,23 @@ try {
}
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- try {
- $FormTemplate = Template\Factory::build('user/form');
- $FormTemplate->set('FORM', [
- 'TYPE' => 'UPDATE',
- 'INFO' => $messages ?? [],
- 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
- 'TOKEN' => Application::getSecurityToken()
- ]);
+ $FormTemplate = Template\Factory::build('user/form');
+ $FormTemplate->set('FORM', [
+ 'TYPE' => 'UPDATE',
+ 'INFO' => $messages ?? [],
+ 'DATA' => array_change_key_case($Attribute->getAll(['password']), CASE_UPPER),
+ 'TOKEN' => Application::getSecurityToken()
+ ]);
- $InsertTemplate = Template\Factory::build('user/update');
- $InsertTemplate->set('HTML', $FormTemplate);
+ $InsertTemplate = Template\Factory::build('user/update');
+ $InsertTemplate->set('HTML', $FormTemplate);
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('NAME', $Language->text('title_user_update'));
- $MainTemplate->set('HTML', $InsertTemplate);
- echo $MainTemplate;
- }
-
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_user_update'));
+ $MainTemplate->set('HTML', $InsertTemplate);
+ echo $MainTemplate;
}
#===============================================================================