mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Added a Module Config option to specify file extensions to treat as HTML
This commit is contained in:
@@ -37,3 +37,5 @@ Added a link in the HTML editor window to swich to plain text mode.
|
||||
Files in the right-hand list are now sorted case-insensitively.
|
||||
When uploading a file, you can now select which Unix user it gets uploaded as.
|
||||
Added Module Config options for the default unzip mode and default user to upload as.
|
||||
---- Changes since 1.360 ----
|
||||
Added a Module Config option to specify file extensions to treat as HTML, rather than always using only .html and .htm.
|
||||
|
||||
@@ -83,6 +83,9 @@ public class FileManager extends Applet
|
||||
// Use text editor for HTML
|
||||
boolean force_text;
|
||||
|
||||
// File extensions to consider as HTML
|
||||
String htmlexts[];
|
||||
|
||||
public void init()
|
||||
{
|
||||
setLayout(new BorderLayout());
|
||||
@@ -126,6 +129,10 @@ public class FileManager extends Applet
|
||||
String force_text_str = getParameter("force_text");
|
||||
if (force_text_str != null && force_text_str.equals("1"))
|
||||
force_text = true;
|
||||
String htmlexts_str = getParameter("htmlexts");
|
||||
if (htmlexts_str == null || htmlexts_str.equals(""))
|
||||
htmlexts_str = ".htm .html";
|
||||
htmlexts = DFSAdminExport.split(htmlexts_str);
|
||||
|
||||
// download language strings
|
||||
String l[] = get_text("lang.cgi");
|
||||
@@ -625,9 +632,7 @@ public class FileManager extends Applet
|
||||
new ErrorWindow(text("top_efile"));
|
||||
else if (f.type == 0 || f.type > 4)
|
||||
new ErrorWindow(text("edit_enormal"));
|
||||
else if ((f.path.toLowerCase().endsWith(".htm") ||
|
||||
f.path.toLowerCase().endsWith(".html")) &&
|
||||
!force_text) {
|
||||
else if (is_html_filename(f.path) && !force_text) {
|
||||
// Open HTML editor
|
||||
try {
|
||||
JSObject win = JSObject.getWindow(this);
|
||||
@@ -825,6 +830,14 @@ public class FileManager extends Applet
|
||||
}
|
||||
}
|
||||
|
||||
boolean is_html_filename(String path)
|
||||
{
|
||||
for(int i=0; i<htmlexts.length; i++)
|
||||
if (path.toLowerCase().endsWith(htmlexts[i]))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean under_root_dir(String p, String roots[])
|
||||
{
|
||||
boolean can = false;
|
||||
@@ -2654,7 +2667,7 @@ class DFSAdminExport
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
String[] split(String s)
|
||||
static String[] split(String s)
|
||||
{
|
||||
StringTokenizer stok = new StringTokenizer(s, " ");
|
||||
String rv[] = new String[stok.countTokens()];
|
||||
|
||||
@@ -8,3 +8,4 @@ small_fixed=Font size for buttons,3,Default (10 points)
|
||||
force_text=Editor for HTML files,1,1-Text editor,0-HTML editor
|
||||
defzip=Default archive mode for uploads,1,2-Extract and delete,1-Extract,0-Do nothing
|
||||
defuser=Default user for uploads,10,root-root,*-Same as directory,Other user
|
||||
htmlexts=File extensions to edit as HTML,3,Default (.htm and .html)
|
||||
|
||||
@@ -7,7 +7,7 @@ $disallowed_buttons{'edit'} && &error($text{'ebutton'});
|
||||
&ReadParse();
|
||||
|
||||
# Work out editing mode
|
||||
if ($in{'text'} || $in{'file'} && $in{'file'} !~ /\.(htm|html|shtml)$/i) {
|
||||
if ($in{'text'} || $in{'file'} && !&is_html_file($in{'file'})) {
|
||||
$text_mode = 1;
|
||||
}
|
||||
|
||||
@@ -72,4 +72,13 @@ print &ui_form_end();
|
||||
|
||||
&popup_footer();
|
||||
|
||||
|
||||
sub is_html_file
|
||||
{
|
||||
local ($file) = @_;
|
||||
local @exts = split(/\s+/, $userconfig{'htmlexts'} || $config{'htmlexts'});
|
||||
@exts = ( ".htm", ".html", ".shtml" ) if (!@exts);
|
||||
foreach my $e (@exts) {
|
||||
return 1 if ($file =~ /\Q$e\E$/i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ open("edit_html.cgi?file="+escape(file)+"&dir="+escape(dir)+"&trust=$trust", "ht
|
||||
<param name=canusers value="$canusers">
|
||||
<param name=contents value="$contents">
|
||||
<param name=force_text value="$config{'force_text'}">
|
||||
<param name=htmlexts value="$config{'htmlexts'}">
|
||||
$config
|
||||
$session
|
||||
$open
|
||||
|
||||
Reference in New Issue
Block a user