Beispiel #1
0
 public string GetPreviewCode(VFSFile file)
 {
     file.extention = file.extention.ToLower();
     if (previewMapping.ContainsKey(file.extention))
     {
         return string.Format(previewMapping[file.extention], FabulousFileServer.ReplaceUrlShit(file.fullName));
     }
     return string.Format("<a href=\"/{0}\"><img src=\"/{0}?" + icon + "\" /></a>", FabulousFileServer.ReplaceUrlShit(file.fullName));
 }
Beispiel #2
0
        public void ReturnFolderPage(VFSFile[] files, VFSFolder[] folders, string path, string args)
        {
            SortMode sortMode = SortMode.Name;

            string[] splittedArgs = args.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < splittedArgs.Length; i++)
            {
                if (FabulousFileServer.sortArgRegex.IsMatch(splittedArgs[i]))
                {
                    string sortModeString = FabulousFileServer.sortArgRegex.Replace(splittedArgs[i], "$1");
                    switch (sortModeString.ToLower())
                    {
                        case "n":
                            sortMode = SortMode.Name;
                            break;
                        case "t":
                            sortMode = SortMode.Time;
                            break;
                        case "e":
                            sortMode = SortMode.Extention;
                            break;
                        case "s":
                            sortMode = SortMode.Size;
                            break;
                        case "~n":
                            sortMode = SortMode.RName;
                            break;
                        case "~t":
                            sortMode = SortMode.RTime;
                            break;
                        case "~e":
                            sortMode = SortMode.RExtention;
                            break;
                        case "~s":
                            sortMode = SortMode.RSize;
                            break;
                    }
                }
            }

            switch (sortMode)
            {
                case SortMode.Name:
                    ReturnSortedPage(files.OrderBy(x => x.name), folders.OrderBy(x => x.name));
                    break;
                case SortMode.Extention:
                    ReturnSortedPage(files.OrderBy(x => x.extention), folders.OrderBy(x => x.name));
                    break;
                case SortMode.Time:
                    ReturnSortedPage(files.OrderBy(x => x.date), folders.OrderBy(x => x.date));
                    break;
                case SortMode.Size:
                    ReturnSortedPage(files.OrderBy(x => x.size), folders.OrderBy(x => x.name));
                    break;
                case SortMode.RName:
                    ReturnSortedPage(files.OrderByDescending(x => x.name), folders.OrderByDescending(x => x.name));
                    break;
                case SortMode.RExtention:
                    ReturnSortedPage(files.OrderByDescending(x => x.extention), folders.OrderByDescending(x => x.name));
                    break;
                case SortMode.RTime:
                    ReturnSortedPage(files.OrderByDescending(x => x.date), folders.OrderByDescending(x => x.date));
                    break;
                case SortMode.RSize:
                    ReturnSortedPage(files.OrderByDescending(x => x.size), folders.OrderByDescending(x => x.name));
                    break;
            }
        }