Name

value_extended —

ATTRIBUTES

Attribute Pos. Req. Default Description

DESCRIPTION

BEHAVIOR

This tag does not appear to be affected by, or affect, the rest of Interchange.

EXAMPLES

No examples are available at this time. We do consider this a problem and will try to supply some.

NOTES

AVAILABILITY

value_extended is available in Interchange versions:

4.6.0-5.9.0 (git-head)

SOURCE

Interchange 5.9.0:

Source: lib/Vend/Interpolate.pm
Lines: 2387

sub tag_value_extended {
  my($var, $opt) = @_;

my $vspace = $opt->{values_space};
my $vref;
if (defined $vspace) {
  if ($vspace eq '') {
    $vref = $Vend::Session->{values};
  }
  else {
    $vref = $Vend::Session->{values_repository}{$vspace} ||= {};
  }
}
else {
  $vref = $::Values;
}

my $yes = $opt->{yes} || 1;
my $no = $opt->{'no'} || '';

if($opt->{test}) {
  $opt->{test} =~ /(?:is)?put/i
    and
    return defined $CGI::put_ref ? $yes : $no;
  $opt->{test} =~ /(?:is)?file/i
    and
    return defined $CGI::file{$var} ? $yes : $no;
  $opt->{test} =~ /defined/i
    and
    return defined $CGI::values{$var} ? $yes : $no;
  return length $CGI::values{$var}
    if $opt->{test} =~ /length|size/i;
  return '';
}

if($opt->{put_contents}) {
  return undef if ! defined $CGI::put_ref;
  return $$CGI::put_ref;
}

my $val = $CGI::values{$var} || $vref->{$var} || return undef;
$val =~ s/</&lt;/g unless $opt->{enable_html};
$val =~ s/\[/&#91;/g unless $opt->{enable_itl};

if($opt->{file_contents}) {
  return '' if ! defined $CGI::file{$var};
  return $CGI::file{$var};
}

if($opt->{put_ref}) {
  return $CGI::put_ref;
}

if($opt->{outfile}) {
  my $file = $opt->{outfile};
  $file =~ s/^\s+//;
  $file =~ s/\s+$//;

  unless (Vend::File::allowed_file($file)) {
    Vend::File::log_file_violation($file, 'value-extended');
    return '';
  }

  if($opt->{ascii}) {
    my $replace = $^O =~ /win32/i ? "\r\n" : "\n";
    if($CGI::file{$var} !~ /\n/) {
      # Must be a mac file.
      $CGI::file{$var} =~ s/\r/$replace/g;
    }
    elsif ( $CGI::file{$var} =~ /\r\n/) {
      # Probably a PC file
      $CGI::file{$var} =~ s/\r\n/$replace/g;
    }
    else {
      $CGI::file{$var} =~ s/\n/$replace/g;
    }
  }
  if($opt->{maxsize} and length($CGI::file{$var}) > $opt->{maxsize}) {
    logError(
      "Uploaded file write of %s bytes greater than maxsize %s. Aborted.",
      length($CGI::file{$var}),
      $opt->{maxsize},
    );
    return $no;
  }
#::logDebug(">$file \$CGI::file{$var}" . uneval($opt));
  $opt->{encoding} ||= $CGI::file_encoding{$var};
  Vend::Util::writefile(">$file", \$CGI::file{$var}, $opt)
    and return $yes;
  return $no;
}

my $joiner;
if (defined $opt->{joiner}) {
  $joiner = $opt->{joiner};
  if($joiner eq '\n') {
    $joiner = "\n";
  }
  elsif($joiner =~ m{\\}) {
    $joiner = $ready_safe->reval("qq{$joiner}");
  }
}
else {
  $joiner = ' ';
}

my $index = defined $opt->{'index'} ? $opt->{'index'} : '*';

$index = '*' if $index =~ /^\s*\*?\s*$/;

my @ary;
if (!ref $val) {
  @ary = split /\0/, $val;
}
elsif($val =~ /ARRAY/) {
  @ary = @$val;
}
else {
  logError( "value-extended %s: passed non-scalar, non-array object", $var);
}

return join " ", 0 .. $#ary if $opt->{elements};

eval {
  @ary = @ary[$ready_safe->reval( $index eq '*' ? "0 .. $#ary" : $index )];
};
logError("value-extended $var: bad index") if $@;

if($opt->{filter}) {
  for(@ary) {
    $_ = filter_value($opt->{filter}, $_, $var);
  }
}
return join $joiner, @ary;
}

AUTHORS

Interchange Development Group

SEE ALSO

DocBook! Interchange!