Esempio n. 1
0
        /// <summary>
        /// The Page_Load event handler on this User Control is used to
        /// obtain a DataReader of banner information from the Banners
        /// table, and then databind the results to a templated DataList
        /// server control.  It uses the DotNetNuke.BannerDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks></remarks>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //exit without displaying banners to crawlers
            if (Request.Browser.Crawler)
            {
                return;
            }
            try
            {
                int    intPortalId     = 0;
                int    intBannerTypeId = 0;
                string strBannerGroup;
                int    intBanners = 0;

                //banner parameters
                switch (Convert.ToString(Settings["bannersource"]))
                {
                case "L":     //local
                case "":
                    intPortalId = PortalId;
                    break;

                case "G":     //global
                    intPortalId = Null.NullInteger;
                    break;
                }
                if (!String.IsNullOrEmpty(Convert.ToString(Settings["bannertype"])))
                {
                    intBannerTypeId = Int32.Parse(Convert.ToString(Settings["bannertype"]));
                }
                strBannerGroup = Convert.ToString(Settings["bannergroup"]);
                if (!String.IsNullOrEmpty(Convert.ToString(Settings["bannercount"])))
                {
                    intBanners = Int32.Parse(Convert.ToString(Settings["bannercount"]));
                }
                if (!String.IsNullOrEmpty(Convert.ToString(Settings["padding"])))
                {
                    lstBanners.CellPadding = Int32.Parse(Convert.ToString(Settings["padding"]));
                }

                //load banners
                if (intBanners != 0)
                {
                    var objBanners = new BannerController();
                    lstBanners.DataSource = objBanners.LoadBanners(intPortalId, ModuleId, intBannerTypeId, strBannerGroup, intBanners);
                    lstBanners.DataBind();
                }

                //set banner display characteristics
                if (lstBanners.Items.Count != 0)
                {
                    //container attributes
                    lstBanners.RepeatLayout = RepeatLayout.Table;
                    if (!String.IsNullOrEmpty(Convert.ToString(Settings["orientation"])))
                    {
                        switch (Convert.ToString(Settings["orientation"]))
                        {
                        case "H":
                            lstBanners.RepeatDirection = RepeatDirection.Horizontal;
                            break;

                        case "V":
                            lstBanners.RepeatDirection = RepeatDirection.Vertical;
                            break;
                        }
                    }
                    else
                    {
                        lstBanners.RepeatDirection = RepeatDirection.Vertical;
                    }
                    if (!String.IsNullOrEmpty(Convert.ToString(Settings["border"])))
                    {
                        lstBanners.ItemStyle.BorderWidth = Unit.Parse(Convert.ToString(Settings["border"]) + "px");
                    }
                    if (!String.IsNullOrEmpty(Convert.ToString(Settings["bordercolor"])))
                    {
                        var objColorConverter = new ColorConverter();
                        lstBanners.ItemStyle.BorderColor = (Color)objColorConverter.ConvertFrom(Convert.ToString(Settings["bordercolor"]));
                    }

                    //item attributes
                    if (!String.IsNullOrEmpty(Convert.ToString(Settings["rowheight"])))
                    {
                        lstBanners.ItemStyle.Height = Unit.Parse(Convert.ToString(Settings["rowheight"]) + "px");
                    }
                    if (!String.IsNullOrEmpty(Convert.ToString(Settings["colwidth"])))
                    {
                        lstBanners.ItemStyle.Width = Unit.Parse(Convert.ToString(Settings["colwidth"]) + "px");
                    }
                }
                else
                {
                    lstBanners.Visible = false;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 2
0
        // The Page_Load event handler on this User Control is used to
        // obtain a DataReader of banner information from the Banners
        // table, and then databind the results to a templated DataList
        // server control.  It uses the DotNetNuke.BannerDB()
        // data component to encapsulate all data functionality.
        protected void Page_Load(Object sender, EventArgs e)
        {
            try
            {
                int    intPortalId     = 0;
                int    intBannerTypeId = 0;
                string strBannerGroup;
                int    intBanners = 0;

                // banner parameters
                switch (Convert.ToString(Settings["bannersource"]))
                {
                case "L":     // local
                    intPortalId = PortalId;
                    break;

                case "":

                    intPortalId = PortalId;
                    break;

                case "G":     // global

                    intPortalId = Null.NullInteger;
                    break;
                }
                if (Convert.ToString(Settings["bannertype"]) != "")
                {
                    intBannerTypeId = int.Parse(Convert.ToString(Settings["bannertype"]));
                }
                strBannerGroup = Convert.ToString(Settings["bannergroup"]);
                if (Convert.ToString(Settings["bannercount"]) != "")
                {
                    intBanners = int.Parse(Convert.ToString(Settings["bannercount"]));
                }
                if (Convert.ToString(Settings["padding"]) != "")
                {
                    lstBanners.CellPadding = int.Parse(Convert.ToString(Settings["padding"]));
                }

                // load banners
                if (intBanners != 0)
                {
                    BannerController objBanners = new BannerController();
                    lstBanners.DataSource = objBanners.LoadBanners(intPortalId, ModuleId, intBannerTypeId, strBannerGroup, intBanners);
                    lstBanners.DataBind();
                }

                // set banner display characteristics
                if (lstBanners.Items.Count != 0)
                {
                    // container attributes
                    lstBanners.RepeatLayout = RepeatLayout.Table;
                    if (Convert.ToString(Settings["orientation"]) != "")
                    {
                        switch (Convert.ToString(Settings["orientation"]))
                        {
                        case "H":

                            lstBanners.RepeatDirection = RepeatDirection.Horizontal;
                            break;

                        case "V":

                            lstBanners.RepeatDirection = RepeatDirection.Vertical;
                            break;
                        }
                    }
                    else
                    {
                        lstBanners.RepeatDirection = RepeatDirection.Vertical;
                    }
                    if (Convert.ToString(Settings["border"]) != "")
                    {
                        lstBanners.ItemStyle.BorderWidth = Unit.Parse(Convert.ToString(Settings["border"]) + "px");
                    }
                    if (Convert.ToString(Settings["bordercolor"]) != "")
                    {
                        ColorConverter objColorConverter = new ColorConverter();
                        lstBanners.ItemStyle.BorderColor = (Color)objColorConverter.ConvertFrom(Convert.ToString(Settings["bordercolor"]));
                    }

                    // item attributes
                    lstBanners.ItemStyle.VerticalAlign = VerticalAlign.Middle;
                    if (Convert.ToString(Settings["rowheight"]) != "")
                    {
                        lstBanners.ItemStyle.Height = Unit.Parse(Convert.ToString(Settings["rowheight"]) + "px");
                    }
                    if (Convert.ToString(Settings["colwidth"]) != "")
                    {
                        lstBanners.ItemStyle.Width = Unit.Parse(Convert.ToString(Settings["colwidth"]) + "px");
                    }
                }
                else
                {
                    lstBanners.Visible = false;
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);


            if (PortalSettings.BannerAdvertising != 0 && Visible)
            {
                int BannerType = 0;
                //read bannertype from definition, if not use portalsetting
                if (!string.IsNullOrEmpty(BannerTypeId))
                {
                    BannerType = Int32.Parse(Convert.ToString(BannerTypeId));
                }
                else
                {
                    if (AllowNullBannerType)
                    {
                        BannerType = PortalController.GetPortalSettingAsInteger("BannerTypeId", PortalSettings.PortalId, 1);
                    }
                }

                //public attributes
                if (String.IsNullOrEmpty(GroupName))
                {
                    GroupName = PortalController.GetPortalSetting("BannerGroupName", PortalSettings.PortalId, "");
                }

                if (String.IsNullOrEmpty(BannerCount))
                {
                    BannerCount = "1";
                }
                int intPortalId;
                if (PortalSettings.BannerAdvertising == 1)
                {
                    intPortalId = PortalSettings.PortalId; //portal
                }
                else
                {
                    intPortalId = Null.NullInteger; //host
                }

                //load banners
                var objBanners = new BannerController();

                ArrayList arrBanners = objBanners.LoadBanners(intPortalId, Null.NullInteger, BannerType, GroupName, int.Parse(BannerCount));

                //bind to datalist
                lstBanners.DataSource = arrBanners;
                lstBanners.DataBind();

                //set banner display characteristics
                if (lstBanners.Items.Count != 0)
                {
                    lstBanners.RepeatLayout = BannerLayout;

                    if (!String.IsNullOrEmpty(Width))
                    {
                        lstBanners.Width = Unit.Parse(Width + "px");
                    }

                    if (BannerColumns > 0)
                    {
                        lstBanners.RepeatColumns = BannerColumns;
                    }

                    if (BannerCellPadding > 0)
                    {
                        lstBanners.CellPadding = BannerCellPadding;
                    }
                    else
                    {
                        lstBanners.CellPadding = lstBanners.Items.Count == 1 ? 0 : 4;
                    }

                    lstBanners.CellSpacing = BannerCellSpacing;

                    if (!String.IsNullOrEmpty(Orientation))
                    {
                        switch (Orientation)
                        {
                        case "H":
                            lstBanners.RepeatDirection = RepeatDirection.Horizontal;
                            break;

                        case "V":
                            lstBanners.RepeatDirection = RepeatDirection.Vertical;
                            break;
                        }
                    }
                    else
                    {
                        lstBanners.RepeatDirection = RepeatDirection.Vertical;
                    }

                    if (!String.IsNullOrEmpty(BorderWidth))
                    {
                        lstBanners.ItemStyle.BorderWidth = Unit.Parse(BorderWidth + "px");
                    }

                    if (!String.IsNullOrEmpty(BorderColor))
                    {
                        var objColorConverter = new ColorConverter();
                        lstBanners.ItemStyle.BorderColor = (Color)objColorConverter.ConvertFrom(BorderColor);
                    }

                    //item attributes
                    if (!String.IsNullOrEmpty(RowHeight))
                    {
                        lstBanners.ItemStyle.Height = Unit.Parse(RowHeight + "px");
                    }

                    if (!String.IsNullOrEmpty(ColWidth))
                    {
                        lstBanners.ItemStyle.Width = Unit.Parse(ColWidth + "px");
                    }
                }
                else
                {
                    lstBanners.Visible = false;
                }
            }
            else
            {
                lstBanners.Visible = false;
            }
        }
Esempio n. 4
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            // public attributes
            if (BannerTypeId == "")
            {
                BannerTypeId = "1"; // banner
            }
            if (BannerCount == "")
            {
                BannerCount = "1";
            }

            if (PortalSettings.BannerAdvertising != 0)
            {
                int intPortalId;
                if (PortalSettings.BannerAdvertising == 1)
                {
                    intPortalId = PortalSettings.PortalId; // portal
                }
                else
                {
                    intPortalId = Null.NullInteger; // host
                }

                // load banners
                BannerController objBanners = new BannerController();
                ArrayList        arrBanners = objBanners.LoadBanners(intPortalId, Null.NullInteger, Int32.Parse(BannerTypeId), VendorID, Int32.Parse(BannerCount));

                if (arrBanners.Count == 0)
                {
                    if (BannerTypeId == "1")
                    {
                        // add default banner if none found
                        BannerInfo objBanner = new BannerInfo();
                        objBanner.BannerId   = -1;
                        objBanner.ImageFile  = Globals.ApplicationPath + "/images/banner.gif";
                        objBanner.URL        = Globals.GetDomainName(Request);
                        objBanner.BannerName = Localization.GetString("Banner", Localization.GetResourceFile(this, MyFileName));
                        arrBanners.Add(objBanner);
                    }
                }

                // bind to datalist
                lstBanners.DataSource = arrBanners;
                lstBanners.DataBind();

                // set banner display characteristics
                if (lstBanners.Items.Count != 0)
                {
                    // container attributes
                    lstBanners.RepeatLayout = RepeatLayout.Table;
                    if (!String.IsNullOrEmpty(Width))
                    {
                        lstBanners.Width = Unit.Parse(Width + "px");
                    }
                    if (lstBanners.Items.Count == 1)
                    {
                        lstBanners.CellPadding = 0;
                        lstBanners.CellSpacing = 0;
                    }
                    else
                    {
                        lstBanners.CellPadding = 4;
                        lstBanners.CellSpacing = 0;
                    }

                    if (!String.IsNullOrEmpty(Orientation))
                    {
                        switch (Orientation)
                        {
                        case "H":

                            lstBanners.RepeatDirection = RepeatDirection.Horizontal;
                            break;

                        case "V":

                            lstBanners.RepeatDirection = RepeatDirection.Vertical;
                            break;
                        }
                    }
                    else
                    {
                        lstBanners.RepeatDirection = RepeatDirection.Vertical;
                    }

                    if (!String.IsNullOrEmpty(BorderWidth))
                    {
                        lstBanners.ItemStyle.BorderWidth = Unit.Parse(BorderWidth + "px");
                    }
                    if (!String.IsNullOrEmpty(BorderColor))
                    {
                        ColorConverter objColorConverter = new ColorConverter();
                        lstBanners.ItemStyle.BorderColor = (Color)objColorConverter.ConvertFrom(BorderColor);
                    }

                    // item attributes
                    lstBanners.ItemStyle.VerticalAlign = VerticalAlign.Middle;
                    if (!String.IsNullOrEmpty(RowHeight))
                    {
                        lstBanners.ItemStyle.Height = Unit.Parse(RowHeight + "px");
                    }
                    if (!String.IsNullOrEmpty(ColWidth))
                    {
                        lstBanners.ItemStyle.Width = Unit.Parse(ColWidth + "px");
                    }
                }
                else
                {
                    lstBanners.Visible = false;
                }
            }
            else
            {
                lstBanners.Visible = false;
            }
        }
Esempio n. 5
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)));
        }
Esempio n. 6
0
        private void LegacyBannerSettings()
        {
            DataList lstBanners = (DataList)FindControl("lstBanners");

            if (!String.IsNullOrEmpty(Convert.ToString(Settings["padding"])))
            {
                lstBanners.CellPadding = Int32.Parse(Convert.ToString(Settings["padding"]));
            }

            //load banners
            if (intBanners != 0)
            {
                var objBanners = new BannerController();
                lstBanners.DataSource = objBanners.LoadBanners(intPortalId, ModuleId, intBannerTypeId, strBannerGroup, intBanners);
                lstBanners.DataBind();
            }

            //set banner display characteristics
            if (lstBanners.Items.Count != 0)
            {
                //container attributes
                lstBanners.RepeatLayout = RepeatLayout.Table;
                if (!String.IsNullOrEmpty(Convert.ToString(Settings["orientation"])))
                {
                    switch (Convert.ToString(Settings["orientation"]))
                    {
                    case "H":
                        lstBanners.RepeatDirection = RepeatDirection.Horizontal;
                        break;

                    case "V":
                        lstBanners.RepeatDirection = RepeatDirection.Vertical;
                        break;
                    }
                }
                else
                {
                    lstBanners.RepeatDirection = RepeatDirection.Vertical;
                }
                if (!String.IsNullOrEmpty(Convert.ToString(Settings["border"])))
                {
                    lstBanners.ItemStyle.BorderWidth = Unit.Parse(Convert.ToString(Settings["border"]) + "px");
                }
                if (!String.IsNullOrEmpty(Convert.ToString(Settings["bordercolor"])))
                {
                    var objColorConverter = new ColorConverter();
                    lstBanners.ItemStyle.BorderColor = (Color)objColorConverter.ConvertFrom(Convert.ToString(Settings["bordercolor"]));
                }

                //item attributes
                if (!String.IsNullOrEmpty(Convert.ToString(Settings["rowheight"])))
                {
                    lstBanners.ItemStyle.Height = Unit.Parse(Convert.ToString(Settings["rowheight"]) + "px");
                }
                if (!String.IsNullOrEmpty(Convert.ToString(Settings["colwidth"])))
                {
                    lstBanners.ItemStyle.Width = Unit.Parse(Convert.ToString(Settings["colwidth"]) + "px");
                }
            }
            else
            {
                lstBanners.Visible = false;
            }
        }