aboutsummaryrefslogtreecommitdiffstats
path: root/core/include/user
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-06-17 22:00:39 +0200
committerThomas Lange <code@nerdmind.de>2021-06-17 22:00:39 +0200
commit5555624546ea48d6327700f32b80848e0662dc90 (patch)
tree47d61fb756a6cb008aaf33586d292fcfe43da2a1 /core/include/user
parent91d8a28c664afa5378735bcd0efe068dd74d589f (diff)
parent0a2614cb69fc732c2115ef2f0c356f39f602d311 (diff)
downloadblog-optimization.tar.gz
blog-optimization.tar.xz
blog-optimization.zip
Merge branch 'master' into 'optimization'optimization
Diffstat (limited to 'core/include/user')
-rw-r--r--core/include/user/list.php67
-rw-r--r--core/include/user/main.php66
2 files changed, 55 insertions, 78 deletions
diff --git a/core/include/user/list.php b/core/include/user/list.php
index adc28ec..72375a4 100644
--- a/core/include/user/list.php
+++ b/core/include/user/list.php
@@ -30,45 +30,44 @@ if(Application::get('USER.SINGLE_REDIRECT') === TRUE AND $count === '1') {
HTTP::redirect($User->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, User\Attribute::TABLE));
+$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
+$Statement = $Database->query(sprintf($execSQL, User\Attribute::TABLE));
- while($Attribute = $Statement->fetchObject('User\Attribute')) {
- try {
- $User = User\Factory::buildByAttribute($Attribute);
- $ItemTemplate = generateUserItemTemplate($User);
+while($Attribute = $Statement->fetchObject('User\Attribute')) {
+ try {
+ $User = User\Factory::buildByAttribute($Attribute);
+ $ItemTemplate = generateUserItemTemplate($User);
- $users[] = $ItemTemplate;
- } catch(User\Exception $Exception){}
- }
-
- $ListTemplate = Template\Factory::build('user/list');
- $ListTemplate->set('PAGINATION', [
- 'THIS' => $currentSite,
- 'LAST' => $lastSite,
- 'HTML' => generateUserNaviTemplate($currentSite)
- ]);
- $ListTemplate->set('LIST', [
- 'USERS' => $users ?? []
- ]);
+ $users[] = $ItemTemplate;
+ } catch(User\Exception $Exception){}
+}
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('HTML', $ListTemplate);
- $MainTemplate->set('HEAD', [
- 'NAME' => $Language->text('title_user_overview', $currentSite)
- ]);
+foreach($userIDs as $userID) {
+ try {
+ $User = User\Factory::build($userID);
+ $ItemTemplate = generateUserItemTemplate($User);
- echo $MainTemplate;
+ $users[] = $ItemTemplate;
+ } 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('user/list');
+$ListTemplate->set('PAGINATION', [
+ 'THIS' => $currentSite,
+ 'LAST' => $lastSite,
+ 'HTML' => generateUserNaviTemplate($currentSite)
+]);
+$ListTemplate->set('LIST', [
+ 'USERS' => $users ?? []
+]);
+
+$MainTemplate = Template\Factory::build('main');
+$MainTemplate->set('HTML', $ListTemplate);
+$MainTemplate->set('HEAD', [
+ 'NAME' => $Language->text('title_user_overview', $currentSite)
+]);
+
+echo $MainTemplate;
diff --git a/core/include/user/main.php b/core/include/user/main.php
index 4f30020..80969da 100644
--- a/core/include/user/main.php
+++ b/core/include/user/main.php
@@ -32,54 +32,33 @@ try {
$user_data['NEXT'] = generateItemTemplateData($NextUser);
} catch(User\Exception $Exception){}
+ $PostCountStatement = $Database->query(sprintf('SELECT COUNT(*) FROM %s WHERE user = %d', Post\Attribute::TABLE, $User->getID()));
+ $PageCountStatement = $Database->query(sprintf('SELECT COUNT(*) FROM %s WHERE user = %d', Page\Attribute::TABLE, $User->getID()));
+
#===============================================================================
- # TRY: Template\Exception
+ # Build document
#===============================================================================
- try {
- #===============================================================================
- # TRY: PDOException
- #===============================================================================
- try {
- $PostCountStatement = $Database->query(sprintf('SELECT COUNT(*) FROM %s WHERE user = %d', Post\Attribute::TABLE, $User->getID()));
- $PageCountStatement = $Database->query(sprintf('SELECT COUNT(*) FROM %s WHERE user = %d', Page\Attribute::TABLE, $User->getID()));
- }
-
- #===============================================================================
- # CATCH: PDOException
- #===============================================================================
- catch(PDOException $Exception) {
- exit($Exception->getMessage());
- }
-
- $UserTemplate = Template\Factory::build('user/main');
- $UserTemplate->set('USER', $user_data);
- $UserTemplate->set('COUNT', [
- 'POST' => $PostCountStatement->fetchColumn(),
- 'PAGE' => $PageCountStatement->fetchColumn()
- ]);
+ $UserTemplate = Template\Factory::build('user/main');
+ $UserTemplate->set('USER', $user_data);
+ $UserTemplate->set('COUNT', [
+ 'POST' => $PostCountStatement->fetchColumn(),
+ 'PAGE' => $PageCountStatement->fetchColumn()
+ ]);
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('HTML', $UserTemplate);
- $MainTemplate->set('HEAD', [
- 'NAME' => $user_data['ATTR']['FULLNAME'],
- 'DESC' => description($user_data['BODY']['HTML'](), Application::get('USER.DESCRIPTION_SIZE')),
- 'PERM' => $User->getURL(),
- 'OG_IMAGES' => $User->getFiles()
- ]);
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $UserTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $user_data['ATTR']['FULLNAME'],
+ 'DESC' => description($user_data['BODY']['HTML'](), Application::get('USER.DESCRIPTION_SIZE')),
+ 'PERM' => $User->getURL(),
+ 'OG_IMAGES' => $User->getFiles()
+ ]);
- # Get access to the current item data from main template
- $MainTemplate->set('TYPE', 'USER');
- $MainTemplate->set('USER', $user_data);
+ # Get access to the current item data from main template
+ $MainTemplate->set('TYPE', 'USER');
+ $MainTemplate->set('USER', $user_data);
- echo $MainTemplate;
- }
-
- #===============================================================================
- # CATCH: Template\Exception
- #===============================================================================
- catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
- }
+ echo $MainTemplate;
}
#===============================================================================
@@ -100,4 +79,3 @@ catch(User\Exception $Exception) {
Application::error404();
}
}
-?> \ No newline at end of file