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

📄 forum.jsp

📁 Jive是基于JSP/JAVA技术构架的一个大型BBS论坛系统
💻 JSP
字号:

<%
/**
 *	$RCSfile: forum.jsp,v $
 *	$Revision: 1.1.1.1 $
 *	$Date: 2002/09/09 13:50:22 $
 */
%>

<%@ page import="java.util.*,
                 com.jivesoftware.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);
    int start = ParamUtils.getIntParameter(request,"start",0);
    int range = myEnv.du.getThreadRange(request,response,pageUser);
    boolean today = ParamUtils.getBooleanParameter(request,"today");
    
    // Load the forum
    Forum forum = forumFactory.getForum(forumID);
%>

<%  String title = titlePrefix + ": " + forum.getName(); %>
<%@ include file="include/header.jsp" %>

<%@ include file="include/branding/header.jsp" %>

<%  // Core page logic
    
    // Get the moderation value for threads in this forum
    int modMinThreadVal = forum.getModerationMinThreadValue();
    
    // A result filter for the list of threads and counts
    ResultFilter filter = new ResultFilter();
    filter.setStartIndex(start);
    filter.setNumResults(range);
    filter.setModerationRangeMin(modMinThreadVal);
    
    // Only show new topics from today if requested
    if (today) {
        long yesterday = CacheTimer.currentTime - JiveGlobals.DAY;
        filter.setCreationDateRangeMin(new Date(yesterday));
    }
    
    // More forum properties
    int numTopics = forum.getThreadCount(filter);
    int numMessages = forum.getMessageCount(filter);
    int msgRange = myEnv.du.getMessageRange(request,response,pageUser);
    
    // Number of new messages posted today
    int numMessagesToday = getNewMessageCount(forum);
    int numPages = 0;
    if (numTopics != range) {
        numPages = (int)Math.ceil((double)numTopics/(double)range);
    } else {
        numPages = 1;
    }
    
    // Iterator of threads
    ForumThreadIterator threads = forum.threads(filter);
%>

<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
    <td valign="top" width="99%">
    
    <span class="header">
    <%  if (rootBreadcrumbText != null && rootBreadcrumbLink != null) { %>
    <a href="<%= rootBreadcrumbLink %>" class="header"
    ><%= rootBreadcrumbText %></a>
    &raquo;
    <%  } %>
    <a href="index.jsp" class="header" title="Go back to the forum listing"
    >Forums</a>
    &raquo;
    <a href="forum.jsp?forum=<%= forumID %>" class="header" title="Go back to the top of the topic list"
    ><%= forum.getName() %></a>
    </span>
    <br>
    
    <font size="-1" color="<%= deckTextColor %>">
    <b><%= numMessages %></b> message<%= ((numMessages == 1)?"":"s") %> in
    <b><%= numTopics %></b> topic<%= ((numTopics == 1)?"":"s") %>.
    <b><%= numMessagesToday %></b> new topic<%= ((numMessagesToday == 1)?"":"s") %> posted
        <a href="forum.jsp?forum=<%= forumID %>&today=true" style="color:<%= deckTextColor %>;"
         title="Click to see a list of today's topics">today</a>.
    <p>
    <%  String description = forum.getDescription(); %>
    <i><%= (description!=null)?description:"" %></i>
    </font>

    </td>
    <td valign="top" width="1%" align="center">
    <%@ include file="include/loginbox.jsp" %>
    </td>
</tr>
</table>

<p>

<table cellpadding="0" cellspacing="2" border="0" width="100%" rows="1" cols="5">
<tr><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,buttonBorderColor,buttonBgColor,buttonBorderColorHover,buttonBgColorHover,"100%") %>
    </td>
    <td width="98%">&nbsp;</td>
</tr>
</table>

<p>

<%  if (today) { %>
<table cellpadding="0" cellspacing="2" border="0" width="100%" rows="1" cols="5">
<tr><td align="center">
    Today's New Topics
    </td>
</tr>
</table>
<p>
<%  } %>

<%  String paginatorHTML = myEnv.du.getForumPaginator(forumID, numTopics, numPages, start, range); %>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tr>
    <td>
    <font size="-1" color="<%= paginatorTextColor %>">
    <%= paginatorHTML %>
    </font>
    </td>
</tr>
</table>

