/// <summary> /// 加载模板 /// </summary> /// <param name="currentThemeName"></param> /// <returns></returns> protected IList<ManageThemeInfo> LoadThemes(string currentThemeName) { HttpContext context = HiContext.Current.Context; XmlDocument document = new XmlDocument(); IList<ManageThemeInfo> list = new List<ManageThemeInfo>(); string themesPath = context.Request.PhysicalApplicationPath + HiConfiguration.GetConfig().FilesPath + @"\Templates\sites\" + HiContext.Current.User.UserId.ToString(); if (Directory.Exists(themesPath)) { string[] themeList = Directory.GetDirectories(themesPath); ManageThemeInfo item = null; DirectoryInfo themeInfo = null; string themeName = string.Empty; foreach (string theme in themeList) { themeInfo = new DirectoryInfo(theme); themeName = themeInfo.Name.ToLower(); if (themeName.Length > 0 && !themeName.StartsWith("_")) { foreach (FileInfo fileInfo in themeInfo.GetFiles(themeName + ".xml")) { item = new ManageThemeInfo(); using (FileStream inStream = fileInfo.OpenRead()) { document.Load(inStream); } item.Name = document.SelectSingleNode("ManageTheme/Name").InnerText; item.ThemeImgUrl = document.SelectSingleNode("ManageTheme/ImageUrl").InnerText; item.ThemeName = themeName; if (string.Compare(item.ThemeName, currentThemeName) == 0) { litThemeName.Text = item.ThemeName; imgThemeImgUrl.ImageUrl = string.Concat(Globals.ApplicationPath, "/Templates/sites/", HiContext.Current.User.UserId, "/", themeName, "/", document.SelectSingleNode("ManageTheme/ImageUrl").InnerText); Image1.ImageUrl = string.Concat(Globals.ApplicationPath, "/Templates/sites/", HiContext.Current.User.UserId, "/", themeName, "/", document.SelectSingleNode("ManageTheme/BigImageUrl").InnerText); } list.Add(item); } } } } return list; }
protected IList<ManageThemeInfo> GetThemes() { IList<ManageThemeInfo> list = new List<ManageThemeInfo>(); SiteSettings siteSettings = SettingsManager.GetSiteSettings(HiContext.Current.User.UserId); string path = HiContext.Current.Context.Request.MapPath(Globals.ApplicationPath + string.Format("/Templates/sites/{0}/{1}/categorythemes", HiContext.Current.User.UserId, siteSettings.Theme)); if (!Directory.Exists(path)) Directory.CreateDirectory(path); string[] strArray = Directory.GetFiles(path); ManageThemeInfo manageThemeInfo = null; foreach (string item in strArray) { if (item.EndsWith(".html")) { manageThemeInfo = new ManageThemeInfo(); manageThemeInfo.ThemeName = manageThemeInfo.Name = Path.GetFileName(item); list.Add(manageThemeInfo); } } return list; }