package com.laoer.bbscs.web.taglib;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.sql.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.IteratorStatus;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.laoer.bbscs.bean.Board;
import com.laoer.bbscs.bean.Forum;
import com.laoer.bbscs.bean.ForumBuy;
import com.laoer.bbscs.bean.UserInfoSimple;
import com.laoer.bbscs.bean.Vote;
import com.laoer.bbscs.comm.BBSCSUtil;
import com.laoer.bbscs.comm.Constant;
import com.laoer.bbscs.comm.Util;
import com.laoer.bbscs.service.Cache;
import com.laoer.bbscs.service.ForumService;
import com.laoer.bbscs.service.UserService;
import com.laoer.bbscs.service.VoteItemService;
import com.laoer.bbscs.service.VoteService;
import com.laoer.bbscs.service.config.ForumConfig;
import com.laoer.bbscs.service.config.SysConfig;
import com.laoer.bbscs.web.servlet.UserCookie;
import com.laoer.bbscs.web.servlet.UserSession;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.TextUtils;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
public class ForumComponent extends Component {
/**
* Logger for this class
*/
private static final Log logger = LogFactory.getLog(ForumComponent.class);
private PageContext pageContext;
private HttpServletRequest request;
private HttpServletResponse response;
private String forumValue = "";
private String boardValue = "%{board}";
private String itemClass = "font2";
private String inPagesValue = "%{inpages}";
private String currentPageValue = "%{page}";
private String currentActionValue = "%{action}";
private String tagIdValue = "%{tagId}";
private String type = "";
private String totalnumValue = "%{totalnum}";
protected String indexValue = "%{rowstatus}";
private WebApplicationContext wc = null;
public ForumComponent(ValueStack stack, PageContext pageContext, HttpServletRequest request,
HttpServletResponse response) {
super(stack);
this.pageContext = pageContext;
this.request = request;
this.response = response;
this.wc = WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext());
}
@SuppressWarnings("unchecked")
public boolean start(Writer writer) {
boolean result = super.start(writer);
if (forumValue == null) {
forumValue = "top";
} else if (altSyntax()) {
if (forumValue.startsWith("%{") && forumValue.endsWith("}")) {
forumValue = forumValue.substring(2, forumValue.length() - 1);
}
}
if (boardValue == null) {
boardValue = "top";
} else if (altSyntax()) {
if (boardValue.startsWith("%{") && boardValue.endsWith("}")) {
boardValue = boardValue.substring(2, boardValue.length() - 1);
}
}
if (inPagesValue == null) {
inPagesValue = "top";
} else if (altSyntax()) {
if (inPagesValue.startsWith("%{") && inPagesValue.endsWith("}")) {
inPagesValue = inPagesValue.substring(2, inPagesValue.length() - 1);
}
}
if (currentPageValue == null) {
currentPageValue = "top";
} else if (altSyntax()) {
if (currentPageValue.startsWith("%{") && currentPageValue.endsWith("}")) {
currentPageValue = currentPageValue.substring(2, currentPageValue.length() - 1);
}
}
if (currentActionValue == null) {
currentActionValue = "top";
} else if (altSyntax()) {
if (currentActionValue.startsWith("%{") && currentActionValue.endsWith("}")) {
currentActionValue = currentActionValue.substring(2, currentActionValue.length() - 1);
}
}
if (tagIdValue == null) {
tagIdValue = "top";
} else if (altSyntax()) {
if (tagIdValue.startsWith("%{") && tagIdValue.endsWith("}")) {
tagIdValue = tagIdValue.substring(2, tagIdValue.length() - 1);
}
}
if (totalnumValue == null) {
totalnumValue = "top";
} else if (altSyntax()) {
if (totalnumValue.startsWith("%{") && totalnumValue.endsWith("}")) {
totalnumValue = totalnumValue.substring(2, totalnumValue.length() - 1);
}
}
if (indexValue == null) {
indexValue = "top";
} else if (altSyntax()) {
if (indexValue.startsWith("%{") && indexValue.endsWith("}")) {
indexValue = indexValue.substring(2, indexValue.length() - 1);
}
}
// WebApplicationContext wc =
// WebApplicationContextUtils.getWebApplicationContext(this.pageContext
// .getServletContext());
SysConfig sysConfig = (SysConfig) wc.getBean("sysConfig");
ResourceBundleMessageSource messageSource = (ResourceBundleMessageSource) wc.getBean("messageSource");
StringBuffer sb = new StringBuffer();
Object forumObj = this.getStack().findValue(forumValue);
if (forumObj == null) {
return result;
}
Forum f = (Forum) forumObj;
if (type.equalsIgnoreCase("floor")) {
int index = 0;
Object statusObj = this.getStack().findValue(indexValue);
if (statusObj != null) {
index = ((IteratorStatus) statusObj).getIndex();
}
int inpages = 1;
Object inpagesObj = this.getStack().findValue(inPagesValue);
if (inpagesObj != null) {
inpages = ((Integer) inpagesObj).intValue();
}
UserCookie uc = new UserCookie(request, response, sysConfig);
int perNum = this.getUserPostPerNum(uc.getPostPerNum(), sysConfig.getPostPerPage());
int floor = (inpages - 1) * perNum + index;
if (floor == 0) {
sb.append(messageSource.getMessage("forum.floor0", null, request.getLocale()));
} else {
sb.append(messageSource.getMessage("forum.floor1", new String[] { String.valueOf(floor) }, request
.getLocale()));
}
this.write(writer, sb.toString());
return result;
}
if (type.equalsIgnoreCase("face")) {
if (f.getFace() == 0) {
sb.append("<img src=\"");
sb.append(sysConfig.getPostDefFaceImg());
sb.append("\" align=\"absmiddle\"/>");
} else {
sb.append("<img src=\"images/");
sb.append(f.getFace());
sb.append(".gif\" align=\"absmiddle\"/>");
}
this.write(writer, sb.toString());
return result;
}
if (type.equalsIgnoreCase("title")) {
Object boardObj = this.getStack().findValue(this.boardValue);
int boardType = 3;
Board board = (Board) boardObj;
boardType = board.getBoardType();
Object forumCurrentPageObj = this.getStack().findValue(this.currentPageValue);
int fcpage = 1;
if (forumCurrentPageObj != null) {
fcpage = ((Integer) forumCurrentPageObj).intValue();
}
String fcaction = "index";
Object fcactionObj = this.getStack().findValue(this.currentActionValue);
if (fcactionObj != null) {
fcaction = (String) fcactionObj;
}
String tagId = "0";
Object tagIdObj = this.getStack().findValue(this.tagIdValue);
if (tagIdObj != null) {
tagId = (String) tagIdObj;
}
if (boardType == 2) {
if (board.getId().longValue() != f.getBoardID()) {
sb.append("[");
sb.append(f.getBoardName());
sb.append("] ");
}
}
if (!f.getTagID().equals("0") && tagId.equals("0")) {
sb.append("[");
sb.append(f.getTagName());
sb.append("] ");
}
if (f.getPostType() != 0) {
if (f.getPostType() == 1) {
sb.append(mes
没有合适的资源?快使用搜索试试~ 我知道了~
完整java论坛
共2000个文件
gif:644个
class:483个
java:383个
需积分: 12 7 下载量 192 浏览量
2012-11-22
11:49:44
上传
评论
收藏 28.38MB RAR 举报
温馨提示
一个完整的java论坛,基本功能都实现了。直接导入myeclipse 找到src下面的bbscs8.sql创建数据库,修改init.properties里面的数据库连接 用tomcat启动就行了
资源推荐
资源详情
资源评论
收起资源包目录
完整java论坛 (2000个子文件)
class_upload.asp 6KB
class_upload.asp 6KB
commands.asp 5KB
connector.asp 3KB
upload.asp 3KB
io.asp 2KB
basexml.asp 2KB
config.asp 1KB
config.asp 1KB
util.asp 1KB
io.asp 697B
connector.aspx 959B
upload.aspx 930B
connector.cfm 11KB
upload.cfm 6KB
spellchecker.cfm 5KB
config.cfm 3KB
config.cfm 3KB
connector.cgi 3KB
ForumServiceImp.class 42KB
ForumComponent.class 37KB
SysConfig.class 33KB
Post.class 30KB
PostUpdate.class 26KB
AdminUserSearch.class 25KB
PostOpt.class 18KB
Util.class 17KB
Test.class 16KB
BBSCSUtil.class 16KB
NoteAction.class 15KB
Read.class 15KB
VotePost.class 15KB
BoardServiceCacheImp.class 15KB
ForumHibernateDAO.class 15KB
JSONObject.class 14KB
ForumArchivesServiceImp.class 13KB
In.class 13KB
Login.class 13KB
UserServiceImp.class 13KB
AdminBoardSet.class 12KB
Forum.class 12KB
UserLoginInterceptor.class 12KB
Reg.class 12KB
IPSeeker.class 12KB
UserDetailSet.class 11KB
ForumAction.class 11KB
Constant.class 11KB
UserCookieNew.class 11KB
BoardInterceptor.class 10KB
Refine.class 10KB
UserInfo.class 10KB
JSONArray.class 10KB
UserCookie.class 10KB
UserConfigSet.class 9KB
Page.class 9KB
TopicComponent.class 9KB
SubscibeSendTimerTask.class 8KB
UserOnlineInterceptor.class 8KB
AdminBoardMasterSet.class 8KB
ForumManage.class 8KB
Rss.class 8KB
ManageAdvance.class 8KB
AdminPostSet.class 8KB
FriendSet.class 7KB
AdminUgSet.class 7KB
AdminBoardUg.class 7KB
BookMarkAction.class 7KB
AdminRole.class 7KB
NotesHibernateDAO.class 7KB
Board.class 6KB
UserSession.class 6KB
NoteHibernateDAO.class 6KB
UserTopServiceImp.class 6KB
CommendServiceImp.class 6KB
UserInfoFileIOImp.class 6KB
UserInfoInPost.class 6KB
UserFace.class 6KB
UserSidCookie.class 6KB
AdminCookiePassSet.class 6KB
UserOnlineHibernateDAO.class 6KB
AdminDateTimeFormatSet.class 6KB
AdminBoardTag.class 6KB
VoteOpt.class 6KB
AdminAttachSet.class 6KB
UserInfoAction.class 6KB
UserPermissionInterceptor.class 6KB
MoveForum.class 6KB
ForumService.class 6KB
SignSet.class 5KB
CommendHibernateDAO.class 5KB
PostComponent.class 5KB
NoteServiceImp.class 5KB
XML.class 5KB
AdminPermission.class 5KB
UserSessionNew.class 5KB
JSONTokener.class 5KB
AdminPmSet.class 5KB
Subs.class 5KB
UserDetail.class 5KB
FriendServiceImp.class 5KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
chenshengqqq
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功