Fixed active menu item in search results
authorMarcel Werk <burntime@woltlab.com>
Wed, 1 Jan 2014 13:30:22 +0000 (14:30 +0100)
committerMarcel Werk <burntime@woltlab.com>
Wed, 1 Jan 2014 13:30:22 +0000 (14:30 +0100)
wcfsetup/install/files/lib/page/SearchResultPage.class.php
wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php
wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php

index fb362e37b3e7d5ac52fba7c3f0bb1dcd13143fe4..6da6e828f14af95fb0895b31845bbfc681cb3507 100644 (file)
@@ -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);
+                       }
+               }
        }
        
        /**
index 165ad8ec4903b1e4643afff608a0b00b4640c5f8..8b3afde43af2ab1224f989e88d9a611622fc8ac4 100644 (file)
@@ -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;
+       }
 }
index 89b44e15ba1cbc441b0a39e1c1c915d50ef910e1..c2e52d4e47ed7b0a8ec1098f187e7bbf0bc2f360 100644 (file)
@@ -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();
 }