Exemplo n.º 1
0
        private void TemplateBanner()
        {
            if (!String.IsNullOrEmpty(Convert.ToString(Settings["bannertype"])))
            {
                intBannerTypeId = Int32.Parse(Convert.ToString(Settings["bannertype"]));
            }
            strBannerGroup = Convert.ToString(Settings["bannergroup"]);
            var       objBanners = new BannerController();
            ArrayList arrBanners = objBanners.LoadBanners(intPortalId, ModuleId, intBannerTypeId, strBannerGroup, intBanners);

            string strHeader, strContent, strContentText, strFooter;

            if (!String.IsNullOrEmpty(Convert.ToString(Settings["bannerheader"])))
            {
                strHeader = Convert.ToString(Settings["bannerheader"]);
            }
            else
            {
                strHeader = "<div>";
            }

            if (!String.IsNullOrEmpty(Convert.ToString(Settings["bannercontent"])))
            {
                strContent = Convert.ToString(Settings["bannercontent"]);
            }
            else
            {
                strContent = "<a href=[LINKBANNER] target='_blank' rel='nofollow'><img src = [URLIMAGE] alt = [ALTERNATE] /></a > ";
            }
            if (!String.IsNullOrEmpty(Convert.ToString(Settings["bannertext"])))
            {
                strContentText = Convert.ToString(Settings["bannertext"]);
            }
            else
            {
                strContentText = "<a href=[LINKBANNER] target='_blank' rel='nofollow'><u>[BANNERNAME]</u></a><br /><span >[ALTERNATE]</span><br />";
            }
            if (!String.IsNullOrEmpty(Convert.ToString(Settings["bannerfooter"])))
            {
                strFooter = Convert.ToString(Settings["bannerfooter"]);
            }
            else
            {
                strFooter = "</div>";
            }
            StringBuilder strHtml = new StringBuilder(2000);

            strHtml.Append(strHeader.Trim());


            foreach (object objbanner in arrBanners)
            {
                BannerInfo banner = (BannerInfo)objbanner;

                string linkBanner  = objBanners.FormatURL(banner.VendorId, banner.BannerId, banner.URL, Convert.ToString(Settings["bannerclickthroughurl"]));
                string strContent2 = "";
                switch (banner.BannerTypeId)
                {
                case (int)BannerType.Text:
                    strContent2 = strContentText;
                    strContent2 = strContent2.Replace("[LINKBANNER]", linkBanner);
                    strContent2 = strContent2.Replace("[BANNERNAME]", banner.BannerName);
                    strContent2 = strContent2.Replace("[ALTERNATE]", banner.Description);

                    break;

                case (int)BannerType.Banner:
                    strContent2 = strContent;
                    strContent2 = strContent2.Replace("[BANNERNAME]", banner.BannerName);
                    strContent2 = strContent2.Replace("[LINKBANNER]", linkBanner);
                    strContent2 = strContent2.Replace("[URLIMAGE]", PortalSettings.HomeDirectory + banner.ImageFile);
                    strContent2 = strContent2.Replace("[ALTERNATE]", banner.Description);
                    break;
                }
                strHtml.Append(strContent2.Trim());
            }



            strHtml.Append(strFooter.Trim());

            phBanner.Controls.Add(new LiteralControl(Convert.ToString(strHtml)));
        }