⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forumpager.cs

📁 community server 源码
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI;
using CommunityServer.Components;
using CommunityServer.Controls;
using CommunityServer.Discussions.Components;

namespace CommunityServer.Discussions.Controls
{
	/// <summary>
	/// Summary description for ForumPager.
	/// </summary>
	public class ForumPager : CommunityServer.Controls.Pager
	{

		public override int PageSize 
		{
			get 
			{
				int pageSize = Convert.ToInt32(ViewState["PageSize"]);

				if (pageSize == 0) 
				{
					if (csContext.PostID > 0) 
					{
						return ForumConfiguration.Instance().PostsPerPage;
					} 
					else 
					{
						return ForumConfiguration.Instance().ThreadsPerPage;
					}
				}

				return pageSize;
			}
			set 
			{
				ViewState["PageSize"] = value;
			}

		}

		int _pageIndex = 0;
		public override int PageIndex 
		{
			get 
			{
				// Give first try to the ViewState if it was a postback
				if (Page.IsPostBack && ViewState["PageIndex"] != null)
					_pageIndex = (int) ViewState["PageIndex"];
				else 
				{
					if (csContext.QueryString["pageindex"] != null)
						_pageIndex = int.Parse(csContext.QueryString["pageindex"]) - 1;
					else if(csContext.QueryString["PermaPostID"] != null)
					{
						if(Context.Request.Cookies["PostSortOrder" + csContext.PostID] != null)
							_pageIndex = Posts.GetPageIndex(int.Parse(csContext.QueryString["PermaPostID"]), this.PageSize, 0, int.Parse(Context.Request.Cookies["PostSortOrder" + csContext.PostID].Value)) - 1;
						else
							_pageIndex = Posts.GetPageIndex(int.Parse(csContext.QueryString["PermaPostID"]), this.PageSize, 0, (int)csContext.User.PostSortOrder) - 1;
					}
				}

				if (_pageIndex < 0)
					return 0;
				else
					return _pageIndex;
			}
			set 
			{
				ViewState["PageIndex"] = value;
				_pageIndex = value;
			}
		}

	}

	public class ForumLinkButtonPager : CommunityServer.Controls.LinkButtonPager
	{

		public override int PageSize 
		{
			get 
			{
				int pageSize = Convert.ToInt32(ViewState["PageSize"]);

				if (pageSize == 0) 
				{
					if (CSContext.Current.PostID > 0) 
					{
						return ForumConfiguration.Instance().PostsPerPage;
					} 
					else 
					{
						return ForumConfiguration.Instance().ThreadsPerPage;
					}
				}

				return pageSize;
			}
			set 
			{
				ViewState["PageSize"] = value;
			}

		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -