/* * (non-Javadoc) * * @see org.sakaiproject.search.tool.SearchBean#getPages() */ public List<SearchPage> getPages() { List<SearchPage> pages = new ArrayList<SearchPage>(); try { SearchList sr = (SearchList) search(); if (sr == null) return pages; int npages = (sr.getFullSize() - 1) / pagesize; int cpage = requestPage - (nlistPages / 2); if (cpage < 0) { cpage = 0; } int lastPage = Math.min(cpage + nlistPages, npages); boolean first = true; if (cpage == lastPage) { return pages; } else { while (cpage <= lastPage) { final String searchURL = "?search=" + URLEncoder.encode(search, "UTF-8") + "&page=" + String.valueOf(cpage) + "&scope=" + this.scope; final String name = String.valueOf(cpage + 1); String cssInd = "1"; if (first) { cssInd = "0"; first = false; } else if (cpage == (lastPage)) { cssInd = "2"; } pages.add( new SearchPage() { public String getName() { return FormattedText.escapeHtml(name, false); } public String getUrl() { return FormattedText.escapeHtml(searchURL, false); } }); cpage++; } } } catch (Exception ex) { log.debug(ex); } return pages; }
/* * (non-Javadoc) * * @see org.sakaiproject.search.tool.SearchBean#getSearchFound() */ public String getSearchFound() { SearchList sr = (SearchList) search(); if (sr == null) return ""; int total = sr.getFullSize(); int start = 0; int end = 0; if (total > 0) { start = sr.getStart(); end = Math.min(start + sr.size(), total); start++; } return MessageFormat.format( Messages.getString("jsp_found_line"), new Object[] { Integer.valueOf(start), Integer.valueOf(end), Integer.valueOf(total), Double.valueOf(timeTaken) }); }
/** * The Total number of results * * @return */ public int getNresults() { return searchResults.getFullSize(); }