Apache-PSP
view release on metacpan or search on metacpan
lib/Template/PSP/autoform.psp view on Meta::CPAN
setpvar('autofill_data', $values);
}
else
{
# include the specified module
eval qq{use $module;};
if ($@)
{
die "The autoformfill tag can't load module ($module): $@\n";
}
my $autofill_data = $module->$method;
# check for errors
unless ($autofill_data)
{
}
setpvar( 'autofill_data', $autofill_data );
}
</perl>
</tag>
<tag name="autotext" body="1" global="1"
accepts="name, diff, size, maxlength">
<perl>
=head2 AutoFill text tag
The C<autotext> tag fills in a form field.
Usage:
<autotext name="full_nm" size="20" maxlength="50" />
=cut
my $af = getpvar('autofill_data');
my $value = $af->{'field'}->{$name} || '';
# differentiate the field name
$diff = '_' . $af->{'field'}{$diff} if $diff;
# translate characters to make them form-safe
$value =~ s/"/"/g;
print qq{<input type="text" name="${name}${diff}" value="$value" size="$size" maxlength="$maxlength" />};
</perl>
</tag>
<tag name="automessage" body="1" global="1"
accepts="name,lookup">
<perl>
=head2 AutoFill message tag
The C<automessage> tag displays a non-editable field.
Usage:
<automessage name="full_nm" />
=cut
my $af = getpvar('autofill_data');
my $value = $af->{'field'}->{$name} || ' ';
if ($lookup)
{
$value = $af->{'lookup'}{$lookup}{$value};
}
# translate characters to make value HTML-safe
$value =~ s/</</g;
$value =~ s/>/>/g;
print qq{$value};
print qq{$body};
</perl>
</tag>
<tag name="autolink" body="1" global="1"
accepts="name, href, fields, cond">
<perl>
=head2 AutoFill link tag
The C<autolink> tag displays a non-editable link.
Usage:
<autolink href="view_user.psp" name="full_nm" />
=cut
print "\n";
my $af = getpvar('autofill_data');
my @fields = split /\s?,\s?/, $fields;
my $value = $body || $af->{'field'}->{$name};
my $query = '';
my $display_link = $cond ? 0 : 1;
# add the specified fields as query variables
foreach my $f (@fields)
{
# translate characters to make value URL-safe
my $value = $af->{'field'}->{$f};
my $url_value = CGI::Minimal->url_encode($value);
$query .= "$f=$url_value&";
if ($cond eq $f and $value)
{
$display_link = 1;
}
}
# display the link unless a condition isn't met
if ($display_link)
{
print qq{<a href="$href?$query">$value</a>};
}
elsif ($cond eq $name)
{
# don't print anything if there's nothing to print
print qq{};
}
else
{
print qq{$value};
}
</perl>
</tag>
<tag name="autoforward" body="1" global="1"
accepts="href, fields">
<perl>
=head2 AutoFill forward tag
The C<autoforward> tag displays a non-editable link.
Usage:
<autoforward href="view_user.psp" fields="" />
=cut
print "\n";
my $af = getpvar('autofill_data');
my $query = '';
foreach my $f (keys %QUERY)
{
foreach my $value (split /\0/, $QUERY{$f})
{
# translate characters to make value URL-safe
my $url_value = CGI::Minimal->url_encode($value);
$query .= "$f=$url_value&";
}
}
print qq{<a href="$href?$query">$body</a>};
</perl>
</tag>
<tag name="autoqueryhidden" body="1" global="1"
accepts="fields">
<perl>
=head2 AutoFill query forwarding tag
The C<autoqueryhidden> tag adds query variables as hidden form fields.
Usage:
<autoqueryhidden />
=cut
print "\n";
my $af = getpvar('autofill_data');
my $query = '';
foreach my $f (keys %QUERY)
{
foreach my $value (split /\0/, $QUERY{$f})
{
# translate characters to make value HTML-safe
$value =~ s/&/&/g;
$value =~ s/</</g;
print qq{<input type="hidden" name="$f" value="$value" />\n};
}
}
</perl>
</tag>
( run in 2.970 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )