jive Study

源代码在线查看: search.jsp

软件大小: 5534 K
上传用户: dhgagfdagfdsdgf
关键词: Study jive
下载地址: 免注册下载 普通下载 VIP

相关代码

				
								/**
				 *	$RCSfile: search.jsp,v $
				 *	$Revision: 1.1.1.1 $
				 *	$Date: 2002/09/09 13:50:24 $
				 */
				%>
				
								                 com.jivesoftware.forum.*,
				                 com.jivesoftware.forum.util.*"
				    errorPage="error.jsp"
				%>
				
				
				
				
				
								    static final int DEFAULT_RESULT_COUNT = 10;
				    static final int[] RESULT_COUNTS = { 10, 15, 30 };
				%>
				
								    long forumID = ParamUtils.getLongParameter(request,"forum",-1L);
				    long[] forumIDs = ParamUtils.getLongParameters(request,"forums",-1L);
				    long threadID = ParamUtils.getLongParameter(request,"thread",-1L);
				    long userID = ParamUtils.getLongParameter(request,"user",-1L);
				    String username = ParamUtils.getParameter(request,"user");
				    String queryText = ParamUtils.getParameter(request,"q");
				    long dateLo = ParamUtils.getLongParameter(request,"dateLo",-1L);
				    long dateHi = ParamUtils.getLongParameter(request,"dateHi",-1L);
				    boolean search = ParamUtils.getBooleanParameter(request,"search");
				    boolean options = ParamUtils.getBooleanParameter(request,"options");
				    int start = ParamUtils.getIntParameter(request,"start",0);
				    int range = ParamUtils.getIntParameter(request,"range",DEFAULT_RESULT_COUNT);
				    
				    // Optionally load a forum
				    Forum forum = null;
				    if (forumID != -1L) {
				        forum = forumFactory.getForum(forumID);
				    }
				    
				    // Optionally load a thread
				    ForumThread thread = null;
				    if (threadID != -1L && forum != null) {
				        thread = forum.getThread(threadID);
				    }
				    
				    // Try to load a user (try by userID first, then try username)
				    UserManager userManager = forumFactory.getUserManager();
				    User user = null;
				    try {
				        user = userManager.getUser(userID);
				    }
				    catch (UserNotFoundException unfe) {
				        try {
				            user = userManager.getUser(username);
				        }
				        catch (UserNotFoundException ignored) {}
				    }
				    if (user != null) {
				        userID = user.getID();
				        username = user.getUsername();
				    }
				%>
				
				
				
				
				
				
				
				    Search
				    
				    
				    
				    				    >
				    »
				    
				    				    >Forums
				
				    »
				    				    >
				
				    
				
				
				
				
				
				
				
				
				
				
				
				    
				    
				        
				        				         value="">
				        
				        
				    
				    
				        
				        
				        				        > Options
				        
				        
				    
				    
				    
				        
				        
				        Show
				        
								            String selected = "";
				            if (range == RESULT_COUNTS[i]) {
				                selected = " selected";
				            }
				%>
				        
				        
				        
				        results per page.
				        
				        
				    
				    
				    
				
				
				
				
				
				
				
				
				
				
				
				    
				    
								        Query query = forum.createQuery();
				        query.setQueryString(queryText);
				        // execute the query
				        Iterator results = query.results(start,range);
				        
				        // display results
				        if (!results.hasNext()) {
				%>
				        No results
				        
								        else {
				            int numResults = query.resultCount();
				%>
				         search results for "".
				        Showing  results per page.
				        
				
								        String[] queryWords = StringUtils.toLowerCaseWordArray(queryText);
				        int messageRange = myEnv.du.getMessageRange(request, response, pageUser);
				        while (results.hasNext()) {
				            ForumMessage message = (ForumMessage)results.next();
						    String body = StringUtils.escapeHTMLTags(message.getUnfilteredBody());
						    body = StringUtils.chopAtWord(body, 150) + " ...";
						    body = StringUtils.highlightWords(body, queryWords, "", "");
				            long mID = message.getID();
				            long tID = message.getForumThread().getID();
				            long fID = message.getForumThread().getForum().getID();
				            Forum f = forumFactory.getForum(fID);
				            ForumThread t = f.getThread(tID);
				            int messageCount = t.getMessageCount();
				            int numPages = (int)Math.ceil((double)messageCount/(double)messageRange);
				            int msgStart = (numPages-1) * messageRange;
				            User author = message.getUser();
				            String authorUsername = "Guest";
				            if (author != null) {
				                authorUsername = author.getUsername();
				            }
				%>
				        
				        
				        
				            
				            )
				            
				        
				        
				            
				            				            >
				            
				            
				            Posted on 
				            by 
				            
				            
				        
				        
				        
				        
				        
				        
								%>
				
				
				
									int total = (numResults/range)+1;
					int i = (start/range)+1;
					int lTotal = i-1;
					int rTotal = total-i;
					int lCount, rCount;
					
					if (i < 5) { lCount = lTotal; }
					else { lCount = 5; }
					
					if (i+5 > total) {
						rCount = total-i;
						//now, add as much as we can to other side
						lCount += 5-(total-i) > lTotal-lCount? lTotal-lCount: 5-(total-i);
					}
					else {
						rCount = 5;
						//Add in more to right if possible;
						if (lCount < 5) {
							rCount += 5-lCount > rTotal-rCount? rTotal-rCount: 5-lCount;
						}
					}
				    String href = "search.jsp?forum=" + forumID + "&thread=" + threadID
				        + "&q=" + java.net.URLEncoder.encode(queryText) + "&range=" + range
				        + "&search=true";
				%>
				
				
				
				    
				    
				    = 0 ) { %>
				    « Previous Page
				    
				     
				    
				    
								            boolean onCurrent = !((range*(idx-1))!=start);
				            String color = (onCurrent)?"blue":"red";
				%>
				    
				    
				    
				    				     style="color:#000000;background-color:#cccccc;">
				    
				    				     >
				    
				    
				    
				    
				    
				    
				     
				    				    Next Page »
				    
				    
				    
				
				
				
				
								%>
				
				
				
								
				    Ability to search by all forums
				    Ability to search one forum
				    Ability to search a set of forums
				    Ability to search within a given thread
				    Search within date range
				    Search by a user
				
				-->
				
				
								document.searchForm.q.focus();
				//-->
				
				
				
				
				
				
				    
				    				    >
				    
				
				
				
				
				
							

相关资源