Пример #1
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), GroupName, 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;
            }
        }
        /// <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);
            }
        }
Пример #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (PortalSettings.BannerAdvertising != 0 && Visible)
            {
                int BannerType = 0;
                if (AllowNullBannerType)
                {
                    if (!string.IsNullOrEmpty(BannerTypeId))
                    {
                        BannerType = Int32.Parse(Convert.ToString(BannerTypeId));
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(BannerTypeId))
                    {
                        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;
            }
        }
        // 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 );
            }
        }