📄 addpost.jsp
字号:
<%--
- $Author: 飞鱼
- $Revision: 1.22 $
- $Date: 2003/02/01 09:41:34 $
- http://www.hnedu.net/fiyu
--%>
<%@ page contentType="text/html;charset=utf-8" %>
<%@ page errorPage="fatalerror.jsp"%>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="fiyucore.exception.BadInputException" %>
<%@ page import="fiyucore.util.ParamUtil" %>
<%@ page import="fiyucore.filter.EnableEmotionFilter" %>
<%@ page import="fiyucore.filter.DisableHtmlTagFilter" %>
<%@ page import="fiyucore.filter.EnableHtmlTagFilter" %>
<%@ page import="fiyuforum.fiyuForumGlobal" %>
<%@ page import="fiyuforum.fiyuForumConstant" %>
<%@ page import="fiyuforum.MyUtil" %>
<%@ page import="fiyuforum.db.*" %>
<%
/**
* This page is used to do 2 actions
* 1. add new post ( action=addnew ), either new thread or reply to a thread
* 2. edit a post ( action=update )
*/
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ include file="inc_common.jsp"%>
<%@ include file="inc_js_myvietnamlib.jsp"%>
<%
int parentPostID = 0;
try {
parentPostID = ParamUtil.getParameterInt(request, "parent");
} catch (BadInputException e) {
// do nothing
}
boolean isQuote = ParamUtil.getParameterBoolean(request, "quote");
boolean isPreviewing = ParamUtil.getParameterBoolean(request, "preview");
boolean attachMore = ParamUtil.getParameterBoolean(request, "AttachMore");
boolean addFavoriteThread = ParamUtil.getParameterBoolean(request, "AddFavoriteParentThread");
boolean addWatchThread = ParamUtil.getParameterBoolean(request, "AddWatchParentThread");
String action = (String)request.getAttribute("action");
if (action == null) action = "";
String mode;
String fullmode;
String replyTopic = "";
String postTopic = "";
String postBody = "";
String postIcon = "";
String previewUrl = "";
PostBean postToEdit = null;// use when edit a post
PostBean parentPostBean = null;//use when reply to a post
if (action.equals("addnew")) {
previewUrl = "addpost";
if (parentPostID == 0) {
mode = "发表新话题";
fullmode = mode;
replyTopic = "";
} else {
mode = "回应本篇文章";
// this is the parent of the reply
parentPostBean = (PostBean)request.getAttribute("ParentPostBean");
String REPLY_PREFIX = "Re: ";
String parentPostTopic = parentPostBean.getPostTopic();
if (parentPostTopic.startsWith(REPLY_PREFIX)) {
postTopic = parentPostTopic;
} else {
postTopic = REPLY_PREFIX + parentPostTopic;
}
if (isQuote) {
postBody = "[quote]" + parentPostBean.getPostBody() + "[/quote]\n";
}
replyTopic = parentPostBean.getPostTopic();
fullmode = mode + " : " + replyTopic;
}
} else if (action.equals("update")) {
previewUrl = "editpost";
mode = "修改本篇文章";
postToEdit = (PostBean)request.getAttribute("PostToEdit");
postTopic = postToEdit.getPostTopic();
postBody = postToEdit.getPostBody();
postIcon = postToEdit.getPostIcon();
fullmode = mode + " : " + postTopic;
} else {
throw new BadInputException("Cannot find the action!");
}
if (isPreviewing) {
postTopic = ParamUtil.getParameter(request, "PostTopic", true);
postTopic = DisableHtmlTagFilter.filter(postTopic);// always disable HTML
postBody = ParamUtil.getParameter(request, "message", true);// use message instead of MessageBody
postBody = DisableHtmlTagFilter.filter(postBody);// always disable HTML
postIcon = ParamUtil.getParameter(request, "PostIcon");
postIcon = DisableHtmlTagFilter.filter(postIcon);// always disable HTML
}
%>
<html >
<head>
<title><%=fiyuForumConfig.getWebName()%> - <%=fullmode%></title>
<%@ include file="/fiyuplugin/fiyuforum/meta.jsp"%>
</head>
<link href="<%=contextPath%>/fiyuplugin/fiyuforum/css/style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/fiyuplugin/fiyuforum/js/fiyucode.js"></script>
<script language="JavaScript1.2" src="<%=contextPath%>/fiyuplugin/fiyuforum/js/vietuni.js" type="text/javascript"></script>
<script language="JavaScript" src="<%=contextPath%>/fiyuplugin/fiyuforum/js/fiyunav.js"></script>
<script type="text/javascript">
function SubmitForm() {
if (ValidateForm() == true ) {
document.fiyuform.submitbutton.disabled=true;
document.fiyuform.previewbutton.disabled=true;
document.fiyuform.submit();
}
}
function PreviewForm() {
if (ValidateForm() == true ) {
document.fiyuform.preview.value='true';
document.fiyuform.action='<%=previewUrl%>';
document.fiyuform.submitbutton.disabled=true;
document.fiyuform.previewbutton.disabled=true;
document.fiyuform.submit();
}
}
function ValidateForm() {
if (isBlank(document.fiyuform.PostTopic, "标题:")) return false;
if (isBlank(document.fiyuform.message, "文章内容:")) return false;
return true;
}
</script>
<!-- Language specific string constants used in fiyucode.js -->
<script language="JavaScript">
// DO NOT ADD LINE-BREAKS BETWEEN THE "...." QUOTES!
// MINI-HELP MESSAGES
b_text = "插入粗体文字";
i_text = "插入斜体文字";
u_text = "插入底线文字";
s_text = "插入删除线文字";
size_text = "改变文字的大小";
font_text = "改变字型";
color_text = "改变字的颜色";
url_text = "插入一个超连结";
email_text = "插入一个电子邮件";
img_text = "插入一张图片";
code_text = "插入一段等宽的文字";
php_text = "插入PHP程式码";
list_text = "插入项目符号";
quote_text = "插入引言";
norm_text = "切换到一般编辑模式";
enha_text = "加强模式:允许巢状式的标记语法";
closecurrent_text = "关闭目前所使用的标记语法";
closeall_text = "关闭所有的标记语法";
// ERROR MESSAGES
enhanced_only_text = "<< 只能在加强模式下使用 >>";
no_tags_text = "<< 没有使用标记语法 >>";
already_open_text = "<< 你已经使用了这个标记 >>";
// TEXT FOR POP-UP PROMPTS
tag_prompt = "下面所输入的文字将会被修改成:";
font_formatter_prompt = "下面所输入的文字将会使用所选择的字型";
link_text_prompt = "下面所输入的文字将会变成超连结的显示文字(可不输入)";
link_url_prompt = "请输入完整的URL";
link_email_prompt = "请输入电子邮件地址";
list_type_prompt = "你想使用什麽型式的项目符号? 输入'1'使用数字编号,输入'a'使用英文字母编号,或是不输入则使用符号";
list_item_prompt = "请输入项目符号\n结束请留空白或是按下取消按钮";
</script>
<script language="JavaScript">
function showMoreEmotion() {
document.getElementById("MoreEmotion").style.display = '';
document.getElementById("showlink").style.display = 'none';
document.getElementById("hidelink").style.display = '';
}
function hideMoreEmotion() {
document.getElementById("MoreEmotion").style.display = 'none';
document.getElementById("showlink").style.display = '';
document.getElementById("hidelink").style.display = 'none';
}
function checkPostIcon() {
var iconToCheck = "<%=EnableHtmlTagFilter.filter(postIcon)%>";
var currentIcon;
for (i = 1; i <= 12; i++) {
currentIcon = document.getElementById("PostIcon" + i);
if (currentIcon.value == iconToCheck) {
currentIcon.checked = true;
break;
}
}
}
</script>
<body leftmargin="0" topmargin="0">
<%@ include file="header.jsp"%>
<br/>
<%
CategoryCache categoryCache = CategoryCache.getInstance();
ForumCache forumCache = ForumCache.getInstance();
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 {//edit mode
forumID_int = postToEdit.getForumID();
}
String forumID = String.valueOf(forumID_int);
String forumName = forumCache.getBean(forumID_int).getForumName();
%>
<table width="95%" align="center">
<tr class="nav">
<td><img src="<%=contextPath%>/fiyuplugin/fiyuforum/images/nav.gif"></td>
<td width="100%" nowrap>
<a class="nav" href="index"><%=fiyuForumConfig.getWebName()%></a> »
<a class="nav" href="listforums">列出所有讨论区</a> »
讨论区: <a class="nav" href="listthreads?forum=<%=forumID%>"><%=forumName%></a> »
<%=mode%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -