diff options
author | Thomas Lange <code@nerdmind.de> | 2021-06-14 20:03:19 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-06-14 20:03:19 +0200 |
commit | 78fcc20190121d487a2e6cf1fca53b66df67dc3a (patch) | |
tree | b9b0dc3da8afc923fbac80ade147305cb7079e3f /admin/user/index.php | |
parent | d453ba414803832bb4e4f9ae5eddec7ae3f60205 (diff) | |
download | blog-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/user/index.php')
-rw-r--r-- | admin/user/index.php | 63 |
1 files changed, 27 insertions, 36 deletions
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; |