home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
FAQ
/
cgi-bin
/
discus4_00
/
source
/
img-list.pl
< prev
next >
Wrap
Text File
|
2009-11-06
|
3KB
|
75 lines
# FILE: img-list.pl
# DESCRIPTION: User Interface list of images in "clipart" directory
# NOTE: See http://support.discusware.com/center/resources/custom/imglist.html
#-------------------------------------------------------------------------------
# DISCUS COPYRIGHT NOTICE
#
# Discus is copyright (c) 2002 by DiscusWare, LLC, all rights reserved.
# The use of Discus is governed by the Discus License Agreement which is
# available from the Discus WWW site at:
# http://www.discusware.com/discus/license
#
# Pursuant to the Discus License Agreement, this copyright notice may not be
# removed or altered in any way.
#-------------------------------------------------------------------------------
use strict;
use vars qw($GLOBAL_OPTIONS $DCONF $PARAMS);
###
### image_lister_control
###
### Generates a listing of the images found in the clipart directory
###
sub image_lister_control {
my $FORMref = defined $_[0] ? $_[0] : parse_form($ENV{'QUERY_STRING'}, $ENV{'CONTENT_LENGTH'});
my $cookie_str = $_[1];
dreq("template");
my $subst = {};
my $dir = defined $FORMref->{dir} ? $FORMref->{dir} : "clipart";
$dir =~ s/\W//g;
error_message("Directory Search Error", "Directory [$dir] cannot be searched!", 0, 1) if $dir eq "messages";
error_message("Directory Search Error", "Directory [$dir] cannot be searched!", 0, 1) if $dir eq "";
my $rdir = join("/", $DCONF->{html_dir}, $dir);
error_message("Directory Search Error", "Directory [$rdir] does not exist!", 0, 1) if ! -e $rdir;
error_message("Directory Search Error", "Directory [$rdir] is not a directory!", 0, 1) if ! -d $rdir;
$subst->{general}->{image_url} = join("/", $DCONF->{html_url}, $dir);
my $tag = defined $FORMref->{tagname} ? $FORMref->{tagname} : read_language()->{ILCLIPTAG};
$tag =~ s/<.*?>//g;
error_message("Illegal Tag Error", "Cannot use the tag you specified!", 0, 1) if $tag !~ /\S/;
$subst->{general}->{clip_tag} = $tag;
my $reg_exp = "(.*)";
$reg_exp = join("", "^", quotemeta($FORMref->{filterbegin}), $reg_exp) if $FORMref->{filterbegin};
$reg_exp = join("", $reg_exp, quotemeta($FORMref->{filterend}), '$') if $FORMref->{filterend};
$reg_exp .= "\\.gif\$" if ! $FORMref->{filterend};
$subst->{general}->{regexp} = $reg_exp;
my $shown = {};
if ($FORMref->{show}) {
foreach my $x (split(/,/, $FORMref->{show})) {
$shown->{$x} = 1;
}
}
$subst->{general}->{pagetitle} = defined $FORMref->{title} ? $FORMref->{title} : read_language()->{ILTITLE};
my @img = ();
if (opendir(DIR, $rdir)) {
while (my $d = readdir(DIR)) {
my $file = join("/", $rdir, $d);
next if ! -f $file;
next if $d !~ /$reg_exp/;
next if scalar(keys(%{ $shown })) && ! $shown->{$d};
next if $d eq "your_image.gif";
next if $d eq "board_logo.gif";
my $i = $d;
$i =~ s/\.(\w+)$// if ! $FORMref->{save_ext};
push @img, { filename => $d, shownfile => $i };
}
}
@img = sort { lc($a->{filename}) cmp lc($b->{filename}) } @img;
$subst->{images} = \@img;
$subst->{general}->{popup} = $FORMref->{popup};
screen_out("img-list", $subst, $cookie_str);
}
1;