aboutsummaryrefslogtreecommitdiffstats
path: root/core/include/search
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/search
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/search')
-rw-r--r--core/include/search/main.php78
1 files changed, 34 insertions, 44 deletions
diff --git a/core/include/search/main.php b/core/include/search/main.php
index 5a9708e..ac7e23a 100644
--- a/core/include/search/main.php
+++ b/core/include/search/main.php
@@ -35,56 +35,46 @@ $search_data = [
];
#===============================================================================
-# TRY: Template\Exception
+# Build document
#===============================================================================
-try {
- if(isset($attributes) AND !empty($attributes)) {
- foreach($attributes as $Attribute) {
- try {
- $Post = Post\Factory::buildByAttribute($Attribute);
- $User = User\Factory::build($Post->attr('user'));
+if(isset($attributes) AND !empty($attributes)) {
+ foreach($attributes as $Attribute) {
+ try {
+ $Post = Post\Factory::buildByAttribute($Attribute);
+ $User = User\Factory::build($Post->attr('user'));
- $posts[] = generatePostItemTemplate($Post, $User);
- }
- catch(Post\Exception $Exception){}
- catch(User\Exception $Exception){}
+ $posts[] = generatePostItemTemplate($Post, $User);
}
-
- $ResultTemplate = Template\Factory::build('search/result');
- $ResultTemplate->set('FORM', $form_data);
- $ResultTemplate->set('SEARCH', $search_data);
- $ResultTemplate->set('RESULT', [
- 'LIST' => $posts ?? []
- ]);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('HTML', $ResultTemplate);
- $MainTemplate->set('HEAD', [
- 'NAME' => $Language->text('title_search_results', escapeHTML($search)),
- 'PERM' => Application::getURL('search/')
- ]);
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
}
- else {
- $SearchTemplate = Template\Factory::build('search/main');
- $SearchTemplate->set('FORM', $form_data);
- $SearchTemplate->set('SEARCH', $search_data);
-
- $MainTemplate = Template\Factory::build('main');
- $MainTemplate->set('HTML', $SearchTemplate);
- $MainTemplate->set('HEAD', [
- 'NAME' => $Language->text('title_search_request'),
- 'PERM' => Application::getURL('search/')
- ]);
- }
+ $ResultTemplate = Template\Factory::build('search/result');
+ $ResultTemplate->set('FORM', $form_data);
+ $ResultTemplate->set('SEARCH', $search_data);
+ $ResultTemplate->set('RESULT', [
+ 'LIST' => $posts ?? []
+ ]);
- echo $MainTemplate;
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $ResultTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $Language->text('title_search_results', escapeHTML($search)),
+ 'PERM' => Application::getURL('search/')
+ ]);
}
-#===============================================================================
-# CATCH: Template\Exception
-#===============================================================================
-catch(Template\Exception $Exception) {
- Application::exit($Exception->getMessage());
+else {
+ $SearchTemplate = Template\Factory::build('search/main');
+ $SearchTemplate->set('FORM', $form_data);
+ $SearchTemplate->set('SEARCH', $search_data);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('HTML', $SearchTemplate);
+ $MainTemplate->set('HEAD', [
+ 'NAME' => $Language->text('title_search_request'),
+ 'PERM' => Application::getURL('search/')
+ ]);
}
-?> \ No newline at end of file
+
+echo $MainTemplate;