Zblog图文列表插件是我去年的时候在Zblog的基础上生产的一款简单的按条件生成图文列表的插件,由于那会Zblog上还没有类似的这样的插件,所以不管是在抢楼活动中的发送,还是以50元/份的方式进行的出售,都受到了大家热情的关注,但是直到现在还是有许多人一直在向我索取。其实1.0版本的功能很简单,只是生成了最新和各个分类的图文列表以及一个固定的flash图文轮播,缺陷很多,本来一直也希望能够改进再发2.0,可惜因为工作和生活的事情一拖再拖,加上最近沉迷于linux和php,asp更是很少动刀了。
本来是想把1.0的图文列表插件免费共享算了,不过觉得对于以前收费购买过的用户很不公平,思考过于决定将图文列表插件的核心源代码分享出来,大家可以任意复制和使用。
ASP/Visual Basic代码
- <%
-
-
-
-
-
-
-
-
-
-
-
-
- Const listsorter_new_count = 10
- Const listsorter_category_count = 10
- Const listsorter_title_size = 16
- Const listsorter_flash_count = 5
- Const listsorter_flash_width = 520
- Const listsorter_flash_height = 300
-
-
-
- Call RegisterPlugin("listsorter","ActivePlugin_listsorter")
-
- Function ActivePlugin_listsorter()
-
- Call Add_Action_Plugin("Action_Plugin_MakeBlogReBuild_Core_Begin","Call listsorter_BlogReBuild()")
- Call Add_Action_Plugin("Action_Plugin_MakeBlogReBuild_Begin","Call listsorter_BlogReBuild()")
-
- End Function
-
-
-
-
-
-
-
- Function listsorter_BlogReBuild()
-
- Blog_ReBuild_listsorternew
- Blog_ReBuild_listsortercategory
- Blog_ReBuild_listsorterflash
-
- End Function
-
-
-
-
- Function listsorter_getimg(ByVal sl)
-
- If sl = "" or isNull(sl) Then Exit Function
-
- If InStr(sl,"<img")>0 then
- listsorter_getimg = Replace(Replace(Split(Split(Split(sl,"<img")(1),"src=")(1)," ")(0),"""",""),"'","")
- ElseIf InStr(sl,"[IMG]")>0 then
- listsorter_getimg = ZC_BLOG_HOST&Split(Split(sl,"[IMG]")(1),"[/IMG]")(0)
- Else
- listsorter_getimg = "NULL"
- End if
-
- End Function
-
-
-
-
- Function listsorter_strReplace(ByVal source)
-
- source=Replace(source,"""","_")
- source=Replace(source,"'","_")
- listsorter_strReplace=source
-
- End Function
-
-
-
-
- Function listsorter_cutTitle(ByVal strtitle,ByVal counts)
- Dim RegExpObj,ReGCheck
- Set RegExpObj=new RegExp
- RegExpObj.Pattern="^[u4e00-u9fa5]+$"
- Dim l,t,c,i
- l=Len(strtitle) : t=0
- For i=1 to l
- c=Mid(strtitle,i,1)
- ReGCheck=RegExpObj.test(c)
- If ReGCheck Then
- t=t+2
- Else
- t=t+1
- End If
-
- If t>=counts Then
- listsorter_cutTitle=left(strtitle,i)"..." : Exit For
- Else
- listsorter_cutTitle=strtitle
- End If
- Next
- Set RegExpObj=nothing
- listsorter_cutTitle=Replace(listsorter_cutTitle,chr(10),"")
- listsorter_cutTitle=Replace(listsorter_cutTitle,chr(13),"")
- End Function
-
-
-
-
-
-
-
-
- Function listsorter_outArticleHtml(ByVal b_objRS,ByVal strOutName,ByVal out_count)
-
- dim i,listsorter_objArticle,strOut_t
- dim strOut : strOut=" "
- dim listsorter_Template,listsorter_flash_data
-
-
- listsorter_Template = "<li><a href=""$ls.url$"" title=""$ls.fulltitle$""><img src=$ls.imgUrl$ width=100 height=100 /><br /><span>$ls.title$</span></a></a></li>"
-
-
- listsorter_flash_data = "img$ls.i$=new Image ();img$ls.i$.src='$ls.imgUrl$';url$ls.i$=new Image ();url$ls.i$.src='$ls.url$'; "
-
-
- If strOutName = "ls_flash" Then listsorter_Template = listsorter_flash_data
-
- If (Not b_objRS.bof) And (Not b_objRS.eof) Then
- For i=1 to out_count
- Set listsorter_objArticle=New TArticle
- If listsorter_objArticle.LoadInfoByID(b_objRS("log_ID")) Then
- strOut_t=listsorter_Template
- strOut_t=Replace(strOut_t,"$ls.i$",i)
- strOut_t=Replace(strOut_t,"$ls.url$",listsorter_objArticle.Url)
- strOut_t=Replace(strOut_t,"$ls.fulltitle$",listsorter_strReplace(listsorter_objArticle.Title))
- strOut_t=Replace(strOut_t,"$ls.imgUrl$",listsorter_getimg(listsorter_objArticle.HtmlContent))
- strOut_t=Replace(strOut_t,"$ls.title$",listsorter_cutTitle(listsorter_objArticle.Title,listsorter_title_size))
- strOut = strOut & strOut_t
- End If
- Set listsorter_objArticle=Nothing
- b_objRS.MoveNext
- If b_objRS.eof Then Exit For
- Next
- End If
- b_objRS.close
-
- If strOutName = "ls_flash" Then
-
- strOut = "<script language=""javascript""> var widths="&listsorter_flash_width";var heights="&listsorter_flash_height";"&strOut"var counts="&out_count";var nn=1;var key=0;function change_img(){if(key==0){key=1;} else if(document.all){document.getElementById(""pic"").filters[0].Apply();document.getElementById(""pic"").filters[0].Play(duration=2);} eval('document.getElementById(""pic"").src=img'+nn+'.src'); eval('document.getElementById(""url"").href=url'+nn+'.src');for (var i=1;i <=counts;i++){document.getElementById(""xxjdjj""+i).className='axx';} document.getElementById(""xxjdjj""+nn).className='bxx'; nn++;if(nn>counts){nn=1;} tt=setTimeout('change_img()',4000);} function changeimg(n){nn=n;window.clearInterval(tt);change_img();}document.write(' <style>'); document.write('.axx{padding:1px 7px;border-left:#cccccc 1px solid;}'); document.write('a.axx:link,a.axx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#666;}'); document.write('a.axx:active,a.axx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#999;}'); document.write('.bxx{padding:1px 7px;border-left:#cccccc 1px solid;}'); document.write('a.bxx:link,a.bxx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}'); document.write('a.bxx:active,a.bxx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}'); document.write(' </style>'); document.write(' <div style=""width:'+widths+'px;height:'+heights+'px;overflow:hidden;text-overflow:clip;"">');document.write(' <div> <a id=""url"" target=""_blank""> <img id=""pic"" style=""border:0px;filter:progid:dximagetransform.microsoft.wipe(gradientsize=1.0,wipestyle=4, motion=forward)"" width='+widths+' height='+heights+' /> </a> </div>');document.write(' <div style=""filter:alpha(style=1,opacity=1,finishOpacity=70,-moz-opacity:0.5; );background: #f1f1f1;width:100%-2px;text-align:right;top:-18px;position:relative;margin:1px;height:12px;padding:0px;margin:0px;border:0px;"">'); for(var i=1;i <counts+1;i++){document.write(' <a href=""javascript:changeimg('+i+');"" id=""xxjdjj'+i+'"" class=""axx"" target=""_self"">'+i+' </a>');} document.write(' </div> </div>');change_img();</script>"
-
- End If
-
- strOut=TransferHTML(strOut,"[no-asp]")
-
- Call SaveToFile(BlogPath & "/include/"&strOutName".asp",strOut,"utf-8",True)
-
- strOut=""
- End Function
-
-
-
-
- Function Blog_ReBuild_listsorternew()
-
- Dim listsorter_objRS1
-
- Set listsorter_objRS1=objConn.Execute("select top " & listsorter_new_count & " [log_ID] from blog_Article WHERE ([log_ID]>0) AND ([log_Level]>2) AND ((inStr([log_content],""<img"")>0) OR (inStr([log_content],""[IMG]"")>0)) order by log_ID desc")
-
- Call listsorter_outArticleHtml(listsorter_objRS1,"ls_new",listsorter_new_count)
-
- End Function
-
-
-
-
- Function Blog_ReBuild_listsortercategory()
-
- Dim i
- Dim Category
- Dim listsorter_objRS1
-
- For Each Category in Categorys
-
- If IsObject(Category) Then
-
- Set listsorter_objRS1=objConn.Execute("select top " & listsorter_category_count & " [log_ID] from blog_Article WHERE ([log_ID]>0) AND ([log_Level]>2) AND ((inStr([log_content],""<img"")>0) OR (inStr([log_content],""[IMG]"")>0)) AND ([log_CateID]="&Category.ID") order by log_ID desc")
- Call listsorter_outArticleHtml(listsorter_objRS1,"ls_category_"&Category.ID,listsorter_category_count)
-
- End If
- Next
-
- End Function
-
-
-
-
- Function Blog_ReBuild_listsorterflash()
-
- Dim listsorter_objRS1
-
- Set listsorter_objRS1=objConn.Execute("select top " & listsorter_flash_count & " [log_ID] from blog_Article WHERE ([log_ID]>0) AND ([log_Level]>2) AND ((inStr([log_content],""<img"")>0) OR (inStr([log_content],""[IMG]"")>0)) order by log_ID desc")
-
- Call listsorter_outArticleHtml(listsorter_objRS1,"ls_flash",listsorter_flash_count)
-
- End Function
- %>
看不懂啊看不懂。不会用啊不会用
确实很强大了
55555.石头,我还是出钱买了。郁闷死了。
不过也值了。
还不错哇这插件
这个代码怎样调用啊
哈哈,共享精神非常好,不过现在不折腾zblog了~
我还是不会用,可我真的需要用
不错的博客,人气也多
这是比较好的一个代码,学习中
这个用到的不是太多吧
不错,挺实用的,常来观望了~~
介个,我不知道放那里哇,直接共享下子喽石头兄!
代码我确实不懂 请不要当我留言是垃圾
我就是付费用户,想共享就共享呗!这样搞有的都不懂!
代码啊 我伤不起
不知道如何使用啊?
非常好,感谢分享!
代码真的很头痛·······自己都不懂代码,唉!
代码部分不少啊,1.0就干了200多行
很感谢博主的博客能让我留言,谢谢
谢谢博主的分享 自己会学到一些东西的
中秋节快乐啊,,代码我先收着了
我以不需要了,因为以有免费插件比这功能还强
中秋快乐、石头哥
为什么用这段代码我就是调试不成功呢?老是提示我语句未结束
楼主真的好强大,我正好用到这段代码,真好啊
受到了大家热情的关注
值得学习和参考,不错的博客。
学学学习 活到老,学到老
真的是不错的
非常给力,顶了
石头BS你,你那个replace和split用的太犀利了,用用正则你会死吗?会死吗?
博主很强大啊。。