Overhauled acp search
authorMarcel Werk <burntime@woltlab.com>
Tue, 31 May 2016 21:11:13 +0000 (23:11 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 31 May 2016 21:11:13 +0000 (23:11 +0200)
wcfsetup/install/files/acp/js/WCF.ACP.js
wcfsetup/install/files/acp/style/layout.scss
wcfsetup/install/files/acp/templates/pageHeaderSearch.tpl
wcfsetup/install/files/lib/data/acp/search/provider/ACPSearchProviderAction.class.php
wcfsetup/install/files/lib/system/WCFACP.class.php
wcfsetup/install/files/lib/system/search/acp/ACPSearchHandler.class.php
wcfsetup/install/files/style/layout/pageHeader.scss

index baf9f337432e6dcf8b3e8b2c4140099d0c5d4f1f..00dc7a21675bedf3f727c3ec09c38068a43d4156 100644 (file)
@@ -1875,6 +1875,12 @@ WCF.ACP.Category.Collapsible = WCF.Collapsible.SimpleRemote.extend({
  * @see        WCF.Search.Base
  */
 WCF.ACP.Search = WCF.Search.Base.extend({
+       /**
+        * name of the selected search provider
+        * @var string
+        */
+       _providerName: '',
+       
        /**
         * @see WCF.Search.Base.init()
         */
@@ -1886,6 +1892,29 @@ WCF.ACP.Search = WCF.Search.Base.extend({
                $('#pageHeaderSearch > form').on('submit', function(event) {
                        event.preventDefault();
                });
+               
+               var $dropdown = WCF.Dropdown.getDropdownMenu('pageHeaderSearchType');
+               $dropdown.find('a[data-provider-name]').on('click', $.proxy(function(event) {
+                       event.preventDefault();
+                       var $button = $(event.target);
+                       $('.pageHeaderSearchType > .button').text($button.text());
+                       
+                       var $oldProviderName = this._providerName;
+                       this._providerName = ($button.data('providerName') != 'everywhere' ? $button.data('providerName') : '');
+                       
+                       if ($oldProviderName != this._providerName) {
+                               var $searchString = $.trim(this._searchInput.val());
+                               if ($searchString) {
+                                       var $parameters = {
+                                               data: {
+                                                       excludedSearchValues: this._excludedSearchValues,
+                                                       searchString: $searchString
+                                               }
+                                       };
+                                       this._queryServer($parameters);
+                               }
+                       }       
+               }, this));
        },
        
        /**
@@ -1942,6 +1971,15 @@ WCF.ACP.Search = WCF.Search.Base.extend({
                this._super(data);
                
                this._list.addClass('acpSearchDropdown');
+       },
+       
+       /**
+        * @see WCF.Search.Base._getParameters()
+        */
+       _getParameters: function(parameters) {
+               parameters.data.providerName = this._providerName;
+               
+               return parameters;
        }
 });
 
index 7e77ca6027ed2c011d0b5543139052e0612d6537..4820f22d595d876da8191496861952a5cb19aecd 100644 (file)
@@ -57,13 +57,50 @@ $wcfAcpMenuWidth: 150px;
                        order: 3;
                        
                        // force to take up the full available height
-                       position: relative;
-                       top: -10px;
+                       /*position: relative;
+                       top: -10px;*/
+                       
+                       .pageHeaderSearchType > .button {
+                               background-color: rgba(0, 0, 0, .2);
+                               color: $wcfHeaderSearchBoxPlaceholderActive;
+                               align-items: center;
+                               border-radius: 0;
+                               display: flex;
+                               height: 50px;
+                               padding: 6px 28px 6px 10px;
+                               
+                               &::after {
+                                       right: 10px;
+                               }
+                               
+                               &:hover {
+                                       background-color: rgba(0, 0, 0, .4);
+                               }
+                       }
+                       
+                       .pageHeaderSearchInputContainer {
+                               background-color: $wcfHeaderMenuBackgroundActive;
+                               border-radius: 0;
+                               box-shadow: none;
+                               padding: 0;
+                       }
                        
                        .pageHeaderSearchInput {
-                               border-width: 0 !important;
                                height: 50px;
                                width: 300px !important;
+                               
+                               background-color: transparent;
+                               color: $wcfHeaderMenuLinkActive;
+                               padding: 6px 8px;
+                               
+                               &:hover,
+                               &:focus {
+                                       background-color: rgba(0, 0, 0, .1);
+                               }
+                       }
+                       
+                       .pageHeaderSearchInputButton {
+                               display: none;
                        }
                }
                
index 57b4ae66c86b154092985735d95782b7023a1e61..7268bec2af4a51e76df3a2f41e9c5dab99c30b4b 100644 (file)
@@ -1,5 +1,17 @@
 <div id="pageHeaderSearch" class="pageHeaderSearch" data-disable-auto-focus="true">
        <div class="pageHeaderSearchInputContainer">
+               <div id="pageHeaderSearchType" class="pageHeaderSearchType dropdown">
+                       <a href="#" class="button dropdownToggle">{lang}wcf.search.type.everywhere{/lang}</a>
+                       <ul class="dropdownMenu">
+                               <li><a href="#" data-provider-name="everywhere">{lang}wcf.search.type.everywhere{/lang}</a></li>
+                               <li class="dropdownDivider"></li>
+                               
+                               {foreach from=$availableAcpSearchProviders item='availableAcpSearchProvider'}
+                                       <li><a href="#" data-provider-name="{@$availableAcpSearchProvider->providerName}">{lang}wcf.acp.search.provider.{@$availableAcpSearchProvider->providerName}{/lang}</a></li>
+                               {/foreach}
+                       </ul>
+               </div>
+               
                <input type="search" name="q" id="pageHeaderSearchInput" class="pageHeaderSearchInput" placeholder="{lang}wcf.global.search.enterSearchTerm{/lang}" autocomplete="off" required="required" value="" data-toggle="search" />
                
                <button class="pageHeaderSearchInputButton" type="submit">
index 70a40b9dca30f99577a7ead5a19a638d6ec01da6..4fc753141a082b9effea0cbfb8f9a39cacab366f 100644 (file)
@@ -36,7 +36,7 @@ class ACPSearchProviderAction extends AbstractDatabaseObjectAction implements IS
         */
        public function getSearchResultList() {
                $data = [];
-               $results = ACPSearchHandler::getInstance()->search($this->parameters['data']['searchString']);
+               $results = ACPSearchHandler::getInstance()->search($this->parameters['data']['searchString'], 10, (!empty($this->parameters['data']['providerName']) ? $this->parameters['data']['providerName'] : ''));
                
                foreach ($results as $resultList) {
                        $items = [];
index 1c6f9410a2957b3c0c3601dde1d85399f72ebf3a..41ceec09b9ff7525158c2405b539ea600af0396e 100644 (file)
@@ -5,6 +5,7 @@ use wcf\acp\form\MasterPasswordInitForm;
 use wcf\data\menu\Menu;
 use wcf\data\menu\MenuCache;
 use wcf\system\application\ApplicationHandler;
+use wcf\system\cache\builder\ACPSearchProviderCacheBuilder;
 use wcf\system\event\EventHandler;
 use wcf\system\exception\AJAXException;
 use wcf\system\exception\PermissionDeniedException;
@@ -212,7 +213,8 @@ class WCFACP extends WCF {
                $path = RouteHandler::getPath();
                
                self::getTPL()->assign([
-                       'baseHref' => $host . $path
+                       'baseHref' => $host . $path,
+                       'availableAcpSearchProviders' => ACPSearchProviderCacheBuilder::getInstance()->getData()
                ]);
        }
        
index 1e633901b5fb2660babc59b0b7c2f6d25ac08c84..dd6aff20e1051656753f9a5960714826123bef70 100644 (file)
@@ -42,15 +42,19 @@ class ACPSearchHandler extends SingletonFactory {
         * 
         * @param       string          $query
         * @param       integer         $limit
+        * @param       string          $providerName
         * @return      ACPSearchResultList[]
         * @throws      SystemException
         */
-       public function search($query, $limit = 10) {
+       public function search($query, $limit = 10, $providerName = '') {
                $data = [];
-               $maxResultsPerProvider = ceil($limit / 2);
+               if ($providerName) $maxResultsPerProvider = $limit;
+               else $maxResultsPerProvider = ceil($limit / 2);
                $totalResultCount = 0;
                
                foreach ($this->cache as $acpSearchProvider) {
+                       if ($providerName && $acpSearchProvider->providerName != $providerName) continue;
+                       
                        $className = $acpSearchProvider->className;
                        if (!is_subclass_of($className, IACPSearchResultProvider::class)) {
                                throw new ImplementationException($className, IACPSearchResultProvider::class);
index f81ef3089fdefc584015689d3c58fee5a2b27d4f..348566994bba16a974005d0f94dd7f6694cf1f47 100644 (file)
                                > .badgeUpdate {
                                        box-shadow: -1px 2px 3px rgba(0, 0, 0, .3), inset 0 2px 5px rgba(225, 225, 225, .3);
                                        left: 26px;
+                                       padding: 1px 6px;
                                        position: absolute;
-                                       top: 2px;
+                                       top: 4px;
+                                       z-index: 101;
                                }
                        }
                        
        
        .pageHeaderSearchType > .button {
                border-radius: 2px 0 0 2px;
-               min-width: 100px;
-               padding: 4px 22px 4px 7px;
+               min-width: 140px;
+               padding: 4px 24px 4px 8px;
                position: relative;
                text-align: left;
                white-space: nowrap;
                        content: $fa-var-caret-down;
                        font-family: FontAwesome;
                        position: absolute;
-                       right: 7px;
+                       right: 8px;
                }
        }