From 231573d1af61ea149435b61a32be5b598fe667de Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Wed, 1 Jan 2014 14:30:22 +0100 Subject: [PATCH] Fixed active menu item in search results --- .../files/lib/page/SearchResultPage.class.php | 9 +++++++++ .../search/AbstractSearchableObjectType.class.php | 13 +++++++++++++ .../system/search/ISearchableObjectType.class.php | 7 +++++++ 3 files changed, 29 insertions(+) diff --git a/wcfsetup/install/files/lib/page/SearchResultPage.class.php b/wcfsetup/install/files/lib/page/SearchResultPage.class.php index fb362e37b3..6da6e828f1 100644 --- a/wcfsetup/install/files/lib/page/SearchResultPage.class.php +++ b/wcfsetup/install/files/lib/page/SearchResultPage.class.php @@ -5,6 +5,7 @@ use wcf\data\search\Search; use wcf\system\event\EventHandler; use wcf\system\exception\IllegalLinkException; use wcf\system\exception\SystemException; +use wcf\system\menu\page\PageMenu; use wcf\system\search\SearchEngine; use wcf\system\WCF; @@ -97,6 +98,14 @@ class SearchResultPage extends MultipleLinkPage { // get messages $this->readMessages(); + + // set active menu item + if (count($this->searchData['selectedObjectTypes']) == 1) { + $objectType = SearchEngine::getInstance()->getObjectType($this->searchData['selectedObjectTypes'][0]); + if (($activeMenuItem = $objectType->getActiveMenuItem())) { + PageMenu::getInstance()->setActiveMenuItem($activeMenuItem); + } + } } /** diff --git a/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php b/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php index 165ad8ec49..8b3afde43a 100644 --- a/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php +++ b/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php @@ -15,6 +15,12 @@ use wcf\system\database\util\PreparedStatementConditionBuilder; * @category Community Framework */ abstract class AbstractSearchableObjectType extends AbstractObjectTypeProcessor implements ISearchableObjectType { + /** + * active main menu item + * @var string + */ + protected $activeMenuItem = ''; + /** * @see \wcf\system\search\ISearchableObjectType::show() */ @@ -89,4 +95,11 @@ abstract class AbstractSearchableObjectType extends AbstractObjectTypeProcessor public function getSpecialSQLQuery(PreparedStatementConditionBuilder &$fulltextCondition = null, PreparedStatementConditionBuilder &$searchIndexConditions = null, PreparedStatementConditionBuilder &$additionalConditions = null, $orderBy = 'time DESC') { return ''; } + + /** + * @see \wcf\system\search\ISearchableObjectType::getActiveMenuItem() + */ + public function getActiveMenuItem() { + return $this->activeMenuItem; + } } diff --git a/wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php b/wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php index 89b44e15ba..c2e52d4e47 100644 --- a/wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php +++ b/wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php @@ -125,4 +125,11 @@ interface ISearchableObjectType { * @return string */ public function getSpecialSQLQuery(PreparedStatementConditionBuilder &$fulltextCondition = null, PreparedStatementConditionBuilder &$searchIndexConditions = null, PreparedStatementConditionBuilder &$additionalConditions = null, $orderBy = 'time DESC'); + + /** + * Returns the name of the active main menu item. + * + * @return string + */ + public function getActiveMenuItem(); } -- 2.20.1