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

📄 addpost.jsp

📁 easy to use, easy to setup bulletin board (forum)
💻 JSP
📖 第 1 页 / 共 2 页
字号:
<%
/*
 * Copyright (C) 2002 by MyVietnam.net
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * All copyright notices regarding mvnForum
 * must remain intact in the scripts and in the outputted HTML
 * The "powered by" text/logo with a link back to
 * http://www.mvnForum.com and http://www.MyVietnam.net in the footer of the pages MUST
 * remain visible when the pages are viewed on the internet or intranet.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Support can be obtained from support forums at:
 * http://www.mvnForum.com/mvnforum/index
 *
 * Correspondence and Marketing Questions can be sent to:
 * info@MyVietnam.net
 *
 * @author: Minh Nguyen  minhnn@MyVietnam.net
 * @author: Mai  Nguyen  mai.nh@MyVietnam.net
 */
%>
<%@ page errorPage="/mvnplugin/mvnforum/error.jsp"%>
<%@ page import="net.myvietnam.mvnplugin.mvnforum.db.*" %>
<%@ page import="net.myvietnam.mvncore.util.ParamUtil" %>
<%@ page import="net.myvietnam.mvncore.exception.BadInputException" %>
<%
/**
 * This page is uesd to do 2 actions
 * 1. add new post ( action=addnew ), either new thread or reply to a thread
 * 2. edit post ( action=update )
 */
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%
int parentPostID = 0;
try {
    parentPostID = ParamUtil.getParameterInt(request, "parent");
} catch (BadInputException e) {
    // do nothing
}
String action = (String)request.getAttribute("action");
if (action == null) action = "";

String mode;
String fullmode;
String replyTopic;
String postTopic = "";
String postBody = "";

PostBean postToEdit  = null;// use when edit a post
PostBean parentPostBean = null;//use when reply to a post

if (action.equals("addnew")) {
    if (parentPostID == 0) {
        mode = "Post new thread";
        fullmode = mode;
        replyTopic = "";
    } else {
        mode = "Reply to the post";
        // this is the parent of the reply
        parentPostBean = (PostBean)request.getAttribute("ParentPostBean");
        replyTopic = parentPostBean.getPostTopic();
        fullmode = mode + " : " + replyTopic;
    }
} else if (action.equals("update")) {
    mode = "Edit a post";
    postToEdit = (PostBean)request.getAttribute("PostToEdit");
    String editTopic = postToEdit.getPostTopic();
    fullmode = mode + " : " + editTopic;
    postTopic = editTopic;//du
    postBody = postToEdit.getPostBody();
} else {
    throw new BadInputException("Cannot find the action!");
}
%>
<html>
<head>
    <title><%=fullmode%></title>
<%@ include file="/mvnplugin/mvnforum/meta.jsp"%>
</head>
<link href="<%=request.getContextPath()%>/mvnplugin/mvnforum/css/style.css" rel=stylesheet type=text/css>

<script language="JavaScript" src="<%=request.getContextPath()%>/mvnplugin/mvnforum/js/vbcode.js"></script>
<script language="JavaScript" src="<%=request.getContextPath()%>/mvnplugin/mvnforum/js/vbcode_language.js"></script>
<style type="text/css">
    SELECT {
        FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Verdana,Arial,Helvetica,sans-serif; BACKGROUND-COLOR: #cfcfcf
    }
    TEXTAREA {
        FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: Verdana,Arial,Helvetica,sans-serif; BACKGROUND-COLOR: #cfcfcf
    }
    .bginput {
        FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: Verdana,Arial,Helvetica,sans-serif; BACKGROUND-COLOR: #cfcfcf
    }
</style>

<body leftmargin=0 topmargin=0>
<script language="JavaScript">
function gotoPage(s) {
    if (s != '') top.location.href = s;
    return 1;
}
</script>

<%@ include file="/mvnplugin/mvnforum/user/header.jsp"%>

<%
CategoryCache categoryCache = CategoryCache.getInstance();
ForumCache forumCache = ForumCache.getInstance();
java.util.Collection forumBeans = forumCache.getBeans();

int forumID_int;
if (action.equals("addnew")) {
    if (parentPostID == 0) {// new thread
        forumID_int = ParamUtil.getParameterInt(request, "forum");
    } else {//reply to a post
        forumID_int = parentPostBean.getForumID();
    }
} else {
    forumID_int = postToEdit.getForumID();
}
String forumID = String.valueOf(forumID_int);
String forumName = forumCache.getBean(forumID_int).getForumName();
%>
<p>
<table width="95%" align="center">
<tr class="nav">
    <td><img src="<%=request.getContextPath()%>/mvnplugin/mvnforum/images/nav.gif"></td>
    <td width="100%" nowrap>
    <a class="navLink" href="index">mvnForum</a>&nbsp;&raquo;&nbsp;
    <a class="navLink" href="listforums">List all forums</a>&nbsp;&raquo;&nbsp;
    Forum: <a class="navLink" href="listthreads?forum=<%=forumID%>"><%=forumName%></a>&nbsp;&raquo;&nbsp;
    <%=mode%><%if (parentPostID != 0) {%> : <a class="navLink" href="viewthread?forum=<%=forumID%>&message=<%=parentPostID%>"><%//=replyTopic%></a><%}%></td>
    </td>
</tr>
</table>
<p>

<table width="95%" align="center">
<tr class="messageText"><td>
<form>
Quick go &raquo; <select name="FastGoForum" onChange="gotoPage(this.options[this.selectedIndex].value)">
<%
java.util.Iterator iterator1 = forumBeans.iterator();
int lastCategoryID = -1;
while(iterator1.hasNext()) {
    ForumBean row = (ForumBean)iterator1.next();
    if (row.getCategoryID() != lastCategoryID) {// to print the category
        lastCategoryID = row.getCategoryID();
        CategoryBean categoryBean = categoryCache.getBean(lastCategoryID);
%>
    <option value=""></option>
    <option value="listforums"><%=categoryBean.getCategoryName()%></option>
    <option value="">---------------------------------</option>
<%
    }//if
%>
    <option value="listthreads?forum=<%=row.getForumID()%>" <%if (row.getForumID() == forumID_int) {%>SELECTED<%}%>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=row.getForumName()%></option>
<%
}//while
%>
</select>

⌨️ 快捷键说明

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