001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018:
019: package org.apache.roller.ui.rendering.pagers;
020:
021: import java.util.Map;
022: import java.util.ResourceBundle;
023: import org.apache.roller.pojos.WebsiteData;
024: import org.apache.roller.ui.rendering.util.WeblogSearchRequest;
025: import org.apache.roller.util.URLUtilities;
026:
027: /**
028: * Pager for navigating through search results.
029: */
030: public class SearchResultsPager implements WeblogEntriesPager {
031:
032: private Map entries = null;
033:
034: private WebsiteData weblog = null;
035: private String locale = null;
036: private String query = null;
037: private String category = null;
038: private int page = 0;
039: private boolean moreResults = false;
040:
041: private static ResourceBundle bundle = ResourceBundle
042: .getBundle("ApplicationResources");
043:
044: public SearchResultsPager() {
045: }
046:
047: public SearchResultsPager(WeblogSearchRequest searchRequest,
048: Map entries, boolean more) {
049:
050: // store search results
051: this .entries = entries;
052:
053: // data from search request
054: this .weblog = searchRequest.getWeblog();
055: this .query = searchRequest.getQuery();
056: this .category = searchRequest.getWeblogCategoryName();
057: this .locale = searchRequest.getLocale();
058: this .page = searchRequest.getPageNum();
059:
060: // does this pager have more results?
061: this .moreResults = more;
062: }
063:
064: public Map getEntries() {
065: return entries;
066: }
067:
068: public String getHomeLink() {
069: return URLUtilities.getWeblogURL(weblog, locale, false);
070: }
071:
072: public String getHomeName() {
073: return bundle.getString("searchPager.home");
074: }
075:
076: public String getNextLink() {
077: if (moreResults) {
078: return URLUtilities.getWeblogSearchURL(weblog, locale,
079: query, category, page + 1, false);
080: }
081: return null;
082: }
083:
084: public String getNextName() {
085: if (getNextLink() != null) {
086: return bundle.getString("searchPager.next");
087: }
088: return null;
089: }
090:
091: public String getPrevLink() {
092: if (page > 0) {
093: return URLUtilities.getWeblogSearchURL(weblog, locale,
094: query, category, page - 1, false);
095: }
096: return null;
097: }
098:
099: public String getPrevName() {
100: if (getPrevLink() != null) {
101: return bundle.getString("searchPager.prev");
102: }
103: return null;
104: }
105:
106: public String getNextCollectionLink() {
107: return null;
108: }
109:
110: public String getNextCollectionName() {
111: return null;
112: }
113:
114: public String getPrevCollectionLink() {
115: return null;
116: }
117:
118: public String getPrevCollectionName() {
119: return null;
120: }
121:
122: }
|