日期:2014-05-18 浏览次数:20532 次
/// <summary>
/// 生成栏目静态页面
/// </summary>
/// <param name="info">栏目名称,如果要生成首页,为null</param>
/// <returns></returns>
public bool GerChannelHtmlForEach(ChannelInfo info)
{
string strShortening, pattern;
int countMatch;
string strContent = string.Empty;
string strTitle = string.Empty;
if (info == null||info.ExtUrl.Length < 1)
{
TemplateInfo tinfo = new TemplateInfo();
BTemplate temp = new BTemplate();
if (info == null)
{
tinfo.TName = "首页模板";
strTitle = Config.WebSiteTitle + " - 首页";
}else
{
/*获取模板内容*/
tinfo.Tid = info.TemplateID;
strTitle = GetTitleStringForPage(info);
}
strContent += GetHeadHTML();
strContent += temp.GetTempInfo(tinfo).TContent;
strContent += GetFooterHTML();
/*页面标题*/
pattern = @"\{\$WUYOUPAGETITLE\$\}";
countMatch = GetMatchCount(pattern, strContent);
for (int index = 0; index < countMatch; index++)
{
strContent = GetMatchString(pattern, strContent, strTitle);
}
Channel channel = new Channel();
ChannelInfo pinfo = new ChannelInfo(); ;
if(info != null)
{
pinfo = info;
}
DataTable dtChannel = channel.GetChannelList(pinfo);
foreach (DataRow dr in dtChannel.Rows)
{
ChannelInfo theinfo = new ChannelInfo();
theinfo.Cid = new Guid(dr["Cid"].ToString());
theinfo = channel.GetChannelInfo(theinfo);
/************************************************************************/
/* 声明,标签以List结尾的一般都需要加参数 ",数字"一个标点逗号和一个数字(英语数字)
/************************************************************************/
//{$WUYOUXWDTList,3$}
//生成文字新闻
strShortening = theinfo.ChannelShortening.ToString().ToUpper();
pattern = @"\{\$WUYOU" + strShortening + @"List,(?<ListCount>\d*)\$\}";
strContent = GetReplaceString(strContent, pattern, theinfo);
//{$WUYOUIMGXWDT$}
//生成图片新闻
pattern = @"\{\$WUYOUIMG" + strShortening + @"List,(?<ListCount>\d*)\$\}";
strContent = GetMacthIMGString(pattern, strContent, theinfo);
//{$WUYOUIMGXWDTTopList,4$}
//生成推荐图片新闻
pattern = @"\{\$WUYOUIMG" + strShortening + @"TopList,(?<ListCount>\d*)\$\}";
strContent = GetMacthIMGString(pattern, strContent, theinfo,true);
//子栏目下的图片和文字新闻
ChannelInfo ainfo = new ChannelInfo();
ainfo.ParentID = theinfo.Cid;
DataTable subChannel = new Channel().GetChannelList(ainfo);
if (subChannel.Rows.Count > 0)
{
foreach (DataRow dri in subChannel.Rows)