對天乙社區bbscs8實現的詳細分析二十二

進入com.laoer.bbscs.web.action包中的ForumAction.java中的excute:
public String execute() { //重寫方法
if (this.getAction().equalsIgnoreCase("index")) {
   return this.index();
} else if (this.getAction().equalsIgnoreCase("hot")) {
   return this.hot();
} else if (this.getAction().equalsIgnoreCase("commend")) {
   return this.commend();
} else if (this.getAction().equalsIgnoreCase("history")) {
   return this.history();
} else {
   return this.index();
}
}
接下來,我們看看index()方法:
public String index() {
if (StringUtils.isNotBlank(this.getViewMode())) {//veiwMode一開始是無
   if (this.getUserCookie().getForumViewMode() != this.getViewModeToInt(this.getViewMode())) {
    this.getUserCookie().addForumViewMode(this.getViewModeToInt(this.getViewMode()));
   } else {
    setViewModeValue(this.getUserCookie().getForumViewMode());
   }
} else {
   setViewModeValue(this.getUserCookie().getForumViewMode());//0
}

int isHidden = 0;
if (this.getUserSession().isHaveSpecialPermission(Constant.SPERMISSION_CAN_SEE_HIDDEN_BOARD)) { // 如果用戶有查看隱藏版區的權限
   isHidden = -1;
}

this.setUrlRewriteValue();//設置urlRewrite
if (this.getBoard().getBoardType() == 1) {
   this.setBoardList(this.getBoardService().findBoardsByParentID(this.getBid(), 1, isHidden,
     Constant.FIND_BOARDS_BY_ORDER));
   return "forumBoard";//顯示版區而已
} else {
   this.setBids(String.valueOf(this.getBid()));//設置bid
   this.setBoardSelectValues(isHidden);//構造一些optionString對象,由new OptionsString(String.valueOf(b.getId()), BBSCSUtil.getBoardPrefixLine(b.getLevel(), "-")+ b.getBoardName())組成
/**
public static String getBoardPrefixLine(int level, String txt) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < level * 2; i++) {
   sb.append(txt);
}
return sb.toString();
}
*/
   Pages pages = new Pages();
   pages.setPage(this.getPage());
   pages.setPerPageNum(this.getUserForumPerNum(this.getUserCookie().getForumPerNum(), this.getSysConfig()
     .getForumPrePage()));//後者是默認值
   if (this.getTotal() > 0) {//在BaseAction中沒有設置其值
    pages.setTotalNum(this.getTotal());
   }
   // pages.setPerPageNum(1);
   if (Constant.USE_URL_REWRITE) {
    pages.setUseUrlRewrite(Constant.USE_URL_REWRITE);
    pages.setFileName("forum-" + this.getAction() + "-" + this.getBid() + "-0-{page}-{total}.html");

   } else {
    pages.setFileName(this.getBasePath()
      + BBSCSUtil.getActionMappingURLWithoutPrefix("forum?action=" + this.getAction() + "&bid="
        + this.getBid()));
   }
   if (this.getTagId().equals("0")) {//沒有tagid
    if (this.getUserCookie().getForumViewMode() == 1) {
     this.setPageList(this.getForumService().findForumsAll(this.getBid(), pages));
    } else if (this.getUserCookie().getForumViewMode() == 2) {
     this.setPageList(this.getForumService().findForumsMainLastRe(this.getBid(), pages));
    } else {
     this.setPageList(this.getForumService().findForumsMainWWW(this.getBid(), pages));
    }
   } else {//有的話
    if (this.getUserCookie().getForumViewMode() == 1) {
     this.setPageList(this.getForumService().findForumsAll(this.getBid(), this.getTagId(), pages));
    } else if (this.getUserCookie().getForumViewMode() == 2) {
     this
       .setPageList(this.getForumService().findForumsMainLastRe(this.getBid(), this.getTagId(),
         pages));
    } else {
     this.setPageList(this.getForumService().findForumsMainWWW(this.getBid(), this.getTagId(), pages));
    }
   }
   this.setParentBoards();//設置ParentBoard!
/**
private void setParentBoards() {
this.setParentBoards(this.getBoardService().findBoardsInIDs(this.getBoard().getParentIDs()));
}
*/
   this.setForumSiteInit();
   return "forum";
}
}
OK!我們先看return的boardforum,再看forum!在boardforum中主要是遍歷顯示而已,不過對於
                <s:url action="forum?action=index" id="forumUrl">
                <s:param name="bid" value="#b.id"/>
                </s:url>
                <a href="${forumUrl}"><s:property value="#b.boardName"/></a>
