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;
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
论坛系统 javaEE开发的 ssh2 简单的论坛项目 (1578个子文件)
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
.classpath 6KB
css1.css 12KB
fck_contextmenu.css 4KB
fck_contextmenu.css 4KB
fck_contextmenu.css 4KB
admin.css 3KB
fck_editor.css 3KB
fck_editor.css 3KB
fck_editor.css 2KB
fck_dialog.css 2KB
incss.css 2KB
fck_dialog.css 2KB
fck_dialog.css 2KB
archiveslist.css 2KB
friend.css 2KB
fck_internal.css 2KB
read.css 2KB
browser.css 2KB
fck_dialog_common.css 2KB
fck_editorarea.css 1KB
fck_showtableborders_gecko.css 1KB
fck_universalkey.css 1KB
spellerStyle.css 888B
archivespost.css 859B
css2.css 218B
QQWry.Dat 5.74MB
Thumbs.db 239KB
Thumbs.db 174KB
Thumbs.db 9KB
Thumbs.db 9KB
Thumbs.db 4KB
vote.ftl 2KB
voteInPost.ftl 2KB
checkboxlist.ftl 1KB
checkboxlist.ftl 1KB
radiomap.ftl 1KB
radiomap.ftl 1KB
checkboxlist.ftl 1KB
checkboxlist.ftl 1KB
fielderror.ftl 1KB
fielderror.ftl 1KB
archivesPostTopic.ftl 1KB
regValidate.ftl 1KB
regValidate.ftl 1KB
regValidate.ftl 1KB
archivesPostMain.ftl 1KB
mailSendTopic.ftl 968B
report.ftl 895B
mailSend.ftl 876B
forumBuy.ftl 458B
actionmessage.ftl 200B
actionmessage.ftl 200B
actionerror.ftl 190B
actionerror.ftl 190B
5.gif 67KB
5.gif 67KB
63.gif 61KB
63.gif 61KB
22.gif 60KB
22.gif 60KB
74.gif 55KB
74.gif 55KB
81.gif 55KB
81.gif 55KB
83.gif 52KB
83.gif 52KB
49.gif 52KB
49.gif 52KB
32.gif 51KB
32.gif 51KB
69.gif 51KB
69.gif 51KB
27.gif 51KB
27.gif 51KB
8.gif 51KB
8.gif 51KB
84.gif 49KB
84.gif 49KB
11.gif 49KB
11.gif 49KB
13.gif 49KB
共 1578 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16
gen0304
- 粉丝: 2
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页