
META-INF.resources.open_search.jspf Maven / Gradle / Ivy
<%--
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
--%>
<%
String primarySearch = ParamUtil.getString(request, "primarySearch");
if (Validator.isNotNull(primarySearch)) {
portalPreferences.setValue(SearchPortletKeys.SEARCH, "primary-search", primarySearch);
}
else {
primarySearch = portalPreferences.getValue(SearchPortletKeys.SEARCH, "primary-search", StringPool.BLANK);
}
List openSearchInstances = com.liferay.portal.search.web.internal.util.SearchUtil.getOpenSearchInstances(primarySearch);
List modelResources = new ArrayList();
for (OpenSearch openSearchInstance : openSearchInstances) {
modelResources.add(ResourceActionsUtil.getModelResource(locale, openSearchInstance.getClassName()));
}
%>
<%= StringUtil.merge(modelResources, StringPool.COMMA_AND_SPACE) %>
<%
int totalResults = 0;
for (int i = 0; i < openSearchInstances.size(); i++) {
OpenSearch openSearch = openSearchInstances.get(i);
int delta = 5;
if (Validator.isNotNull(primarySearch) && primarySearch.equals(openSearch.getClassName())) {
delta = ParamUtil.getInteger(request, SearchContainer.DEFAULT_DELTA_PARAM + i, SearchContainer.DEFAULT_DELTA);
}
SearchContainer openSearchSearchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM + i, delta, searchDisplayContext.getPortletURL(), null, LanguageUtil.format(request, "no-results-were-found-that-matched-the-keywords-x", "" + HtmlUtil.escape(searchDisplayContext.getKeywords()) + "", false));
String xml = openSearch.search(request, groupId, themeDisplay.getUserId(), searchDisplayContext.getKeywords(), openSearchSearchContainer.getCur(), openSearchSearchContainer.getDelta(), format);
LinkedHashMap groupParams = new LinkedHashMap();
groupParams.put("active", Boolean.FALSE);
int inactiveGroupsCount = GroupLocalServiceUtil.searchCount(themeDisplay.getCompanyId(), null, null, groupParams);
Tuple tuple = com.liferay.portal.search.web.internal.util.SearchUtil.getElements(xml, openSearch.getClassName(), inactiveGroupsCount);
List resultRows = (List)tuple.getObject(0);
int totalRows = (Integer)tuple.getObject(1);
%>
<%
totalResults = totalResults + totalRows;
%>
<%
boolean filterSearch = false;
if (openSearch instanceof HitsOpenSearchImpl) {
HitsOpenSearchImpl hitsOpenSearchImpl = (HitsOpenSearchImpl)openSearch;
Indexer hitsOpenSearchImplIndexer = hitsOpenSearchImpl.getIndexer();
filterSearch = hitsOpenSearchImplIndexer.isFilterSearch();
}
// When the total is <= to the delta, we know the result is accurate
// since we've filtered the entire result set. Otherwise, we simply
// indicate that there are possibly many more. (� la Google)
%>
<%= ResourceActionsUtil.getModelResource(locale, openSearch.getClassName()) %> (<%= searchContainer.getDelta() %> )
<%= ResourceActionsUtil.getModelResource(locale, openSearch.getClassName()) %> (<%= searchContainer.getTotal() %>)
<%
String entryTitle = element.elementText("title");
String summary = element.elementText("summary");
String entryClassName = element.elementText("entryClassName");
long entryClassPK = GetterUtil.getLong(element.elementText("entryClassPK"));
String[] queryTerms = StringUtil.split(element.elementText("queryTerms"), StringPool.COMMA_AND_SPACE);
%>
<%= HighlightUtil.highlight(HtmlUtil.escape(entryTitle), queryTerms) %>
<%= HighlightUtil.highlight(HtmlUtil.escape(summary), queryTerms) %>
»
<%
}
%>
<%
String pageDescription = LanguageUtil.get(request, "search-results");
if (!modelResources.isEmpty()) {
pageDescription = LanguageUtil.get(request, "searched") + StringPool.SPACE + StringUtil.merge(modelResources, StringPool.COMMA_AND_SPACE);
}
PortalUtil.setPageDescription(pageDescription, request);
%>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy