From 5f43eff70913035fcb3c2e68e490bb9f327b205f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 18 Jul 2017 12:22:40 +0200 Subject: [PATCH] Preserve general search scope inside search Closes #2328 --- com.woltlab.wcf/templates/pageHeaderSearch.tpl | 2 +- wcfsetup/install/files/lib/form/SearchForm.class.php | 6 +++++- wcfsetup/install/files/lib/page/SearchResultPage.class.php | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/com.woltlab.wcf/templates/pageHeaderSearch.tpl b/com.woltlab.wcf/templates/pageHeaderSearch.tpl index 32f3909c33..a682135211 100644 --- a/com.woltlab.wcf/templates/pageHeaderSearch.tpl +++ b/com.woltlab.wcf/templates/pageHeaderSearch.tpl @@ -70,7 +70,7 @@ {if !OFFLINE || $__wcf->session->getPermission('admin.general.canViewPageDuringOfflineMode')} {/if} \ No newline at end of file diff --git a/wcfsetup/install/files/lib/form/SearchForm.class.php b/wcfsetup/install/files/lib/form/SearchForm.class.php index e963710f20..4c535248ff 100644 --- a/wcfsetup/install/files/lib/form/SearchForm.class.php +++ b/wcfsetup/install/files/lib/form/SearchForm.class.php @@ -388,6 +388,9 @@ class SearchForm extends AbstractCaptchaForm { // init form foreach (SearchEngine::getInstance()->getAvailableObjectTypes() as $objectType) $objectType->show($this); + $searchPreselectObjectType = 'everywhere'; + if (count($this->selectedObjectTypes) === 1) $searchPreselectObjectType = reset($this->selectedObjectTypes); + WCF::getTPL()->assign([ 'query' => $this->query, 'subjectOnly' => $this->subjectOnly, @@ -398,7 +401,8 @@ class SearchForm extends AbstractCaptchaForm { 'sortField' => $this->sortField, 'sortOrder' => $this->sortOrder, 'selectedObjectTypes' => $this->selectedObjectTypes, - 'objectTypes' => SearchEngine::getInstance()->getAvailableObjectTypes() + 'objectTypes' => SearchEngine::getInstance()->getAvailableObjectTypes(), + 'searchPreselectObjectType' => $searchPreselectObjectType ]); } diff --git a/wcfsetup/install/files/lib/page/SearchResultPage.class.php b/wcfsetup/install/files/lib/page/SearchResultPage.class.php index dffc5f931d..d1fa1803e0 100644 --- a/wcfsetup/install/files/lib/page/SearchResultPage.class.php +++ b/wcfsetup/install/files/lib/page/SearchResultPage.class.php @@ -154,6 +154,9 @@ class SearchResultPage extends MultipleLinkPage { public function assignVariables() { parent::assignVariables(); + $searchPreselectObjectType = 'everywhere'; + if (count($this->searchData['selectedObjectTypes']) === 1) $searchPreselectObjectType = reset($this->searchData['selectedObjectTypes']); + WCF::getTPL()->assign([ 'query' => $this->searchData['query'], 'objects' => $this->messages, @@ -166,7 +169,8 @@ class SearchResultPage extends MultipleLinkPage { 'objectTypes' => SearchEngine::getInstance()->getAvailableObjectTypes(), 'resultListTemplateName' => $this->resultListTemplateName, 'resultListApplication' => $this->resultListApplication, - 'application' => ApplicationHandler::getInstance()->getAbbreviation(ApplicationHandler::getInstance()->getActiveApplication()->packageID) + 'application' => ApplicationHandler::getInstance()->getAbbreviation(ApplicationHandler::getInstance()->getActiveApplication()->packageID), + 'searchPreselectObjectType' => $searchPreselectObjectType ]); } -- 2.20.1