threadmode1.jsp

来自「Jive是基于JSP/JAVA技术构架的一个大型BBS论坛系统,这是Jive论坛」· JSP 代码 · 共 785 行 · 第 1/3 页

JSP
785
字号
<%/** *	$RCSfile: threadMode1.jsp,v $ *	$Revision: 1.15 $ *	$Date: 2002/08/10 18:07:46 $ */%><%@ page import="java.net.*,                 java.util.*,                 com.jivesoftware.util.*,                 com.jivesoftware.forum.*,                 com.jivesoftware.forum.util.*,                 java.text.DecimalFormat"    errorPage="error.jsp"%><%! // Global vars, methods, etc..        // Formatter for file attachment sizes.    static final DecimalFormat sizeFormatter = new DecimalFormat("#,##0.0");%><%@ include file="global.jsp" %><%  // Put the request URI and query string in the session as an attribute.    // This is done so the error.jsp and auth.jsp pages can figure out what    // page sent it an error and redirect appropriately.    setRedirectURL(request);%><%  //    // This page displays the messages in the thread in a "threaded" view.    //    // 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 = getMessageRange(request,response,pageUser);    String searchWords = ParamUtils.getParameter(request,"q");    boolean unlock = ParamUtils.getBooleanParameter(request,"unlock");    boolean unarchive = ParamUtils.getBooleanParameter(request,"unarchive");    // "nav" indicates if we show the next/prev links    boolean nav = false;    // Only show nav if the thread starting point and thread range are passed in:    int threadStart = ParamUtils.getIntParameter(request,"tstart",-1);    int threadRange = ParamUtils.getIntParameter(request,"trange",-1);    int nextStart = threadStart;    int prevStart = threadStart;    if (threadStart > -1 && threadRange > -1) {        nav = true;        // If the starting point is not zero, back it up one (because the last thread        // is likely the one before it)        if (threadStart > 0) {            threadStart --;        }        // Always increment the range by one since we don't know        // if the last thread on the thread list page was clicked:        threadRange++;        // Adjust the start of the next & prev links        nextStart ++;        prevStart --;        if (prevStart < 0) {            prevStart = 0;        }    }        boolean hilite = (searchWords != null);    // Unescape search words:    if (searchWords != null) {        searchWords = new String(StringUtils.decodeHex(searchWords));    }	    // Load the forum    Forum forum = forumFactory.getForum(forumID);    // The requested thread object    ForumThread thread = forum.getThread(threadID);	    // Indicates if the pageUser is a moderator of this forum:    boolean isModerator = isModerator(forumFactory, forum);    // unlock or unarchive the thread if requested by the moderator:    if (unlock) {        if (!isModerator) {            throw new UnauthorizedException("You do not have permission to unlock this topic");        }        thread.deleteProperty("locked");        response.sendRedirect("thread.jsp?forum="+forumID+"&thread="+threadID+"&tstart="+threadStart+"&trange="+threadRange);        return;    }    if (unarchive) {        if (!isModerator) {            throw new UnauthorizedException("You do not have permission to unarchive this topic");        }        thread.deleteProperty("archived");        response.sendRedirect("thread.jsp?forum="+forumID+"&thread="+threadID+"&tstart="+threadStart+"&trange="+threadRange);        return;    }    // 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    	// TreeWalker lets us get an iterator of nested messages	TreeWalker treeWalker = thread.treeWalker();	// Root message of the thread	ForumMessage rootMessage = thread.getRootMessage();    // Message iterator	Iterator messages = treeWalker.recursiveChildren(rootMessage);        // A user manager lets us get information about users    UserManager userManager = forumFactory.getUserManager();        // Get a thread iterator (for the next/previous thread feature):    ForumThreadIterator threadIterator = null;    ForumThread prevThread = null;    ForumThread nextThread = null;    // Only get a next/prev iterator if it is turned on. The only case where    // it should be turned off is when coming from the post page.    if (nav) {        threadIterator = forum.threads();        // Set its index to this thread:        threadIterator.setIndex(thread);        // Get the previous and next threads:        if (threadIterator.hasPrevious()) {            prevThread = (ForumThread)threadIterator.previous();            // advance the iterator pointer back to the original index            threadIterator.next();         }        if (threadIterator.hasNext()) {            nextThread = (ForumThread)threadIterator.next();        }    }        // Get a watch manager to manage watches on this page.    WatchManager watchManager = null;    // Indicates if this thread is watched    boolean isWatchedThread = false;    if (!isGuest) {        watchManager = forumFactory.getWatchManager();        isWatchedThread = watchManager.isWatchedThread(pageUser, thread, WatchManager.NORMAL_WATCH);    }    // Formatter for short dates    SimpleDateFormat shortDateFormatter = new SimpleDateFormat("MMM, yyyy", locale);        // Check if this topic is archived:    boolean isArchived = "true".equals(thread.getProperty("archived"));    // Check if this topic is locked:    boolean isLocked = "true".equals(thread.getProperty("locked"));        // Get the minimum moderation value for this forum since we need to manually    // mark each message as moderated or not    int minModValue = forum.getModerationMinMessageValue();    List titleDisplay = new ArrayList(1);    titleDisplay.add(thread.getName());        String title = SkinUtils.getLocalizedString("skin.default.thread.title", locale, titleDisplay);%><%@ include file="header.jsp" %><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>    <td width="99%" valign="top">         <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.linkColor") %>">    <b><%= rootMessage.getSubject() %></b>    </font>    <br>        <%-- Breadcrumbs --%>            <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.linkColor") %>">    <b>    <a href="<%= JiveGlobals.getJiveProperty("skin.default.homeURL") %>"    ><%= SkinUtils.getLocalizedString("skin.default.global.home",locale) %></a>    &raquo;    <a href="index.jsp" title="<%= SkinUtils.getLocalizedString("skin.default.global.go_back_to_forum_list",locale) %>"    ><%= SkinUtils.getLocalizedString("skin.default.global.forums",locale) %></a>    &raquo;    <a href="forum.jsp?forum=<%= forumID %>" title="<%= SkinUtils.getLocalizedString("skin.default.global.go_back_to_topic_list",locale) %>"    ><%= forum.getName() %></a>    </b>    </font>        <p>        <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"     face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">    <%= SkinUtils.getLocalizedString("skin.default.global.replies",locale) %><%= SkinUtils.getLocalizedString("skin.default.global.colon",locale) %>    <b><%= SkinUtils.getLocalizedNumber(numReplies,locale) %></b>    &nbsp;    <%  // Print out the most recently reply in this thread (if there are replies):        if (numReplies > 0) {            ForumMessage lastPost = null;            User author = null;            if (!"false".equals(JiveGlobals.getJiveProperty("skin.default.showLastPostLink"))) {                lastPost = SkinUtils.getLastPost(thread);            if (lastPost != null) {                    author = lastPost.getUser();                }    %>    <a href="thread.jsp?forum=<%= lastPost.getForumThread().getForum().getID() %>&thread=<%= lastPost.getForumThread().getID() %>&message=<%= lastPost.getID() %>#latest"     title=""    ><img src="images/go_to.gif" width="13" height="10" border="0" hspace="2"></a>    <%= SkinUtils.getLocalizedString("skin.default.thread.most_recent_reply_posted_by",locale) %><%= SkinUtils.getLocalizedString("skin.default.global.colon",locale) %>    <%  if (author == null) { %>        <i><%= SkinUtils.getLocalizedString("skin.default.global.guest", locale) %></i>    <%  } else { %>        <%= author.getUsername() %>    <%  } %>    (<%= SkinUtils.formatDate(request,pageUser,lastPost.getCreationDate()) %>)    <%      } // end if lastPost != null        } // end if numReplies > 0    %>    </font>        </td>    <td valign="top" width="1%" align="center">    <%@ include file="loginbox.jsp" %>    </td></tr></table><%  if (isGuest) { %><p><%  } %><%  if (isWatchedThread) { %><table bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableBorderColor") %>"     cellpadding="1" cellspacing="0" border="0" width="400"><tr><td><table bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableBorderColor") %>"     cellpadding="3" cellspacing="0" border="0" width="100%">    <tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.prefsHeaderBgColor") %>">        <td valign="top" width="1%" nowrap><img src="images/watch.gif" width="17" height="17" border="0"></td>        <td width="99%">            <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"             face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">            <%-- Watching this Topic --%>            <b><%= SkinUtils.getLocalizedString("skin.default.thread.watching_this_topic",locale) %></b>            <br>            <%-- watch description --%>    <%= SkinUtils.getLocalizedString("skin.default.thread.watch_description",locale) %>            </font>            <br>            <table cellpadding="2" cellspacing="0" border="0">            <tr><td><img src="images/watch_remove.gif" width="17" height="14" border="0"></td>                <td>                    <%-- Stop Watching Topic --%>                    <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"

⌨️ 快捷键说明

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