温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:风讯dotNETCMSv1.0免安装版源码
当前文件:
FooSunCMS/Foosun.CMS/Collect/PageList.cs[7K,2009-6-12 11:42:42],打开代码结构图
FooSunCMS/Foosun.CMS/Collect/PageList.cs[7K,2009-6-12 11:42:42],打开代码结构图1//=========================================================== 2
//== (c)2007 Foosun Inc. by dotNETCMS 1.0 == 3
//== Forum:bbs.foosun.net == 4
//== website:www.foosun.net == 5
//== Address:NO.109 HuiMin ST.,Chengdu ,China == 6
//== TEL:86-28-85098980/66026180 == 7
//== qq:655071,MSN:ikoolls@gmail.com == 8
//== Code By JiangDong == 9
//=========================================================== 10
using System; 11
using System.Collections.Generic; 12
using System.Text; 13
using System.Text.RegularExpressions; 14
using System.Collections; 15
16
namespace Foosun.CMS.Collect 17
{ 18
public class PageList : Page 19
{ 20
private string _List; 21
private ArrayList _NewsUrlList; 22
private string listrule = ""; 23
private string linkrule = ""; 24
public string RuleOfList 25
{ 26
set { listrule = value; } 27
} 28
public string RuleOfLink 29
{ 30
set { linkrule = value; } 31
} 32
public PageList(string url) : base(url) { } 33
public PageList(string url, string encode) : base(url, encode) { } 34
public void FigureList() 35
{ 36
if (listrule == null || listrule.IndexOf("[列表内容]") < 0) 37
throw new Exception("列表内容规则没有设定"); 38
_List = ""; 39
if (_Doc.Equals("")) 40
{ 41
if (!this.Fetch()) 42
throw new Exception(_Error); 43
} 44
Match m = Utility.GetMatch(_Doc, listrule, "[列表内容]"); 45
while (m.Success) 46
{ 47
_List += m.Groups["TARGET"].Value; 48
m = m.NextMatch(); 49
} 50
} 51
public string List 52
{ 53
get 54
{ 55
return _List; 56
} 57
set 58
{ 59
_List = value; 60
} 61
} 62
public void FigureNewsUrls() 63
{ 64
if (linkrule == null || linkrule.IndexOf("[列表URL]") < 0) 65
throw new Exception("列表URL规则没有设定"); 66
_NewsUrlList = new ArrayList(); 67
_NewsUrlList.Clear(); 68
Match m = Utility.GetMatchUrl(_List, linkrule, "[列表URL]"); 69
while (m.Success) 70
{ 71
_NewsUrlList.Add(Utility.StickUrl(_Url, m.Groups["TARGET"].Value)); 72
m = m.NextMatch(); 73
} 74
} 75
public string[] NewsUrl 76
{ 77
get 78
{ 79
if (_NewsUrlList == null || _NewsUrlList.Count < 1) 80
return null; 81
else 82
return (string[])_NewsUrlList.ToArray(typeof(string)); 83
} 84
} 85
public string[] Pagination(string profile, int total) 86
{ 87
string[] result = new string[total]; 88
GetOtherPage(this._Url, _Doc, profile, ref result, total, 0); 89
return result; 90
} 91
private void GetOtherPage(string otherurl, string PageDoc, string pattern, ref string[] r, int total, int n) 92
{ 93
Match m = Utility.GetMatchUrl(PageDoc, pattern, "[其他页面]"); 94
if (m.Success) 95
{ 96
string obturl = Utility.StickUrl(otherurl, m.Groups["TARGET"].Value); 97
if (!obturl.Trim().Equals(otherurl.Trim())) 98
{ 99
PageList pglst = new PageList(obturl, _Encode); 100
ArrayList arraylist = GetListUrl(pglst); 101
if (arraylist != null && arraylist.Count > 0) 102
{ 103
int len = arraylist.Count; 104
int j = len + n; 105
if (j < total) 106
arraylist.CopyTo(0, r, n, len); 107
else 108
{ 109
arraylist.CopyTo(0, r, n, total - n); 110
return; 111
} 112
n = j; 113
} 114
if (n < total) 115
{ 116
GetOtherPage(obturl, pglst._Doc, pattern, ref r, total, n); 117
} 118
} 119
} 120
} 121
public string[] SinglePagination(string profile, int total) 122
{ 123
string[] result = new string[total]; 124
int n = 0; 125
Match m = Utility.GetMatchUrl(_Doc, profile, "[其他页面]"); 126
while (m.Success) 127
{ 128
if (n >= total) 129
break; 130
string otherurl = Utility.StickUrl(_Url, m.Groups["TARGET"].Value); 131
if (!otherurl.Trim().Equals(this._Url.Trim())) 132
{ 133
PageList pglst = new PageList(otherurl, _Encode); 134
ArrayList arraylist = GetListUrl(pglst); 135
if (arraylist != null && arraylist.Count > 0) 136
{ 137
int len = arraylist.Count; 138
int j = len + n; 139
if (j < total) 140
arraylist.CopyTo(0, result, n, len); 141
else 142
{ 143
arraylist.CopyTo(0, result, n, total - n); 144
break; 145
} 146
n = j; 147
} 148
} 149
m = m.NextMatch(); 150
} 151
return result; 152
} 153
public string[] IndexPagination(string profile, int min, int max, int total) 154
{ 155
string[] result = new string[total]; 156
int n = 0; 157
for (int i = min; i <= max; i++) 158
{ 159
if (n >= total) 160
break; 161
string otherurl = profile.Replace("[页码]", i.ToString()); 162
if (!otherurl.Trim().Equals(this._Url.Trim())) 163
{ 164
PageList pglst = new PageList(otherurl, _Encode); 165
ArrayList arraylist = GetListUrl(pglst); 166
if (arraylist != null && arraylist.Count > 0) 167
{ 168
int len = arraylist.Count; 169
int j = len + n; 170
if (j < total) 171
arraylist.CopyTo(0, result, n, len); 172
else 173
{ 174
arraylist.CopyTo(0, result, n, total - n); 175
break; 176
} 177
n = j; 178
} 179
} 180
} 181
return result; 182
} 183
184
private ArrayList GetListUrl(PageList pl) 185
{ 186
if (pl == null) 187
return null; 188
pl.linkrule = this.linkrule; 189
pl.listrule = this.listrule; 190
if (!pl.Fetch()) 191
{ 192
return null; 193
} 194
pl.FigureList(); 195
pl.FigureNewsUrls(); 196
return pl._NewsUrlList; 197
} 198
} 199
} 200






}
}