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.");
        }
Esempio n. 3
0
        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.");
        }
Esempio n. 4
0
 public TreeBuilder(Silversite.Web.UI.FileManager m)
 {
     M = m;
 }
Esempio n. 5
0
 /// <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);
 }
Esempio n. 6
0
 /// <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;
 }
Esempio n. 7
0
 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();
     };
 }
Esempio n. 8
0
        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("", "&nbsp;&nbsp;");
                    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 = "&nbsp;" });
                    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;
            }
        }
Esempio n. 9
0
 /// <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;
 }
Esempio n. 10
0
 public override void Open(Silversite.Web.UI.FileManager m, string path)
 {
     Services.Files.Response(path);
 }
Esempio n. 11
0
 public MenuBuilder(Silversite.Web.UI.FileManager m)
 {
     M = m;
 }
Esempio n. 12
0
 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);
 }
Esempio n. 13
0
 public abstract void Open(Silversite.Web.UI.FileManager m, string path);
Esempio n. 14
0
 public override void Open(Silversite.Web.UI.FileManager m, string path)
 {
 }
Esempio n. 15
0
 public override void FxpCopy(string fileName, Silversite.Services.Ftp.FtpClient destination)
 {
     FtpClient.FxpCopy(fileName, ((StarksoftProvider)destination.Provider).FtpClient);
 }