📄 forumcontent.jsp
字号:
<%
/**
* $RCSfile: forumContent.jsp,v $
* $Revision: 1.4 $
* $Date: 2000/12/18 02:06:21 $
*/
%>
<%@ page import="java.util.*,
java.text.SimpleDateFormat,
com.coolservlets.forum.*,
com.coolservlets.forum.util.*,
com.coolservlets.forum.util.admin.*"
errorPage="error.jsp"
%>
<jsp:useBean id="adminBean" scope="session"
class="com.coolservlets.forum.util.admin.AdminBean"/>
<%! //////////////////////////
// global vars
// date formatter for message dates
private final SimpleDateFormat dateFormatter
= new SimpleDateFormat( "yyyy.MM.dd h:mm a" );
private final static int RANGE = 15;
private final static int START = 0;
%>
<% ////////////////////////////////
// Jive authorization check
// check the bean for the existence of an authorization token.
// Its existence proves the user is valid. If it's not found, redirect
// to the login page
Authorization authToken = adminBean.getAuthToken();
if( authToken == null ) {
response.sendRedirect( "/mainctrl/bbs/admin" );
return;
}
%>
<% ////////////////////
// Security check
// make sure the user is authorized to administer users:
ForumFactory forumFactory = ForumFactory.getInstance(authToken);
ForumPermissions permissions = forumFactory.getPermissions(authToken);
boolean isSystemAdmin = permissions.get(ForumPermissions.SYSTEM_ADMIN);
boolean isUserAdmin = permissions.get(ForumPermissions.FORUM_ADMIN);
// redirect to error page if we're not a forum admin or a system admin
if( !isUserAdmin && !isSystemAdmin ) {
request.setAttribute("message","您没有权限管理论坛!");
response.sendRedirect("error.jsp");
return;
}
%>
<% ////////////////////
// get parameters
int forumID = ParamUtils.getIntParameter(request,"forum",-1);
boolean deleteThread = ParamUtils.getBooleanParameter(request,"deleteThread");
int threadID = ParamUtils.getIntParameter(request,"thread",-1);
int start = ParamUtils.getIntParameter(request,"start",START);
int range = ParamUtils.getIntParameter(request,"range",RANGE);
%>
<% //////////////////////////////////
// global error variables
String errorMessage = "";
boolean noForumSpecified = (forumID < 0);
boolean noThreadSpecified = (threadID < 0);
%>
<% ////////////////////
// make a profile manager
ProfileManager manager = forumFactory.getProfileManager();
%>
<% /////////////////////
// delete a thread
if( deleteThread ) {
Forum tempForum = forumFactory.getForum(forumID);
ForumThread tempThread = tempForum.getThread(threadID);
tempForum.deleteThread(tempThread);
response.sendRedirect("forumContent.jsp?forum="+forumID);
return;
}
%>
<html>
<head>
<title></title>
<link rel="stylesheet" href="style/global.css">
</head>
<body background="images/shadowBack.gif" bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<% ///////////////////////
// pageTitleInfo variable (used by include/pageTitle.jsp)
String[] pageTitleInfo = { "论坛 : 管理论坛内容" };
%>
<% ///////////////////
// pageTitle include
%><%@ include file="include/pageTitle.jsp" %>
<p>
<% //////////////////////
// show the name of the forum we're working with (if one was selected)
Forum currentForum = null;
if( !noForumSpecified ) {
try {
currentForum = forumFactory.getForum(forumID);
%>
您正在管理论坛: <b><%= currentForum.getName() %></b>
<p>
论题数量:<%= currentForum.getThreadCount() %>,帖子数量:<%= currentForum.getMessageCount() %>
<% }
catch( ForumNotFoundException fnfe ) {
%>
<span class="errorText">没有找到此论坛。</span>
<% }
catch( UnauthorizedException ue ) {
%>
<span class="errorText">您没有权限管理此论坛。</span>
<% }
}
%>
<p>
<% ///////////////////////
// show a pulldown box of forums where this user can manage content:
Iterator forumIterator = forumFactory.forums();
if( !forumIterator.hasNext() ) {
%>
没有论坛。
<% }
%>
<p>
<form>
<select size="1" name="" onchange="location.href='forumContent.jsp?forum='+this.options[this.selectedIndex].value;">
<option value="-1">管理下列论坛内容
<option value="-1">---------------------
<% while( forumIterator.hasNext() ) {
Forum forum = (Forum)forumIterator.next();
%>
<option value="<%= forum.getID() %>"><%= forum.getName() %>
<% }
%>
</select>
</form>
<% if( noForumSpecified ) {
out.flush();
return;
}
%>
<p>
<%-- thread table --%>
<% int numThreads = currentForum.getThreadCount(); %>
<%-- table for paging --%>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<td width="50%">
<% if( start > 0 ) { %>
<a href="forumContent.jsp?forum=<%=forumID%>&start=<%= (start-range) %>&range=<%= range %>" class="toolbar"
>前<%= range %>个论题</a>
<% } %>
</td>
<td width="50%" align="right">
<% if( numThreads > (start+range) ) { %>
<% int numRemaining = (numThreads-(start+range)); %>
<a href="forumContent.jsp?forum=<%=forumID%>&start=<%= (start+range) %>&range=<%= range %>" class="toolbar"
>后<%= (numRemaining>range)?range:numRemaining %>个论题</a>
<% } %>
</td>
</table>
<%-- /table for paging --%><p>
<table bgcolor="#cccccc" cellpadding=0 cellspacing=0 border=0 width="100%">
<td>
<table bgcolor="#cccccc" cellpadding=3 cellspacing=1 border=0 width="100%">
<tr bgcolor="#dddddd">
<td class="forumListHeader" width="1%" nowrap bgcolor="#cccccc"><b>删除?</b></td>
<td class="forumListHeader" width="95%">主题</td>
<td class="forumListHeader" width="1%" nowrap>回复</td>
<td class="forumListHeader" width="1%" nowrap>作者</td>
<td class="forumListHeader" width="1%" nowrap>日期</td>
</tr>
<% /////////////////////
// get an iterator of threads
Iterator threadIterator = currentForum.threads(start,range);
if( !threadIterator.hasNext() ) {
%>
<tr bgcolor="#ffffff">
<td colspan="5" align="center" class="forumListCell">
<br><i>此论坛中没有帖子。</i><br><br>
</td>
</tr>
<% }
while( threadIterator.hasNext() ) {
ForumThread currentThread = (ForumThread)threadIterator.next();
int currentThreadID = currentThread.getID();
ForumMessage rootMessage = currentThread.getRootMessage();
boolean rootMsgIsAnonymous = rootMessage.isAnonymous();
User rootMessageUser = rootMessage.getUser();
String username = rootMessageUser.getUsername();
String name = rootMessageUser.getName();
String email = rootMessageUser.getEmail();
%>
<tr>
<form>
<td width="1%" class="forumListCell" align="center">
<input type="radio"
onclick="if(confirm('您确定要删除此论题和它所有的帖子吗?')){location.href='forumContent.jsp?forum=<%=forumID%>&deleteThread=true&thread=<%= currentThreadID %>';}">
</td>
<td class="forumListCell" width="96%">
<a href="threadContent.jsp?forum=<%=forumID%>&thread=<%=currentThreadID%>"><%= currentThread.getName() %></a>
</td>
<td class="forumListCell" width="1%" nowrap align="center">
<%= currentThread.getMessageCount()-1 %>
</td>
<td class="forumListCell" width="1%" nowrap align="center">
<% if( rootMsgIsAnonymous ) { %>
<i>匿名者</i>
<% } else { %>
<a href="mailto:<%=email%>" title="<%= name %>"><%= username %></a>
<% } %>
</td>
<td class="forumListDateCell" width="1%" nowrap>
<%= dateFormatter.format(rootMessage.getCreationDate()) %>
</td>
</form>
</tr>
<% }
%>
</table>
</td>
</table>
<%-- /thread table --%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -