Exemple #1
0
		private void Forum_Load( object sender, EventArgs e )
		{
			string m_baseDir = YafForumInfo.ForumFileRoot;

			if ( Request.QueryString ["g"] != null )
			{
				try
				{
					_page = (ForumPages)Enum.Parse(typeof(ForumPages), Request.QueryString ["g"], true);
				}
				catch (Exception)
				{
					_page = ForumPages.forum;
				}
			}
			else
			{
				_page = ForumPages.forum;
			}

			if ( !ValidPage( _page ) )
			{
				YafBuildLink.Redirect( ForumPages.topics, "f={0}", LockedForum );
			}

			string src = string.Format( "{0}pages/{1}.ascx", m_baseDir, _page );
			if ( src.IndexOf( "/moderate_" ) >= 0 )
				src = src.Replace( "/moderate_", "/moderate/" );
			if ( src.IndexOf( "/admin_" ) >= 0 )
				src = src.Replace( "/admin_", "/admin/" );
			if ( src.IndexOf( "/help_" ) >= 0 )
				src = src.Replace( "/help_", "/help/" );

			try
			{
				// handle script manager first...
				if ( ScriptManager.GetCurrent( Page ) == null )
				{
					// add a script manager since one doesn't exist...
					ScriptManager yafScriptManager = new ScriptManager();
					yafScriptManager.ID = "YafScriptManager";
					yafScriptManager.EnablePartialRendering = true;
					this.Controls.Add( yafScriptManager );
				}

				YAF.Classes.Base.ForumPage forumControl = ( YAF.Classes.Base.ForumPage ) LoadControl( src );
				forumControl.PageTitleSet += new EventHandler<YAF.Classes.Base.ForumPageArgs>( forumControl_PageTitleSet );

				forumControl.ForumFooter = _footer;
				forumControl.ForumHeader = _header;
			
				// add the header control before the page rendering...
				if ( YafContext.Current.Settings.LockedForum == 0 && _origHeaderClientID == _header.ClientID )
					this.Controls.AddAt( 0, _header );

				this.Controls.Add( forumControl );

				// add the footer control after the page...
				if ( YafContext.Current.Settings.LockedForum == 0 && _origFooterClientID == _footer.ClientID )
					this.Controls.Add( _footer );
			}
			catch ( System.IO.FileNotFoundException )
			{
				throw new ApplicationException( "Failed to load " + src + "." );
			}
		}
Exemple #2
0
        private void Forum_Load(object sender, EventArgs e)
        {
            string m_baseDir = YafForumInfo.ForumFileRoot;

            if (Request.QueryString ["g"] != null)
            {
                try
                {
                    _page = (ForumPages)Enum.Parse(typeof(ForumPages), Request.QueryString ["g"], true);
                }
                catch (Exception)
                {
                    _page = ForumPages.forum;
                }
            }
            else
            {
                _page = ForumPages.forum;
            }

            if (!ValidPage(_page))
            {
                YafBuildLink.Redirect(ForumPages.topics, "f={0}", LockedForum);
            }

            string src = string.Format("{0}pages/{1}.ascx", m_baseDir, _page);

            if (src.IndexOf("/moderate_") >= 0)
            {
                src = src.Replace("/moderate_", "/moderate/");
            }
            if (src.IndexOf("/admin_") >= 0)
            {
                src = src.Replace("/admin_", "/admin/");
            }
            if (src.IndexOf("/help_") >= 0)
            {
                src = src.Replace("/help_", "/help/");
            }

            try
            {
                // handle script manager first...
                if (ScriptManager.GetCurrent(Page) == null)
                {
                    // add a script manager since one doesn't exist...
                    ScriptManager yafScriptManager = new ScriptManager();
                    yafScriptManager.ID = "YafScriptManager";
                    yafScriptManager.EnablePartialRendering = true;
                    this.Controls.Add(yafScriptManager);
                }

                YAF.Classes.Base.ForumPage forumControl = (YAF.Classes.Base.ForumPage)LoadControl(src);
                forumControl.PageTitleSet += new EventHandler <YAF.Classes.Base.ForumPageArgs>(forumControl_PageTitleSet);

                forumControl.ForumFooter = _footer;
                forumControl.ForumHeader = _header;

                // add the header control before the page rendering...
                if (YafContext.Current.Settings.LockedForum == 0 && _origHeaderClientID == _header.ClientID)
                {
                    this.Controls.AddAt(0, _header);
                }

                this.Controls.Add(forumControl);

                // add the footer control after the page...
                if (YafContext.Current.Settings.LockedForum == 0 && _origFooterClientID == _footer.ClientID)
                {
                    this.Controls.Add(_footer);
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                throw new ApplicationException("Failed to load " + src + ".");
            }
        }