<%  if (!threads.hasNext()) { %>
    <center>
    <font size="-1">
    <i>No topics have been posted in this forum.</i>
    </font>
    </center>
<%  } else { %>
<table bgcolor="<%= tableBorderColor %>" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
    <td>
    <table bgcolor="<%= tableBorderColor %>" cellpadding="2" cellspacing="1" border="0" width="100%">
    <tr bgcolor="<%= tableHeaderBgColor %>">
        <td width="1%">&nbsp;</td>
        <td width="96%"><font size="-2" color="<%= tableHeaderTextColor %>"><b>SUBJECT</b></font></td>
        <td width="1%" align="center"><font size="-2" color="<%= tableHeaderTextColor %>"><b>AUTHOR</b></font></td>
        <td width="1%"><font size="-2" color="<%= tableHeaderTextColor %>"><b>REPLIES</b></font></td>
        <td width="1%" nowrap align="center"><img src="images/sort_arrow_down.gif" width="8" height="7" border="0" hspace="4"><font size="-2" color="<%= tableHeaderTextColor %>"><b>LAST POST</b></font></td>
    </tr>
<%  int row = 0;
    while (threads.hasNext()) {
        ForumThread thread = (ForumThread)threads.next();
        long threadID = thread.getID();
        ForumMessage rootMessage = thread.getRootMessage();
        String subject = rootMessage.getSubject();
        User author = rootMessage.getUser();
        String username = "Guest";
        if (!rootMessage.isAnonymous()) {
            username = author.getUsername();
        }
        else {
            String name = rootMessage.getProperty("name");
            String email = rootMessage.getProperty("email");
            String nameAndEmail = myEnv.du.getNameAndEmailDisplay(name, email);
            if (nameAndEmail != null) {
                username = nameAndEmail;
            }
        }
		// Number of topics, messages in this forum
		int numThreadMessages = thread.getMessageCount();
        int numReplies = numThreadMessages - 1;
        // number of messages to show per thread page:
        int messageRange = myEnv.du.getMessageRange(request,response,pageUser);
		// Number of pages of messages in this thread
		int numMsgPages = (int)Math.ceil((double)numThreadMessages/(double)messageRange);
        // Indicate if this thread has been modified since the last time the
        // user visited the page
        boolean isNew = (thread.getModifiedDate().getTime() > lastVisited);
%>
    <tr bgcolor="<%= tableRowColor1 %>">
        <td>
            <font size="-2" color="#ff0000">
        <%  if (isNew) { %>
            <b>&#149;</b>
        <%  } else { %>
            &nbsp;
        <%  } %>
            </font>
        </td>
        <td>
            <font size="-1">
            <a href="thread.jsp?forum=<%= forumID %>&thread=<%= threadID %>" class="forum"><b><%= subject %></b></a>
            </font>
<%          // Print out "Page 1 2..." links. This makes it easy to jump to other
            // parts of the thread.
            if (numMsgPages > 1) {
%>          &nbsp;
		    <font size="-2">
		    [Page: 
<%          for (int i=0; (i<numMsgPages && i<5); i++) { %>
		    <a href="thread.jsp?forum=<%=forumID%>&thread=<%= threadID %>&start=<%=(i*msgRange)%>&msRange=<%=msgRange%>"
		    ><%= i+1 %></a>
<%          }
            if (numMsgPages > 5) {
%>
		    ... <a href="thread.jsp?forum=<%=forumID%>&thread=<%= threadID %>&start=<%=((numMsgPages-1)*msgRange)%>&msRange=<%=msgRange%>"><%= numMsgPages %></a>
<%          } %>
		    ]
		    </font>
<%          } %>
        </td>
        <td nowrap>
            <font size="-1">
            &nbsp;
            <%  if (rootMessage.isAnonymous()) { %>
            <i><%= username %></i>
            <%  } else { %>
            <a href="profile.jsp?user=<%= author.getID() %>"><b><%= username %></b></a>
            <%  } %>
            &nbsp;
            </font>
        </td>
        <td align="center">
            <font size="-1">
            <%= (thread.getMessageCount()-1) %>
            </font>
        </td>
        <td nowrap>
            <font size="-1" color="#333333">
            <%= SkinUtils.formatDate(request,response,pageUser,thread.getModifiedDate()) %>
            </font>
        </td>
    </tr>
<%  } %>
    </table>
    </td>
</tr>
</table>
<%  } %>

<table bgcolor="<%= tableBorderColor %>" cellpadding="1" cellspacing="0" border="0" width="100%">
<tr>
    <td>
<table bgcolor="<%= paginatorTableBgColor %>" cellpadding="3" cellspacing="0" border="0" width="100%">
<tr>
    <td>
    <font size="-1" color="<%= paginatorTextColor %>">
    <%= paginatorHTML %>
    </font>
    </td>
</tr>
</table>
    </td>
</tr>
</table>

<br>

<table cellpadding="0" cellspacing="2" border="0" width="100%">
<tr>
    <td width="1%">
    <%= printBox("<img src=images/back_12_12.gif border=0 width=12 height=12 alt=\"Back to forum list\"> Back to forum list","index.jsp",buttonBorderColor,buttonBgColor,buttonBorderColorHover,buttonBgColorHover,"100%") %>
    </td>
    <td width="99%">&nbsp;</td>
</tr>
</table>

<br>
    
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
    <td align="right">
    <a href="http://www.jivesoftware.com/poweredby/" target="_blank"
    ><img src="images/powered_by_jive.gif" width="100" height="30" alt="Powered by Jive" border="0"></a>
    </td>
</tr>
</table>

<%@ include file="include/branding/footer.jsp" %>

<jsp:include page="include/footer.jsp" flush="true"/>

<%! // Global vars, methods, etc
    
    // Returns a property formatted name and email address string,
    // like <a href="mailto:foo">Foo Bar</a>
    private String myEnv.du.getNameAndEmailDisplay(String name, String email) {
        if (name == null && email == null) {
            return null;
        }
        StringBuffer buf = new StringBuffer(40);
        // name is not null, so try to make a like like:
        // <a href="mailto:foo@bar.com">Foo Bar</a>
        if (name != null) {
            if (email != null) {
                buf.append("<a href=\"mailto:").append(email).append("\">");
                buf.append(name);
                buf.append("</a>");
            }
            else {
                buf.append(name);
            }
        }
        // Else, name is null so just try to use the email:
        // <a href="mailto:foo@bar.com">foo@bar.com</a>
        else if (email != null) {
            String display = email;
            if (email.length() > 15) {
                display = email.substring(0,15) + "..";
            }
            buf.append("<a href=\"mailto:").append(email).append("\">");
            buf.append(display);
            buf.append("</a>");
        }
        
        if (buf.length() == 0) {
            return null;
        }
        else {
            return buf.toString();
        }
    }
%>

⌨️ 快捷键说明

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