/// <summary> /// Make the body markup for the AutoImage utility. /// </summary> /// <param name="context">Web site HttpContext object</param> /// <param name="onlyPublic">If true restrict to public subdirectories</param> public static string MakeAutoImageMarkup (HttpContext context, bool onlyPublic) { StringBuilder builder = new StringBuilder(); // path in the file system string directoryPath = FileTools.GetDirectoryPath(context); // path as a tilde web directory path string tildeDirectoryPath = HttpContextTools.GetTildeDirectoryPath(context); List <string> subdirectoryList = HttpContextTools.MakeSubdirectoryList(context, onlyPublic); List <string> imageList = HttpContextTools.MakeFileList(context, FileTools.IMAGE); int M = subdirectoryList.Count; int N = imageList.Count; // create markup builder.Append("\n<p><b>Web Directory: "); builder.Append(tildeDirectoryPath); builder.Append("</b></p>\n"); if (M > 0) { builder.Append("\n<p><b>Subdirectories:</b></p>\n"); MakeSubdirectoryLinks(builder, subdirectoryList); } builder.Append("\n<p><b>Image Count in this Web Directory: "); builder.Append(N); builder.Append("</b></p>\n"); MakeImageLinks(builder, directoryPath, imageList); return(builder.ToString()); }
/// <summary> /// Returns the markup for the list of files /// that reside in the context web directory /// and that match the given file type. /// /// Each file name will link to the file viewer. /// /// The filetype should take one of seven values: /// 1: Text files /// 2: Image files /// 3: Viewable files, that is, text or image files /// 4: Non-viewable files /// 5: Text files plus non-viewable files /// 6: Image files plus non-viewable files /// 7: All files /// /// If no files match the filetype then the empty /// string will be returned as the markup. /// /// The optional comment heads the list of file names. /// If omitted, a default comment is provided. /// </summary> /// <param name="context">Web site HttpContext object</param> /// <param name="fileType">The filetype mask</param> /// <param name="comment">Optional comment to head list</param> /// <param name="extras">If true show extras</param> public static string MakeFileListMarkup (HttpContext context, int fileType, string comment) { if (context == null) { return(""); } fileType &= FileTools.ALL; if (fileType == 0) { return(""); } List <string> filelist = HttpContextTools.MakeFileList(context, fileType); int count = filelist.Count; if (count == 0) { return(""); } string tildeDirectoryPath = HttpContextTools.GetTildeDirectoryPath(context); StringBuilder builder = new StringBuilder(); builder.Append(HTML_Tools.open_p); if (StringTools.IsTrivial(comment)) { switch (fileType) { case 1: builder.Append("Text files in "); break; case 2: builder.Append("Image files in "); break; case 3: builder.Append("Viewable files in "); break; case 4: builder.Append("Non-viewable files in "); break; case 5: builder.Append("Text and non-viewable files in "); break; case 6: builder.Append("Image and non-viewable files in "); break; case 7: builder.Append("All files in "); break; default: break; } builder.Append(tildeDirectoryPath); builder.Append(" ["); builder.Append(count); builder.Append("]:"); } else { builder.Append(comment); } builder.Append(HTML_Tools.shut_p); foreach (string filename in filelist) { string tildeFilePath = tildeDirectoryPath + filename; string filelink = MakeFileViewLinkMarkup(context, tildeFilePath); builder.Append(filelink); } return(builder.ToString()); }