From 749cca086ee11d039d96f9d96edf5be9ca6e5c39 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 21 May 2013 01:00:09 +0200 Subject: [PATCH] Merged com.woltlab.wcf.search into WCF --- com.woltlab.wcf/objectTypeDefinition.xml | 5 + com.woltlab.wcf/option.xml | 33 ++ com.woltlab.wcf/template/header.tpl | 2 +- com.woltlab.wcf/template/search.tpl | 147 ++++++ com.woltlab.wcf/template/searchArea.tpl | 35 ++ com.woltlab.wcf/template/searchResult.tpl | 60 +++ com.woltlab.wcf/template/searchResultList.tpl | 25 + .../install/files/js/WCF.Search.Message.js | 124 +++++ .../files/js/WCF.Search.Message.min.js | 1 + .../data/search/ISearchResultObject.class.php | 73 +++ .../search/keyword/SearchKeyword.class.php | 25 + .../keyword/SearchKeywordAction.class.php | 58 +++ .../keyword/SearchKeywordEditor.class.php | 20 + .../keyword/SearchKeywordList.class.php | 20 + .../files/lib/form/SearchForm.class.php | 465 ++++++++++++++++++ .../files/lib/page/SearchResultPage.class.php | 181 +++++++ .../cronjob/DailyCleanUpCronjob.class.php | 16 + .../AbstractSearchableObjectType.class.php | 92 ++++ .../search/ISearchableObjectType.class.php | 128 +++++ .../lib/system/search/SearchEngine.class.php | 209 ++++++++ .../search/SearchIndexManager.class.php | 113 +++++ .../search/SearchKeywordManager.class.php | 60 +++ .../search/SearchResultTextParser.class.php | 207 ++++++++ wcfsetup/install/files/style/search.less | 5 + wcfsetup/install/lang/de.xml | 27 + wcfsetup/install/lang/en.xml | 27 + wcfsetup/setup/db/install.sql | 29 ++ 27 files changed, 2186 insertions(+), 1 deletion(-) create mode 100644 com.woltlab.wcf/template/search.tpl create mode 100644 com.woltlab.wcf/template/searchArea.tpl create mode 100644 com.woltlab.wcf/template/searchResult.tpl create mode 100644 com.woltlab.wcf/template/searchResultList.tpl create mode 100644 wcfsetup/install/files/js/WCF.Search.Message.js create mode 100644 wcfsetup/install/files/js/WCF.Search.Message.min.js create mode 100644 wcfsetup/install/files/lib/data/search/ISearchResultObject.class.php create mode 100644 wcfsetup/install/files/lib/data/search/keyword/SearchKeyword.class.php create mode 100644 wcfsetup/install/files/lib/data/search/keyword/SearchKeywordAction.class.php create mode 100644 wcfsetup/install/files/lib/data/search/keyword/SearchKeywordEditor.class.php create mode 100644 wcfsetup/install/files/lib/data/search/keyword/SearchKeywordList.class.php create mode 100644 wcfsetup/install/files/lib/form/SearchForm.class.php create mode 100644 wcfsetup/install/files/lib/page/SearchResultPage.class.php create mode 100644 wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php create mode 100644 wcfsetup/install/files/lib/system/search/ISearchableObjectType.class.php create mode 100644 wcfsetup/install/files/lib/system/search/SearchEngine.class.php create mode 100644 wcfsetup/install/files/lib/system/search/SearchIndexManager.class.php create mode 100644 wcfsetup/install/files/lib/system/search/SearchKeywordManager.class.php create mode 100644 wcfsetup/install/files/lib/system/search/SearchResultTextParser.class.php create mode 100644 wcfsetup/install/files/style/search.less diff --git a/com.woltlab.wcf/objectTypeDefinition.xml b/com.woltlab.wcf/objectTypeDefinition.xml index 2596592e8c..2a5d72bfb4 100644 --- a/com.woltlab.wcf/objectTypeDefinition.xml +++ b/com.woltlab.wcf/objectTypeDefinition.xml @@ -114,5 +114,10 @@ com.woltlab.wcf.tagging.taggableObject wcf\system\tagging\ITaggable + + + com.woltlab.wcf.searchableObjectType + wcf\system\search\ISearchableObjectType + diff --git a/com.woltlab.wcf/option.xml b/com.woltlab.wcf/option.xml index e9a602c187..fe2fd27934 100644 --- a/com.woltlab.wcf/option.xml +++ b/com.woltlab.wcf/option.xml @@ -177,6 +177,10 @@ message + + + message + @@ -1023,6 +1027,35 @@ DESC:wcf.global.sortOrder.descending]]> 255 + + + + + + diff --git a/com.woltlab.wcf/template/header.tpl b/com.woltlab.wcf/template/header.tpl index 63cdb2585a..322f5df1b2 100644 --- a/com.woltlab.wcf/template/header.tpl +++ b/com.woltlab.wcf/template/header.tpl @@ -13,7 +13,7 @@ {/hascontent} - {event name='searchArea'} + {include file='searchArea'} diff --git a/com.woltlab.wcf/template/search.tpl b/com.woltlab.wcf/template/search.tpl new file mode 100644 index 0000000000..86e58b73fb --- /dev/null +++ b/com.woltlab.wcf/template/search.tpl @@ -0,0 +1,147 @@ +{include file='documentHeader'} + + + {lang}wcf.search.title{/lang} - {PAGE_TITLE|language} + + {include file='headInclude'} + + + + +{include file='header'} + +
+

{lang}wcf.search.title{/lang}

