Skip to content

Commit dd37e8a

Browse files
committed
Add ability to hide dotfiles in FIle Manager #1578
1 parent 0ea5c6d commit dd37e8a

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

extensions/file-manager/file-manager-lib.pl

+21-4
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ sub get_user_config
140140
}
141141
}
142142

143+
sub get_user_config_showhidden
144+
{
145+
return get_user_config('config_portable_module_filemanager_show_dot_files') ne 'false';
146+
}
147+
143148
sub kill_previous
144149
{
145150
my $pid = tokenize($_[0]);
@@ -270,6 +275,7 @@ sub test_all_items_query
270275
sub get_entries_list
271276
{
272277
my @entries_list;
278+
my $show_dot_files = get_user_config_showhidden();
273279
if (test_all_items_query()) {
274280
if ($in{'query'}) {
275281
@entries_list = exec_search('list');
@@ -279,7 +285,7 @@ sub get_entries_list
279285
wanted => sub {
280286
my $found = $File::Find::name;
281287
$found =~ s/^\Q$cwd\/\E//g;
282-
if ($_ ne '.' && $_ ne '..' && $found !~ /\//) {
288+
if ($_ ne '.' && $_ ne '..' && $found !~ /\// && ($show_dot_files || ($_ !~ /^\./ && $found !~ /\/\./))) {
283289
push(@entries_list, $found);
284290
}
285291
},
@@ -443,6 +449,8 @@ sub exec_search
443449
my @results;
444450
my @excludes;
445451

452+
my $show_dot_files = get_user_config_showhidden();
453+
446454
my @results_cached = cache_search($fsid);
447455
if (@results_cached) {
448456
return @results_cached;
@@ -606,7 +614,9 @@ sub exec_search
606614
}
607615
}
608616
if (!$extra_exclude && (!$exclude || (@excludes && !$excluded))) {
609-
push(@results, $found);
617+
if ($show_dot_files || ($_ !~ /^\./ && $found !~ /\/\./)) {
618+
push(@results, $found);
619+
}
610620
}
611621
}
612622
}
@@ -676,6 +686,8 @@ sub print_content
676686
$path =~ s/[\/]+/\//g;
677687
return $path;
678688
};
689+
690+
my $show_dot_files = get_user_config_showhidden();
679691

680692
# In case of search trim the list accordingly
681693
if ($query) {
@@ -685,7 +697,8 @@ sub print_content
685697
print_error("$text{'theme_xhred_global_error'}: [tt]`$cwd`[/tt]- $!.");
686698
exit;
687699
}
688-
@list = grep {$_ ne '.' && $_ ne '..'} readdir(DIR);
700+
701+
@list = grep {$_ ne '.' && $_ ne '..' && ($show_dot_files || ($_ !~ /^\./ && $_ !~ /\/\./))} readdir(DIR);
689702
closedir(DIR);
690703
}
691704

@@ -1113,6 +1126,8 @@ sub get_tree
11131126
my @af = length($p) ? ($p) : @ap;
11141127
my $fu = scalar(@af) == 1;
11151128

1129+
my $show_dot_files = get_user_config_showhidden();
1130+
11161131
# Check the queried path is allowed in the first place
11171132
if (length($p)) {
11181133
return \@r if (grep {$_ =~ /^\Q$p\E/} @ap);
@@ -1128,7 +1143,9 @@ sub get_tree
11281143
my $pp = ($fu && $afic ne '/') ? $afic : undef;
11291144
my $c = $r{$td} =
11301145
{ key => html_escape("$pp/$td"), title => (defined($cd) ? html_escape($cd) : html_escape($td)), link => $ltd };
1131-
defined $pd ? (push @{ $r{$pd}{'children'} }, $c) : (push @r, $c);
1146+
if ($show_dot_files || ($td !~/^\./ && $td !~/\/\./ && $cd !~/^\./ && $cd !~/\/\./)) {
1147+
defined $pd ? (push @{ $r{$pd}{'children'} }, $c) : (push @r, $c);
1148+
}
11321149
};
11331150

11341151
my $dc = $td =~ tr[/][];

modules/filemin/config.defaults

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ per_page=30
44
config_portable_module_filemanager_default_sort=0
55
config_portable_module_filemanager_records_for_server_pagination=1000
66
config_portable_module_filemanager_move_to_trash=false
7+
config_portable_module_filemanager_show_dot_files=true
78

89
config_portable_module_filemanager_hide_tree_view=false
910
config_portable_module_filemanager_tree_expand_search=true

modules/filemin/config.info

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ config_portable_module_filemanager_force_tar=Force <code>tar</code> command&#44;
2727
config_portable_module_filemanager_files_safe_mode=Do not overwrite existing files upon operations,1,true-Yes,false-No
2828
config_portable_module_filemanager_switch_users=Automatically set owner and group equivalent to user home on file operations,1,true-Yes,false-No
2929
config_portable_module_filemanager_hide_actions=Hide column containing action icons,1,true-Yes,false-No
30+
config_portable_module_filemanager_show_dot_files=Show all hidden files,1,true-Yes,false-No

unauthenticated/js/defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ var
129129
config_portable_module_filemanager_view_limit = 512000,
130130
config_portable_module_filemanager_checksum_limit = 1024000,
131131
config_portable_module_filemanager_move_to_trash = false,
132+
config_portable_module_filemanager_show_dot_files = true,
132133

133134
// Locale defaults
134135
config_portable_theme_locale_format_full = 'LLLL',

0 commit comments

Comments
 (0)