public virtual void SaveImage(Site site, string themeName, string fileName, Stream stream) { Theme theme = new Theme(site, themeName); ThemeImageFile image = new ThemeImageFile(theme, fileName); image.Save(stream); }
public virtual void DeleteImage(Site site, string themeName, string fileName) { Theme theme = new Theme(site, themeName); ThemeImageFile image = new ThemeImageFile(theme, fileName); if (!image.Exists()) { throw new FriendlyException("image:" + fileName + " does not exist!"); } image.Delete(); }
public void TestVirtualPath() { string themeName = "theme1"; var site = new Site("Site1"); var theme = new Theme(site, themeName); var themeImageFile = new ThemeImageFile(theme, "image1.jpg"); string expected1 = Kooboo.Web.Url.UrlUtility.Combine(site.VirtualPath, "themes", themeName, "Images", "image1.jpg"); Assert.AreEqual(expected1, themeImageFile.VirtualPath, true); }
public void TestPhysicalPath() { string themeName = "theme1"; var site = new Site("Site1"); var theme = new Theme(site, themeName); var themeImageFile = new ThemeImageFile(theme, "image1.jpg"); string expected1 = Path.Combine(site.PhysicalPath, "themes", themeName, "Images", "image1.jpg"); Assert.AreEqual(expected1, themeImageFile.PhysicalPath, true); }
public IEnumerable <ThemeImageFile> AllImagesEnumerable(Theme theme) { List <ThemeImageFile> list = new List <ThemeImageFile>(); theme = theme.LastVersion(); if (theme.Exists()) { ThemeImageFile dummy = new ThemeImageFile(theme, "dummy"); var baseDir = dummy.BasePhysicalPath; if (Directory.Exists(baseDir)) { foreach (var file in Directory.EnumerateFiles(baseDir)) { list.Add(new ThemeImageFile(theme, Path.GetFileName(file))); } } } return(list); }