📄 labelmass_method1.cs
字号:
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Text;
using System.Text.RegularExpressions;
using NetCMS.Config;
using NetCMS.Model;
namespace NetCMS.Publish
{
public partial class LabelMass
{
public const string newLine = "\r\n";
/// <summary>
/// NT:LabelType=List标签处理函数
/// </summary>
/// <returns></returns>
public string Analyse_List(string Tags, string isConstr)
{
string mystyle = this.Mass_Inserted;
string styleid = Regex.Match(mystyle, @"\[\#NT:StyleID=(?<sid>[^\]]+)]", RegexOptions.Compiled).Groups["sid"].Value.Trim();
if (!styleid.Equals(string.Empty))
{
mystyle = LabelStyle.GetStyleByID(styleid);
}
if (mystyle.Trim().Equals(string.Empty))
return string.Empty;
string str_NewsType = this.GetParamValue("NT:NewsType");
string str_SubNews = this.GetParamValue("NT:SubNews");
string str_ClassID = this.GetParamValue("NT:ClassID");
string str_SpecialID = this.GetParamValue("NT:SpecialID");
int n_Cols;
if (!int.TryParse(this.GetParamValue("NT:Cols"), out n_Cols))
n_Cols = 1;
if (n_Cols < 1)
n_Cols = 1;
string str_Desc = this.GetParamValue("NT:Desc");
string str_DescType = this.GetParamValue("NT:DescType");
string str_isDiv = this.GetParamValue("NT:isDiv");
if (str_isDiv == null)
{
str_isDiv = "true";
}
string str_isPic = this.GetParamValue("NT:isPic");
string str_TitleNumer = this.GetParamValue("NT:TitleNumer");
string str_ContentNumber = this.GetParamValue("NT:ContentNumber");
string str_NaviNumber = this.GetParamValue("NT:NaviNumber");
string str_ClickNumber = this.GetParamValue("NT:ClickNumber");
string str_ShowDateNumer = this.GetParamValue("NT:ShowDateNumer");
string str_isSub = this.GetParamValue("NT:isSub");
string str_ShowNavi = this.GetParamValue("NT:ShowNavi");
string str_NaviCSS = this.GetParamValue("NT:NaviCSS");
string str_ColbgCSS = this.GetParamValue("NT:ColbgCSS");
string str_NaviPic = this.GetParamValue("NT:NaviPic");
string str_ClassStyle = this.GetParamValue("ClassStyle");
string str_HashNaviContent = this.GetParamValue("NT:HashNaviContent");
string SqlFields = " [ID] ";
string SqlCondition = DBConfig.TableNamePrefix + "News Where [isRecyle]=0 And [isLock]=0 And [SiteID]='" + this.Param_SiteID + "'";
if (str_HashNaviContent != null)
{
if (str_HashNaviContent == "false")
{
SqlCondition += " and NaviContent=''";
}
else if (str_HashNaviContent == "true")
{
SqlCondition += " and NaviContent<>''";
}
}
///判断新闻类型
switch (str_NewsType)
{
case "Last":
break;
case "Rec":
SqlCondition += " And NewsProperty like '1%'";
break;
case "Hot":
SqlCondition += " And NewsProperty like '____1%'";
break;
case "Tnews":
SqlCondition += " And NewsProperty like '________1%'";
break;
case "ANN":
SqlCondition += " And NewsProperty like '__________1%'";
break;
case "MarQuee":
SqlCondition += " And NewsProperty like '__1%'";
break;
case "Special":
if (str_SpecialID != null)
{
SqlCondition += " And [NewsID] In (Select [NewsID] From [" + DBConfig.TableNamePrefix + "special_news] Where [SpecialID]='" + str_SpecialID + "')";
}
else if (this.Param_CurrentSpecialID != null)
{
SqlCondition += " And [NewsID] In (Select [NewsID] From [" + DBConfig.TableNamePrefix + "special_news] Where [SpecialID]='" + this.Param_CurrentSpecialID + "')";
}
else
{
return "专题新闻标签参数错误";
}
break;
case "SubNews":
if (this.Param_CurrentClassID != null)
{
return getSubNewsList(mystyle, styleid, n_Cols, str_Desc, str_DescType, str_isDiv, "",
"", str_isPic, str_TitleNumer, str_ContentNumber, str_NaviNumber, str_ClickNumber,
str_ShowDateNumer, str_ShowNavi, str_NaviCSS, str_ColbgCSS, str_NaviPic, str_SubNews, str_ClassStyle);
}
else
{
return "";
}
default:
break;
}
//-------判断是否调用图片
if (str_isPic == "true")
{
SqlCondition += " And [NewsType]=1";
}
else if (str_isPic == "false")
{
SqlCondition += " And ([NewsType]=0 Or [NewsType]=2)";
}
//-------判断是否显示点击率大于多少
if (str_ClickNumber != null && str_ClickNumber != "")
{
SqlCondition += " And [Click] > " + int.Parse(str_ClickNumber);
}
//-------判断显示最近多少天内信息
if (str_ShowDateNumer != null && str_ShowDateNumer != "")
{
SqlCondition += " And DateDiff(Day,[CreatTime] ,Getdate()) < " + int.Parse(str_ShowDateNumer);
}
//判断是否相关新闻
if (Tags != null && Tags != "")
{
string[] arr_Tags = Tags.Split('|');
if (arr_Tags.Length == 1)
SqlCondition += " And ([Tags] Like '%" + Tags + "%' or NewsTitle Like '%" + Tags + "%')";
else
{
SqlCondition += " And (";
for (int i_tags = 0; i_tags < arr_Tags.Length; i_tags++)
{
SqlCondition += "[Tags] Like '%" + arr_Tags[i_tags].ToString() + "%' or NewsTitle Like '%" + arr_Tags[i_tags].ToString() + "%' or ";
}
SqlCondition += " 1=2)";
}
}
//判断是否投稿新闻
if (isConstr == "1")
{
SqlCondition += " And [isConstr]=1";
}
string SqlOrderBy = string.Empty;
if (str_Desc != null && str_Desc.ToLower() == "asc")
{
SqlOrderBy += " asc";
}
else
{
SqlOrderBy += " Desc";
}
switch (str_DescType)
{
case "id":
SqlOrderBy = " Order By id " + SqlOrderBy + "";
break;
case "date":
SqlOrderBy = " Order By [CreatTime] " + SqlOrderBy + ",id " + SqlOrderBy + "";
break;
case "click":
SqlOrderBy = " Order By [Click] " + SqlOrderBy + ",id " + SqlOrderBy + "";
break;
case "pop":
SqlOrderBy = " Order By [OrderID]" + SqlOrderBy + ",id " + SqlOrderBy + "";
break;
case "digg":
SqlOrderBy = " Order By [TopNum]" + SqlOrderBy + ",id " + SqlOrderBy + "";
break;
default:
if (str_NewsType == "Hot")
{
SqlOrderBy = " Order By [Click] " + SqlOrderBy + ",id " + SqlOrderBy + "";
}
else
{
SqlOrderBy = " Order By [CreatTime] " + SqlOrderBy + ",id " + SqlOrderBy + "";
}
break;
}
//}
#region 对栏目进行判断
string str_SubNaviCSS = string.Empty;
bool subTF = false;
if (str_SubNews != null)
{
if (str_SubNews == "true")
{
subTF = true;
if (this.GetParamValue("NT:SubNaviCSS") != null)
{
str_SubNaviCSS = this.GetParamValue("NT:SubNaviCSS");
}
}
}
string Sql = string.Empty;
#region 子类
if (str_NewsType != "Special")
{
if (str_ClassID == "0")
{
if (str_isSub == "true")
{
SqlCondition += " And [ClassID] In (" + getChildClassID(this.Param_CurrentClassID) + ")";
}
//if (this._TemplateType == TempType.Class)
//{
// SqlCondition += " And [ClassID]='" + this.Param_CurrentClassID + "'";
//}
}
else if (str_ClassID != null && str_ClassID != "-1")
{
if (str_isSub == "true")
{
SqlCondition += " And [ClassID] In (" + getChildClassID(str_ClassID) + ")";
}
else
{
SqlCondition += " And [ClassID] ='" + str_ClassID + "'";
}
}
}
Sql = "select top " + Param_Loop + SqlFields + " from " + SqlCondition + SqlOrderBy;
#endregion
#endregion 对栏目进行判断
DataTable dt = CommonData.DalPublish.ExecuteSql(Sql);
if (dt == null || dt.Rows.Count < 1) return string.Empty;
string str_newslist = string.Empty;
int i;
int nTitleNum = 30, nContentNum = 200, nNaviNumber = 200;
if (str_TitleNumer != null && NetCMS.Common.Input.IsInteger(str_TitleNumer))
{
nTitleNum = int.Parse(str_TitleNumer);
}
if (str_ContentNumber != null && NetCMS.Common.Input.IsInteger(str_ContentNumber))
{
nContentNum = int.Parse(str_ContentNumber);
}
if (str_NaviNumber != null && NetCMS.Common.Input.IsInteger(str_NaviNumber))
{
nNaviNumber = int.Parse(str_NaviNumber);
}
int dtcount = dt.Rows.Count;
string[] arr_ColbgCSS = null;
bool b_ColbgCss = false;
if (str_ColbgCSS != null)
{
arr_ColbgCSS = str_ColbgCSS.Split('|');
b_ColbgCss = true;
}
string row = "";
for (i = 0; i < dtcount; i++)
{
str_ColbgCSS = "";
if (b_ColbgCss)
{
if (i % 2 == 0)
str_ColbgCSS = " class=\"" + arr_ColbgCSS[0].ToString() + "\"";
else
str_ColbgCSS = " class=\"" + arr_ColbgCSS[1].ToString() + "\"";
}
if (str_isDiv == "true")
{
if (b_ColbgCss)
{
str_newslist += "<span" + str_ColbgCSS + ">";
}
string s_navi = getNavi(str_ShowNavi, str_NaviCSS, str_NaviPic, i);
str_newslist += Analyse_ReadNews((int)dt.Rows[i][0], nTitleNum, nContentNum, nNaviNumber, mystyle, styleid, 1, 1, 0, s_navi);
//开始调用副新闻
if (subTF)
{
NetCMS.Model.NewsContent sNCI = new NetCMS.Model.NewsContent();
sNCI = this.getNewsInfo((int)dt.Rows[i][0], null);
str_newslist += getSubSTR(sNCI.NewsID, str_SubNaviCSS);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -