From: Alexander Ebert Date: Tue, 18 Jul 2017 10:22:40 +0000 (+0200) Subject: Preserve general search scope inside search X-Git-Tag: 3.1.0_Alpha_1~247 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5f43eff70913035fcb3c2e68e490bb9f327b205f;p=GitHub%2FWoltLab%2FWCF.git Preserve general search scope inside search Closes #2328 --- 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 ]); }