<%-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --%> <%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %> <%@ page language="java" pageEncoding="UTF-8"%> <%@ page import="org.apache.log4j.*" %> <%@ page import="org.apache.wiki.*" %> <%@ page import="org.apache.wiki.ui.*" %> <%@ page import="java.util.*" %> <%@ page import="java.util.Collection" %> <%@ page import="org.apache.commons.lang.*" %> <%@ page import="java.net.URLEncoder" %> <%@ page import="org.apache.wiki.auth.*" %> <%@ page import="org.apache.wiki.auth.permissions.*" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ page import="javax.servlet.jsp.jstl.fmt.*" %> <%! public void jspInit() { wiki = WikiEngine.getInstance( getServletConfig() ); } Logger log = Logger.getLogger("JSPWikiSearch"); WikiEngine wiki; %> <% /* ********************* actual start ********************* */ /* FIXME: too much hackin on this level -- should better happen in toplevel jsp's */ /* Create wiki context and check for authorization */ WikiContext wikiContext = wiki.createContext( request, WikiContext.FIND ); if(!wikiContext.hasAccess( response )) return; String query = request.getParameter( "query"); if( (query != null) && ( !query.trim().equals("") ) ) { try { Collection list = wiki.findPages( query ); // Filter down to only those that we actually have a permission to view AuthorizationManager mgr = wiki.getAuthorizationManager(); ArrayList items = new ArrayList(); for( Iterator i = list.iterator(); i.hasNext(); ) { SearchResult r = (SearchResult)i.next(); WikiPage p = r.getPage(); PagePermission pp = new PagePermission( p, PagePermission.VIEW_ACTION ); try { if( mgr.checkPermission( wikiContext.getWikiSession(), pp ) ) { items.add( r ); } } catch( Exception e ) { log.error( "Searching for page "+p, e ); } } pageContext.setAttribute( "searchresults", items, PageContext.REQUEST_SCOPE ); } catch( Exception e ) { wikiContext.getWikiSession().addMessage( e.getMessage() ); } } %> <% int startitem = 0; // first item to show int maxitems = 20; // number of items to show in result String parm_start = request.getParameter( "start"); if( parm_start != null ) startitem = Integer.parseInt( parm_start ) ; Collection list = (Collection)pageContext.getAttribute( "searchresults", PageContext.REQUEST_SCOPE ); if( startitem == -1 ) maxitems = list.size(); //show all %>

Google | Wikipedia

<% String[] contexts = searchref.getContexts(); if( (contexts != null) && (contexts.length > 0) ) { %> <% } %> <%-- details --%>
<%= searchref.getScore() %>
<% for (int i = 0; i < contexts.length; i++) { %> <%= (i > 0 ) ? " ... " : "" %> <%= contexts[i] %> <% } %>
${pagination}