NetCMS修改之四:扩展轮换幻灯片属性(NorFilt),具有导读显示

    NetCMS有两种幻灯片显示方式:Flash幻灯片和轮换幻灯片。Flash幻灯片是通过将图片新闻中的图片合成Flash后再在页面上显示。轮换幻灯片则是使用脚本进行控制(准确地说,是使用VBScript)。

    其实,这两种显示形式差不多,只不过Flash幻灯片是通过Flash实现图片的过渡效果,而轮换幻灯片是利用IE提供的Filter属性实现图片过渡效果的。

    鉴于轮换幻灯片是通过脚本控制Img标记的Src属性及Div标记的Innerhtml属性来实现图片切换和标题切换的。因此就想实现在图片右边显示新闻导读,效果如下:

    轮换幻灯片的标签定义如下:

    [NT:Loop,NT:SiteID=0,NT:LabelType=NorFilt,NT:Number=10,NT:ClassID=0,NT:isSub=true,NT:TitleNumer=25,NT:WCSS=css,NT:ShowTitle=true,
NT:FlashSize=参数1|参数2,NT:Target=_blank][/NT:Loop]

    各参数的意义请参看NetCMS官方网站对此标签的说明(http://www.aspxcms.com/help/label/start.html#NorFilt)。

    现给其增加以下参数:

    NT:HashNaviContent:true或flase,是否显示导读。如果不显示导读,则与原来效果一致。

    NT:NaviContentWidth:导读部分的宽度(px)

    NT:NaviTitleCSS:导读部分标题的CSS样式

    NT:NaviCntCSS:导读部分内容的CSS样式

 

    对NorFilt标签的处理,是由NetCMS.Publish.LabelMass类中的Analyse_NorFilt()方法(NetCMS.Publish/Label/LabelMass_Method4.cs)进行处理的。现将改动后的Analyse_NorFilt()方法提供如下,增加或修改部分均做了注释:

        /// <summary>
        /// 轮换幻灯片
        /// </summary>
        /// <returns></returns>
        public string Analyse_NorFilt()
        {
            string str_NorFilt = "";
            string str_ClassID = this.GetParamValue("NT:ClassID");
            string str_isSub = this.GetParamValue("NT:isSub");
            string str_TitleNumer = this.GetParamValue("NT:TitleNumer");
            string str_WCSS = this.GetParamValue("NT:WCSS");
            string str_ShowTitle = this.GetParamValue("NT:ShowTitle");
            string str_FlashSize = this.GetParamValue("NT:FlashSize");
            string str_Target = this.GetParamValue("NT:Target");

            // 以下由Whitewin于2009-4-21添加
            // 给NorFilt幻灯新闻增加右部的导读。
            string str_HashNaviContent = this.GetParamValue("NT:HashNaviContent");//获取导读标记
            string str_NaviContentWidth = this.GetParamValue("NT:NaviContentWidth"); //获取导读部分宽度
            string str_NaviTitleCSS = this.GetParamValue("NT:NaviTitleCSS");   //获取导读部分标题样式
            string str_NaviCntCSS = this.GetParamValue("NT:NaviCntCSS");   // 获取导读部分内容文本样式
            // --------------------------------------------------------------------------------

            string SqlCondition = " Where [isRecyle]=0 And [isLock]=0 And [SiteID]='" + this.Param_SiteID + "' And [NewsType]=1 And SubString([NewsProperty],7,1)='1'";
            string SqlOrderBy = " Order By [CreatTime] Desc";

            #region 对栏目进行判断
            DataTable dt = null;
            string Sql = string.Empty;
            if (str_ClassID == null || str_ClassID == "-1")
            {
                if (this._TemplateType == TempType.Class)
                {
                    if (str_isSub == "true")
                        SqlCondition += " And [ClassID] In (" + getChildClassID(this.Param_CurrentClassID) + ")";
                    Sql = "select top " + Param_Loop + " * from [" + DBConfig.TableNamePrefix + "News] " + SqlCondition + " And ClassID='" + this.Param_CurrentClassID + "' " + SqlOrderBy;
                }
                else
                {
                    Sql = "select top " + Param_Loop + " * from [" + DBConfig.TableNamePrefix + "News] " + SqlCondition + SqlOrderBy;
                }
            }
            else if (str_ClassID == "0")
            {
                Sql = "select top " + Param_Loop + " * from [" + DBConfig.TableNamePrefix + "News]" + SqlCondition + SqlOrderBy;
            }
            else
            {
                if (str_isSub == "true")
                    SqlCondition += " And [ClassID] In (" + getChildClassID(str_ClassID) + ")";
                Sql = "select top " + Param_Loop + " * from [" + DBConfig.TableNamePrefix + "News]" + SqlCondition + SqlOrderBy;
            }
            dt = CommonData.DalPublish.ExecuteSql(Sql);
            #endregion 对栏目进行判断

            if (dt != null)
            {
                if (dt.Rows.Count < 2)
                {
                    str_NorFilt = "至少需要两条幻灯新闻才能正确显示幻灯效果";
                    return str_NorFilt;
                }
                string str_FlashWidth = " width='200'";
                string str_FlashHeight = " height='100'";

                if (str_FlashSize != null)
                {
                    string[] arr_FlashSize = str_FlashSize.Split('|');
                    str_FlashWidth = " width='" + arr_FlashSize[0].ToString() + "'";
                    str_FlashHeight = " height='" + arr_FlashSize[1].ToString() + "'";
                }
                if (str_WCSS != null)
                    str_WCSS = " class='" + str_WCSS + "'";
                if (str_Target != null)
                    str_Target = " target='" + str_Target + "'";

                string str_Imgstr = "";     // 图片链接
                string str_Linkstr = "";    // 新闻链接
                string str_Txtstr = "";     // 标题链接
                string str_FirstTxt = "";   // 第一次显示时的新闻标题

                // 以下由Whitewin于2009-4-21添加
                // 给NorFilt幻灯新闻增加右部的导读。
                string str_NaviCnt = "";    // 导读新闻内容
                string str_FirstNaviCnt = "";  // 第一次显示时的导读新闻内容
                string str_NaviTitle = "";  // 导读新闻标题
                string str_FirstNaviTitle = ""; // 第一次显示时的导读新闻标题
                if (str_NaviTitleCSS != null)
                    str_NaviTitleCSS = " class='" + str_NaviTitleCSS + "'";
                if (str_NaviCntCSS !=null)
                    str_NaviCntCSS = " class='" + str_NaviCntCSS + "'";
                // ------------------------------------------------------------

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    PubClassInfo ci = CommonData.GetClassById(dt.Rows[i]["ClassID"].ToString());

                    string str_PicUrl = RelpacePicPath(dt.Rows[i]["PicURL"].ToString());
                    string str_Link = getNewsURL(dt.Rows[i]["isDelPoint"].ToString(), dt.Rows[i]["NewsID"].ToString(), dt.Rows[i]["SavePath"].ToString(), ci.SavePath + "/" + ci.SaveClassframe, dt.Rows[i]["FileName"].ToString(), dt.Rows[i]["FileEXName"].ToString());
                    string str_Txt = dt.Rows[i]["NewsTitle"].ToString();
                    string str_NaviCntTxt = dt.Rows[i]["NaviContent"].ToString();

                    // 以下由Whitewin于2009-4-21添加
                    // 给NorFilt幻灯新闻增加右部的导读。
                    // 获取完整新闻标题,用作导读部分标题的提示
                    string uTitle = str_Txt;
                    // -----------------------------------------

                    if (str_TitleNumer != null)
                        str_Txt = NetCMS.Common.Input.GetSubString(str_Txt, Convert.ToInt32(str_TitleNumer));

                    if (str_PicUrl != "" && str_PicUrl != null)
                    {
                        if (str_Imgstr == "")
                        {
                            str_Imgstr += str_PicUrl;
                            str_Linkstr += str_Link;
                            str_Txtstr += "<a href='" + str_Link + "' " + str_Target + " " + str_WCSS + ">" + str_Txt + "</a>";
                            str_FirstTxt = str_Txtstr;
                            // 以下由Whitewin于2009-4-21添加
                            // 给NorFilt幻灯新闻增加右部的导读。
                            // 处理导读部分新闻标题
                            str_NaviTitle = "<a href='" + str_Link + "' title='" + uTitle +"' " + str_Target + " " + str_NaviTitleCSS + ">" + str_Txt + "</a>";
                            str_FirstNaviTitle = str_NaviTitle;
                            str_NaviCnt = str_NaviCntTxt + "<a href='" + str_Link + "' " + str_Target + " " + ">" + "[详情]" + "</a>";   //处理导读新闻内容
                            str_FirstNaviCnt = str_NaviCnt;
                            // --------------------------------------------------------------------------------

                        }
                        else
                        {
                            str_Imgstr += "," + str_PicUrl;
                            str_Linkstr += "," + str_Link;
                            str_Txtstr += ",<a href='" + str_Link + "' " + str_Target + " " + str_WCSS + ">" + str_Txt + "</a>";
                            // 以下由Whitewin于2009-4-21添加
                            // 给NorFilt幻灯新闻增加右部的导读。
                            // 处理导读部分新闻标题
                            str_NaviTitle += ",<a href='" + "' title='" + uTitle + "' " + str_Target + " " + str_NaviTitleCSS + ">" + str_Txt + "</a>";
                            str_NaviCnt += "<#NaviContent>" + str_NaviCntTxt + "<a href='" + str_Link + "' " + str_Target + " " + ">" + "[详情]" + "</a>";    //处理导读新闻内容
                            // --------------------------------------------------------------------------------
                        }
                    }
                }
                str_NorFilt += "<script language=/"vbscript/">" + newLine;

                // 以下由Whitewin于2009-4-21修改
                // 给NorFilt幻灯新闻增加右部的导读。原句为:
                // str_NorFilt += "Dim FileList,FileListArr,TxtList,TxtListArr,LinkList,LinkArr" + newLine;
                // 增加导读内容数组的定义.注意导读内容中不能出现<#NaviContent>
                str_NorFilt += "Dim FileList,FileListArr,TxtList,TxtListArr,LinkList,LinkArr,NaviTitleList,NaviTitleArr,NaviCntList,NaviCntArr" + newLine;
                // --------------------------------------------------------------------------------

                str_NorFilt += "FileList = /"" + str_Imgstr + "/"" + newLine;
                str_NorFilt += "LinkList = /"" + str_Linkstr + "/"" + newLine;
                str_NorFilt += "TxtList = /"" + str_Txtstr + "/"" + newLine;

                // 以下由Whitewin于2009-4-21添加
                // 给NorFilt幻灯新闻增加右部的导读。
                // 处理导读新闻
                str_NorFilt += "NaviCntList = /"" + str_NaviCnt + "/"" + newLine;
                str_NorFilt += "NaviCntArr = Split(NaviCntList,/"<#NaviContent>/")" + newLine;
                str_NorFilt += "NaviTitleList = /"" + str_NaviTitle + "/"" + newLine;
                str_NorFilt += "NaviTitleArr = Split(NaviTitleList,/",/")" + newLine;
                // --------------------------------------------------------------------------------

                str_NorFilt += "FileListArr = Split(FileList,/",/")" + newLine;
                str_NorFilt += "LinkArr = Split(LinkList,/",/")" + newLine;
                str_NorFilt += "TxtListArr = Split(TxtList,/",/")" + newLine;
                str_NorFilt += "Dim CanPlay" + newLine;
                str_NorFilt += "CanPlay = CInt(Split(Split(navigator.appVersion,/";/")(1),/" /")(2))>5" + newLine;
                str_NorFilt += "Dim FilterStr" + newLine;
                str_NorFilt += "FilterStr = /"RevealTrans(duration=2,transition=23)/"" + newLine;
                str_NorFilt += "FilterStr = FilterStr + /";BlendTrans(duration=2)/"" + newLine;
                str_NorFilt += "If CanPlay Then" + newLine;
                str_NorFilt += "FilterStr = FilterStr + /";progid:DXImageTransform.Microsoft.Fade(duration=2,overlap=0)/"" + newLine;
                str_NorFilt += "FilterStr = FilterStr + /";progid:DXImageTransform.Microsoft.Wipe(duration=3,gradientsize=0.25,motion=reverse)/"" + newLine;
                str_NorFilt += "Else" + newLine;
                str_NorFilt += "Msgbox /"幻灯片播放具有多种动态图片切换效果,但此功能需要您的浏览器为IE5.5或以上版本,否则您将只能看到部分的切换效果。/",64" + newLine;
                str_NorFilt += "End If" + newLine;
                str_NorFilt += "Dim FilterArr" + newLine;
                str_NorFilt += "FilterArr = Split(FilterStr,/";/")" + newLine;
                str_NorFilt += "Dim PlayImg_M" + newLine;
                str_NorFilt += "PlayImg_M = 5 * 1000  " + newLine;

                // 以下由Whitewin于2009-4-21添加
                // 给NorFilt幻灯新闻增加右部的导读。
                // 有导读时,轮换时间延长到原来的2倍
                if (str_HashNaviContent == "true")
                    str_NorFilt += "PlayImg_M = 2 * PlayImg_M  " + newLine;
                // --------------------------------------------------------------------------------

                str_NorFilt += "Dim I" + newLine;

                str_NorFilt += "I = 1" + newLine;
                str_NorFilt += "Sub ChangeImg" + newLine;
                str_NorFilt += "Do While FileListArr(I)=/"/"" + newLine;
                str_NorFilt += "I = I + 1" + newLine;
                str_NorFilt += "If I>UBound(FileListArr) Then I = 0" + newLine;
                str_NorFilt += "Loop" + newLine;
                str_NorFilt += "Dim J" + newLine;
                str_NorFilt += "If I>UBound(FileListArr) Then I = 0" + newLine;
                str_NorFilt += "Randomize" + newLine;
                str_NorFilt += "J = Int(Rnd * (UBound(FilterArr)+1))" + newLine;
                str_NorFilt += "Img.style.filter = FilterArr(J)" + newLine;
                str_NorFilt += "Img.filters(0).Apply" + newLine;
                str_NorFilt += "Img.Src = FileListArr(I)" + newLine;
                str_NorFilt += "Img.filters(0).play" + newLine;
                str_NorFilt += "Link.Href = LinkArr(I)" + newLine;
                if (str_ShowTitle == "true")
                {
                    str_NorFilt += "Txt.filters(0).Apply" + newLine;
                    str_NorFilt += "Txt.innerHTML = TxtListArr(I)" + newLine;
                    str_NorFilt += "Txt.filters(0).play" + newLine;
                }

                // 以下由Whitewin于2009-4-21添加
                // 给NorFilt幻灯新闻增加右部的导读。
                if (str_HashNaviContent == "true")
                {
                    str_NorFilt += "NaviTitle.filters(0).Apply" + newLine;
                    str_NorFilt += "NaviTitle.innerHTML = NaviTitleArr(I)" + newLine;
                    str_NorFilt += "NaviTitle.filters(0).play" + newLine;

                    str_NorFilt += "NaviCnt.filters(0).Apply"+newLine;
                    str_NorFilt += "NaviCnt.innerHTML = NaviCntArr(I)"+newLine;
                    str_NorFilt += "NaviCnt.filters(0).play" + newLine;
                }
                // --------------------------------------------------------------------------------

                str_NorFilt += "I = I + 1" + newLine;
                str_NorFilt += "If I>UBound(FileListArr) Then I = 0" + newLine;
                str_NorFilt += "TempImg.Src = FileListArr(I)" + newLine;
                str_NorFilt += "TempLink.Href = LinkArr(I)" + newLine;
                str_NorFilt += "SetTimeout /"ChangeImg/", PlayImg_M,/"VBScript/"" + newLine;
                str_NorFilt += "End Sub" + newLine;
                str_NorFilt += "</SCRIPT>" + newLine;
                str_NorFilt += "<TABLE WIDTH=/"100%/" height=/"100%/" BORDER=/"0/" CELLSPACING=/"0/" CELLPADDING=/"0/">" + newLine;
                str_NorFilt += "<TR ID=/"NoScript/">" + newLine;
                str_NorFilt += "<TD Align=/"Center/" Style=/"Color:White/">对不起,图片浏览功能需脚本支持,但您的浏览器已经设置了禁止脚本运行。请您在浏览器设置中调整有关安全选项。</TD>" + newLine;
                str_NorFilt += "</TR>" + newLine;

                // 以下由Whitewin于2009-4-21添加
                // 给NorFilt幻灯新闻增加右部的导读。
                // 将原有图片部分包含在表格中
                if (str_HashNaviContent == "true")
                {
                    str_NorFilt += "<tr><td><table WIDTH=/"100%/" height=/"100%/" BORDER=/"0/" CELLSPACING=/"0/" CELLPADDING=/"0/">" + newLine;
                    str_NorFilt += "<tr><td width=/"200px/"><table>" + newLine;
                }
                // --------------------------------------------------------------------------------

                str_NorFilt += "<TR Style=/"Display:none/" ID=/"CanRunScript/"><TD HEIGHT=/"100%/" Align=/"Center/" vAlign=/"Center/"><a id=/"Link/" " + str_Target + "><Img ID=/"Img/" " + str_FlashWidth + " " + str_FlashHeight + " Border=/"0/" ></a>" + newLine;
                str_NorFilt += "</TD></TR><TR Style=/"Display:none/"><TD><a id=TempLink ><Img ID=/"TempImg/" Border=/"0/"></a></TD></TR>" + newLine;
                if (str_ShowTitle == "true")
                {
                    str_NorFilt += "<TR><TD HEIGHT=/"100%/" Align=/"Center/" vAlign=/"Top/">" + newLine;
                    str_NorFilt += "<div ID=/"Txt/" style=/"PADDING-LEFT: 5px; Z-INDEX: 1; FILTER: progid:DXImageTransform.Microsoft.Fade(duration=1,overlap=0); POSITION:/" >" + str_FirstTxt + "</div>" + newLine;
                    str_NorFilt += "</TD></TR>" + newLine;
                }

                // 以下由Whitewin于2009-4-21添加
                // 给NorFilt幻灯新闻增加右部的导读。
                // 添加导读部分
                if (str_HashNaviContent == "true")
                {
                    str_NorFilt += "</table></td><td valign=/"top/"><table WIDTH=/""+str_NaviContentWidth+"/" height=/"100%/" BORDER=/"0/" CELLSPACING=/"0/" CELLPADDING=/"0/" >" + newLine;
                    str_NorFilt += "<tr><td><div id=/"NaviTitle/" style=/"PADDING-LEFT: 5px; Z-INDEX: 1;  text-align:center; FILTER: progid:DXImageTransform.Microsoft.Fade(duration=1,overlap=0); POSITION:/">" + str_FirstNaviTitle + "</div></td></tr>" + newLine;
                    str_NorFilt += "<tr><td>&nbsp;</td></tr>";
                    str_NorFilt += "<tr><td><div id=/"NaviCnt/" style=/"PADDING-LEFT: 5px; Z-INDEX: 1; FILTER: progid:DXImageTransform.Microsoft.Fade(duration=1,overlap=0); POSITION:/"" + str_NaviCntCSS + ">" + str_FirstNaviCnt + "</div></td></tr></table></td></tr></table></td></tr>" + newLine;
                }
                // --------------------------------------------------------------------------------

                str_NorFilt += "</TABLE>" + newLine;
                str_NorFilt += "<Script Language=/"VBScript/">" + newLine;
                str_NorFilt += "NoScript.Style.Display = /"none/"" + newLine;
                str_NorFilt += "CanRunScript.Style.Display = /"/"" + newLine;
                str_NorFilt += "Img.Src = FileListArr(0)" + newLine;
                str_NorFilt += "Link.Href = LinkArr(0)" + newLine;
                str_NorFilt += "SetTimeout /"ChangeImg/", PlayImg_M,/"VBScript/"" + newLine;
                str_NorFilt += "</Script>" + newLine;

                dt.Clear(); dt.Dispose();
            }
            else
            {
                str_NorFilt = "没有幻灯片";
            }
            return str_NorFilt;
        }

    对NetCMS.Publish项目和NetCMS.Web重新生成后,将NetCMS.Web/Bin文件夹下的NetCMS.Publish.Dll文件复制到Web服务器对应的Bin文件夹下,替换掉原来的NetCMS.Publish.Dll文件即可。

阅读更多

没有更多推荐了,返回首页