* @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()
*/
$('#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));
},
/**
this._super(data);
this._list.addClass('acpSearchDropdown');
+ },
+
+ /**
+ * @see WCF.Search.Base._getParameters()
+ */
+ _getParameters: function(parameters) {
+ parameters.data.providerName = this._providerName;
+
+ return parameters;
}
});
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;
}
}
<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">
*/
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 = [];
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;
$path = RouteHandler::getPath();
self::getTPL()->assign([
- 'baseHref' => $host . $path
+ 'baseHref' => $host . $path,
+ 'availableAcpSearchProviders' => ACPSearchProviderCacheBuilder::getInstance()->getData()
]);
}
*
* @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);
> .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;
}
}