diff options
author | Thomas Lange <code@nerdmind.de> | 2021-06-17 22:00:39 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-06-17 22:00:39 +0200 |
commit | 5555624546ea48d6327700f32b80848e0662dc90 (patch) | |
tree | 47d61fb756a6cb008aaf33586d292fcfe43da2a1 /core/include/search/main.php | |
parent | 91d8a28c664afa5378735bcd0efe068dd74d589f (diff) | |
parent | 0a2614cb69fc732c2115ef2f0c356f39f602d311 (diff) | |
download | blog-optimization.tar.gz blog-optimization.tar.xz blog-optimization.zip |
Merge branch 'master' into 'optimization'optimization
Diffstat (limited to 'core/include/search/main.php')
-rw-r--r-- | core/include/search/main.php | 78 |
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; |