+
+ +{include file='userNotice'} + +{if $errorField} +

{lang}wcf.global.form.error{/lang}

+{/if} + +{if $errorMessage|isset} +

{@$errorMessage}

+{/if} + +
+
+
+ {lang}wcf.search.general{/lang} + + +
+
+ + {if $errorField == 'q'} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.search.query.error.{@$errorType}{/lang} + {/if} + + {/if} + + {event name='queryOptions'} + +

{lang}wcf.search.query.description{/lang}

+
+ + +
+
+
+ + + {event name='authorOptions'} +
+
+ +
+
+
+ + + {event name='periodOptions'} +
+
+ +
+
+
+ + + + {event name='displayOptions'} +
+
+ + {event name='generalFields'} + +
+
{lang}wcf.search.type{/lang}
+
+ {foreach from=$objectTypes key=objectTypeName item=objectType} + {if $objectType->isAccessible()} + + {/if} + {/foreach} +
+
+
+ + {event name='fieldsets'} + {if $useCaptcha}{include file='recaptcha'}{/if} + + {foreach from=$objectTypes key=objectTypeName item=objectType} + {if $objectType->isAccessible() && $objectType->getFormTemplateName()} + {assign var='__jsID' value='.'|str_replace:'_':$objectTypeName} +
+ {lang}wcf.search.type.{@$objectTypeName}{/lang} + + {include file=$objectType->getFormTemplateName() application=$objectType->getApplication()} + + +
+ {/if} + {/foreach} +
+ +
+ +
+
+ +{include file='footer'} + + + + + \ No newline at end of file diff --git a/com.woltlab.wcf/template/searchArea.tpl b/com.woltlab.wcf/template/searchArea.tpl new file mode 100644 index 0000000000..8cd2752e44 --- /dev/null +++ b/com.woltlab.wcf/template/searchArea.tpl @@ -0,0 +1,35 @@ +{capture assign='__searchFormLink'}{link controller='Search'}{/link}{/capture} +{capture assign='__searchInputPlaceholder'}{lang}wcf.global.search.enterSearchTerm{/lang}{/capture} +{capture assign='__searchDropdownOptions'}{/capture} +{assign var='__searchHiddenInputFields' value=''} + +{event name='settings'} + + + + + \ No newline at end of file diff --git a/com.woltlab.wcf/template/searchResult.tpl b/com.woltlab.wcf/template/searchResult.tpl new file mode 100644 index 0000000000..aca7cf64c1 --- /dev/null +++ b/com.woltlab.wcf/template/searchResult.tpl @@ -0,0 +1,60 @@ +{include file='documentHeader'} + + + {lang}wcf.search.results{/lang} - {PAGE_TITLE|language} + + {include file='headInclude'} + + + + +{include file='header'} + +
+

{if $query}{lang}wcf.search.results{/lang}{else}{lang}wcf.search.results{/lang}{/if}

+

{lang}wcf.search.results.description{/lang}

+
+ +{include file='userNotice'} + +
+ {assign var=encodedHighlight value=$highlight|urlencode} + {pages print=true assign=pagesLinks controller='SearchResult' id=$searchID link="pageNo=%d&highlight=$encodedHighlight"} + + {hascontent} + + {/hascontent} +
+ +{include file=$resultListTemplateName application=$resultListApplication} + +
+ {@$pagesLinks} + + {hascontent} + + {/hascontent} +
+ +{include file='footer'} + + + \ No newline at end of file diff --git a/com.woltlab.wcf/template/searchResultList.tpl b/com.woltlab.wcf/template/searchResultList.tpl new file mode 100644 index 0000000000..162a53837c --- /dev/null +++ b/com.woltlab.wcf/template/searchResultList.tpl @@ -0,0 +1,25 @@ +
+ +
\ No newline at end of file diff --git a/wcfsetup/install/files/js/WCF.Search.Message.js b/wcfsetup/install/files/js/WCF.Search.Message.js new file mode 100644 index 0000000000..98eac69bf0 --- /dev/null +++ b/wcfsetup/install/files/js/WCF.Search.Message.js @@ -0,0 +1,124 @@ +/** + * Namespace + */ +WCF.Search.Message = {}; + +/** + * Provides quick search for search keywords. + * + * @see WCF.Search.Base + */ +WCF.Search.Message.KeywordList = WCF.Search.Base.extend({ + /** + * @see WCF.Search.Base._className + */ + _className: 'wcf\\data\\search\\keyword\\SearchKeywordAction', + + /** + * dropdown divider + * @var jQuery + */ + _divider: null, + + /** + * true, if submit should be forced + * @var boolean + */ + _forceSubmit: false, + + /** + * @see WCF.Search.Base.init() + */ + init: function(searchInput, callback, excludedSearchValues) { + if (!$.isFunction(callback)) { + console.debug("[WCF.Search.Message.KeywordList] The given callback is invalid, aborting."); + return; + } + + this._callback = callback; + this._excludedSearchValues = []; + if (excludedSearchValues) { + this._excludedSearchValues = excludedSearchValues; + } + this._searchInput = $(searchInput).keyup($.proxy(this._keyUp, this)).keydown($.proxy(function(event) { + // block form submit + if (event.which === 13) { + // ... unless there are no suggestions + if (this._itemCount) { + event.preventDefault(); + } + } + }, this)); + + var $dropdownMenu = this._searchInput.next('.dropdownMenu'); + var $lastDivider = $dropdownMenu.find('li.dropdownDivider').last(); + this._divider = $('