?? topic.jsp
字號:
<%@ page contentType="text/html;charset=gbk" errorPage="error.jsp"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="com.hongshee.ejforum.util.PageUtils"%>
<%@ page import="com.hongshee.ejforum.common.ForumSetting"%>
<%@ page import="com.hongshee.ejforum.common.IConstants"%>
<%@ page import="com.hongshee.ejforum.common.CacheManager"%>
<%@ page import="com.hongshee.ejforum.data.UserDAO.UserInfo"%>
<%@ page import="com.hongshee.ejforum.data.BoardDAO.BoardVO"%>
<%@ page import="com.hongshee.ejforum.data.SectionDAO.SectionVO"%>
<%@ page import="com.hongshee.ejforum.data.TopicDAO"%>
<%@ page import="com.hongshee.ejforum.data.ReplyDAO"%>
<%@ page import="com.hongshee.ejforum.data.TopicDAO.TopicVO"%>
<%@ page import="com.hongshee.ejforum.data.ReplyDAO.PostVO"%>
<%@ page import="com.hongshee.ejforum.data.GroupDAO.GroupVO"%>
<%@ page import="com.hongshee.ejforum.data.AttachDAO.AttachVO"%>
<%
UserInfo userinfo = PageUtils.getSessionUser(request);
ForumSetting setting = ForumSetting.getInstance();
int pageRows = setting.getInt(ForumSetting.DISPLAY, "postsPerPage");
int pageNo = 1;
String topicID = request.getParameter("tid");
String replyID = request.getParameter("rid");
if (replyID != null && replyID.length() > 0)
{
pageNo = ReplyDAO.getInstance().getPageNo(topicID, replyID, pageRows, userinfo);
}
else
{
String strPageNo = request.getParameter("page");
pageNo = PageUtils.getPageNo(strPageNo);
}
TopicVO aTopic = TopicDAO.getInstance().getTopic(request, topicID, pageNo, pageRows, userinfo);
if (aTopic == null)
{
request.setAttribute("errorMsg", "此主題不存在或已經被刪除");
request.getRequestDispatcher("/error.jsp").forward(request, response);
return;
}
String sectionID = aTopic.sectionID;
String boardID = aTopic.boardID;
CacheManager cache = CacheManager.getInstance();
SectionVO aSection = cache.getSection(sectionID);
BoardVO aBoard = cache.getBoard(aSection, boardID);
GroupVO userGroup = PageUtils.getGroupVO(userinfo, aSection, aBoard);
if (!PageUtils.isPermitted(aBoard,userGroup,IConstants.PERMIT_VISIT_FORUM)
|| aBoard.allowGroups.indexOf(userGroup.groupID) < 0)
{
if (userinfo == null) // Guest
{
String fromPath = request.getRequestURI();
String queryStr = request.getQueryString();
if (queryStr != null)
fromPath = fromPath + "?" + queryStr;
request.setAttribute("fromPath", fromPath);
request.getRequestDispatcher("/login.jsp").forward(request, response);
return;
}
else
{
request.setAttribute("errorMsg", "很抱歉,您缺乏足夠的訪問權限");
request.getRequestDispatcher("/error.jsp").forward(request, response);
return;
}
}
boolean isModerator = false;
if (userGroup.groupID == 'A' || userGroup.groupID == 'M' || userGroup.groupID == 'S')
isModerator = true;
if (aTopic.state=='R' && !isModerator)
{
request.setAttribute("errorMsg", "此主題已經被刪除");
request.getRequestDispatcher("/error.jsp").forward(request, response);
return;
}
String ctxPath = request.getContextPath();
String serverName = request.getServerName();
if (!ctxPath.equals("/"))
serverName = serverName + ctxPath;
String forumStyle = PageUtils.getForumStyle(request, response, aBoard);
String forumName = setting.getForumName();
String title = PageUtils.getTitle(forumName);
String[] menus = PageUtils.getHeaderMenu(request, userinfo);
int maxReplies = setting.getInt(ForumSetting.FUNCTIONS, "maxReplies");
StringBuilder sbuf = new StringBuilder();
sbuf.append("./forum-").append(sectionID).append("-").append(boardID).append("-1.html");
String forumUrl = response.encodeURL(sbuf.toString());
String homeUrl = response.encodeURL("./index.jsp");
sbuf.setLength(0);
sbuf.append("./topic-").append(topicID).append("-1.html");
String topicUrl = response.encodeURL(sbuf.toString());
sbuf.setLength(0);
sbuf.append("./post.jsp?sid=").append(sectionID).append("&fid=").append(boardID);
String postUrl = response.encodeURL(sbuf.toString());
sbuf.setLength(0);
sbuf.append("report.jsp?sid=").append(sectionID).append("&fid=").append(boardID)
.append("&tid=").append(topicID).append("&page=").append(pageNo);
String reportUrl = response.encodeURL(sbuf.toString());
ArrayList sections = cache.getSections();
String showSectionLink = setting.getString(ForumSetting.DISPLAY, "showSectionLink");
String sectionLink = null;
if (showSectionLink.equalsIgnoreCase("yes"))
{
sbuf.setLength(0);
sbuf.append(" » <A href=\"./index.jsp?sid=").append(sectionID)
.append("\">").append(aSection.sectionName).append("</A>");
sectionLink = response.encodeURL(sbuf.toString());
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE><%= aTopic.title %> - <%= aBoard.boardName %> - <%= title %></TITLE>
<%= PageUtils.getMetas(title, aBoard) %>
<LINK href="styles/<%= forumStyle %>/ejforum.css" type=text/css rel=stylesheet>
</HEAD>
<BODY onkeydown="if(event.keyCode==27) return false;">
<SCRIPT src="js/common.js" type=text/javascript></SCRIPT>
<SCRIPT src="js/topic.js" type=text/javascript></SCRIPT>
<DIV class=wrap>
<DIV id=header>
<%= PageUtils.getHeader(request, title) %>
<%= PageUtils.getHeadAdBanner(request, aBoard) %></DIV>
<%= menus[0] %>
<DIV id=foruminfo>
<DIV id=nav><A href="<%= homeUrl %>"><%= forumName %></A><%= sectionLink==null?"":sectionLink %> »
<A href="<%= forumUrl %>"><%= aBoard.boardName %></A> » <%= aTopic.title %></DIV>
<DIV id=headsearch>
<SCRIPT type=text/javascript>
function doSearch() {
if(trim($('frmsearch').q.value)=='')
{
alert('請輸入搜索關鍵字');
return false;
}
frmsearch.submit();
}
</SCRIPT>
<FORM id="frmsearch" name="frmsearch"
action="http://www.google.cn/search" onsubmit="doSearch(); return false;" method=get target="google_window">
<INPUT type=hidden value="GB2312" name=ie>
<INPUT type=hidden value="GB2312" name=oe>
<INPUT type=hidden value=zh-CN name=hl>
<INPUT type=hidden value="<%= serverName %>" name=sitesearch>
<div style="padding-left:20px"><div onclick="javascript:window.open('http://www.google.cn/')"
style="cursor:pointer;float:left;width:70px;height:23px;background: url(images/google.png)! important;background: none; filter:
progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/google.png',sizingMethod='scale')"></div></div>
<INPUT id=q maxLength=255 size=12 name=q class="search">
<a href="#" onclick="doSearch(); return false;">
<img src="styles/<%= forumStyle %>/images/search.gif" border="0" alt="站內搜索" align="absmiddle"/></a>
</FORM></DIV></DIV>
<DIV id=ad_text></DIV>
<DIV class=pages_btns>
<div class="pages"><a href="<%= forumUrl %>" class="next"> ‹‹ 返回主題列表</a></div>
<%
if (aTopic.pageHTML != null)
{
%>
<%= aTopic.pageHTML %>
<%
}
%>
<SPAN class=postbtn id="newtopic" onmouseover="$('newtopic').id = 'newtopictmp';this.id = 'newtopic';showMenu(this.id);">
<A href="<%= postUrl %>"><IMG src="styles/<%= forumStyle %>/images/newtopic.gif" border=0></A></SPAN>
<SPAN class=replybtn><A href="javascript:replyTopic();">
<IMG alt="發表回復" src="styles/<%= forumStyle %>/images/reply.gif" border=0></A></SPAN></DIV>
<UL class="popmenu_popup newtopicmenu" id="newtopic_menu" style="display: none">
<LI><a href="<%= postUrl %>">發新話題</a></LI>
<LI class="reward"><a href="<%= postUrl %>&act=reward">發布懸賞</a></LI>
</UL>
<%
PostVO aPost = null;
String userID = null;
String nickname = null;
String avatar = null;
String avatarPath = ctxPath + "/upload/avatar/";
GroupVO aGroup = null;
boolean isManager = false;
boolean isAuthor = false;
String moderators = PageUtils.getModerators(aSection, aBoard);
String showAvatar = setting.getString(ForumSetting.DISPLAY, "showAvatar");
String spaceURL = response.encodeURL("uspace.jsp?uid=");
StringBuilder userPostIDs = null;
int seqno = 0;
int startSeq = (aTopic.pageNo - 1) * pageRows;
if (aTopic.pageNo > 1) startSeq++;
for (int i=0; i<aTopic.postList.size(); i++)
{
aPost = (PostVO)aTopic.postList.get(i);
if (aPost.isHidePost == 'T')
{
userID = "";
nickname = "匿名";
}
else
{
userID = aPost.u_userID;
nickname = (aPost.u_nickname==null || aPost.u_nickname.length()==0) ? userID : aPost.u_nickname;
}
aGroup = PageUtils.getGroupVO(userID, aPost.u_groupID, aPost.u_credits, moderators);
avatar = aPost.u_avatar;
if (avatar == null || avatar.length() == 0)
avatar = "sample/unknown.gif";
else if (aGroup.rights.indexOf(IConstants.PERMIT_UPLOAD_AVATAR) < 0 && !avatar.startsWith("sample/"))
avatar = "sample/unknown.gif";
int count1 = -1;
int count2 = aGroup.stars;
if (aGroup.stars > 5)
{
count1 = aGroup.stars / 5;
count2 = aGroup.stars % 5;
}
seqno = startSeq + i;
%>
<DIV class="mainbox viewtopic">
<%
if (i == 0) {
%>
<SPAN class=headactions>
<A class=notabs href="./member/my_addfavor.jsp?tid=<%= topicID %>&fid=<%= boardID %>">收藏</A> </SPAN>
<H1><%= aTopic.title %> <% if (aTopic.isDigest=='T') out.write(" ~ 精華"); %></H1>
<%
}
%>
<TABLE id="rid<%= aPost.replyID %>" cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD class=postauthor rowspan="2">
<CITE><A href="<%= spaceURL %><%= userID %>" target=_blank><%= nickname.length()==0?"游客":nickname %></A></CITE>
<%
if (showAvatar.equals("yes")) {
int maxAvatarSize = setting.getInt(ForumSetting.MISC, "maxAvatarPixels");
%>
<DIV class=avatar>
<IMG src="<%= avatarPath %><%= avatar %>" border=0 onload="resizeImage(this, <%= maxAvatarSize %>);"></DIV>
<%
}
%>
<P><EM><%= aGroup.groupName %></EM>
<% for (int j=0; j<count1; j++) { %><IMG alt="Rank: <%= aGroup.stars %>"
src="images/star_5.gif" align="absmiddle" border="0"><% } for (int j=0; j<count2; j++) { %><IMG
alt="Rank: <%= aGroup.stars %>" src="images/star_1.gif" align="absmiddle" border="0"><% } %>
</P>
<DL class="profile">
<DT>帖子 </DT><DD><%= aPost.u_posts %> </DD>
<DT>積分 </DT><DD><%= aPost.u_credits %> </DD>
</DL>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -