06
2007
04

Oblog首页调用群组增加横排,让群主可以修改群名与类别,群组中显示昵称

适用于Oblog4.02

修改js.asp文件,增加群组调用横排功能

'x:1- 最新创建/2-最活跃群组(贴数最多)/3-规模大(人数最多) / 4-推荐群组
'n: 数目
'l: 题目显示长度
'y: 是否显示图标
'w: 图标宽度,不写则默认50
'h: 图标高度,不写则默认50

'rc:横排还是纵排,不写默认纵排,0为纵排,1为横排
'rn:横排时每排的数量,>=2才有意义,如果rc=1,则rn不写默认为5

Sub show_teams()
      Dim x,l,y,w,h
      x=clng(request("x"))
     w=(request("w"))
      h=(request("h")) 
      l=clng(request("l")) 
      y=request("y")

     '新定义两个变量
     dim rc,rn
     rc=request("rc")
     rn=clng(request("rn"))

     Dim rs,Sql,sRet,sIco
     Sql="Select top " & n & " teamid,t_name,t_ico,icount0,(icount1+icount2) From oblog_team Where istate=3 and isdel=0  "
     Select Case x
     Case 1
         Sql= Sql & " Order By teamid Desc"
     Case 2
         Sql= Sql & " Order By (icount1+icount2) Desc"
     Case 3
         Sql= Sql & " Order By icount0 Desc"
     Case 4
         Sql= Sql & " and isbest=1"
     End Select
     Set rs=oblog.Execute(Sql)
     sRet="<div><ul>"
 
 '如果要横排,gs来计每排排了的数,zgs来计是否排完
      if rc=1 then
     dim gs,zgs
      gs=0
     zgs=0
     if rn=0 then
       rn=5
     end if

            sRet=sRet & "<table>"
     Do While Not rs.Eof
      
'刚开始和换行后加上<tr>
      if gs=0 then
        sRet=sRet & "<tr>"
      end if
      If y=1 Then
                         If w="" Then w=50:h=50
                                   sIco=LCase(Ob_IIF(rs(2),"images/ico_default.gif"))   
                                   If Left(sico,7)<>"http://" Then sico=blogdir & sico
                                   sRet=sRet & "<td><a href=""group.asp?gid=" & rs(0) & """ target=""_blank""><img src=""" & sico & """ width=""" & w &""" height=""" &h &"""/></a><BR/>"
                                  sRet=sRet & "<a href=""group.asp?gid=" & rs(0) & """ target=""_blank"">" & Left(oblog.filt_html((rs(1))),l) & "</a>(" & rs(3) & "人/" & rs(4) & ")</td>"
               
else
                                  sRet=sRet & "<td><a href=""group.asp?gid=" & rs(0) & """ target=""_blank"">" & Left(oblog.filt_html((rs(1))),l) & "</a>(" & rs(3) & "人/" & rs(4) & "贴)</td>"
                End if

       '某一行增加了一个
      gs=gs+1
      zgs=zgs+1
      '如果一行排完,则加上</tr>,重新开始下一行计数。如果总数排完,则再加上</table>
      if gs=rn or zgs=n then
                            gs=0
                            sRet=sRet & "</tr>" & Vbcrlf
                            if zgs=n  then
                                  sRet=sRet & "</table>"
                            end if
                  end if

      rs.movenext
      Loop

       else
      Do While Not rs.Eof
       sRet=sRet & "<li>"
       If y=1 Then
          If w="" Then w=50:h=50
          sIco=LCase(Ob_IIF(rs(2),"images/ico_default.gif"))   
          If Left(sico,7)<>"http://" Then sico=blogdir & sico
           sRet=sRet & "<img src=""" & sico & """ width=""" & w &""" height=""" & h &"""/><BR/>"
       End if 
       sRet=sRet & "<a href=""group.asp?gid=" & rs(0) & """ target=""_blank"">" & Left(oblog.filt_html((rs(1))),l) & "</a>(" & rs(3) & "/" & rs(4) & ")"
       sRet=sRet & "</li>" & Vbcrlf
       rs.movenext
       Loop
     end if

     Set rs=Nothing
     sRet=sRet & "</ul></div>"
     Response.WRITE oblog.htm2js (sRet)
