preview.jsp

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

JSP
308
字号
<%/** *	$RCSfile: preview.jsp,v $ *	$Revision: 1.10 $ *	$Date: 2002/07/02 20:38:02 $ */%><%@ page import="java.net.*,                 java.util.*,                 com.jivesoftware.util.*,                 com.jivesoftware.forum.*,                 com.jivesoftware.forum.util.*"    errorPage="error.jsp"%><%  // Get the forumID and threadID parameters    long forumID = ParamUtils.getLongParameter(request,"forum",-1L);	long threadID = ParamUtils.getLongParameter(request,"thread",-1L);    boolean post = request.getParameter("doPost") != null;    boolean edit = request.getParameter("edit") != null;    // Before any other code, check the "subject" and "body" parameters. If a    // value is found in either, put it in the session put only if we're    // coming from the post.jsp page (the var post will be false in that case)    String subject = ParamUtils.getParameter(request, "subject", true);    String body = ParamUtils.getParameter(request, "body", true);    String name = ParamUtils.getParameter(request, "name", true);    String email = ParamUtils.getParameter(request, "email", true);    if (!post && subject != null) {        subject = new String(StringUtils.decodeHex(subject), "UTF-8");        session.setAttribute("jive.post.subject."+forumID+"."+threadID, subject);    }    if (!post && body != null) {        body = new String(StringUtils.decodeHex(body), "UTF-8");        session.setAttribute("jive.post.body."+forumID+"."+threadID, body);    }    if (!post && name != null) {        name = new String(StringUtils.decodeHex(name), "UTF-8");        session.setAttribute("jive.post.name."+forumID+"."+threadID, name);    }    if (!post && email != null) {        email = new String(StringUtils.decodeHex(email), "UTF-8");        session.setAttribute("jive.post.email."+forumID+"."+threadID, email);    }%><%@ include file="global.jsp" %><%! // Global vars/methods etc    /**     * Method to apply filters to a message object (used to preview a message)     */    private ForumMessage applyFilters(ForumFactory forumFactory, Forum forum,            ForumMessage message)    {        try {            FilterManager filterManager = forumFactory.getFilterManager();            message = filterManager.applyFilters(message);            filterManager = forum.getFilterManager();            message = filterManager.applyFilters(message);        } catch (Exception e) { e.printStackTrace(); }        return message;    }%><%  // Get parameters    long messageID = ParamUtils.getLongParameter(request,"message",-1L);    boolean reply = ParamUtils.getBooleanParameter(request,"reply");    boolean attachment = ParamUtils.getBooleanParameter(request,"attachment");    boolean addWatch = ParamUtils.getBooleanParameter(request,"addWatch");    if (post || edit) {        // Redirect back to the post page        StringBuffer buf = new StringBuffer("post.jsp?");        buf.append("forum=").append(forumID);        buf.append("&thread=").append(threadID);        buf.append("&message=").append(messageID);        buf.append("&fromPreview=true");        buf.append("&reply=").append(reply);        buf.append("&attachment=").append(attachment);        buf.append("&addWatch=").append(addWatch);        if (!isGuest) {            buf.append("&isLoggedIn=true");        }        if (post) {            buf.append("&doPost=true");        }        response.sendRedirect(buf.toString());        return;    }    // Get the value of the subject & body out of the session:    if (subject == null) {        subject = (String)session.getAttribute("jive.post.subject."+forumID+"."+threadID);    }    if (body == null) {        body = (String)session.getAttribute("jive.post.body."+forumID+"."+threadID);    }    if (name == null) {        name = (String)session.getAttribute("jive.post.name."+forumID+"."+threadID);    }    if (email == null) {        email = (String)session.getAttribute("jive.post.email."+forumID+"."+threadID);    }    // Load the forum we're posting in.    Forum forum = forumFactory.getForum(forumID);    // Load a user manager    UserManager userManager = forumFactory.getUserManager();    ForumMessage newMessage = null;    if (isGuest) {        newMessage = forumFactory.createMessage();    }    else {        newMessage = forumFactory.createMessage(pageUser);    }    newMessage.setSubject(subject);    newMessage.setBody(body);    // set message properties if this is a guest user    if (isGuest) {        if (name != null) { newMessage.setProperty("name", name); }        if (email != null) { newMessage.setProperty("email", email); }    }    if (subject != null) {        session.setAttribute("jive.post.subject."+forumID+"."+threadID,subject);    }    if (body != null) {        session.setAttribute("jive.post.body."+forumID+"."+threadID,body);    }    if (name != null) {        session.setAttribute("jive.post.name."+forumID+"."+threadID,name);    }    if (email != null) {        session.setAttribute("jive.post.email."+forumID+"."+threadID,email);    }    newMessage = applyFilters(forumFactory, forum, newMessage);    // Formatter for short dates    SimpleDateFormat shortDateFormatter = new SimpleDateFormat("MMM, yyyy", locale);    List titleDisplay = new ArrayList(1);    titleDisplay.add(forum.getName());    String title = SkinUtils.getLocalizedString("skin.default.preview.title", locale, titleDisplay);%><%@ include file="header.jsp" %><table cellpadding="0" ccellspacing="0" border="0" width="100%"><tr>    <td>    <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"     color="<%= JiveGlobals.getJiveProperty("skin.default.linkColor") %>">    <%  if (reply) { %>        <b><%= SkinUtils.getLocalizedString("skin.default.preview.post_reply",locale) %></b>    <%  } else { %>        <b><%= SkinUtils.getLocalizedString("skin.default.preview.post_new",locale) %></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>    </td></tr></table><p><font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"><%= SkinUtils.getLocalizedString("skin.default.preview.description",locale) %></font><p><script language="JavaScript" type="text/javascript"><!--var checked = false;function checkPost() {    if (!checked) {        checked = true;        return true;    }    return false;}//--></script><form action="preview.jsp" method="post" name="postForm" onsubmit="return checkPost();"><input type="hidden" name="reply" value="<%=reply%>"><input type="hidden" name="forum" value="<%=forumID%>"><input type="hidden" name="thread" value="<%=threadID%>"><input type="hidden" name="message" value="<%=messageID%>"><input type="hidden" name="attachment" value="<%= attachment %>"><input type="hidden" name="addWatch" value="<%= addWatch %>"><%  if (subject != null) { %><input type="hidden" name="subject" value="<%= StringUtils.encodeHex(subject.getBytes("UTF-8")) %>"><%  } %><%  if (body != null) { %><input type="hidden" name="body" value="<%= StringUtils.encodeHex(body.getBytes("UTF-8")) %>"><%  } %><%  if (name != null) { %><input type="hidden" name="name" value="<%= StringUtils.encodeHex(name.getBytes("UTF-8")) %>"><%  } %><%  if (email != null) { %><input type="hidden" name="email" value="<%= StringUtils.encodeHex(email.getBytes("UTF-8")) %>"><%  } %><%	User author = newMessage.getUser(); %><table bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableBorderColor") %>" cellpadding="0" cellspacing="0" border="0" width="100%" align="center"><tr><td>    <table bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableBorderColor") %>"     cellpadding="4" cellspacing="1" border="0" width="100%">    <tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableRowColor2") %>">        <td width="1%" rowspan="2" valign="top">        <table cellpadding="0" cellspacing="0" border="0" width="140">        <tr><td>            <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"             face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"><%	    if (author == null) {            // Check to see if there is an extended property for name & email            // since the gateway feature imports names and emails as extended            // props.            String guestName = newMessage.getProperty("name");            String guestEmail = newMessage.getProperty("email");            String nameAndEmail = getNameAndEmailDisplay(guestName, guestEmail);            if (nameAndEmail != null) {%>            <i><%= SkinUtils.getLocalizedString("skin.default.global.guest",locale) %><%= SkinUtils.getLocalizedString("skin.default.global.colon",locale) %> <%= nameAndEmail %></i><%          } else { %>			<i><%= SkinUtils.getLocalizedString("skin.default.global.guest",locale) %></i><%          }        } else {            String userStatus = author.getProperty("status");%>			<a href="profile.jsp?user=<%= author.getID() %>"             ><b><%= author.getUsername() %></b></a>            </font>            <font size="<%= JiveGlobals.getJiveProperty("skin.default.buttonFontSize") %>"             face="<%= JiveGlobals.getJiveProperty("skin.default.buttonFontFace") %>">            <br><br>            <%= SkinUtils.getLocalizedString("skin.default.global.posts",locale) %><%= SkinUtils.getLocalizedString("skin.default.global.colon",locale) %> <%= SkinUtils.getLocalizedNumber(userManager.userMessageCount(author),locale) %>            <br>            <%  String location = author.getProperty("location");            if (location != null) { %>            <%= SkinUtils.getLocalizedString("skin.default.global.from",locale) %><%= SkinUtils.getLocalizedString("skin.default.global.colon",locale) %> <%= location %><br>            <%  } %>            <%= SkinUtils.getLocalizedString("skin.default.global.registered",locale) %><%= SkinUtils.getLocalizedString("skin.default.global.colon",locale) %> <%= shortDateFormatter.format(author.getCreationDate()) %>            <br><br><%      } %>            </font>            </td>        </tr>        </table>        </td>        <td width="98%">        <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"         face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">        <b><%= newMessage.getSubject() %></b>        </font>		</td>        <td width="1%" nowrap>        <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"         face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">        <%= SkinUtils.getLocalizedString("skin.default.global.posted",locale) %><%= SkinUtils.getLocalizedString("skin.default.global.colon",locale) %> <%= SkinUtils.formatDate(request,pageUser,newMessage.getCreationDate()) %>        </font>        </td>    </tr>    <tr bgcolor="<%= JiveGlobals.getJiveProperty("skin.default.tableRowColor2") %>">        <td width="99%" colspan="2" valign="top">        <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"         face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">        <%= newMessage.getBody() %>        </font>		<p>        </td>    </tr>    </table></td></tr></table><br><input type="submit" value="<%= SkinUtils.getLocalizedString("skin.default.global.go_back_or_edit",locale) %>" name="edit"><input type="submit" value="<%= SkinUtils.getLocalizedString("skin.default.global.post_message",locale) %>" name="doPost"></form><br><%@ include file="footer.jsp" %>

⌨️ 快捷键说明

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