📄 thread.jsp
字号:
<%
/**
* $RCSfile: thread.jsp,v $
* $Revision: 1.1.1.1 $
* $Date: 2002/09/09 13:50:24 $
*/
%>
<%@ page import="java.util.*,
com.jivesoftware.forum.*,
com.jivesoftware.forum.util.*"
errorPage="error.jsp"
%>
<%@ include file="include/branding/style.jsp" %>
<%@ include file="include/forumSetup.jsp" %>
<% // Get parameters
long forumID = ParamUtils.getLongParameter(request,"forum",-1L);
long threadID = ParamUtils.getLongParameter(request,"thread",-1L);
long messageID = ParamUtils.getLongParameter(request,"message",-1L);
int start = ParamUtils.getIntParameter(request,"start",0);
int range = myEnv.du.getMessageRange(request,response,pageUser);
boolean hilite = ParamUtils.getBooleanParameter(request,"hilite");
boolean redirect = ParamUtils.getBooleanParameter(request,"redirect");
String searchWords = ParamUtils.getParameter(request,"q");
// Load the forum
Forum forum = forumFactory.getForum(forumID);
// The requested thread object
ForumThread thread = forum.getThread(threadID);
// Compute number of topics, messages in this forum, number of pages
int numMessages = thread.getMessageCount();
int numReplies = numMessages-1; // subtract 1 because the root message is counted
int numPages = (int)Math.ceil((double)numMessages/(double)range);
int numMessagesToday = getNewMessageCount(thread);
// Determine if we need to adjust the start index and redirect
Iterator messages = null;
if (redirect && messageID != -1) {
// get an iterator of all messages
messages = thread.messages();
int index = 0;
int messageRange = myEnv.du.getMessageRange(request,response,pageUser);
StringBuffer redirectTo = new StringBuffer("thread.jsp");
redirectTo.append("?forum=").append(forumID);
redirectTo.append("&thread=").append(threadID);
redirectTo.append("&hilite=true");
redirectTo.append("&q=").append(java.net.URLEncoder.encode(searchWords));
while (messages.hasNext()) {
ForumMessage message = (ForumMessage)messages.next();
if (message.getID() != messageID) {
index++;
}
else {
redirectTo.append("&start=");
redirectTo.append(((index/messageRange))*messageRange);
redirectTo.append("#").append(messageID);
break;
}
}
response.sendRedirect(redirectTo.toString());
return;
}
// Get all iterators
ResultFilter filter = ResultFilter.createDefaultMessageFilter();
filter.setStartIndex(start);
filter.setNumResults(range);
// reinitialize the message iterator to show the appropriate range
messages = thread.messages(filter);
Iterator popularThreads = forum.popularThreads();
ForumMessage rootMessage = thread.getRootMessage();
// A user manager lets us get information about users
UserManager userManager = forumFactory.getUserManager();
// indicate whether or not this user is the author of the root message
boolean pageUserIsThreadAuthor =
((pageUser != null) && (!rootMessage.isAnonymous())
&& (pageUser.getID() == rootMessage.getUser().getID()));
// Get a thread iterator (for the next/previous thread feature)
ForumThreadIterator threadIterator = forum.threads();
threadIterator.setIndex(thread);
%>
<% String title = titlePrefix + ": " + thread.getName(); %>
<%@ include file="include/header.jsp" %>
<%@ include file="include/branding/header.jsp" %>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="99%" valign="top">
<span class="header">
<%= rootMessage.getSubject() %>
</span>
<br>
<font size="-1">
<span class="header">
<% if (rootBreadcrumbText != null && rootBreadcrumbLink != null) { %>
<a href="<%= rootBreadcrumbLink %>" class="header"
><%= rootBreadcrumbText %></a>
»
<% } %>
<a href="index.jsp" class="header" title="Go back to the forum listing"
>Forums</a>
»
<a href="forum.jsp?forum=<%= forumID %>" class="header" title="Go back to the topic list"
><%= forum.getName() %></a>
</span>
</font>
<p>
<font size="-1" color="<%= deckTextColor %>">
<b><%= numReplies %></b> <%= ((numReplies==1)?"reply":"replies") %> on
<b><%= numPages %></b> <%= ((numPages==1)?"page":"pages") %>.
<b><%= numMessagesToday %></b> <%= ((numMessagesToday == 1)?"reply":"replies") %> posted today.
<% if (numReplies > 0) {
String recentUsername = null;
ForumMessage recentMessage = getMostRecentMessage(thread);
if (recentMessage != null) {
User recentUser = recentMessage.getUser();
long recentMessageID = recentMessage.getID();
if (!recentMessage.isAnonymous()) {
recentUsername = recentUser.getUsername();
}
// starting page of the recent message:
int recentMessageStart = (numPages-1) * range;
%>
<br>
<a href="thread.jsp?forum=<%= forumID %>&thread=<%= threadID %>&start=<%= recentMessageStart %>#<%= recentMessageID %>"
style="color:<%= deckTextColor %>;" title="Go to the most recent message in this topic">Most recent message</a> posted in this topic by:
<% if (recentMessage.isAnonymous()) { %>
<i>Guest</i>
<% } else { %>
<a href="profile.jsp?user=<%= recentUser.getID() %>" style="color:<%= deckTextColor %>;" title="<%= recentUsername %>'s profile"><%= recentUsername %></a>
<% }
}
}
%>
</font>
<p>
</td>
<td valign="top" width="1%" align="center">
<%@ include file="include/loginbox.jsp" %>
</td>
</tr>
</table>
<table cellpadding="0" cellspacing="2" border="0" width="100%" rows="1" cols="5">
<tr><td width="1%">
<%= printBox("<img src=images/reply_12_12.gif border=0 width=12 height=12 alt=\"Reply to this topic\"> Reply to this topic","post.jsp?forum="+forumID+"&thread="+threadID+"&reply=true",buttonBorderColor,buttonBgColor,buttonBorderColorHover,buttonBgColorHover,"100%") %>
</td>
<td width="1%">
<%= printBox("<img src=images/post_new_12_12.gif border=0 width=12 height=12 alt=\"Post a new topic\"> Post a new topic","post.jsp?forum="+forumID,buttonBorderColor,buttonBgColor,buttonBorderColorHover,buttonBgColorHover,"100%") %>
</td>
<td width="1%">
<%= printBox("<img src=images/search_12_12.gif border=0 width=12 height=12 alt=\"Search this forum\"> Search this forum","search.jsp?forum="+forumID+"&thread="+threadID,buttonBorderColor,buttonBgColor,buttonBorderColorHover,buttonBgColorHover,"100%") %>
</td>
<td width="97%"> </td>
</tr>
</table>
<p>
<table cellpadding="0" cellspacing="2" border="0" width="100%" rows="1" cols="5">
<tr>
<td width="1%">
<% if (threadIterator.hasPrevious()) {
ForumThread prevThread = (ForumThread)threadIterator.previous();
// advance the iterator pointer back to the original index
threadIterator.next();
String subj = prevThread.getRootMessage().getSubject();
%>
<%= printBox("<span title=\""+subj+"\">« Previous Thread</span>","thread.jsp?forum="+forumID+"&thread="+prevThread.getID(),buttonBorderColor,buttonBgColor,buttonBorderColorHover,buttonBgColorHover,"100%") %>
<% } else { %>
<% } %>
</td>
<td width="98%"> </td>
<td width="1%">
<% if (threadIterator.hasNext()) {
ForumThread nextThread = (ForumThread)threadIterator.next();
String subj = nextThread.getRootMessage().getSubject();
%>
<%= printBox("<span title=\""+subj+"\">Next Thread »</span>","thread.jsp?forum="+forumID+"&thread="+nextThread.getID(),buttonBorderColor,buttonBgColor,buttonBorderColorHover,buttonBgColorHover,"100%") %>
<% } else { %>
<% } %>
</td>
</tr>
</table>
<p>
<%-- end the special wrapping table --%>
</td></tr>
</table>
<table bgcolor="<%= tableHeaderBgColor %>" cellpadding="3" cellspacing="0" border="0" width="98%" align="center">
<tr><td width="99%">
<font size="-1" color="<%= tableHeaderTextColor %>">
This topic has <b><%= numReplies %></b> <%= ((numReplies==1)?"reply":"replies") %>
on <b><%= numPages %></b> <%= ((numPages==1)?"page":"pages") %>
<% if (numPages > 1) { %>
[
<% if (start > 0) { %>
<a href="thread.jsp?forum=<%=forumID%>&thread=<%=threadID%>&start=<%= (start-range) %>&msRange=<%= range %>"
title="Previous page" style="color:#ffffff;">«</a>
|
<% }
int currentPage = (start/range)+1;
int lo = currentPage - 3;
if (lo <= 0) {
lo = 1;
}
int hi = currentPage + 5;
while (lo < currentPage) {
%>
<a href="thread.jsp?forum=<%=forumID%>&thread=<%=threadID%>&start=<%= ((lo-1)*range) %>&msRange=<%= range %>"
style="color:#ffffff;"><%= lo %></a>
<% lo++;
}
%>
<b><span style="background-color:#ffffff;color:#000000;"><%= currentPage %></span></b>
<% while ((currentPage < hi) && (currentPage<numPages)) { %>
<a href="thread.jsp?forum=<%=forumID%>&thread=<%=threadID%>&start=<%= ((currentPage)*range) %>&msRange=<%= range %>"
style="color:#ffffff;"><%= currentPage+1 %></a>
<% currentPage++;
}
if (numMessages > (start+range)) {
int numRemaining = (int)(numMessages-(start+range));
%>
|
<a href="thread.jsp?forum=<%=forumID%>&thread=<%=threadID%>&start=<%= (start+range) %>&msRange=<%= range %>"
title="Next page" style="color:#ffffff;">»</a>
<% } %>
]
<% } %>
</font>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -