public override void Open(Silversite.Web.UI.FileManager m, string path) { var info = Services.Files.DirectoryInfoVirtual(path); var files = info.Children .OfType<System.Web.Hosting.VirtualFileBase>() .Select(f => Services.Paths.Normalize(f.VirtualPath)); switch (m.View) { case Silversite.Web.UI.FileManager.Views.HugeIcons: case Silversite.Web.UI.FileManager.Views.BigIcons: case Silversite.Web.UI.FileManager.Views.MediumIcons: case Silversite.Web.UI.FileManager.Views.SmallIcons: foreach (var name in files) File.Add(m, this, name); break; case Silversite.Web.UI.FileManager.Views.List: foreach (var name in files) File.Add(m, this, name); break; case Silversite.Web.UI.FileManager.Views.Details: var head = new Literal() { Text = "<table style=\"background:white;width:100%;height:100%;\">" }; m.DetailsView.Controls.Add(head); foreach (var name in files) File.Add(m, this, name); var foot = new Literal() { Text = "</table>" }; m.DetailsView.Controls.Add(foot); break; } }
public override void CreateChildControls(Silversite.Web.UI.Presenter p) { if (p is Web.UI.FileManager) { var m = (Web.UI.FileManager)p; UserControls.FileManager uc = new UserControls.FileManager(); uc = (UserControls.FileManager)uc.LoadControl("~/Silversite/Extensions/Silversite.FileManager/FileManager.ascx"); m.Controls.Add(uc); uc.Container = m; if (Services.Files.FileExists(m.Path)) uc.Item = new FileInfo(m.Path); else uc.Item = new DirectoryInfo(m.Path); } else throw new NotSupportedException("Unknown Presenter. Only Silversite.Web.UI.FileManager is supported by this Provider."); }
public override void CreateChildControls(Silversite.Web.UI.Presenter p) { if (p is Web.UI.FileManager) { var m = (Web.UI.FileManager)p; m.Content = new Content(); m.Menu = new Menu(); m.Hierarchy = new Hierarchy(); m.Controls.Add(m.Menu); /* var splitter = new Silversite.Web.UI.Splitter(); splitter.LeftPane = m.Hierarchy; splitter.RightPane = m.Content; splitter.LeftPanePixelWidth = 160; splitter.LeftPaneMinPixelWidth = 0; splitter.CssClass = "Silversite-SplitterPanel"; */ //m.Controls.Add(splitter); } else throw new NotSupportedException("Unknown Presenter. Only Silversite.Web.UI.FileManager is supported by this Provider."); }
public TreeBuilder(Silversite.Web.UI.FileManager m) { M = m; }
/// <summary> /// Gets the document with the supplied key. /// </summary> /// <param name="db">The Context to use.</param> /// <param name="key">The document to look for.</param> /// <returns>The Document with the given key.</returns> public static Document Current(Silversite.Context db, int contentKey) { return db.Documents.FirstOrDefault(d => (d.ContentKey == contentKey || d.Key == contentKey) && d.IsCurrentRevision == true); }
/// <summary> /// True if the passed string is a known user (and not a user role). /// </summary> /// <param name="db">The DbContext to access the database.</param> /// <param name="userOrRole">A string containing a user or a role.</param> /// <returns></returns> private static bool IsNameUser(Silversite.Context db, string userOrRole) { var user = Persons.Find(userOrRole); return user != null; }
public static void SetupButton(Silversite.Web.UI.FileManager m, LinkButton button, string path) { var p = path; button.Click += (sender, args) => { m.Path = p; m.Apply(); }; }
public static void Add(Silversite.Web.UI.FileManager m, Handler h, string Path) { Panel details = m.DetailsView; var button = new LinkButton(); var View = m.View; var Selected = m.Selection.Contains(Path); // icon int width = 81; int height = 60; switch (View) { case Silversite.Web.UI.FileManager.Views.HugeIcons: width *= 2; height *= 3; break; case Silversite.Web.UI.FileManager.Views.BigIcons: break; case Silversite.Web.UI.FileManager.Views.MediumIcons: width = width * 4 / 7; height = height * 4 / 7; break; case Silversite.Web.UI.FileManager.Views.SmallIcons: case Silversite.Web.UI.FileManager.Views.List: case Silversite.Web.UI.FileManager.Views.Details: width = width / 5; height = height / 5; break; } var icon = new Icon(Path, width, height); icon.ToolTip = Stats(Path); var label = new Label(); label.ToolTip = Stats(Path); label.Font.Size = new FontUnit(8); label.Style.Add("line-height", "0.8em"); label.Font.Names = new string[] { "Tahoma", "Arial", "Helvetica", "Sans serif" }; switch (View) { case Silversite.Web.UI.FileManager.Views.List: case Silversite.Web.UI.FileManager.Views.SmallIcons: case Silversite.Web.UI.FileManager.Views.MediumIcons: case Silversite.Web.UI.FileManager.Views.BigIcons: label.Text = Paths.File(Path); break; case Silversite.Web.UI.FileManager.Views.Details: //label.Text = Stats.Replace("", " "); break; } var div = new Panel(); var outerdiv = new Panel(); var innerdiv = new Panel(); outerdiv.Style.Add("background", "white"); //outerdiv.Style.Add("border", "1px solid blue"); div.Controls.Add(innerdiv); outerdiv.Controls.Add(div); outerdiv.Style.Add("overflow", "hidden"); var str = new StringBuilder(); foreach (char ch in label.Text) { str.Append(ch); str.Append("<wbr/>"); } div.Style.Add("border-radius", "3px"); switch (View) { case Silversite.Web.UI.FileManager.Views.HugeIcons: innerdiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.TextAlign, "center"); innerdiv.Style.Add("margin", "auto"); div.Style.Add(System.Web.UI.HtmlTextWriterStyle.TextAlign, "center"); outerdiv.Style.Add("float", "left"); outerdiv.Style.Add("padding", "5px"); innerdiv.Controls.Add(icon); innerdiv.Controls.Add(new Literal() { Text = "<br/>" }); label.Text = str.ToString(); innerdiv.Controls.Add(label); div.Width = 200; div.Height = 298; outerdiv.Height = 318; outerdiv.Width = 210; button.Controls.Add(outerdiv); details.Controls.Add(button); SetupButton(m, button, Path); break; case Silversite.Web.UI.FileManager.Views.BigIcons: innerdiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.TextAlign, "center"); innerdiv.Style.Add("margin", "auto"); div.Style.Add(System.Web.UI.HtmlTextWriterStyle.TextAlign, "center"); outerdiv.Style.Add("float", "left"); outerdiv.Style.Add("padding", "5px"); innerdiv.Controls.Add(icon); innerdiv.Controls.Add(new Literal() { Text = "<br/>" }); label.Text = str.ToString(); innerdiv.Controls.Add(label); div.Width = 105; div.Height = 144; outerdiv.Height = 154; outerdiv.Width = 115; button.Controls.Add(outerdiv); details.Controls.Add(button); SetupButton(m, button, Path); break; case Silversite.Web.UI.FileManager.Views.MediumIcons: innerdiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.TextAlign, "center"); innerdiv.Style.Add("margin", "auto"); div.Style.Add(System.Web.UI.HtmlTextWriterStyle.TextAlign, "center"); outerdiv.Style.Add("float", "left"); outerdiv.Style.Add("padding", "5px"); innerdiv.Controls.Add(icon); innerdiv.Controls.Add(new Literal() { Text = "<br/>" }); label.Text = str.ToString(); innerdiv.Controls.Add(label); div.Width = 60; div.Height = 81; outerdiv.Height = 91; outerdiv.Width = 65; button.Controls.Add(outerdiv); details.Controls.Add(button); SetupButton(m, button, Path); break; case Silversite.Web.UI.FileManager.Views.SmallIcons: case Silversite.Web.UI.FileManager.Views.List: div.Style.Add(System.Web.UI.HtmlTextWriterStyle.TextAlign, "left"); innerdiv.Style.Add(System.Web.UI.HtmlTextWriterStyle.TextAlign, "left"); innerdiv.Style.Add("margin", "auto"); innerdiv.Controls.Add(icon); innerdiv.Controls.Add(new Literal() { Text = " " }); innerdiv.Controls.Add(label); div.Controls.Add(innerdiv); div.Width = 81; div.Height = 20; div.Style.Add("text-align", "left"); div.Style.Add("border-radius", "3px"); outerdiv.Width =91; outerdiv.Height = 24; outerdiv.Style.Add("padding", "5px 2px 5px 2px"); outerdiv.Style.Add("float", "left"); button.Controls.Add(outerdiv); details.Controls.Add(button); SetupButton(m, button, Path); break; case Silversite.Web.UI.FileManager.Views.Details: var tr = new Literal() { Text = "<tr style=\"background:white;\"><td>" }; details.Controls.Add(tr); var iconbutton = new LinkButton(); iconbutton.Controls.Add(icon); details.Controls.Add(iconbutton); var textbutton = new LinkButton(){ Text = Paths.File(Path) }; details.Controls.Add(textbutton); var datebutton = new LinkButton() { Text = Stats(Path).Tokens().First() }; details.Controls.Add(datebutton); var sizebutton = new LinkButton() { Text = Stats(Path).Tokens().Last() }; details.Controls.Add(sizebutton); SetupButton(m, iconbutton, Path); SetupButton(m, datebutton, Path); SetupButton(m, sizebutton, Path); details.Controls.Add(new Literal() { Text = "</td></tr>" }); break; } }
/// <summary> /// Find the person that corresponds to the supplied username. /// </summary> /// <param name="db">A Database Context.</param> /// <param name="username">The username.</param> /// <returns>The person that correspond to the username.</returns> public static Person Find(Silversite.Context db, string username) { if (Current != null && Current.UserName == username) return Current; return null; }
public override void Open(Silversite.Web.UI.FileManager m, string path) { Services.Files.Response(path); }
public MenuBuilder(Silversite.Web.UI.FileManager m) { M = m; }
public override void Files(Uri source, Uri dest, Silversite.Services.Sync.Mode mode, string logfile, string excludePatterns, bool verbose) { var sync = new Silversite.FtpSync.Sync(mode, verbose, excludePatterns, logfile); sync.Directory(source, dest); }
public abstract void Open(Silversite.Web.UI.FileManager m, string path);
public override void Open(Silversite.Web.UI.FileManager m, string path) { }
public override void FxpCopy(string fileName, Silversite.Services.Ftp.FtpClient destination) { FtpClient.FxpCopy(fileName, ((StarksoftProvider)destination.Provider).FtpClient); }