aboutsummaryrefslogtreecommitdiffstats
path: root/admin/post
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 /admin/post
parent91d8a28c664afa5378735bcd0efe068dd74d589f (diff)
parent0a2614cb69fc732c2115ef2f0c356f39f602d311 (diff)
downloadblog-optimization.tar.gz
blog-optimization.tar.xz
blog-optimization.zip
Merge branch 'master' into 'optimization'optimization
Diffstat (limited to 'admin/post')
-rw-r--r--admin/post/delete.php44
-rw-r--r--admin/post/index.php72
-rw-r--r--admin/post/insert.php60
-rw-r--r--admin/post/search.php26
-rw-r--r--admin/post/update.php60
5 files changed, 106 insertions, 156 deletions
diff --git a/admin/post/delete.php b/admin/post/delete.php
index 78fdf6e..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;
}
#===============================================================================
@@ -63,4 +54,3 @@ try {
catch(Post\Exception $Exception) {
Application::error404();
}
-?> \ No newline at end of file
diff --git a/admin/post/index.php b/admin/post/index.php
index 7e492ba..1269236 100644
--- a/admin/post/index.php
+++ b/admin/post/index.php
@@ -13,8 +13,8 @@ require '../../core/application.php';
#===============================================================================
# Pagination
#===============================================================================
-$site_size = Application::get('POST.LIST_SIZE');
-$site_sort = Application::get('POST.LIST_SORT');
+$site_size = Application::get('ADMIN.POST.LIST_SIZE');
+$site_sort = Application::get('ADMIN.POST.LIST_SORT');
$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', Post\Attribute::TABLE))->fetchColumn() / $site_size);
@@ -31,49 +31,39 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}";
$Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
-#===============================================================================
-# TRY: Template\Exception
-#===============================================================================
-try {
- while($Attribute = $Statement->fetchObject('Post\Attribute')) {
- try {
- $Post = Post\Factory::buildByAttribute($Attribute);
- $User = User\Factory::build($Post->attr('user'));
+while($Attribute = $Statement->fetchObject('Post\Attribute')) {
+ try {
+ $Post = Post\Factory::buildByAttribute($Attribute);
+ $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());
-}
-?> \ No newline at end of file
+$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 d35d527..6065c95 100644
--- a/admin/post/insert.php
+++ b/admin/post/insert.php
@@ -37,43 +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());
-}
-?> \ No newline at end of file
+$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 ac472f8..261cc06 100644
--- a/admin/post/search.php
+++ b/admin/post/search.php
@@ -27,24 +27,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());
-}
-?> \ No newline at end of file
+echo $MainTemplate;
diff --git a/admin/post/update.php b/admin/post/update.php
index d2cf979..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;
}
#===============================================================================
@@ -86,4 +77,3 @@ try {
catch(Post\Exception $Exception) {
Application::error404();
}
-?> \ No newline at end of file