use of net.jforum.search.SearchArgs in project jforum2 by rafaelsteil.
the class SearchAction method search.
private void search(SearchOperation operation) {
SearchArgs args = this.buildSearchArgs();
int start = args.startFrom();
int recordsPerPage = SystemGlobals.getIntValue(ConfigKeys.TOPICS_PER_PAGE);
SearchResult searchResult = operation.performSearch(args);
operation.prepareForDisplay();
this.setTemplateName(operation.viewTemplate());
this.context.put("results", operation.filterResults(operation.results()));
this.context.put("categories", ForumRepository.getAllCategories());
this.context.put("searchArgs", args);
this.context.put("fr", new ForumRepository());
this.context.put("pageTitle", I18n.getMessage("ForumBase.search"));
this.context.put("openModeration", "1".equals(this.request.getParameter("openModeration")));
this.context.put("postsPerPage", new Integer(SystemGlobals.getIntValue(ConfigKeys.POSTS_PER_PAGE)));
ViewCommon.contextToPagination(start, searchResult.numberOfHits(), recordsPerPage);
TopicsCommon.topicListingBase();
}
use of net.jforum.search.SearchArgs in project jforum2 by rafaelsteil.
the class SearchAction method buildSearchArgs.
private SearchArgs buildSearchArgs() {
SearchArgs args = new SearchArgs();
args.setKeywords(this.request.getParameter("search_keywords"));
if (this.request.getParameter("search_author") != null) {
args.setAuthor(this.request.getIntParameter("search_author"));
}
args.setOrderBy(this.request.getParameter("sort_by"));
args.setOrderDir(this.request.getParameter("sort_dir"));
args.startFetchingAtRecord(ViewCommon.getStartPage());
args.setMatchType(this.request.getParameter("match_type"));
if (this.request.getObjectParameter("from_date") != null && this.request.getObjectParameter("to_date") != null) {
args.setDateRange((Date) this.request.getObjectParameter("from_date"), (Date) this.request.getObjectParameter("to_date"));
}
if ("all".equals(args.getMatchType())) {
args.matchAllKeywords();
}
if (this.request.getParameter("forum") != null) {
args.setForumId(this.request.getIntParameter("forum"));
}
return args;
}
Aggregations