/// <summary>
        /// 页尾内容
        /// </summary>
        /// <returns></returns>
        public string FootContext()
        {
            string strShopUrl = BasePage.ShopRootUrl;

            string strFootContext = Mall_FriendLink.GetString_FootContext();
            if (!string.IsNullOrEmpty(strFootContext))
            {
                Regex regImg = new Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>", RegexOptions.IgnoreCase);
                MatchCollection matches = regImg.Matches(strFootContext);

                int i = 0;

                string[] sUrlList = new string[matches.Count];
                if (matches.Count > 0)
                {
                    // 取得匹配项列表 
                    foreach (Match match in matches)
                    {
                        sUrlList[i++] = match.Groups["imgUrl"].Value;
                    }
                    string strAllEndUrl = strFootContext;
                    for (int iCount = 0; iCount < sUrlList.Length; iCount++)
                    {
                        string strPicUrl = sUrlList[iCount].ToString();
                        if (!strPicUrl.Contains("http://"))
                        {
                            string strEndUrl = strShopUrl + strPicUrl;//链接
                            string strReplaceText = strAllEndUrl.Replace(strPicUrl, strEndUrl);
                            strAllEndUrl = strReplaceText;
                        }
                    }
                    return strAllEndUrl;
                }
                else
                {
                    return strFootContext;
                }
            }
            else
            {
                return strFootContext;
            }
        }

        /// <summary>
        /// 尾部帮助信息广告
        /// </summary>
        /// <returns></returns>
        public string BottomLinkAd()
        {
            string strShopUrl = BasePage.ShopRootUrl;
            string strBottomLinkAd = Mall_FriendLink.GetString_AdContent("尾部帮助信息广告");
            if (!string.IsNullOrEmpty(strBottomLinkAd))
            {
                Regex regImg = new Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>", RegexOptions.IgnoreCase);
                MatchCollection matches = regImg.Matches(strBottomLinkAd);

                int i = 0;

                string[] sUrlList = new string[matches.Count];
                if (matches.Count > 0)
                {
                    // 取得匹配项列表 
                    foreach (Match match in matches)
                    {
                        sUrlList[i++] = match.Groups["imgUrl"].Value;
                    }
                    string strAllEndUrl = strBottomLinkAd;
                    for (int iCount = 0; iCount < sUrlList.Length; iCount++)
                    {
                        string strPicUrl = sUrlList[i - 1].ToString();
                        if (!strPicUrl.Contains("http://"))
                        {
                            string strEndUrl = strShopUrl + strPicUrl;//链接
                            string strReplaceText = strAllEndUrl.Replace(strPicUrl, strEndUrl);
                            strAllEndUrl = strReplaceText;
                        }
                    }
                    return strAllEndUrl;
                }
                else
                {
                    return strBottomLinkAd;
                }
            }
            else
            {
                return strBottomLinkAd;
            }

        }

 

posted on 2013-01-17 10:07  .NET每天一小步  阅读(425)  评论(0)    收藏  举报