好,我們看forum.jsp,我們分幾部分來分析之:
第一個table用於顯示導航條及tag:社區首頁 ? 天乙社區 ? 社區技術
關鍵點是父board的遍歷,其代碼:<s:iterator id="pboard" value="%{parentBoards}">
      &raquo;
   <s:if test="%{urlRewrite}">
   <a href="forum-index-<s:property value="#pboard.id"/>.html"><s:property value="#pboard.boardName"/></a>
   </s:if>
   <s:else>
   <s:url action="forum?action=index" id="forumUrl">
   <s:param name="bid" value="#pboard.id"/>
   </s:url>
   <a href="${forumUrl}"><s:property value="#pboard.boardName"/></a>
   </s:else>
   </s:iterator>
而 <td>
        <s:text name="forum.all.num">
        <s:param value="%{pageList.pages.totalNum}"></s:param>//版區內帖子數!
        </s:text>
        </td>
marquee區域:
<td><marquee direction="left" scrollamount="3" onMouseOver="this.stop();" onMouseOut="this.start();"><s:text name="board.bulletin"/>:<s:property value="%{board.bulletin}" escape="false"/></marquee></td>
接下來是一個空的table用於一空行吧,下一個table用於顯示一些常見的操作!注意發貼和發投票帖需action=index!next table是用於顯示討論版/精華帖/熱門帖/推薦帖/歷史帖 以及瀏覽方式(viewmode)和分頁信息的. 注意
<tr class="bgColor1">
     <td height="3" colspan="2"></td>
   </tr>
用於空行的格式化!接下來的這個table是顯示帖子列表的!第一行爲標題,用了<thead>,我們重點看下面的代碼:
<tbody>
   <s:iterator id="f" value="%{pageList.objectList}">
      <tr>
        <td class="bgColor4">
          <div align="left">
            <bbscs:forum type="face" forumValue="#f"/>//圖標
   <s:if test="#f.canNotDel==1">
   M
   </s:if>
          </div>
        </td>
        <td class="bgColor2">
          <div id="t<s:property value="#f.id"/>">
            <span class="font1"><bbscs:forum forumValue="#f" type="title" currentPageValue="%{page}"/></span>//標題(含摘要顯示圖標吧)
            <bbscs:forum forumValue="#f" type="titleitem" currentPageValue="%{page}"/>//有什麼特色(如:精華、置頂)
          </div>
          <div id="u<s:property value="#f.id"/>">
            <span class="link1">
     <s:url action="userInfo?action=id" id="userInfoUrl">
     <s:param name="id" value="#f.userID"/>
     </s:url>
     <a href="${userInfoUrl}"><s:property value="#f.nickName"/>[<em><s:property value="#f.userName"/></em>]</a>//作者
            </span>
            <span class="font4">(<bbscs:forum forumValue="#f" type="posttime"/>)</span>//時間
          </div>
          <div class="summary1" id="s<s:property value="#f.id"/>" style="display:none">//摘要的顯示div
          </div>
        </td>
        <td class="bgColor4"><div align="center"><bbscs:forum forumValue="#f" type="click"/></div></td>//點擊數
        <td class="bgColor2"><div align="center"><bbscs:forum forumValue="#f" type="renum"/></div></td>//回覆數
        <td class="bgColor4">
          <div align="right" class="font4">
            <span class="font4"><bbscs:forum forumValue="#f" type="lasttime"/></span>//最後回覆時間
            <br/>
   <s:if test="#f.lastPostNickName.equals("---")">
   <s:property value="#f.lastPostNickName"/>
   </s:if>
   <s:else>
   <s:url action="userInfo?action=name" id="userInfoUrl">
   <s:param name="username" value="#f.lastPostUserName"/>
   </s:url>
   <span class="link1"><a href="${userInfoUrl}"><s:property value="#f.lastPostNickName"/></a></span>
   </s:else>
          </div>
        </td>
      </tr>
      </s:iterator>
      </tbody>
