1 # Copyright 2005-2007 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: imagedir.widget,v 1.7 2007-03-30 23:40:58 pajamian Exp $
10 CodeDef imagedir Widget 1
11 CodeDef imagedir Description Image listing
12 CodeDef imagedir ExtraMeta <<EOM
14 _order => [ qw/ follow_symlinks / ],
17 label => 'Follow Symlinks',
18 help => 'Set to yes if you want to list all files, even following symbolic links',
23 CodeDef imagedir Routine <<EOR
27 my $dir = delete $opt->{dir} || delete $opt->{outboard};
28 my $suf = delete $opt->{suffix} || delete $opt->{options};
29 return undef unless -d $dir;
30 #::logDebug("passed suf=$suf");
31 $suf = '\.(GIF|gif|JPG|JPEG|jpg|jpeg|png|PNG)'
34 if($suf and $suf !~ /[\.|]/) {
35 my @types = grep /\S/, split /[,\s\0]+/, $suf;
36 $suf = '\.(' . join("|", @types) . ')';
46 return undef unless -f $_;
47 return undef unless $_ =~ $regex;
48 my $n = $File::Find::name;
52 find({ wanted => $wanted, follow => $opt->{follow_symlinks} }, $dir);
53 $opt->{passed} = [ '=None', sort @names ];
54 $opt->{type} = delete $opt->{variant} || 'combo';
55 return Vend::Form::display($opt);