End Sub

对群组显示功能的修改(从我另一博客中挪过来http://www.keepnew.com/user/duanyj/archives/2006/2006119205838.htm),修改了以下文件

inc/class_qq.asp

 1、“群组首页”下的显示方式

a、将群空间首页的日志最后更新时间显示为自己设定的发布日期(原来显示的是实际提交时的真实日期,改这个只是为了我的个人原因,没有意义
在inc/class_qq.asp中做如下修改:
找到Function GetIndexList(iMode)
将以下红色部分代码改为蓝色部分代码
'原来 最后更新 显示的是真正的日志提交时间,并不是发表日志时设定的时间,为了需要进行了改动
  'Sql="Select  * from (select top 500 isbest,istop,logid,postid,topic,author,replys,lastupdate From oblog_teampost Where teamid=" & Group_id & " And iDepth=0 And isTop=1 " & SqlPart & " Order By Lastupdate Desc"
  'Sql= Sql & " union "
  'Sql= Sql & " Select  top 500 isbest,istop,logid,postid,topic,author,replys,lastupdate From oblog_teampost Where teamid=" & Group_id & " And iDepth=0 And isTop=0  " & SqlPart & " Order by Lastupdate desc ) DERIVEDTBL ORDER BY istop DESC , lastupdate DESC"
  Sql="Select  * from (select top 500 isbest,istop,logid,postid,topic,author,replys,lastupdate,addtime From oblog_teampost Where teamid=" & Group_id & " And iDepth=0 And isTop=1 " & SqlPart & " Order By addtime Desc"
  Sql= Sql & " union "
  Sql= Sql & " Select  top 500 isbest,istop,logid,postid,topic,author,replys,lastupdate,addtime From oblog_teampost Where teamid=" & Group_id & " And iDepth=0 And isTop=0  " & SqlPart & " Order by addtime desc ) DERIVEDTBL ORDER BY istop DESC , addtime DESC"

'原来 最后更新 显示的是真正的日志提交时间,并不是发表日志时设定的时间,为了需要进行了改动
   'sRet1=sRet1&"<td class='s4'>"&rs("lastupdate")&"</td>"
   sRet1=sRet1&"<td class='s4'>"&rs("addtime")&"</td>"

红色为原来的代码,蓝色为改动后的代码,简单的替换,呵呵。为了汇报
b、作者显示内容的改动
还是在Function GetIndexList(iMode)中进行
再增加定义两个变量
Dim rs,lPage,lAll,lPages,sTitle,sMBar,rst,nickname
if int(i/2)*2=i then r=1 else r=2后边加上如下几行代码
'以下几行是为了显示作者的呢称
   sql="select nickname from oblog_user where username="&"'"&rs("author")&"'"
   Set rst=Server.CreateObject("Adodb.RecordSet")
   rst.Open Sql,conn,1,1
   nickname=rst("nickname")
   rst.close
   set rst=nothing
将以下红色部分改为蓝色部分代码
'原来只显示用户名,现在改为如果用户呢称不为空则显示用户呢称,否则显示用户名
   'sRet1=sRet1&"<td class='s2'><a href='go.asp?user="&rs("author")&"' title=""作者"&rs("author")&""">"&rs("author")&"</td>"
   sRet1=sRet1&"<td class='s2'><a href='go.asp?user="&rs("author")&"' title=""作者"&rs("author")&""">"&OB_IIF(nickname,rs("author"))&"</td>"
c、单篇日志页面的显示修改
   找到Function GetPost(byval pid,sRet,sRet1)
'Sql="Select a.*,b.user_icon1 From oblog_teampost a,oblog_user b Where a.postid="& pid &" and a.userid=b.userid And iDepth=0"
  Sql="Select a.*,b.user_icon1,b.nickname From oblog_teampost a,oblog_user b Where a.postid="& pid &" and a.userid=b.userid And iDepth=0"

'sRet=Replace(sRet,"$group_post_user$",rs("author"))
  sRet=Replace(sRet,"$group_post_user$",OB_IIF(rs("nickname"),rs("author")))
 
'rs.Open "Select a.*,b.user_icon1,b.username From (Select top 500 * From oblog_teampost Where idepth>0 And parentid=" & pid & " Order By postid Desc) a,oblog_user b Where a.userid=b.userid",conn,1,1
  rs.Open "Select a.*,b.user_icon1,b.username,b.nickname From (Select top 500 * From oblog_teampost Where idepth>0 And parentid=" & pid & " Order By postid Desc) a,oblog_user b Where a.userid=b.userid",conn,1,1
 
'sRet1=Replace(sRet1,"$group_reply_user$","<a href='go.asp?user="&rs("author")&"'>"&rs("author")&"</a>")
    sRet1=Replace(sRet1,"$group_reply_user$","<a href='go.asp?user="&rs("author")&"'>"&OB_IIF(rs("nickname"),rs("author"))&"</a>")

2、“成员列表”下的显示方式
在function GetInfo()中修改
'sRet= sRet & "<li class=""u2""><a href=""go.asp?userid=" _fcksavedurl="""go.asp?userid="" _fcksavedurl="""go.asp?userid="" _fcksavedurl="""go.asp?userid="" _fcksavedurl="""go.asp?userid="" & rs("userid") & """ target=_blank>" &  rs("username") &"</a></li>" & vbcrlf
   sRet= sRet & "<li class=""u2""><a href=""go.asp?userid=" & rs("userid") & """ target=_blank>" &  OB_IIF(rs("nickname"),rs("username")) &"</a></li>" & vbcrlf
经过以上的改动,如果用户呢称不为空将显示用户呢称否则显示用户名
3、“申请加入”下的显示方式
在Function JoinForm(id)中修改
'sRet=sRet & oblog.DecodeCookie(Request.Cookies(cookies_name)("username")) & ",请填写您的申请信息
"

  sRet=sRet & oblog.l_unickname & ",请填写您的申请信息
"
4、“发个新贴”下的显示方式
Function CommentForm(id)中修改
'sRet=sRet & "<ul><p>" & oblog.l_uname & " , 欢迎您参与" &P_QQ_NAME& "讨论,在此处发布的内容将不显示在您的博客中</p></ul>"
  sRet=sRet & "<ul><p>" & oblog.l_unickname & " , 欢迎您参与" &P_QQ_NAME& "讨论,在此处发布的内容将不显示在您的博客中</p></ul>"
以上是4.02前的修改,4.02中增加了个sName,但此处修改后不起作用,不知为何
'sName=oblog.l_uname
sName=OB_IIF(oblog.l_unickname,oblog.l_uname)
5、“群组信息”下的显示方式
Sub GetGroupInfo(byref arrInfo)、function GetInfo()中修改
'Sql="Select * From oblog_team Where teamid=" & Group_id
  Sql="Select a.*,b.nickname From oblog_team a,oblog_user b Where a.managerid=b.userid and teamid=" & Group_id
 
'sRet=sRet & "<li>创建者:" & rs("managername") &"</li>"
  sRet=sRet & "<li>创建者:" & OB_IIF(rs("nickname"),rs("managername")) &"</li>"
 
'sRet= sRet & "<li class=""u2""><a href=""go.asp?userid=" & rs("userid") & """ target=_blank>" &  rs("username") &"</a></li>" & vbcrlf
   sRet= sRet & "<li class=""u2""><a href=""go.asp?userid=" & rs("userid") & """ target=_blank>" &  OB_IIF(rs("nickname"),rs("username")) &"</a></li>" & vbcrlf
 
小结:修改每个按钮下的信息时,首先根据所对应的链接中cmd=后的字符串信息在group.asp中查找该链接所要调用的子程序,然后在inc/class_qq.asp中查找相应子程序,再在该子程序中查找调用的函数,找到后对函数进行相应的修改。
如:“群组信息”对应的链接为group.asp?cmd=info&gid=1,其中cmd=info,所以在group.asp中查找到
Case "info" 
  Call oTeam.ShowInfo
现在知道要调用的子过程为Showinfo,所以在inc/class_qq.asp中查找到
Public Sub ShowInfo()
  Dim sRet
  sRet=MakeMainPage()
  sRet=Replace(sRet,"$group_replys$","")
  sRet=Replace(sRet,"$group_posts$",GetInfo)
  Response.Write sRet
  sRet=""
End Sub
该子程序调用的函数为Getinfo,所以再找到function GetInfo(),现在就可以进行相应的修改了
群主不能修改群组类别与名称的解决从这http://www.keepnew.com/user/duanyj/archives/2006/2006101012622.htm挪过来
打开user_team.asp
一、找到sub teamadmin()
1、在下面这段代码(473行后)
set rs=oblog.execute("select * from oblog_team where teamid="&teamid&"")
 ReCountTeamInfo(teamid)
 teamadmin_top()
后边加上
dim rstname,stname
set rstname=oblog.execute("select classname from oblog_logclass where id="&rs("classid")&"")
stname=rstname("classname")
rstname.close
set rstname=nothing
2、将以下代码中的disabled去掉
<tr>
  <td class="win_user_team_table_td"><%=P_QQ_NAME%>名称:</td>
  <td><input type="text" name="name" size="30" value="<%=rs("t_name")%>" disabled></td>
</tr> 
3、在下面这段代码
<tr>
     <td class="win_user_team_table_td">标记图片(120*90)</td>
     <td><div class="user_face"><img id="imgIcon" width=120 height=90 src="<%=oblog.filt_html(OB_IIF(rs("t_ico"),""))%>">
     <p><iframe id="d_file" frameborder="0" src="upload.asp?tMode=9&re=" width="300" height="80" scrolling="no"></iframe>
    
图像地址,只支持jpg,gif,png,尺寸为120*90

     外部调用:<input name="ico"  type="text" value="/<%=oblog.filt_html(rs("t_ico"))%>" size="50" maxlength="200" / onblur="getImg();">
    
你可以直接输入一个有效的图片地址,也可以在这里直接选择一个系统可用的图片</p></div></td>
</tr>
后边加上
<tr>
       <td class="win_user_team_table_td"><%=P_QQ_NAME%>类别:</td>
       <td><input type=text disabled="true" value="<%=stname%>">选择新的类别
          <select name="classid" id="classid" >
                <%=oblog.show_class("log",0,2)%>
         </select>  
      </td>
</tr>
 
二、找到sub modifyteaminfo()
1、定义两个变量classid,strstate即在Dim name, rs, intro, sql, str,ico,tags,t1,t2,t3后加上,classid,strstate
2、在t3 = Trim(request.Form("t3"))
      后边加上
      '增加群组类别、名称的编辑
      name=oblog.filt_badword(Trim(request.Form("name")))
      classid = Trim(request.Form("classid"))
      strstate=""
3、在rs("intro")=intro
      后边加上
      '增加群组名称、类别编辑
       rs("t_name")=name
       if classid<>0 then
               rs("classid")=classid
       end if
       If oblog.CacheConfig(49) = 1 Then
              if t_name<>name or teamid<>classid then
                   rs("istate")=1
                   strstate=",修改群组名称、类别需要重新审核"
              end if
       end if
« 上一篇: 文章即将发表在《科技情报开发与... 下一篇: Z-Blog后台文件管理中增加... »
与此文相关的文章,有兴趣就接着看看吧:

 

评论列表:

1.pingfen  2008-06-13 17:50:21 回复该评论
看代码有点晕
2.上海驾校  2007-09-21 14:52:12 回复该评论
好文章,支持~~~

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。