這裏充分利用了forum這個tag,我們看看bbscs.tld是怎麼定義它的!
<tag>
<name>forum</name>
<tag-class>com.laoer.bbscs.web.taglib.ForumTag</tag-class>
<body-content>empty</body-content>
<attribute>
   <name>forumValue</name>
   <required>true</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
   <name>boardValue</name>
   <required>false</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
   <name>itemClass</name>
   <required>false</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
   <name>type</name>
   <required>true</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
   <name>currentPageValue</name>
   <required>false</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
   <name>currentActionValue</name>
   <required>false</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
   <name>inPagesValue</name>
   <required>false</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
   <name>totalnumValue</name>
   <required>false</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
   <name>tagIdValue</name>
   <required>false</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
   <name>indexValue</name>
   <required>false</required>
   <rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
我們先在ForumTag.java中看到其屬性,這些初始值對後面有十分重要的作用:
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}";//沒有就用它
我們按forum.jsp中的順序來一一解決之,首先是<bbscs:forum type="face" forumValue="#f"/>:
--> 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;
}
<bbscs:forum forumValue="#f" type="title" currentPageValue="%{page}"/>這個主要是顯示出標題部分的一些信息:
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);//從stack中取page值!
   int fcpage = 1;
   if (forumCurrentPageObj != null) {
    fcpage = ((Integer) forumCurrentPageObj).intValue();
   }

   String fcaction = "index";
   Object fcactionObj = this.getStack().findValue(this.currentActionValue);//action值
   if (fcactionObj != null) {
    fcaction = (String) fcactionObj;
   }

   String tagId = "0";
   Object tagIdObj = this.getStack().findValue(this.tagIdValue);//tag值
   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(messageSource.getMessage("post.firstpus", null, this.request.getLocale()));//加上標誌!
     sb.append(" ");
     // sb.append("[原創] ");
    }
    if (f.getPostType() == 2) {
     sb.append(messageSource.getMessage("post.fw", null, this.request.getLocale()));
     sb.append(" ");
     // sb.append("[轉載] ");
    }
   }
   if (f.getIsVote() == 1) {
    // sb.append("[投票] ");
    sb.append(messageSource.getMessage("post.vote.title", null, this.request.getLocale()));
    sb.append(" ");
   }
   if (f.getTitleColor() != 0) {//標題color!
    sb.append("<a href="");
    if (Constant.USE_URL_REWRITE) {
     sb.append("read-topic-" + f.getBoardID() + "-" + f.getMainID() + "-" + tagId + "-" + fcpage + "-"
       + fcaction + "-1" + ".html");
    } else {
     sb.append(BBSCSUtil.getActionMappingURL("/read?action=topic&id=" + f.getMainID() + "&bid="
       + f.getBoardID() + "&fcpage=" + fcpage + "&fcaction=" + fcaction + "&tagId=" + tagId,
       request));
    }
    sb.append("">");
    sb.append("<font color="");
    sb.append(Constant.TITLECOLOR[f.getTitleColor()]);
    sb.append(""><strong>");
    sb.append(TextUtils.htmlEncode(f.getTitle()));
    sb.append("</strong></font>");
    sb.append("</a>");
   } else {
    sb.append("<a href="");
    if (Constant.USE_URL_REWRITE) {
     sb.append("read-topic-" + f.getBoardID() + "-" + f.getMainID() + "-" + tagId + "-" + fcpage + "-"
       + fcaction + "-1" + ".html");
    } else {
     sb.append(BBSCSUtil.getActionMappingURL("/read?action=topic&id=" + f.getMainID() + "&bid="
       + f.getBoardID() + "&fcpage=" + fcpage + "&fcaction=" + fcaction + "&tagId=" + tagId,
       request));
    }

    sb.append("">");
    sb.append(TextUtils.htmlEncode(f.getTitle()));
    sb.append("</a>");
   }
   this.write(writer, sb.toString());
   return result;
}
接下來是<bbscs:forum forumValue="#f" type="titleitem" currentPageValue="%{page}"/>:顯示的是
[ 1 2] (摘要圖標) [(類型圖標) 附件] [置頂] [精華] [推薦] 分別根據sysConfig.getUseLinkToPages() == 1/f.getHaveAttachFile() != 0/f.getIsTop() != 0/f.getIsLock() != 0/f.getElite() != 0/f.getCommend() != 0來確定之!下面一個是<bbscs:forum forumValue="#f" type="posttime"/>:
if (type.equalsIgnoreCase("posttime")) {
   UserCookie uc = new UserCookie(request, response, sysConfig);
   if (sysConfig.getDateShowType() == 0) {
    sb.append(BBSCSUtil.formatDateTime(new Date(f.getPostTime()), sysConfig.getForumDateTimeFormat(), uc
      .getTimeZone()));
   } else {
    if (BBSCSUtil.isTodayTime(f.getPostTime(), uc.getTimeZone())) {
     sb.append(messageSource.getMessage("bbscs.today", null, request.getLocale()));
     sb.append(" ");
     sb.append(BBSCSUtil.formatDateTime(new Date(f.getPostTime()), sysConfig.getTimeFormat(), uc
       .getTimeZone()));
    } else if (BBSCSUtil.isYesterdayTime(f.getPostTime(), uc.getTimeZone())) {
     sb.append(messageSource.getMessage("bbscs.yesterday", null, request.getLocale()));
     sb.append(" ");
     sb.append(BBSCSUtil.formatDateTime(new Date(f.getPostTime()), sysConfig.getTimeFormat(), uc
       .getTimeZone()));
    } else {
     sb.append(BBSCSUtil.formatDateTime(new Date(f.getPostTime()), sysConfig.getForumDateTimeFormat(),
       uc.getTimeZone()));
    }
   }
   this.write(writer, sb.toString());
   return result;
}
我們看樣式先:(昨天 13:23)另外一種是(08-03 19:01) 注意這樣用了BBSCSUtil類的一些方法:
public static boolean isTodayTime(Date atime, String timeZone) {
Calendar cld = Calendar.getInstance(TimeZone.getTimeZone(timeZone));
cld.set(Calendar.MILLISECOND, 0);
int nowyear = cld.get(Calendar.YEAR);
int nowmonth = cld.get(Calendar.MONTH);
int nowday = cld.get(Calendar.DAY_OF_MONTH);

Calendar c = Calendar.getInstance(TimeZone.getTimeZone(timeZone));
c.setTime(atime);
c.set(Calendar.MILLISECOND, 0);
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
if (year == nowyear && month == nowmonth && day == nowday) {//與時區一致!
   return true;
} else {
   return false;
}
}
public static boolean isYesterdayTime(Date atime, String timeZone) {
Calendar cld = Calendar.getInstance(TimeZone.getTimeZone(timeZone));
cld.set(Calendar.MILLISECOND, 0);
cld.add(Calendar.DAY_OF_MONTH, -1);//現在的時間減一即爲昨天!
int yyear = cld.get(Calendar.YEAR);
int ymonth = cld.get(Calendar.MONTH);
int yday = cld.get(Calendar.DAY_OF_MONTH);

Calendar c = Calendar.getInstance(TimeZone.getTimeZone(timeZone));
c.setTime(atime);
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// int second = c.get(Calendar.SECOND);

if (year == yyear && month == ymonth && day == yday) {
   return true;
} else {
   return false;
}
}
public static String formatDateTime(Date date, String format, String timeZone) {
SimpleDateFormat outFormat = new SimpleDateFormat(format);
Calendar c = Calendar.getInstance();
c.setTimeInMillis(date.getTime());
c.set(Calendar.MILLISECOND, 0);
c.setTimeZone(TimeZone.getTimeZone(timeZone));
return outFormat.format(c.getTime());
}
public static String getFileTypeIcon(String fileExt) {      //圖標的顯示!
String fileTypeIcon = (String) Constant.ICON_MAP.get(fileExt);
if (fileTypeIcon == null) {
   fileTypeIcon = "default.icon.gif";
}
return fileTypeIcon;
}
OK,接下來<bbscs:forum forumValue="#f" type="click"/>和<bbscs:forum forumValue="#f" type="renum"/>兩個:
if (type.equalsIgnoreCase("click")) {
   if (f.getClick() >= sysConfig.getForumHotViews()) {//熱
    sb.append("<span class="");
    sb.append(this.getItemClass());//private String itemClass = "font2";
    sb.append("">");
    sb.append(f.getClick());
    sb.append("</span>");
   } else {
    sb.append(f.getClick());
   }
   this.write(writer, sb.toString());
   return result;
}
if (type.equalsIgnoreCase("renum")) {
   sb.append("[");
   if (f.getReNum() > 0) {
    if (f.getReNum() >= sysConfig.getForumHotRes()) {
     sb.append("<span class="");
     sb.append(this.getItemClass());
     sb.append("">");
     sb.append("+");
     sb.append(f.getReNum());
     sb.append("</span>");
    } else {
     sb.append("+");
     sb.append(f.getReNum());
    }
   } else {
    sb.append(f.getReNum());
   }
   sb.append("]");
   this.write(writer, sb.toString());
   return result;
}
OK,next!<bbscs:forum forumValue="#f" type="lasttime"/>它與posttime差不多!
if (type.equalsIgnoreCase("lasttime")) {
   UserCookie uc = new UserCookie(request, response, sysConfig);
   if (sysConfig.getDateShowType() == 0) {//不用DateShow!而使用系統config的!
    sb.append(BBSCSUtil.formatDateTime(new Date(f.getLastTime()), sysConfig.getForumDateTimeFormat(), uc
      .getTimeZone()));
   } else {
    if (BBSCSUtil.isTodayTime(f.getLastTime(), uc.getTimeZone())) {
     sb.append(messageSource.getMessage("bbscs.today", null, request.getLocale()));
     sb.append(" ");
     sb.append(BBSCSUtil.formatDateTime(new Date(f.getLastTime()), sysConfig.getTimeFormat(), uc
       .getTimeZone()));
    } else if (BBSCSUtil.isYesterdayTime(f.getLastTime(), uc.getTimeZone())) {
     sb.append(messageSource.getMessage("bbscs.yesterday", null, request.getLocale()));
     sb.append(" ");
     sb.append(BBSCSUtil.formatDateTime(new Date(f.getLastTime()), sysConfig.getTimeFormat(), uc
       .getTimeZone()));
    } else {
     sb.append(BBSCSUtil.formatDateTime(new Date(f.getLastTime()), sysConfig.getForumDateTimeFormat(),
       uc.getTimeZone()));
    }

   }
   this.write(writer, sb.toString());
   return result;
}
我們來看這個頁面的幾個JS:其中一個是摘要的顯示,我們在講titleitem時知道他的js函數是viewSummary帶f.getBoardID()和f.getId()兩個參數,這裏用了Ajax:
var ViewSummaryOjb = function(bid,id){
this.bid = bid;
this.id = id;
}
ViewSummaryOjb.prototype.execute = function(resText) {
$('s' + this.id).innerHTML = resText;
}

function viewSummary(bid,id) {
Element.show("s" + id);
$('s' + id).innerHTML = pageLoading;

var url = getActionMappingURL("/read");
var pars = "action=summary&ajax=shtml&id=" + id + "&bid=" + bid;
var myAjax = new Ajax.Updater('s' + id, url, {method: 'get', parameters: pars});
}
好,我們在看刷新功能javascript:load():
function load() {
var name=navigator.appName
var vers=navigator.appVersion
if(name=='Netscape'){
    window.location.reload(true)
}
else{
    history.go(0)
}
}
加進珍藏功能boardsave('<s:property value="%{bid}"/>'):
function boardsave(bid) {
showExeMsg();
var url = getActionMappingURL("/boardSave");
var pars = "action=save&ajax=xml&bid="+bid;

var myAjax = new Ajax.Request(url, {method: 'get', parameters: pars, onComplete: boardsaveComplete});
}
function boardsaveComplete(res) {
resText = res.responseText;
var jsonMsgObj = new JsonMsgObj(resText);
var codeid = jsonMsgObj.getCodeid();
hiddenExeMsg();
alert(jsonMsgObj.getMessage());
}
還有底部的選擇版區所觸發的onchange事件:
function changeBoard() {
var boardSelectObj = document.getElementById("boardSelect");
var boardId = boardSelectObj.options[boardSelectObj.selectedIndex].value;
var url = "";
if (useUrlRewrite == "true") {
    url = "forum-index-" + boardId + ".html";
}
else {
    url = getActionMappingURL("/forum?action=index&bid=" + boardId);
}
window.location.href = url;//GO!
}
我們再次看分頁處的鏈接和viewMode處的鏈接再一次到index去理解一次,我們就可以獲得最好的認識了!我們點擊熱門帖http://bbs.laoer.com/forum.bbscs?action=hot&bid=6還有推薦http://bbs.laoer.com/forum.bbscs?action=commend&bid=6以及歷史帖http://bbs.laoer.com/forum.bbscs?action=history&bid=6都將由forumAction中的其它三個方法進行執行!注意他們都沒有viewMode了,其中前兩者用到的是forum.jsp,我們看歷史帖的顯示:
public String history() {
int isHidden = 0;
if (this.getUserSession().isHaveSpecialPermission(Constant.SPERMISSION_CAN_SEE_HIDDEN_BOARD)) { // 如果用戶有查看隱藏版區的權限
   isHidden = -1;
}
this.setBids(String.valueOf(this.getBid()));
this.setBoardSelectValues(isHidden);
this.setUrlRewriteValue();
if (this.getBoard().getBoardType() != 3) {
   return ERROR;
}
Pages pages = new Pages();
pages.setPage(this.getPage());//可能有page
pages.setPerPageNum(this.getUserForumPerNum(this.getUserCookie().getForumPerNum(), this.getSysConfig()
    .getForumPrePage()));
if (this.getTotal() > 0) {
   pages.setTotalNum(this.getTotal());
}
if (Constant.USE_URL_REWRITE) {
   pages.setUseUrlRewrite(Constant.USE_URL_REWRITE);
   pages.setFileName("forum-" + this.getAction() + "-" + this.getBid() + "-0-{page}-{total}.html");//page是當前頁,total是帖子數!

} else {
   pages.setFileName(this.getBasePath()
     + BBSCSUtil.getActionMappingURLWithoutPrefix("forum?action=" + this.getAction() + "&bid="
       + this.getBid()));
}
this.setPageList(this.getForumHistoryService().findForumsMainWWW(this.getBid(), pages));//WWW方式瀏覽
this.setParentBoards();
this.setArchivesMonth(BBSCSUtil.getArchivesMonths(this.getBid()));
/**有一個文件專門存儲了bid的存檔月份用的!
public static List<String> getArchivesMonths(long bid) {
List<String> l = new ArrayList<String>();
File archivesMonthsFile = new File(Constant.ROOTPATH + "archives/archivesmonths-" + bid + ".txt");
String month = "";
try {
   month = FileUtils.readFileToString(archivesMonthsFile, Constant.CHARSET);
} catch (IOException e) {
   return l;
}
String[] months = month.split(",");
if (months.length > 0) {
   for (int i = (months.length - 1); i >= 0; i--) {
    if (StringUtils.isNotBlank(months[i])) {
     l.add(months[i]);
    }
   }
}
return l;
}
*/
return "forumHistory";
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章