Blueimp 論壇首頁
  首頁  | 討論區  | 最新話題  | 搜尋  | XML  |  登入
博客來購書 | 《主管這樣帶人就對了!》
貝殼鯨魚兒童程式啟蒙教育課程(點我去報名)

此話題中所有文章數: 1 [ 話題狀態: 一般 ]
上一話題 此文章已經觀看 1727 次 而且有 篇回應 下一話題
會員大頭照
男寶寶 jieh
《騎士團團長》
文章: 6700

mvnforum 精華文章功能範例



最近一直在看mvnforum sad 遗憾的是到现在对代码还不是很熟悉。花了接近一天的时间才写出来,贴上来和大家一起探讨学习 smile 本次修改参考了wangyi的帖子http://www.shorelinesolution.com/forum/viewthread?thread=115#480 上次写了论坛实现版主功能的帖子,jing 还有wangyi提了很好的建议,同时在他们那也学到很多东西 laughing 受益非浅。在此表示感谢。废话不多说了 smile
首先需要改的页面文件为:listforums.jsp、listthreads.jsp、editthreadtype.jsp。
listforums.jsp里面加入的代码为:
<% String typeImage = "";
switch (thread.getThreadType()) {
case ThreadBean.THREAD_TYPE_STICKY: typeImage = "sticky.gif"; hasSticky = true; break;
case ThreadBean.THREAD_TYPE_FORUM_ANNOUNCEMENT: typeImage = "announce.gif"; hasAnnouncement = true; break;
case ThreadBean.THREAD_TYPE_GLOBAL_ANNOUNCEMENT: typeImage = "global_announce.gif"; hasGlobalAnnouncement = true; break;
//////add by dyhjjk begin
case ThreadBean.THREAD_TYPE_PINK: typeImage="[精华]";
//////end

default:break;
} %>
<% if ( thread.getThreadType() != ThreadBean.THREAD_TYPE_DEFAULT) { %>


<%
if(thread.getThreadType()==ThreadBean.THREAD_TYPE_PINK){
out.print(""+typeImage+"");
}else{
%>





<%}%>

listthreads.jsp里面加入的代码为:
<% String typeImage = "";
switch (threadBean.getThreadType()) {
case ThreadBean.THREAD_TYPE_STICKY: typeImage = "sticky.gif"; hasSticky = true; break;
case ThreadBean.THREAD_TYPE_FORUM_ANNOUNCEMENT: typeImage = "announce.gif"; hasAnnouncement = true; break;
case ThreadBean.THREAD_TYPE_GLOBAL_ANNOUNCEMENT: typeImage = "global_announce.gif"; hasGlobalAnnouncement = true; break;

//***************add by dyhjjk**************************
case ThreadBean.THREAD_TYPE_PINK: typeImage="[精华]";
break;
//***************add by dyhjjk**************************

default:break;
} %>
<% if ( threadBean.getThreadType() != ThreadBean.THREAD_TYPE_DEFAULT) {
%>


<%
if(threadBean.getThreadType()==ThreadBean.THREAD_TYPE_PINK){
out.print(""+typeImage+"");
}else{
%>




<% }%>
editthreadtype.jsp中加入的代码为:

<%
if (threadType!=4){
%>

<%}%>

需要改的类文件有:
ThreadBean.java
/****
* add by dyhjjk 设置精华帖子
*/

public final static int THREAD_TYPE_PINK = 4;

public final static int THREAD_TYPE_FORUM_ANNOUNCEMENT = 2;
/**********
* modify by dyhjjk
*/
public final static int THREAD_TYPE_GLOBAL_ANNOUNCEMENT = 5;
ThreadDAO.java
/*****************
* add by dyhjjk 获得精华帖子
* @param forumID
* @return
* @throws DatabaseException
*/
public Collection getPinkForum(int forumID)
throws DatabaseException;
ThreadCache.java
/******************
* add by dyhjjk 返回精华帖子
* @return
* @throws DatabaseException
*/
public Collection getPinkForum(int forumID)
throws DatabaseException {

Collection result = null;
if (cache != null) {
StringBuffer buffer = new StringBuffer(128);
buffer.append("getPinkForum").append(forumID);
String key = buffer.toString();
result = (Collection)cache.retrieve(key);
if (result == null) {
result = DAOFactory.getThreadDAO().getPinkForum(forumID);

cache.store(key, result, TIME_OUT);
}
} else {
result = DAOFactory.getThreadDAO().getPinkForum(forumID);
}

return result;
}
ThreadDAOImplJDBC.java
/*****************
* add by dyhjjk 获得精华帖子
*/
public Collection getPinkForum(int forumID)throws DatabaseException{
return getEnableThreads_inType_inForum(forumID,ThreadBean.THREAD_TYPE_PINK);
}
ThreadWebHandler.java
在prepareList_limit()中加入

/***********
*add by dyhjjk 从缓存中取得精华帖子
*/
Collection pinkforum=ThreadCache.getInstance().getPinkForum(forumID);
allThreadBeans.addAll(pinkforum);
MyUtil.java
getThreadTypeName中加入
/*************
* modify by dyhjjk
*/

case ThreadBean.THREAD_TYPE_PINK:
result="精华贴";
break;
----------------------------------------
支持小惡魔
BTC : 19tn3RnCuwZVukXAwyhDWZD4uBgUZoGJPx
LTC : LTFa17pSvvoe3aU5jbmfcmEpo1xuGa9XeA
知識跟八卦一樣,越多人知道越有價值;知識最好的備份方法,散播!
藍色小惡魔(林永傑): 臉書


[2007/10/25 下午 12:52:31] 友善列印   [返迴此篇文章頂端 ]  回到頂端 
[顯示可以列印的版本]