图文列表插件代码放送

石头 发布于2011-9-3 09:48:17 分类: 生活片段 已浏览393 网友评论41条 我要评论

Zblog图文列表插件是我去年的时候在Zblog的基础上生产的一款简单的按条件生成图文列表的插件,由于那会Zblog上还没有类似的这样的插件,所以不管是在抢楼活动中的发送,还是以50元/份的方式进行的出售,都受到了大家热情的关注,但是直到现在还是有许多人一直在向我索取。其实1.0版本的功能很简单,只是生成了最新和各个分类的图文列表以及一个固定的flash图文轮播,缺陷很多,本来一直也希望能够改进再发2.0,可惜因为工作和生活的事情一拖再拖,加上最近沉迷于linux和php,asp更是很少动刀了。

本来是想把1.0的图文列表插件免费共享算了,不过觉得对于以前收费购买过的用户很不公平,思考过于决定将图文列表插件的核心源代码分享出来,大家可以任意复制和使用。

ASP/Visual Basic代码
  1. <%   
  2. '///////////////////////////////////////////////////////////////////////////////   
  3. '//              Z-Blog   
  4. '// 作    者:   石头   
  5. '// 版权所有:    www.stou.info   
  6. '// 技术支持:    stck@vip.qq.com   
  7. '// 程序名称:    图文列表   
  8. '// 英文名称:    ListSorter   
  9. '// 开始时间:    2010.8.31   
  10. '// 最后修改:       
  11. '// 备    注:    only for zblog1.8 本插件部分代码参考了巴士列表插件,感谢-巴士飞扬   
  12. '///////////////////////////////////////////////////////////////////////////////   
  13.   
  14. Const listsorter_new_count = 10 '最新图文数量   
  15. Const listsorter_category_count = 10 '分类图文数量   
  16. Const listsorter_title_size = 16 '标题长度   
  17. Const listsorter_flash_count = 5 'flash图文轮播条数   
  18. Const listsorter_flash_width = 520 'flash轮播宽度   
  19. Const listsorter_flash_height = 300 'flash轮播高度   
  20.   
  21.   
  22. '注册插件   
  23. Call RegisterPlugin("listsorter","ActivePlugin_listsorter")   
  24.   
  25. Function ActivePlugin_listsorter()   
  26.            
  27.         Call Add_Action_Plugin("Action_Plugin_MakeBlogReBuild_Core_Begin","Call listsorter_BlogReBuild()")'在系统重建之前   
  28.         Call Add_Action_Plugin("Action_Plugin_MakeBlogReBuild_Begin","Call listsorter_BlogReBuild()")'在系统重建之前   
  29.   
  30. End Function  
  31. 'Action_Plugin_MakeBlogReBuild_Core_Begin  'Z-BLOG 1.8 S 使用这个接口   
  32. 'Action_Plugin_MakeBlogReBuild_Begin 'Z-BLOG 1.8 Devo 使用这个接口   
  33.   
  34.   
  35. '*********************************************************   
  36. ' 目的:生成重建种类文章排行   
  37. '*********************************************************   
  38. Function listsorter_BlogReBuild()   
  39.   
  40.         Blog_ReBuild_listsorternew   
  41.         Blog_ReBuild_listsortercategory   
  42.         Blog_ReBuild_listsorterflash   
  43.        
  44. End Function  
  45.   
  46. '*********************************************************   
  47. ' 取得内容中的图片地址   
  48. '*********************************************************   
  49. Function listsorter_getimg(ByVal sl)   
  50.        
  51.         If sl = "" or isNull(sl) Then Exit Function  
  52.   
  53.         If InStr(sl,"<img")>0 then   
  54.             listsorter_getimg = Replace(Replace(Split(Split(Split(sl,"<img")(1),"src=")(1)," ")(0),"""",""),"'","")   
  55.         ElseIf InStr(sl,"[IMG]")>0 then   
  56.             listsorter_getimg = ZC_BLOG_HOST&Split(Split(sl,"[IMG]")(1),"[/IMG]")(0)   
  57.         Else  
  58.             listsorter_getimg = "NULL"  
  59.         End if   
  60.   
  61. End Function  
  62.   
  63. '*********************************************************   
  64. '过滤单引号和双引号   
  65. '*********************************************************   
  66. Function listsorter_strReplace(ByVal source)   
  67.            
  68.         source=Replace(source,"""","_")   
  69.         source=Replace(source,"'","_")         
  70.         listsorter_strReplace=source   
  71.   
  72. End Function  
  73.   
  74. '*********************************************************   
  75. ' 取字符串的前几个字,大于字数时,显示...   
  76. '*********************************************************   
  77. Function listsorter_cutTitle(ByVal strtitle,ByVal counts)      
  78.         Dim RegExpObj,ReGCheck   
  79.         Set RegExpObj=new RegExp    
  80.         RegExpObj.Pattern="^[u4e00-u9fa5]+$"    
  81.         Dim l,t,c,i   
  82.         l=Len(strtitle) : t=0   
  83.         For i=1 to l   
  84.             c=Mid(strtitle,i,1)      
  85.             ReGCheck=RegExpObj.test(c)   
  86.             If ReGCheck Then  
  87.                 t=t+2   
  88.             Else  
  89.                 t=t+1   
  90.             End If  
  91.                
  92.             If t>=counts Then  
  93.                 listsorter_cutTitle=left(strtitle,i)"..." : Exit For  
  94.             Else  
  95.                 listsorter_cutTitle=strtitle   
  96.             End If  
  97.         Next  
  98.         Set RegExpObj=nothing    
  99.         listsorter_cutTitle=Replace(listsorter_cutTitle,chr(10),"")   
  100.         listsorter_cutTitle=Replace(listsorter_cutTitle,chr(13),"")   
  101. End Function     
  102.   
  103. '*********************************************************   
  104. ' 目的:    列表记录的数据   
  105. ' 参数说明:    
  106. ' b_objRS => 数据集合   
  107. ' strOutName => 保存到include时的名字(不带后缀名)   
  108. ' out_count => 多少条记录   
  109. '*********************************************************   
  110. Function listsorter_outArticleHtml(ByVal b_objRS,ByVal strOutName,ByVal out_count)   
  111.   
  112.         dim i,listsorter_objArticle,strOut_t   
  113.         dim strOut : strOut=" "  
  114.         dim listsorter_Template,listsorter_flash_data   
  115.            
  116.         '图文列表模板   
  117.         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>"  
  118.            
  119.         'flash图文轮播数据模板   
  120.         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$'; "  
  121.            
  122.         '   
  123.         If strOutName = "ls_flash" Then listsorter_Template = listsorter_flash_data        
  124.            
  125.         If (Not b_objRS.bof) And (Not b_objRS.eof) Then  
  126.             For i=1 to out_count   
  127.                 Set listsorter_objArticle=New TArticle   
  128.                 If  listsorter_objArticle.LoadInfoByID(b_objRS("log_ID")) Then  
  129.                     strOut_t=listsorter_Template   
  130.                     strOut_t=Replace(strOut_t,"$ls.i$",i)   
  131.                     strOut_t=Replace(strOut_t,"$ls.url$",listsorter_objArticle.Url)   
  132.                     strOut_t=Replace(strOut_t,"$ls.fulltitle$",listsorter_strReplace(listsorter_objArticle.Title))   
  133.                     strOut_t=Replace(strOut_t,"$ls.imgUrl$",listsorter_getimg(listsorter_objArticle.HtmlContent))   
  134.                     strOut_t=Replace(strOut_t,"$ls.title$",listsorter_cutTitle(listsorter_objArticle.Title,listsorter_title_size))   
  135.                     strOut = strOut & strOut_t   
  136.                 End If  
  137.                 Set listsorter_objArticle=Nothing  
  138.                 b_objRS.MoveNext   
  139.                 If b_objRS.eof Then Exit For  
  140.             Next  
  141.         End If  
  142.         b_objRS.close   
  143.        
  144.         If strOutName = "ls_flash" Then  
  145.            
  146.             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>"  
  147.                
  148.         End If  
  149.        
  150.         strOut=TransferHTML(strOut,"[no-asp]")   
  151.        
  152.         Call SaveToFile(BlogPath & "/include/"&strOutName".asp",strOut,"utf-8",True)   
  153.        
  154.         strOut=""  
  155. End Function  
  156.   
  157. '*********************************************************   
  158. ' 生成最新文章图文列表   
  159. '*********************************************************   
  160. Function Blog_ReBuild_listsorternew()   
  161.   
  162.     Dim listsorter_objRS1   
  163.        
  164.     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")   
  165.            
  166.     Call listsorter_outArticleHtml(listsorter_objRS1,"ls_new",listsorter_new_count)   
  167.        
  168. End Function  
  169.   
  170. '*********************************************************   
  171. ' 生成分类图文列表   
  172. '*********************************************************   
  173. Function Blog_ReBuild_listsortercategory()   
  174.        
  175.     Dim i   
  176.     Dim Category   
  177.     Dim listsorter_objRS1   
  178.        
  179.     For Each Category in Categorys   
  180.        
  181.         If IsObject(Category) Then  
  182.   
  183.             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")   
  184.             Call listsorter_outArticleHtml(listsorter_objRS1,"ls_category_"&Category.ID,listsorter_category_count)   
  185.                
  186.         End If  
  187.     Next  
  188.   
  189. End Function  
  190.   
  191. '*********************************************************   
  192. ' 生成flash图文轮播列表   
  193. '*********************************************************   
  194. Function Blog_ReBuild_listsorterflash()   
  195.   
  196.     Dim listsorter_objRS1   
  197.        
  198.     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")   
  199.        
  200.     Call listsorter_outArticleHtml(listsorter_objRS1,"ls_flash",listsorter_flash_count)   
  201.   
  202. End Function  
  203. %>  

已经有(41)位网友发表了评论,你也评一评吧!

原创文章转载请注明引自石头博客 http://www.stou.info/ 欢迎订阅石头博客

猜你也喜欢

  1. 发表于2012-01-09 07:47:29

    看不懂啊看不懂。不会用啊不会用

  2. 发表于2011-10-22 16:48:58

    确实很强大了

  3. 发表于2011-10-19 23:23:05

    55555.石头,我还是出钱买了。郁闷死了。 不过也值了。

  4. 发表于2011-10-19 17:41:18

    还不错哇这插件

  5. 发表于2011-10-09 14:58:22

    这个代码怎样调用啊

  6. 发表于2011-10-04 18:00:51

    哈哈,共享精神非常好,不过现在不折腾zblog了~

  7. 发表于2011-09-29 22:29:39

    我还是不会用,可我真的需要用

  8. 发表于2011-09-29 21:51:14

    不错的博客,人气也多

  9. 发表于2011-09-29 13:31:35

    这是比较好的一个代码,学习中

  10. 发表于2011-09-28 16:44:04

    这个用到的不是太多吧

  11. 发表于2011-09-27 13:57:01

    不错,挺实用的,常来观望了~~

  12. 发表于2011-09-26 18:51:03

    介个,我不知道放那里哇,直接共享下子喽石头兄!

  13. 发表于2011-09-26 16:02:42

    代码我确实不懂 请不要当我留言是垃圾

  14. 发表于2011-09-25 22:45:53

    我就是付费用户,想共享就共享呗!这样搞有的都不懂!

    kaka 2012-02-02 03:10:09回复说 回复该评论 #1

    好人+有钱

    黑哈龙 2011-12-04 18:02:10回复说 回复该评论 #1

    说对了! 我正在研究怎么把源码搞上去!

  15. 发表于2011-09-20 19:04:56

    代码啊 我伤不起

  16. 发表于2011-09-20 15:59:52

    不知道如何使用啊?

  17. 发表于2011-09-20 09:22:40

    非常好,感谢分享!

  18. 发表于2011-09-19 22:23:49

    代码真的很头痛·······自己都不懂代码,唉!

  19. 发表于2011-09-19 11:07:08

    代码部分不少啊,1.0就干了200多行

  20. 发表于2011-09-16 13:41:06

    很感谢博主的博客能让我留言,谢谢

  21. 发表于2011-09-13 18:22:03

    谢谢博主的分享 自己会学到一些东西的

  22. 发表于2011-09-13 11:22:09

    中秋节快乐啊,,代码我先收着了

  23. 发表于2011-09-12 03:08:10

    我以不需要了,因为以有免费插件比这功能还强

    黑哈龙 2011-12-04 21:39:10回复说 回复该评论 #1

    我也遇到同样!

    stone 2011-09-12 20:15:32回复说 回复该评论 #1

    好久没有进入ZBLOG社区了,我OUT了,是清风的那插件么?

  24. 发表于2011-09-10 09:25:49

    中秋快乐、石头哥

    stone 2011-09-12 20:17:43回复说 回复该评论 #1

    非常感谢loker!那么早就来给我说中秋快乐,却因为一直瞎忙没有回复。在此中秋团圆之际,祝你中秋快乐,心想事成哈!

  25. 发表于2011-09-07 22:32:28

    为什么用这段代码我就是调试不成功呢?老是提示我语句未结束

    stone 2011-09-08 23:25:06回复说 回复该评论 #1

    是不是代码没有复制完整呢?

    黑哈龙 2011-12-04 21:43:09回复说 回复该评论 #2

    我也是一样的问题!

    7夜落羽 2011-09-09 20:14:02回复说 回复该评论 #2

    第93行

  26. 发表于2011-09-07 20:09:54

    楼主真的好强大,我正好用到这段代码,真好啊

  27. 发表于2011-09-07 15:56:06

    受到了大家热情的关注

  28. 发表于2011-09-06 19:49:38

    值得学习和参考,不错的博客。

  29. 发表于2011-09-06 18:24:54

    学学学习 活到老,学到老

  30. 发表于2011-09-05 13:50:36

    真的是不错的

  31. 发表于2011-09-04 13:11:21

    非常给力,顶了

  32. 发表于2011-09-04 11:12:20

    石头BS你,你那个replace和split用的太犀利了,用用正则你会死吗?会死吗?

  33. 发表于2011-09-03 16:39:44

    博主很强大啊。。

称呼:

邮件:

网站:

验证:

记住我的信息,下次不用再输入小诀窍:按ctrl+y键可以启动搜狗云输入法