⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forum.jsp

📁 jive的源码
💻 JSP
字号:
<%/** *	$RCSfile: forum.jsp,v $ *	$Revision: 1.6 $ *	$Date: 2002/10/28 02:35:23 $ */%><%@ page import="java.util.*,                 com.jivesoftware.util.*,                 com.jivesoftware.forum.*,                 com.jivesoftware.forum.util.*,                 com.jivesoftware.base.*"    errorPage="error.jsp"%><%  // Page Description:    //    // This page displays content in a forum, specifically the list of topics    // and some brief details about each topic. Some details of the forum -    // number of topics and messages and description - will also be displayed.%><%  // global.jsp - see description on index.jsp %><%@ include file="global.jsp" %><%  // Get parameters:    // The ID of the incoming forum:    long forumID = ParamUtils.getLongParameter(request,"forum",-1L);    // The starting thread index (more below) -- 0 is the default:    int start = ParamUtils.getIntParameter(request,"start",0);    // Load the forum:    Forum forum = forumFactory.getForum(forumID);    // The number of topics to show per page    int range = 20;%><%@ include file="header.html" %><jsp:include page="breadcrumbs.jsp" flush="true">    <jsp:param name="forum" value="<%= String.valueOf(forum.getID()) %>" /></jsp:include><%-- Print out the number of topics, messages and the forum description: --%><p>Topics: <%= forum.getThreadCount() %>, Messages: <%= forum.getMessageCount() %>,Last Post: <%= dateFormatter.format(forum.getModificationDate()) %></p><p><i><%= forum.getDescription() %></i></p><%-- Display a link to post a new topic and search in this forum: --%><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>    <td width="99%">        [<a href="post.jsp?forum=<%= forum.getID() %>">Post New Topic</a>]        &nbsp;        [<a href="search.jsp?forum=<%= forum.getID() %>">Search this Forum</a>]    </td>    <td width="1%" nowrap>        <%  // Display the forum paginator if there is more than one page in this            // forum. The number of pages is total number of topics in a forum            // divided by the number of topics to display per page (the 'range'            // variable. We also need to add one to the calculation because integer            // division always rounds down:            int numPages = (forum.getThreadCount() / range) + 1;            if (numPages > 1) {        %>        <table class="paginator" cellpadding="2" cellspacing="0" border="0" width="100%">        <tr>            <td nowrap>                Pages: [                <%  // Loop over all the pages or to a max a 10 pages:                    for (int i=0; (i<numPages&&i<10); i++) {                        // Add a little bit of logic to determine if this page link                        // is the current page - this will allow us to specially                        // designate it via CSS:                        boolean isCurrent = (start == (i*range));                %>                    <a href="forum.jsp?forum=<%= forum.getID() %>&start=<%= (i*range) %>"                     class="<%= (isCurrent?"current-page":"") %>"                     ><%= (i+1) %></a>                <%  } %>                ]            </td>        </tr>        </table>        <%  } %>    </td></tr></table><br><%  // Get a list of topics in the forum. The threads() method of a forum    // returns an iterator of all threads in the forum. Since there might be    // a large number of threads in the system, we'll pass in a ResultFilter    // object to the threads() method - this allows us to specify a starting    // index in the list of topics and the number of topics to retrieve. We    // could also do more advanced things like sort the list of topics by    // different fields and different orders. By default, topics are returned    // in descending modification date. The effect of this is that topics with    // the newest content will be bumped to the top of the topic list. For    // more information, please read the ResultFilter JavaDocs.    ResultFilter filter = new ResultFilter();    filter.setStartIndex(start);    filter.setNumResults(range);    Iterator threads = forum.getThreads(filter);%><%  // Iterate through the list of topics. First, check if there are no topics    // in the system and if so, print out an error message:    if (!threads.hasNext()) {%>        <i>There are no topics in this forum.</i><%  }    else {%>    <table id="thread-list" cellpadding="3" cellspacing="2" border="0" width="100%">    <tr>        <th colspan="2">Subject</th>        <th>Author</th>        <th>Replies</th>        <th>Last Post</th>    </tr>    <%  // Loop through the threads - keep a counter variable so we can        // keep track of alternating rows:        int counter = 0;        while (threads.hasNext()) {            ForumThread thread = (ForumThread)threads.next();            counter ++;            // Get the user of the root message of the thread - this is the            // user who posted the message:            User author = thread.getRootMessage().getUser();            // Note, below 'thread.getName()' is called - this message is a            // shortcut for 'thread.getRootMessage().getSubect()'.            // Also, note below that the number of replies in a thread is            // the total number of messages in the thread minus one - this is            // because the root message is counted by the getMessageCount method.            // Figure out if this topic was posted after the last time the page            // user visited the site. Do this by checking the creation date of            // the thread compared to the date of the last visit (the last            // visited time is in a global variable called 'lastVisited' and            // is initialized in the global.jsp page):            boolean isNew = lastVisited.getTime() < thread.getCreationDate().getTime();    %>        <tr class="alt-color-<%= ((counter%2==0)?"2":"1") %>">            <td align="center" width="1%" nowrap>                <%  // Display a bullet with different CSS tags to indicate                    // new/old content. The CSS should customize the colors                    // so a new piece of content is visually distinguished from                    // an old one:                    if (isNew) {                %>                    <span class="new-content">&#149;</span>                <%  } else { %>                    <span class="old-content">&#149;</span>                <%  } %>            </td>            <td width="96%">                <%-- Display the thread name (as a link to that thread) --%>                <a href="thread.jsp?forum=<%= forum.getID() %>&thread=<%= thread.getID() %>"                 ><%= thread.getName() %></a>            </td>            <td align="center" width="1%"nowrap>                <%  // Print 'Guest' if the author was anonymous, otherwise print                    // the user's username and a link to their profile page:                    if (author == null) {                %>                    <i>Guest</i>                <%  } else { %>                    <a href="profile.jsp?user=<%= author.getID() %>"                     ><%= author.getUsername() %></a>                <%  } %>            </td>            <td align="center" width="1%" nowrap>                <%= (thread.getMessageCount()-1) %>            </td>            <td width="1%" nowrap>                <%= dateFormatter.format(thread.getModificationDate()) %>            </td>        </tr>    <%        } // end of while loop    %>    </table><%    } // end of else%><%@ include file="footer.html" %>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -