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

📄 thread.jsp

📁 jive3论坛开源 最新 有版主功能 jive3论坛开源 最新 有版主功能 jive3论坛开源 最新 有版主功能
💻 JSP
字号:
<%/** *	$RCSfile: thread.jsp,v $ *	$Revision: 1.3 $ *	$Date: 2002/09/30 20:12:19 $ */%><%@ page import="java.util.*,                 com.jivesoftware.util.*,                 com.jivesoftware.forum.*,                 com.jivesoftware.forum.util.*"    errorPage="error.jsp"%><%  // Page Description:    //    // This page will display the messages of a specified thread. For    // simplicity's sake all messages in the thread will be displayed in flat    // mode - that is, all messages will appear under each other without any    // indentation:    //    //  Root Message    //  [body]    //     |- Reply 1    //        [body]    //     |- Reply 2    //        [body]    //     |- Reply 3 (is a reply to "Reply 1")    //        [body]    //     |- Reply 4 (is a reply to "Reply 3")    //        [body]    //    // This mode is used because it's easy to illustrate in a skin like this,    // it's a familiar UI for many forum users and it's easy to paginate (more    // on this below).    //    // It is possible to write a thread page that shows all of the messages    // in nested order:    //    //  Root Message    //  [body]    //     |- Reply 1    //        [body]    //       |- Reply 3    //          [body]    //         |- Reply 4    //         [body]    //     |- Reply 2    //        [body]    //    // It's also possible to show just one message per page and make the replies    // all links to their respective message:    //    //  Root Message    //  [body]    //     |- Reply 1 [link]    //         |- Reply 3 [link]    //             |- Reply 4 [link]    //     |- Reply 2 [link]    //    // For more information about threaded views, please see the TreeWalker    // JavaDocs (package com.jivesoftware.forum).%><%  // 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 ID of the incoming thread:    long threadID = ParamUtils.getLongParameter(request,"thread",-1L);    // The starting message index (more below) -- 0 is the default:    int start = ParamUtils.getIntParameter(request,"start",0);    // Load the forum:    Forum forum = forumFactory.getForum(forumID);    // Load the thread:    ForumThread thread = forum.getThread(threadID);    // The number of messages to show per page -- 10 is the default:    int range = 10;%><%@ include file="header.html" %><jsp:include page="breadcrumbs.jsp" flush="true">    <jsp:param name="forum" value="<%= String.valueOf(forum.getID()) %>" />    <jsp:param name="thread" value="<%= String.valueOf(thread.getID()) %>" /></jsp:include><p class="thread-title">Topic: <%= thread.getName() %></p><p>Replies: <%= (thread.getMessageCount()-1) %>,Last Post: <%= dateFormatter.format(thread.getModificationDate()) %></p><%-- Display a link to reply to this topic, a search link and a next/prev topic link --%><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>    <td width="99%">        [<a href="post.jsp?forum=<%= forum.getID() %>&thread=<%= thread.getID() %>&reply=true"          >Reply to this Topic</a>]        &nbsp;        [<a href="search.jsp?forum=<%= forum.getID() %>">Search this Forum</a>]    </td>    <td width="1%" nowrap>        <%  // To show the previous/next links, use a ForumThreadIterator. A            // ForumThreadIterator implements all the methods of            // java.util.Iterator plus a previous(), hasPrevious() and            // setIndex() method so we can get the previous thread            // in the thread list from the current one:            ForumThreadIterator threads = forum.getThreads();            // Set the index point of the iterator to the current thread:            threads.setIndex(thread);            // Get the thread previous to this one:            ForumThread prevThread = null;            if (threads.hasPrevious()) {                prevThread = (ForumThread)threads.previous();            }            // Reset the index point:            threads.setIndex(thread);            // Get the next thread:            ForumThread nextThread = null;            if (threads.hasNext()) {                nextThread = (ForumThread)threads.next();            }        %>        Topics: [        <%  if (prevThread != null) { %>            <a href="thread.jsp?forum=<%= forum.getID() %>&thread=<%= prevThread.getID() %>"             >Previous</a>            |        <%  } %>        <%  if (nextThread != null) { %>            <a href="thread.jsp?forum=<%= forum.getID() %>&thread=<%= nextThread.getID() %>"             >Next</a>        <%  } %>        ]    </td></tr></table><br><%  // Display the thread paginator if there is more than one page in this    // topic. The number of pages is total number of messages in a topic    // divided by the number of messages to display per page (the 'range'    // variable). We also need to add one to the calculation because integer    // division always rounds down:    int numPages = (thread.getMessageCount() / range) + 1;    if (numPages > 1) {%><table class="paginator" cellpadding="2" cellspacing="0" border="0" width="100%"><tr>    <td>        Pages: [        <%  for (int i=0; i<numPages; 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="thread.jsp?forum=<%= forum.getID() %>&thread=<%= thread.getID() %>&start=<%= (i*range) %>"             class="<%= (isCurrent?"current-page":"") %>"             ><%= (i+1) %></a>        <%  } %>        ]    </td></tr></table><%  } %><%-- Message tables --%><%  // Loop through all messages in this thread - this will include the root    // message (the original message of the topic). Similiar to the thread    // list on the forum page we'll pass in a result filter to limit the number    // of messages shown per page as well as the starting message to show.    // We initialize the filter by calling a factory method of ResultFilter -    // createDefaultMessageFilter -- this is different than a default message    // filter because it will order items in ascending creation date order. This    // will produce a list of messages in the order they were created (with the    // newest at the top of the list and the oldest at the bottom).    ResultFilter filter = ResultFilter.createDefaultMessageFilter();    filter.setStartIndex(start);    filter.setNumResults(range);    Iterator messages = thread.getMessages(filter);    // There is never a case where there are no messages in a thread - there will    // always be at least one (the root message).    // Create a message counter, used to keep track of alternating row colors    // (this is the same thing done on the forum page):    int counter = 0;    while (messages.hasNext()) {        ForumMessage message = (ForumMessage)messages.next();        counter ++;        // Determine if this is the root message - we'll need to know this below        // so we can have the ability to show different pieces of information        // for the root message as opposed to other messages. We'll know it's        // the root message when the ID of the current message is equal to the        // message ID of the thread's root message:        boolean isRootMessage = (message.getID() == thread.getRootMessage().getID());        // Get the author of this message:        User author = message.getUser();%>    <table id="message-list" cellpadding="2" cellspacing="2" border="0" width="100%">    <tr class="alt-color-<%= ((counter%2==0)?"2":"1") %>" valign="top">        <td width="1%">            <table cellpadding="0" cellspacing="0" border="0" width="150">            <tr>                <td>                    <%  // Guest:                        if (author == null) {                    %>                        Author: <i>Guest</i>                    <%  }                        // Registered User:                        else {                    %>                        Author:                        <a href="profile.jsp?user=<%= author.getID() %>"                         ><%= author.getUsername() %></a>                        <br><br>                        <%-- Show the number of messages they've posted: --%>                        Posts: <%= forumFactory.getUserMessageCount(author) %>                        <br>                        Registered: <%= shortDateFormatter.format(author.getCreationDate()) %>                    <%  } %>                </td>            </tr>            </table>        </td>        <td width="99%">            <table cellpadding="2" cellspacing="0" border="0" width="100%">            <tr class="message-subject-row">                <td class="message-subject" width="99%">                    Subject: <%= message.getSubject() %>                </td>                <td width="1%">                    [<a href="post.jsp?forum=<%= forum.getID() %>&thread=<%= thread.getID() %>&message=<%= message.getID() %>&reply=true"                     >Reply</a>]                </td>            </tr>            <tr>                <td class="message-body" colspan="2">                    <%= message.getBody() %>                </td>            </tr>            </table>        </td>    </tr>    </table>    <%  // If this is the root message, print out an extra <br> just to add        // a little visual space between the root message and its replies:        if (isRootMessage) {    %>        <br>    <%        }    %><%    } // end of while for message iterator%><%@ include file="footer.html" %>

⌨️ 快捷键说明

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