| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 416 人关注过本帖
标题:[求助]自动将长文章分页输出
只看楼主 加入收藏
jnzsk
Rank: 1
等 级:新手上路
威 望:1
帖 子:403
专家分:0
注 册:2004-11-13
收藏
 问题点数:0 回复次数:1 
[求助]自动将长文章分页输出
谁有自动将长文章分页输出的类!
搜索更多相关主题的帖子: 输出 自动 
2006-07-12 15:48
jnzsk
Rank: 1
等 级:新手上路
威 望:1
帖 子:403
专家分:0
注 册:2004-11-13
收藏
得分:0 

Class AutoPaging
'*************************************************************
'目   的:自动将长文章分页输出
'属   性:Splitchar:分页搜索标志。以一维数组方式输入,默认array("<br/>","<BR>","<Br>","<bR>")
'      PagingString:要进行分页的字符串
'      PagingSize:分页长度
'      CurrentPage:当前输出页码
'      DefaultRange:默认搜索分页标志范围
'      StepRange:搜索步长
'方   法:getTotalPageCount():返回总分页数
'      OutputString:输出当前分页内容
'*************************************************************
public Splitchar'分页搜索标志,数组
public PagingString'分页字符串
public PagingSize'页面最大长度
public CurrentPage'当前页码
public DefaultRange'默认起始范围
public StepRange'步长
private Truncate'2维数组m,n。m0=页码、m1=起始字符、m2=结束字符,n=总页数
private intStart'开始位置
private intLen'截取长度
private tmpStr
private Range'起始范围

private Sub Class_Initialize()
Splitchar=array("<br/>","<BR>","<Br>","<bR>")
PagingSize = 2000
DefaultRange=1
StepRange = 1
intStart = 0
intEnd = 0
End Sub

public Function getTotalPageCount()'返回总页数
if len(PagingString) mod PagingSize > 0 then
getTotalPageCount = int(len(PagingString) / PagingSize) + 1
else
getTotalPageCount = len(PagingString) / PagingSize
end if
End Function

public Sub OutputString
redim Truncate(2,getTotalPageCount())

For tmpI = 0 to getTotalPageCount()
Truncate(0,tmpI)=tmpI
Next

For tmpI = 1 to ubound(Truncate,2)
if Truncate(0,tmpI) = 1 then
Truncate(1,tmpI) = 1
else
Truncate(1,tmpI)=Truncate(1,tmpI - 1) + Truncate(2,tmpI - 1)
end if
Range = DefaultRange
Do while Range < PagingSize
tmpStr=right(mid(PagingString,Truncate(1,tmpI),PagingSize),Range)
For tmpInt=0 to ubound(Splitchar)
if instr(1,tmpStr,Splitchar(tmpInt)) > 0 then
Truncate(2,tmpI) = (PagingSize - (len(tmpStr) - instr(1,tmpStr,Splitchar(tmpInt)))) - 1
exit do
end if
Next
Range = Range + StepRange
Loop
if tmpI = Cint(CurrentPage) then
intStart = Truncate(1,tmpI)
intLen = Truncate(2,tmpI)
end if
next
if Cint(CurrentPage) = getTotalPageCount() then
response.write(mid(PagingString,intStart))'如果当前分页为最后一页,则取剩下的所有字符
else
response.write(mid(PagingString,intStart,intLen))
end if
End Sub
End Class

调用示例

set paging=new autopaging
with paging
.pagingstring=Content
.pagingsize=WordLength
.splitchar=array("<br/>","<BR>","<Br>","<bR>","<p>","<P>")
end with
TotalPage = paging.gettotalpagecount()
Page=request("page")
if Page="" or Cint(Page)<1 then
Page=1
else
if Cint(Page) > TotalPage then
Page = TotalPage
else
if CheckValid(Page)=false or not isnumeric(Page) then
response.write("页码参数非法,请返回!")
response.end
end if
end if
end if
paging.currentpage=Page
paging.outputstring
set paging=nothing
分页页码部分:
<%
if TotalPage > 1 then
For i=1 to TotalPage
if i = Cint(Page) then
response.write("<b>" & i & "</b> ")
else
response.write("<a href=readnews.asp?newsid=" & NewsID & "&bigclassid=" & BigClassID & "&smallclassid=" & SmallClassid & "&specialid=" & SpecialID & "&page=" & i & ">[" & i & "]</a> ")
end if
Next
end if
%>

应用示例
http://www.chceg.com/readnews.asp?newsid=227&bigclassid=9&smallclassid=36&specialid=5

缺陷,输出内容中不可包含table标签。


2006-07-12 16:36
快速回复:[求助]自动将长文章分页输出
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014198 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved