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

📄 globals.cs

📁 1、用SQL查询器打开install目录下的dooogo.sql运行之后创建数据库dooogo。 2、然后打开web.config修改 <DbProvider type="Club.Fram
💻 CS
字号:
using System;
using System.Web;
using Club.Framework.Configuration;
using Club.Framework.Providers;
using Club.Framework.Data;
using Club.Framework.Format;
using Club.Framework.Email;
namespace Club.Framework
{
	/// <summary>
	/// Globals 的摘要说明。
	/// </summary>
	public class Globals
	{
		public enum SortType
		{
			Photo=1,
			Article=5,
			Diary=7,
			Pic=2,
			Music=6,
			AddressList=4,
			Favorite=3,
		}
		/// <summary>
		/// 获取网站绝对地址
		/// </summary>
		/// <param name="localPath">相对地址</param>
		/// <returns>绝对地址</returns>
		public static string GetWebPath(string localPath)
		{
			string path=HttpContext.Current.Request.ApplicationPath;
			string thisPath;
			string thisLocalPath;
			//如果不是根目录就加上"/" 根目录自己会加"/"
			if(path!="/")
			{
				thisPath=path+"/";
			}
			else
			{
				thisPath=path;
			}
			if(localPath.StartsWith("~/"))
			{
				thisLocalPath=localPath.Substring(2);
			}
			else
			{
				return localPath;
			}
			return thisPath+thisLocalPath;
		}
		/// <summary>
		///  获取网站绝对地址
		/// </summary>
		/// <returns></returns>
		public static string GetWebPath()
		{
			string path=System.Web.HttpContext.Current.Request.ApplicationPath;
			string thisPath;
			//如果不是根目录就加上"/" 根目录自己会加"/"
			if(path!="/")
			{
				thisPath=path+"/";
			}
			else
			{
				thisPath=path;
			}
			return thisPath;
		}
		public static IDTOProvider DbProvider
		{
			get
			{
				return DTOProvider.Instance();
			}
		}
		public static IMailProvider SystemMail
		{
			get
			{
				return EmailProvider.Instance();
			}
		}
		public static UrlFormats UrlFormats
		{
			get
			{
				return UrlFormatProvider.Instance(GetWebPath());
			}
		}
		public static Js Javascript
		{
			get
			{
				return JsFormatProvider.Instance(GetWebPath());
			}
		}
		/// <summary>
		/// 获取绝对路径
		/// </summary>
		/// <param name="localPath">相对路径或绝对路径</param>
		/// <returns>绝对路径</returns>
		public static string GetFilePath(string localPath)
		{
			if(System.Text.RegularExpressions.Regex.IsMatch(localPath,@"([A-Za-z]):\\([\S]*)"))
			{
				return localPath;
			}
			else
			{
				return System.Web.HttpContext.Current.Server.MapPath(localPath);
			}
		}
		public static string GetSPhotoPath(int registerId,string imageName)
		{
			string photoPath=Globals.GetWebPath(Config.ClubSPhotoPath);
			if(Config.Settings.UpFileIsMakeDir)
			{
				photoPath=photoPath+registerId+"/";
			}
			return photoPath+imageName;
		}
		public static string GetPhotoPath(int registerId,string imageName)
		{
			string photoPath=Globals.GetWebPath(Config.ClubPhotoPath);
			if(Config.Settings.UpFileIsMakeDir)
			{
				photoPath=photoPath+registerId+"/";
			}
			return photoPath+imageName;
		}
		/// <summary>
		/// 判断显示栏目
		/// </summary>
		/// <param name="siteMenuSetting"></param>
		/// <returns></returns>
		public static string GetMenu(int registerId,int currentId,string siteMenuSetting)
		{
			if(siteMenuSetting==null||siteMenuSetting=="")
			{
				return getMenuString(registerId,currentId,true,true,true,true,true,true,true);
			}
			bool[] isChecks=new bool[5];
			string[] values=siteMenuSetting.Split(',','|');
			for(int i=0;i<isChecks.Length;i++)
			{
				if(values.Length>i)
				{
					try
					{
						isChecks[i] = bool.Parse(values[i]);
					}
					catch
					{
						isChecks[i]=false;
					}
				}
				else
				{
					isChecks[i]=false;
				}
			}
			return getMenuString(registerId,currentId,isChecks);
		}
		private static string getMenuString(int registerId,int currentId,params bool[] isChecks)
		{
			string reString="";
			reString+=" <a href=\""+Globals.UrlFormats.SiteHome(registerId)+"\" class=\""+(currentId==-1?"curr":"menu")+"\" >首页</a> ";
			reString+=isChecks[3]?" <a href=\""+Globals.UrlFormats.SiteDiary(registerId)+"\" class=\""+(currentId==3?"curr":"menu")+"\" >Blog</a> ":"";
			reString+=isChecks[2]?" <a href=\""+Globals.UrlFormats.SiteArticle(registerId)+"\" class=\""+(currentId==2?"curr":"menu")+"\" >文章</a> ":"";
			reString+=isChecks[0]?" <a href=\""+Globals.UrlFormats.SitePhoto(registerId,1)+"\" class=\""+(currentId==0?"curr":"menu")+"\" >相册</a> ":"";
			reString+=isChecks[1]?" <a href=\""+Globals.UrlFormats.SitePhoto(registerId,2)+"\" class=\""+(currentId==1?"curr":"menu")+"\" >图片</a> ":"";
			reString+=isChecks[4]?" <a href=\""+Globals.UrlFormats.SiteMusic(registerId)+"\" class=\""+(currentId==4?"curr":"menu")+"\" >音乐盒</a> ":"";
			reString+=" <a href=\""+Globals.UrlFormats.SiteGuestBook(registerId)+"\" class=\""+(currentId==5?"curr":"menu")+"\" >留言</a> ";
			return reString;
		}	
		public static string GetPlace(int country,int province,int city)
		{
			string reText=string.Empty;
			string[] place=Xml.ReadXML.ReadPlace("~/Javascript/Place.xml",country,province,city);
			if(place[0]!=null)
			{
				reText+=place[0];
			}
			if(place[1]!=null)
			{
				reText+=","+place[1];
			}
			if(place[2]!=null)
			{
				reText+=","+place[2];
			}
			return reText;
		}
		public Globals()
		{
		}
	}
}

⌨️ 快捷键说明

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