Interchange Reference Pages: Filters


For a complete introduction to Interchange filters, please see the filter glossary entry.

Table of Contents

acl2hash — convert Interchange ACL string to a Perl hash representation
alpha — eliminate non-alpha characters
alphanumeric — eliminate non-alphanumeric characters
backslash — eliminate backslashes
bold — enclose input in HTML <b> (bold) tag
cgi — expand to value of the CGI variable specified in body
checkbox — return user-supplied value if its length is 1 or more, an empty string otherwise
colons_to_null — replace double colons "::" with \0 (null) character
commify — add thousands separator to a number, and trim to specified number of decimal places
compress_space — eliminate leading and trailing whitespace and compress all "in-string" whitespace occurrences to exactly 1 space each
convert_date — convert date to a specified format
crypt — run Unix crypt() function on input data
currency — format number as currency, honoring default or specified locale
date2time — convert date (possibly with specified time) to number of seconds since Epoch
date_change — convert MMDDYYYY date (possibly with specified time) to YYYYMMDDhhmm
datetime2epoch — convert date (possibly with specified time) to number of seconds since Epoch
dbi_quote — safely quote strings for use in SQL statements using DBI's quote method
decode_entities — decode encoded HTML characters back to their unencoded representation
digits — eliminate non-digit characters
digits_dash — eliminate non-digit characters, with the exception of dashes
digits_dot — eliminate non-digit characters, with the exception of dots
dos — convert UNIX or Max ASCII text to DOS format
duration — calculate end date from given start date and duration
encode_entities — encode non-standard HTML characters
encode_special_entities
encrypt — PGP-encrypt input
filesafe — make sure the input is ready for use as a filename
filter_select — automatically select filter based on HTML widget type
gate — return input verbatim if the specified Scratch variable exists, empty string otherwise
hash2acl — convert Interchange ACL hash to string representation
html2text — transform basic HTML input to plain-text
integer — return integer value of the input
italics — enclose input in HTML <i> (italic) tag
large — enclose input in HTML <large> tag
last_non_null — return last non-null entry from an input consisting of null-separated fields
lc — transform all input to lowercase
lcfirst — transform first character in input to lowercase
line — output just the first line of input
line2options — replace newlines in input with commas
linkdecode — decode hex-encoded entities found within URLs
liven_urls — make all kinds of URLs clickable
loc — localize provided input
lookup — perform lookup in another database
lspace_to_nbsp — replace leading spaces (" ") with nonbreakable space ("&nbsp;") characters
mac — convert UNIX or DOS ASCII text to Apple Macintosh format
mailto — enclose input in HTML <a href='mailto: ...'> link
md5 — calculate MD5 sum of input
mime_type — print file MIME type, based on file extension
name — transform "Last, First" name format to "First Last"
namecase — transform any "NAME" to "Name"
next_sequential
no_white — eliminate all whitespace in input
null_to_colons — replace \0 (null) characters with double colon "::"
null_to_comma — replace \0 (null) characters with comma ","
null_to_space — replace \0 (null) characters with space " "
nullselect — split input on \0 (null) characters and return first non-empty string
oneline — delete everything after first null or newline character, effectively "onelining" the input
option_format
options2line — replace commas in input with newlines
pagefile — make sure the input is ready for use as an Interchange page filename
pgbool — return "f" (false) or "t" (true), depending on input data
pgbooln — return undef (NULL), "f" (false) or "t" (true), depending on input data
pre — enclose input in HTML <pre> (preformatted) tag
qb_safe — make input safe for QuickBooks by removing unfriendly characters
restrict_html — filter out all but the restricted set of allowed HTML tags in input
roman — transform input integer to Roman numerals
round — round value in floating-point-safe way
sha1 — calculate SHA1 sum of input
show_null — replace null-characters (\0) with literal "\0"
small — enclose input in HTML <small> tag
space_to_nbsp — replace all spaces (" ") with nonbreakable space ("&nbsp;") characters
space_to_null — replace space " " with \0 (null) character
sql — quote strings for use in SQL statements, without referencing a specific database
strftime — transform UNIX time (number of seconds) to a date/time string, according to specified format
strikeout — enclose input in HTML <strike> tag
strip — trim leading and trailing whitespace
strip_html
strip_path
tabbed — replace newlines in input with TAB characters
text2html — transform input plain-text to most basic HTML
textarea_get — replace &amp; (ampersand) entities in input with literal &
textarea_put — replace &, < and [ characters with their encoded representation
tt — enclose input in HTML <tt> (typewriter) tag
uc — transform all input to uppercase
ucfirst — transform first character in input to uppercase
unix — convert DOS or Mac ASCII text to Unix format
upload
urldecode — replace encoded (hex) characters with their unencoded representation
urlencode — replace non-word characters or a colon with encoded (hex) representation
value — expand to value of the UserDB variable specified in body
vars_and_comments — interpolate variables and remove comments
word — eliminate any non-word characters
yesno — return Yes for non-empty input, No otherwise
zerofix — eliminate possible zeros at beginning of input

Name

acl2hash — convert Interchange ACL string to a Perl hash representation

DESCRIPTION

The filter is specific to the ACL widget and probably should not be used otherwise.

The filter doesn't need to be selected for the widget to operate in the table-editor.

EXAMPLES

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

NOTES

AVAILABILITY

acl2hash is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/acl2hash.filter
Lines: 34


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: acl2hash.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $

CodeDef acl2hash Filter
CodeDef acl2hash Description acl2hash
CodeDef acl2hash Visibility private
CodeDef acl2hash Routine <<EOR
sub {
my ($value) = @_;
my $orig = $value;
$value =~ s/^[\s,\0]+//;
$value =~ s/[\s,\0]+$//;
return $value if $value =~ /^\{.*\}$/s;
$value =~ s/\0//g;
my $hash = Vend::Util::get_option_hash($value)
  or return '{}';

my @del;
while(my ($k, $v) = each %$hash) {
  push @del, $k if $v =~ /d/;
  push @del, $k if ! length($k);
}
delete @{$hash}{@del} if @del;
my $out = ::uneval_it($hash);
return $out;
}
EOR


Name

alpha — eliminate non-alpha characters

DESCRIPTION

The filter eliminates any non-alpha characters (anything not in a-zA-Z range).

EXAMPLES

Example: Filter example

[filter alpha]** Test 1: Hello, World! **[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

alpha is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/alpha.filter
Lines: 20


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: alpha.filter,v 1.7 2007-08-20 21:11:09 jon Exp $

CodeDef alpha Filter
CodeDef alpha Description A-Za-z only
CodeDef alpha Help  Returns only ASCII alphabetic characters (A-Z and a-z)
CodeDef alpha Routine <<EOR
sub {
my $val = shift;
$val =~ s/[^A-Za-z]+//g;
return $val;
}
EOR


Name

alphanumeric — eliminate non-alphanumeric characters

DESCRIPTION

The filter eliminates any non-alphanumeric characters (anything not in a-zA-Z0-9 range).

EXAMPLES

Example: Filter example

[filter alphanumeric]** Test 2: Hello, World! **[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

alphanumeric is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/alphanumeric.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: alphanumeric.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef alphanumeric Filter
CodeDef alphanumeric Description A-Za-z0-9 only
CodeDef alphanumeric Routine <<EOR
sub {
my $val = shift;
$val =~ s/[^A-Za-z0-9]+//g;
return $val;
}
EOR

SEE ALSO

alpha(7ic)


Name

backslash — eliminate backslashes

DESCRIPTION

The filter eliminates backslashes.

EXAMPLES

Example: Filter example

[filter backslash]The filter will remove all of those: \\\\ \\\\[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

backslash is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/backslash.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: backslash.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef backslash Filter
CodeDef backslash Description Strip backslash
CodeDef backslash Routine <<EOR
sub {
my $val = shift;
$val =~ s/\\+//g;
return $val;
}
EOR

SEE ALSO


Name

bold — enclose input in HTML <b> (bold) tag

DESCRIPTION

The filter encloses input data in HTML <b> (bold) tag.

EXAMPLES

Example: Filter example

"[filter bold]To Boldly Go Where No One Has Gone Before![/filter]"
  -- Star Trek

NOTES

AVAILABILITY

bold is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/bold.filter
Lines: 17


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: bold.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef bold Filter
CodeDef bold Description HTML bold
CodeDef bold Routine <<EOR
sub {
return '<b>' . shift(@_) . '</b>'; 
}
EOR

SEE ALSO

italics(7ic)


Name

cgi — expand to value of the CGI variable specified in body

DESCRIPTION

The filter expands to the value of a CGI variable. Name of the variable is specified in filter body.

EXAMPLES

Example: Filter example

[cgi name=online_cgi_test set="TEST VALUE" hide=1]

My test value is [filter cgi]online_cgi_test[/filter]

NOTES

AVAILABILITY

cgi is available in Interchange versions:

4.8.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/cgi.filter
Lines: 17


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: cgi.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef cgi Filter
CodeDef cgi Description Get CGI value of variable
CodeDef cgi Routine <<EOR
sub {
return $CGI::values{$_[0]};
}
EOR

SEE ALSO


Name

checkbox — return user-supplied value if its length is 1 or more, an empty string otherwise

DESCRIPTION

The filter checks for the length of input. When the length of input is non-zero, the filter returns input itself. When the length is zero, the filter returns an empty string.

The filter is suitable for retrieving values out of HTML checkboxes.

EXAMPLES

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

NOTES

AVAILABILITY

checkbox is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/checkbox.filter
Lines: 17


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: checkbox.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $

CodeDef checkbox Filter
CodeDef checkbox Routine <<EOR
sub {
my $val = shift;
return length($val) ? $val : '';
}
EOR


Name

colons_to_null — replace double colons "::" with \0 (null) character

DESCRIPTION

The filter replaces double colons (::) with a \0 (null) character.

EXAMPLES

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

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

colons_to_null is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/colons_to_null.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: colons_to_null.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef colons_to_null Filter
CodeDef colons_to_null Description :: to NULL
CodeDef colons_to_null Routine <<EOR
sub {
my $val = shift;
$val =~ s/::/\0/g;
return $val;
}
EOR


Name

commify — add thousands separator to a number, and trim to specified number of decimal places

DESCRIPTION

The filter adds a thousands separator to a number, and trims decimal places to a specified maximum length.

EXAMPLES

Example: Filter example

[set online_commify_test]1234567890.123456[/set]
[filter op=commify.2 interpolate=1][scratchd online_commify_test][/filter]

NOTES

The thousands separator is a comma (","), and does not honor Locale mon_thousands_sep.

AVAILABILITY

commify is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/commify.filter
Lines: 18


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.

CodeDef commify Filter
CodeDef commify Description Commify
CodeDef commify Routine <<EOR
sub {
my ($val, $tag, $places) = @_;
$places = 2 unless defined $places;
$val = sprintf("%.${places}f", $val) if defined $places;
return Vend::Util::commify($val);
}
EOR

SEE ALSO


Name

compress_space — eliminate leading and trailing whitespace and compress all "in-string" whitespace occurrences to exactly 1 space each

DESCRIPTION

The filter eliminates leading and trailing whitespace, and compresses all occurrences of whitespace in a string to exactly 1 space on each occurrence.

EXAMPLES

Example: Filter example

[filter compress_space]   LEADING   Hello,  World!   TRAILING  [/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

compress_space is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/compress_space.filter
Lines: 21


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: compress_space.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef compress_space Filter
CodeDef compress_space Description Collapse whitespace
CodeDef compress_space Routine <<EOR
sub {
my $val = shift;
$val =~ s/\s+$//g;
$val =~ s/^\s+//g;
$val =~ s/\s+/ /g;
return $val;
}
EOR

SEE ALSO


Name

convert_date — convert date to a specified format

DESCRIPTION

The filter calls convert-date to output date according to the specified format string.

For the accepted formats in which the input date needs to be specified, see convert-date.

See time glossary entry for a list and description of format specifiers.

EXAMPLES

Example: Filter example

Year is [filter convert_date.%Y][time][/filter].

Example: Filter example

To get a pretty formatted date, such as "May 16, 2007", use
[filter convert_date."%B %e, %Y"][time][/filter].

NOTES

This filter looks almost exactly like the convert-date tag, but there's a simple difference in the implementation. convert-date tag called with an empty or invalid time string it will default to the current time; this filter called with an empty or invalid time string will default to an empty value.

AVAILABILITY

convert_date is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/convert_date.filter
Lines: 26


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: convert_date.filter,v 1.7 2007-03-30 23:40:44 pajamian Exp $

CodeDef convert_date Filter
CodeDef convert_date Description Convert date
CodeDef convert_date Visibility  private
CodeDef convert_date Routine <<EOR
sub {
my $time = shift(@_);
# Don't convert nothing to something
return '' unless $time;
shift(@_);
my $fmt = shift(@_);
while(my $add = shift(@_)) {
  $fmt .= " $add";
}
return $Tag->convert_date({ fmt => $fmt, body => $time});
}
EOR

SEE ALSO


Name

crypt — run Unix crypt() function on input data

DESCRIPTION

The filter calls Perl crypt function to encrypt input data.

EXAMPLES

Example: Filter example with random salt

The encrypted string should be different each time you run the code because the salt is random.
Encrypted string TEST with random salt is: 
[filter crypt]TEST[/filter].

Example: Filter example with hand-specified salt

The encrypted string should be the same each time you run the code because the salt does not change.
Encrypted string TEST with salt of AB is: 
[filter crypt.AB]TEST[/filter].

NOTES

AVAILABILITY

crypt is available in Interchange versions:

4.8.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/crypt.filter
Lines: 18


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: crypt.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $

CodeDef crypt Filter
CodeDef crypt Description Crypt
CodeDef crypt Routine <<EOR
sub {
my ($val, $tag, $salt) = @_;
return crypt($val, $salt ? $salt : random_string(2));
}
EOR


Name

currency — format number as currency, honoring default or specified locale

DESCRIPTION

The filter formats input number as a currency. All currency-related options and default locale are honored, and a specific locale can also be set as well.

EXAMPLES

Example: Displaying a value formatted as a currency

[filter currency]40.2[/filter]

Example: Displaying a value in specific locale formatted as a currency

[filter currency.fr_FR]40.2[/filter]

NOTES

AVAILABILITY

currency is available in Interchange versions:

4.8.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/currency.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: currency.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef currency Filter
CodeDef currency Description Currency
CodeDef currency Routine <<EOR
sub {
my ($val, $tag, $locale) = @_;
my $convert = $locale ? 1 : 0;
return Vend::Util::currency($val, 0, $convert, { locale => $locale });
}
EOR


Name

date2time — convert date (possibly with specified time) to number of seconds since Epoch

DESCRIPTION

The filter replaces date specification in form of

MM[/-]DD[/-]YY(YY)?(:hh(mm)?)?

to a number of seconds since epoch.

If the year specification contains 2 digits only and is less than 50, as is say, 02, then it is treated as an offset from year 2000, and not 1900. In other words, 05 is understood as year 2005, 80 is understood as 1980.

Unspecified month or day default to 1, unspecified hours or minutes default to 0.

EXAMPLES

Example: Converting dates and times to seconds since Epoch

[filter date2time]01/01/2005[/filter]
[filter date2time]01/01/05[/filter]

[filter date2time]01-01-2005[/filter]
[filter date2time]01-01-05[/filter]

[filter date2time]01-01-2005:10[/filter]
[filter date2time]01-01-05:1045[/filter]

NOTES

This filter is considered deprecated, and is replaced by <filter>datetime2epoch</filter>.

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

The timelocal() function used in the filter comes from the Time::Local Perl module.

AVAILABILITY

date2time is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/date2time.filter
Lines: 50


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: date2time.filter,v 1.6 2007-03-30 23:40:44 pajamian Exp $

CodeDef date2time Filter
CodeDef date2time Description Date to UNIX time (deprecated - use datetime2epoch instead)
CodeDef date2time Visibility private
CodeDef date2time Routine <<EOR
sub {
my $val = shift;
use Time::Local;

$val =~ s/\0+//g;
if($val =~ m:(\d+)[-/]+(\d+)[-/]+(\d+):) {
  my ($yr, $mon, $day) = ($3, $1, $2);

  my $time;
  $val =~ /:(\d+)$/
    and $time = $1;
  if(length($yr) < 4) {
    $yr =~ s/^0//;
    $yr = $yr < 50 ? $yr + 2000 : $yr + 1900;
  }
  $mon =~ s/^0//;
  $day =~ s/^0//;
  $val = sprintf("%d%02d%02d", $yr, $mon, $day);
  return $val unless $time;
  $val .= sprintf('%04d', $time);
}

my $time;
$val =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)?(\d\d)?/;
my ($yr, $mon, $day, $hr, $min) = ($1 || 0, $2 || 1, $3 || 1, $4 || 0, $5 || 0);
$mon--;
eval {
  $time = timelocal(0, $min, $hr, $day, $mon, $yr);
};
if($@) {
  logError("bad time value passed to date2time: %s", $@);
  return 0;
}
return $time;
}
EOR


Name

date_change — convert MMDDYYYY date (possibly with specified time) to YYYYMMDDhhmm

DESCRIPTION

The filter replaces date specification in form of

MM[/-]DD[/-]YY(YY)?(:hh(mm)?)?

or

YYYY[/-]MM[/-]DD(:hh(mm)?)?

to

YYYYMMDD((hh)?(mm)?)?.

If the year specification contains 2 digits only and is less than 50, as is say, 02, then it is treated as an offset from year 2000, and not 1900. In other words, 05 is understood as year 2005, 80 is understood as year 1980.

Time specification unspecified in input get omitted from output as well.

The filter optionally accepts three arguments:

  • iso - output date in ISO format

  • undef - don't default to current date if no date is specified

  • no_time - output only date, without time portion

EXAMPLES

Example: Using date_change

[filter date_change]2005-01-01[/filter]
[filter date_change]2005/01/01[/filter]

[filter date_change]2005-01-01:10[/filter]
[filter date_change]2005/05/29:1536[/filter]

[filter date_change]05-29-2005:1536[/filter]
[filter date_change]05-29-05:1536[/filter]

[filter date_change]0000-00-00[/filter]
[filter date_change][/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

The filter is most commonly used with date selection fields.

If only two out of four time digits are specified, then due to the operation of the sprintf() function, they tend to indicate minutes and not hours!

When the input data starts with year specification, the year must have 4-digit format (i.e. 2005 and not just 05)!

If the date is empty, the filter defaults to current date. To force an absence of a date (as required by some SQL databases), use the undef filter option.

AVAILABILITY

date_change is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/date_change.filter
Lines: 82


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: date_change.filter,v 1.8 2007-03-30 23:40:44 pajamian Exp $

CodeDef date_change Filter
CodeDef date_change Description Date widget
CodeDef date_change Routine <<EOR
sub {
my $val = shift; 
shift;  # discard tag
my $opt = { map { $_ => 1 } @_ };

HTML::Entities::decode_entities($val) if $val =~ /&/;
$val =~ s/\0+//g;
my $re = $opt->{undef}
  ? qr:^(\d*)[-/]+(\d*)[-/]+(\d*)(.*)$:
    : qr:^(\d+)[-/]+(\d+)[-/]+(\d+)(.*)$:
      ;
return $val unless $val =~ /$re/;

my ($year, $month, $day, $timeval);

if (length($1) == 4) {
  # ISO date style 2003-03-20
  ($year, $month, $day) = ($1, $2, $3);
}
else {
  # U.S. date style 3/20/2003 or 3/20/03
  ($year, $month, $day) = ($3, $1, $2);
}

$timeval = $4;

if ($opt->{undef}) {
  # return nothing (undef, which DBI treats as SQL NULL) for an
  # empty date (all zeroes or nothing at all)
  return unless grep /[1-9]/, ($year, $month, $day);
}

# Y2K fun: Try to guess intent of year "03" as "2003"
if (length($year) < 4) {
  $year = $year < 50 ? $year + 2000 : $year + 1900;
}

my ($date_format, $time_format);
if ($opt->{iso}) {
  $date_format = '%04d-%02d-%02d';
  $time_format = 'T%02d:%02d:%02d';
}
else {
  $date_format = '%04d%02d%02d';
  $time_format = '%02d%02d';
}

my $time;
if ($timeval =~ /^:(\d{1,4})\s*$/) {
  # accept traditional Interchange date_time widget times
  # of format '0130', e.g. '20080201:0130'
  $time = sprintf('%04d', $1);
  $time = sprintf($time_format, substr($time, 0, 2), substr($time, 2, 2));
}
elsif (
  # accept times of format '1:30', '1:30:05',
  # to support PostgreSQL's timestamp with time zone format
  # e.g. '2008-02-01 01:30:05-07'
  my ($hours, $minutes, $seconds)
     = ($timeval =~ /\s(\d\d?):(\d\d?)(?::(\d\d+))/)
    ) {
  $time = sprintf($time_format, $hours, $minutes, $seconds);
}

my $out = sprintf($date_format, $year, $month, $day);
$out .= $time if $time and not $opt->{no_time};
return $out;
}
EOR


Name

datetime2epoch — convert date (possibly with specified time) to number of seconds since Epoch

DESCRIPTION

The filter replaces date specification with optional time, in format of

MM[/-]DD[/-]YY(YY)?(:hh(:?mm(:ss)?)?)?, or
YYYY-MM-DD([T ]hh(:mm(:ss)?)?)?

to a number of seconds since Unix epoch.

If the year specification contains 2 digits only and is less than 50, then it is treated as an offset from year 2000, and not 1900. In other words, 05 is understood as year 2005, 80 is understood as 1980.

Unspecified month or day default to 01, unspecified hours or minutes default to 00.

EXAMPLES

Example: Converting dates and times to seconds since Epoch

[filter datetime2epoch]01/01/2008[/filter]
[filter datetime2epoch]01/01/08[/filter]

[filter datetime2epoch]01-01-2008[/filter]
[filter datetime2epoch]01-01-08[/filter]

[filter datetime2epoch]01-01-2008:10[/filter]
[filter datetime2epoch]01-01-08:10:45[/filter]
[filter datetime2epoch]01-01-08:10:45:00[/filter]

Example: Converting ISO/MySQL dates and times to seconds since Epoch

[filter datetime2epoch]2008-01-01 10[/filter]
[filter datetime2epoch]2008-01-01 10:45[/filter]
[filter datetime2epoch]2008-01-01 10:45:00[/filter]

NOTES

This filter is designed to replace <filter>date2time</filter>, which can be considered deprecated.

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

The timelocal() function used in the filter comes from the Time::Local Perl module.

AVAILABILITY

datetime2epoch is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/datetime2epoch.filter
Lines: 46


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: datetime2epoch.filter,v 1.2 2007-03-30 23:40:44 pajamian Exp $

CodeDef datetime2epoch Filter
CodeDef datetime2epoch Description Date and optional time to seconds since the UNIX Epoch
CodeDef datetime2epoch Routine <<EOR
sub {
  use Time::Local;

  my ($year, $mon, $day, $hr, $min, $sec, $time);

  my $val = shift;
  $val =~ s/\0+//g;

  $val =~ m%^\s*(\d\d)[-/]+(\d+)[-/]+(\d+)% and do {
($year, $mon, $day) = ($3, $1, $2);

$val =~ /:(\d\d):?(\d\d)?:?(\d\d)?\s*$/
    and $time = sprintf('T%02d:%02d:%02d', $1, $2 || 0, $3 || 0);

if (length($year) < 4) {
    $year =~ s/^0//;
    $year = $year < 50 ? $year + 2000 : $year + 1900;
}
$val = sprintf('%d-%02d-%02d%s', $year, $mon || 1, $day || 1, $time);
  };

  $val =~ /^\s*(\d\d\d\d)-(\d\d)-(\d\d)(?:[T\s](\d\d)?(?::(\d\d)?(?::(\d\d)?)?)?)?/;
  ($year, $mon, $day, $hr, $min, $sec) = ($1, $2, $3, $4 || 0, $5 || 0,$6 || 0);
  eval {
$time = timelocal($sec, $min, $hr, $day, --$mon, $year);
  };
  if ($@) {
logError("bad time value passed to datetime2epoch: %s", $@);
return 0;
  }
  return $time;
}
EOR

AUTHORS

Kevin Walsh


Name

dbi_quote — safely quote strings for use in SQL statements using DBI's quote method

DESCRIPTION

This filter uses the Perl DBI quoting method (or actually the DBD, if it redefines it) to make strings safe for use in SQL commands.

All database-specific needs are honored, including (but not limited to) \ escapes for PostgreSQL or MySQL, truncating at the first ASCII NUL for PostgreSQL, and turning a newline into a literal two-character \n for MySQL.

The default database handle is used (the first ProductFiles database), unless a different one is specified.

EXAMPLES

Example: Quoting a literal string, specifying DBI quote method

[filter dbi_quote.DATABASE_NAME]some string \ or other[/filter]

The above would produce 'some string \\ or other' for MySQL or PostgreSQL, and 'some string \ or other' for Oracle.


Example: Quoting for the $Db query method

ActionMap set <<EOR
sub {
	my ($action, $name) = split('/', shift, 2);
	my ($val, $set);
	
	# lookup code first
	$Tag->perl({tables => 'sets'});

	$val = $Tag->filter({op => 'dbi_quote.sets', body => $name});
	$set = $Db{sets}->query({sql => "select code,description from sets where name = $val"});

	...
}
EOR

NOTES

DBI quoting is different from Interchange's native <filter>sql</filter> filter. See the DBI man page details about the DBI quoting method.

Since the filter uses database handles, safe must be considered if it is being used via the $Tag object in a Perl block.

For more information see DBI(3) and the DBD documentation for your database.

AVAILABILITY

dbi_quote is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/dbi_quote.filter
Lines: 26


# Copyright 2005-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: dbi_quote.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $

CodeDef dbi_quote Filter
CodeDef dbi_quote Description SQL quoting using DBI
CodeDef dbi_quote Routine <<EOR
sub {
my ($val, $tag, $table) = @_;

$table ||= $Vend::Cfg->{ProductFiles}[0];

my $db;
unless ($db = dbref($table)) {
  ::logError("filter dbi_quote cannot find database handle for table '%s'", $table);
  return;
}

return $db->quote($val);
}
EOR


Name

decode_entities — decode encoded HTML characters back to their unencoded representation

DESCRIPTION

The filter decodes encoded HTML characters back to their unencoded representation.

EXAMPLES

Example: Filter example

[filter decode_entities]One & Two & Three[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

The filter is most commonly used as pre_filter in mv_metadata entries, for fields that contain characters from a character set other than iso8859-1.

For example, &amp; is replaced with &, &lt; with < etc.

AVAILABILITY

decode_entities is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/decode_entities.filter
Lines: 17


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: decode_entities.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef decode_entities Filter
CodeDef decode_entities Description Decode HTML entities
CodeDef decode_entities Routine <<EOR
sub {
return HTML::Entities::decode(shift);
}
EOR

SEE ALSO


Name

digits — eliminate non-digit characters

DESCRIPTION

The filter eliminates any non-digit characters (that is, anything that's not in 0-9 range).

EXAMPLES

Example: Filter example

[filter digits]Only 2 digits should come out of this 1 line ;-)[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

digits is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/digits.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: digits.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef digits Filter
CodeDef digits Description Digits only
CodeDef digits Routine <<EOR
sub {
my $val = shift;
$val =~ s/\D+//g;
return $val;
}
EOR


Name

digits_dash — eliminate non-digit characters, with the exception of dashes

DESCRIPTION

The filter eliminates any non-digit characters, except dashes. (That is, anything that's not a dash ("-") or in a 0-9 range).

EXAMPLES

Example: Filter example

[filter digits_dash]Digits-dash code is: 90901212-3124[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

digits_dash is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/digits_dash.filter
Lines: 19


# Copyright 2008 Interchange Development Group
# Copyright 2008 Davor Ocelic
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: digits_dash.filter,v 1.1 2008-04-27 17:37:10 docelic Exp $

CodeDef digits_dash Filter
CodeDef digits_dash Description Digits-dashes
CodeDef digits_dash Routine <<EOR
sub {
my $val = shift;
$val =~ s/[^\d-]+//g;
return $val;
}
EOR


Name

digits_dot — eliminate non-digit characters, with the exception of dots

DESCRIPTION

The filter eliminates any non-digit characters, except dots. (That is, anything that's not a dot (".") or in a 0-9 range).

EXAMPLES

Example: Filter example

[filter digits_dot]Only the date should come out, and it is 01.01.2000[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

digits_dot is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/digits_dot.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: digits_dot.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef digits_dot Filter
CodeDef digits_dot Description Digits-dots
CodeDef digits_dot Routine <<EOR
sub {
my $val = shift;
$val =~ s/[^\d.]+//g;
return $val;
}
EOR


Name

dos — convert UNIX or Max ASCII text to DOS format

DESCRIPTION

convert UNIX or Mac ASCII newlines to DOS format.

Unix uses LF (Line feed: \n) sequence to identify a newline.

DOS uses CRLF (Carriage return/Line feed: \r\n) sequence to identify a newline.

Mac uses CR (Carriage return: \r) sequence to identify a newline.

EXAMPLES

Example: Filter example

[filter dos]
  Input text with Unix newlines
  Input text with DOS newlines
  Input text with Max newlines
[/filter]

NOTES

AVAILABILITY

dos is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/dos.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: dos.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef dos Filter
CodeDef dos Description UNIX to DOS newlines
CodeDef dos Routine <<EOR
sub {
my $val = shift;
$val =~ s/\r?\n/\r\n/g;
return $val;
}
EOR


Name

duration — calculate end date from given start date and duration

DESCRIPTION

The filter takes a start date and a duration as inputs, and outputs the end date.

EXAMPLES

Example: Obtaining an end date string

The following example sets start date to Feb 12, 2005 (at 8:00 am), and the duration to 12 hours.
[cgi name=start_date set=200502120800 hide=1]
[cgi name=length     set="12 hours"   hide=1]
[filter op=duration.start_date.length /]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

The timelocal() function used in the filter comes from the Time::Local Perl module.

AVAILABILITY

duration is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/duration.filter
Lines: 76


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: duration.filter,v 1.7 2009-05-01 13:50:00 pajamian Exp $

CodeDef duration Filter
CodeDef duration Description Duration
CodeDef duration Routine <<EOR
sub {
my ($val, undef, $startvar, $durvar, @extra) = @_;

## Accepts two parameters, the name of the CGI variables which
## hold the start date/time and the duration value. With this:
#
#  [cgi name=start_date set=200502120800]
#  [cgi name=length set="12 hours"]
#  [filter op=duration.start_date.length /]
#
# The filter call will return 20050212200000
#
## Can also be used like this, with the same output:
#
#  [filter duration.-dummy.12.hours]200502120800[/filter]
#
use vars qw/$CGI/;
my $start = $CGI->{$startvar} || $val;
my $durstring = $CGI->{$durvar};
use Time::Local;

if (!length($durstring) && $durvar =~ /^\d+$/) {
  $durstring = join(' ', $durvar, @extra);
}

## Want to allow setting the value directly
return $val unless $durstring;

$start =~ s/\0+//g;
if($start =~ m:(\d+)[-/]+(\d+)[-/]+(\d+):) {
  my ($yr, $mon, $day) = ($3, $1, $2);

  my $time;
  $start =~ /:(\d+)$/
    and $time = $1;
  if(length($yr) < 4) {
    $yr =~ s/^0//;
    $yr = $yr < 50 ? $yr + 2000 : $yr + 1900;
  }
  $mon =~ s/^0//;
  $day =~ s/^0//;
  $start = sprintf("%d%02d%02d", $yr, $mon, $day);
  return $val unless $time;
  $start .= sprintf('%04d', $time);
}

my $time;
$start =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)?(\d\d)?/;
my ($yr, $mon, $day, $hr, $min) = ($1 || 0, $2 || 1, $3 || 1, $4 || 0, $5 || 0);
$mon--;
eval {
  $time = timelocal(0, $min, $hr, $day, $mon, $yr);
};
if($@) {
  logError("bad time value passed to duration filter: %s", $@);
  return 0;
}

$time = adjust_time($durstring, $time);

return POSIX::strftime("%Y%m%d%H%M%S", localtime($time));
}
EOR


Name

encode_entities — encode non-standard HTML characters

DESCRIPTION

The filter encodes non-standard HTML characters to their encoded representation.

EXAMPLES

Example: Filter example

[filter encode_entities]One & Two & Three[filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

The filter is most commonly used to make untrusted CGI input variables harmless to the Interchange environment.

For example, & is replaced with &amp;, < with &lt; etc.

AVAILABILITY

encode_entities is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/encode_entities.filter
Lines: 23


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: encode_entities.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $

CodeDef e Filter
CodeDef e Alias encode_entities

CodeDef entities Filter
CodeDef entities Alias encode_entities

CodeDef encode_entities Filter
CodeDef encode_entities Description Encode HTML entities
CodeDef encode_entities Routine <<EOR
sub {
return HTML::Entities::encode(shift, $ESCAPE_CHARS::std);
}
EOR

SEE ALSO

evalue(7ic)


Name

encode_special_entities —

DESCRIPTION

EXAMPLES

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

NOTES

AVAILABILITY

encode_special_entities is available in Interchange versions:

5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/encode_special_entities.filter
Lines: 21


# Copyright 2010 Interchange Development Group
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.

CodeDef encode_special_entities Filter
CodeDef encode_special_entities Description Encode HTML special entities "&<>
CodeDef encode_special_entities Routine <<EOR
sub {
my $val = shift;

$val =~ s/"/&quot;/g;
$val =~ s/&/&amp;/g;
$val =~ s/</&lt;/g;
$val =~ s/>/&gt;/g;

return $val;
}
EOR

SEE ALSO


Name

encrypt — PGP-encrypt input

DESCRIPTION

The filter PGP-encrypts the provided input.

It accepts two optional arguments, encryption key and encryption program.

Specifying command line options for the encryption program isn't possible, but it isn't needed as Interchange automatically adds the following options, depending on the program recognized:

  • gpg --batch --always-trust -e -a -r KEY

  • pgpe -fat -r KEY

  • pgp -fat - KEY

EXAMPLES

Example: Filter example using specific key ID

[filter encrypt.KEY]Secret phrase or a credit card number[/filter]

Example: Filter example using specific key ID and encrypt program

[filter encrypt.KEY./usr/local/bin/gpg]Secret phrase or a credit card number[/filter]

NOTES

AVAILABILITY

encrypt is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/encrypt.filter
Lines: 18


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: encrypt.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $

CodeDef encrypt Filter
CodeDef encrypt Description PGP encrypt
CodeDef encrypt Routine <<EOR
sub {
my ($val, $tag, $key) = @_;
return Vend::Order::pgp_encrypt($val, $key);
}
EOR


Name

filesafe — make sure the input is ready for use as a filename

DESCRIPTION

The filter makes sure (possibly by intervening) that the input string is ready and safe to be used as a filename.

EXAMPLES

Example: Filter example

Here's a hypothetical download filename from the Prelinger Collection at archive.org.
[filter filesafe]/tmp/uploads/new_world_through_chemistry/new_world_through_chemistry_edit.mp4[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

filesafe is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/filesafe.filter
Lines: 17


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: filesafe.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef filesafe Filter
CodeDef filesafe Description Safe for filename
CodeDef filesafe Routine <<EOR
sub {
return Vend::Util::escape_chars(shift);
}
EOR


Name

filter_select — automatically select filter based on HTML widget type

DESCRIPTION

The filter identifies the widget type and returns the name of the corresponding suitable filter for it.

EXAMPLES

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

NOTES

Keep in mind that you can specify <filter>filter_select</filter> along with your custom filters in the same call.

AVAILABILITY

filter_select is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/filter_select.filter
Lines: 32


# Copyright 2005-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: filter_select.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $

CodeDef calculated Filter
CodeDef calculated Alias filter_select
CodeDef filter_select Filter
CodeDef filter_select Description Auto-select filter
CodeDef filter_select Visibility private
CodeDef filter_select Version $Revision: 1.3 $
CodeDef filter_select Routine <<EOR
sub {
## This replaces the calculated filter for the survey
## Selects an appropriate filter based on the widget type
my $wid = $CGI->{type};
if($wid =~ /fillin/) {
  return 'nullselect';
}
elsif($wid =~ /select.*multip/) {
  return 'null_to_comma';
}
elsif ($wid =~ /checkbox/) {
  return 'checkbox null_to_comma';
}
return '';
}
EOR

SEE ALSO


Name

gate — return input verbatim if the specified Scratch variable exists, empty string otherwise

DESCRIPTION

The filter allows "conditional output" of the input string, based on the value of a scratch variable.

In other words, received input is passed through verbatim, if the specified scratch variable holds a true value. Empty string is returned otherwise.

EXAMPLES

Example: Filter example

[set tide]1[/set]

[filter gate.tide]The Gate is open.[/filter]

NOTES

AVAILABILITY

gate is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/gate.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: gate.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef gate Filter
CodeDef gate Description Gate with scratch
CodeDef gate Routine <<EOR
sub {
my ($val, $var) = @_;
return '' unless $::Scratch->{$var};
return $val;
}
EOR

SEE ALSO


Name

hash2acl — convert Interchange ACL hash to string representation

DESCRIPTION

The filter is specific to the ACL widget and probably should not be used otherwise.

The filter doesn't need to be selected for the widget to operate in the table-editor.

EXAMPLES

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

NOTES

AVAILABILITY

hash2acl is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/hash2acl.filter
Lines: 34


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: hash2acl.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $

CodeDef hash2acl Filter
CodeDef hash2acl Description hash2acl
CodeDef hash2acl Visibility private
CodeDef hash2acl Routine <<EOR
sub {
my ($value) = @_;
my $orig = $value;
$value =~ s/^\s+//;
$value =~ s/\s+$//;
$value =~ s/\0+//g;
my $hash = Vend::Util::get_option_hash($value)
  or return $orig;
my @opts;
for(sort keys %$hash) {
  ! defined $hash and $hash->{$_} = '';
  my $val = $_;
  $val =~ s/,/&#44;/g;
  $val =~ s/=/&#61;/g;
  push @opts, "$val=$hash->{$_}";
}
$value = join ",", @opts;
return $value;
}
EOR


Name

html2text — transform basic HTML input to plain-text

DESCRIPTION

The filter performs simple replacement of input HTML — it strips the <b>, <i> and <u> tags, and replaces line breaks (<br>) and paragraphs (<p>) with newlines.

EXAMPLES

Example: Filter example

[filter html2text]
<p>
Perl is <b>a lot</b> of <u>fun</u>!
</p>
<p>
Interesting tricks with <i>the language</i> can be seen at: <br>
MJD's <a href="http://perl.plover.com/">plover.com</a>.
</p>
<p>
Programming is an art.
</p>
[/filter]

NOTES

Support for stripping <b>, <i> and <u> tags was added in Interchange 5.5.2.

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

html2text is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/html2text.filter
Lines: 18


# Copyright 2002-2009 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.

CodeDef html2text Filter
CodeDef html2text Description Simple html2text
CodeDef html2text Routine <<EOR
sub {
my $val = shift;
$val =~ s%\s*<(?:br\s*/?|/?p[^>]*)>\s*%\n%gi;
$val =~ s%<[/!a-zA-Z].*?>%%gs;
return $val;
}
EOR

SEE ALSO


Name

integer — return integer value of the input

DESCRIPTION

The filter returns integer value of the inputr.

EXAMPLES

Example: Filter example

[filter integer]12.4[/filter] 

Example: Erase whitespace, filter out non-digits, and return integer part of the number

The whole is:  [filter op="no_white digits_dot integer"]Stock 904.82[/filter] 

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

integer is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/integer.filter
Lines: 17


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: integer.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef integer Filter
CodeDef integer Description Integer
CodeDef integer Routine <<EOR
sub {
return int(shift);
}
EOR

SEE ALSO


Name

italics — enclose input in HTML <i> (italic) tag

DESCRIPTION

The filter encloses input data in HTML <i> (italics) tag.

EXAMPLES

Example: Filter example

"[filter italics]To Italicly Go Where No One Has Gone Before![/filter]"
  -- Modified Star Trek ;-)

NOTES

AVAILABILITY

italics is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/italics.filter
Lines: 18


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: italics.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $

CodeDef italics Filter
CodeDef italics Description HTML Italics
CodeDef italics Visibility  private
CodeDef italics Routine <<EOR
sub {
return '<i>' . shift(@_) . '</i>';
}
EOR


Name

large — enclose input in HTML <large> tag

DESCRIPTION

The filter encloses input data in HTML <large> tag.

EXAMPLES

Example: Filter example

You can see that "[filter large] This text is larger than usual. [/filter]"

NOTES

AVAILABILITY

large is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/large.filter
Lines: 18


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: large.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $

CodeDef large Filter
CodeDef large Description HTML large
CodeDef large Visibility  private
CodeDef large Routine <<EOR
sub {
return '<large>' . shift(@_) . '</large>';
}
EOR

SEE ALSO

small(7ic)


Name

last_non_null — return last non-null entry from an input consisting of null-separated fields

DESCRIPTION

The filter splits the input on a null character (\0) and returns the last non-null entry.

EXAMPLES

Example: Filter example

[perl]
  $Tag->filter({
    op   => 'last_non_null',
    body => "One\0Two\0Three\0\0\0"
  });
[/perl]

NOTES

AVAILABILITY

last_non_null is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/last_non_null.filter
Lines: 21


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: last_non_null.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef last_non_null Filter
CodeDef last_non_null Description Reverse combo
CodeDef last_non_null Routine <<EOR
sub {
my @some = reverse split /\0+/, shift;
for(@some) {
  return $_ if length $_;
}
return '';
}
EOR

SEE ALSO


Name

lc — transform all input to lowercase

DESCRIPTION

The filter transforms all input to lowercase.

EXAMPLES

Example: Filter example

[filter lc]YOU ARE KINDLY INVITED TO
<a href="http://www.j-walk.com/other/conf/">The 3rd Annual Nigerian EMail Conference</a>.
[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

lc is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/lc.filter
Lines: 24


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: lc.filter,v 1.7 2007-03-30 23:40:44 pajamian Exp $

CodeDef lower Filter
CodeDef lower Alias lc

CodeDef lc Filter
CodeDef lc Description Lower case
CodeDef lc Routine <<EOR
sub {
use locale;
if ($Scratch->{mv_locale}) {
    POSIX::setlocale(LC_CTYPE, $Scratch->{mv_locale});
}
return lc(shift);
}
EOR

SEE ALSO


Name

lcfirst — transform first character in input to lowercase

DESCRIPTION

The filter transforms first character in input to lowercase.

EXAMPLES

Example: Filter example

[filter lcfirst]ABC DEF[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

lcfirst is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/lcfirst.filter
Lines: 20


# Copyright 2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: lcfirst.filter,v 1.1 2007-07-13 08:22:47 racke Exp $

CodeDef lcfirst Filter
CodeDef lcfirst Description First character lower case
CodeDef lcfirst Routine <<EOR
sub {
use locale;
if ($Scratch->{mv_locale}) {
    POSIX::setlocale(LC_CTYPE, $Scratch->{mv_locale});
}
return lcfirst(shift);
}
EOR

SEE ALSO


Name

line — output just the first line of input

DESCRIPTION

The filter outputs just the first line of input.

EXAMPLES

Example: Filter example

[filter line]Line 1  (visible)
Line 2  (not visible)
Line 3  (not visible)
[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

line is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/line.filter
Lines: 20


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: line.filter,v 1.5 2007-03-30 23:40:44 pajamian Exp $

CodeDef line Filter
CodeDef line Description First line
CodeDef line Routine <<EOR
sub {
my $val = shift;

$val =~ s/^(.*?)\r?\n.*$/$1/s;
return $val;
}
EOR


Name

line2options — replace newlines in input with commas

DESCRIPTION

The filter replaces newlines in input (any combination of \r and \n) with commas. It also takes care of removing trailing whitespace along the way.

EXAMPLES

Example: Filter example

[filter line2options]
one
two
three
[/filter]

NOTES

AVAILABILITY

line2options is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/line2options.filter
Lines: 27


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: line2options.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef line2options Filter
CodeDef line2options Description line2options
CodeDef line2options Routine <<EOR
sub {
my ($value, $tag, $delim) = @_;
return $value unless length $value;
$value =~ s/\s+$//;
$value =~ s/^\s+//;
my @opts = split /[\r\n]+/, $value;
for(@opts) {
  s/^\s+//;
  s/[,\s]+$//;
  s/,/&#44;/g;
}
return join ",", @opts;
}
EOR


Name

linkdecode — decode hex-encoded entities found within URLs

DESCRIPTION

The filter decodes hex-encoded entities found within URLs.

The filter is explicitly called linkdecode because it only operates on <form action=>, href= and src= contents. Therefore, it is likely to be useful only when passed lines containing HTML URLs or source specifiers (such as <a> or <img> tags).

EXAMPLES

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

NOTES

AVAILABILITY

linkdecode is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/linkdecode.filter
Lines: 25


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: linkdecode.filter,v 1.6 2007-03-30 23:40:44 pajamian Exp $

CodeDef linkdecode Filter
CodeDef linkdecode Description URLdecode link text
CodeDef linkdecode Visibility  private
CodeDef linkdecode Routine <<EOR
sub {
my $body = shift;
$body =~ s{(<form\s+[^>]*action=)(["'])(\%5b\w+.*?\%5d)\2}
      { $1 . $2 . unhexify($3) . $2 }egi;
$body =~ s{(<\w+\s+[^>]*href=)(["'])(\%5b\w+.*?\%5d)\2}
      { $1 . $2 . unhexify($3) . $2 }egi;
$body =~ s{(<i\w+\s+[^>]*src=)(["'])(\%5b\w+.*?\%5d)\2}
      { $1 . $2 . unhexify($3) . $2 }egi;
return $body;
}
EOR

SEE ALSO


Name

liven_urls — make all kinds of URLs clickable

DESCRIPTION

The filter searches the input for all kinds of links, and wraps them into the standard HTML <a href=></a> package.

The filter can recognize all sorts of URLs and to a great detail.

EXAMPLES

Example: Filter example

Here's an incomplete collection of URLs that the filter can recognize.
[filter liven_urls]
http://www.clusty.com/
ftp://@host.com/
ftp://host.com/
ftp://foo:@host.com/
ftp://myname@host.dom/%2Fetc/motd
ftp://myname@host.dom/etc/motd
ftp://myname@host.dom//etc/motd
mailto:noaddress@host.dom
file://vms.host.edu/disk$user/my/notes/note12345.txt
prospero://host.dom//pros/name
ldap:///o=University%20of%20Michigan,c=US
ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US
ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress
ldap:///o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen)
ldap://ldap.itd.umich.edu/c=GB?objectClass?one
z39.50s://melvyl.ucop.edu/cat
z39.50r://melvyl.ucop.edu/mags?elecworld.v30.n19
z39.50r://cnidr.org:2100/tmf?bkirch_rules__a1;esn=f;rs=marc
mid:foo4%25foo1@bar.net
cid:foo4*foo1@bar.net
mid:960830.1639@XIson.com/partA.960830.1639@XIson.com
[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

The matching expressions were generated with the help of Abigail's Regex for URLs (link appears broken, and no replacement found).

To save on processing time, only the most common protocols (http/https, ftp and mailto) are actually enabled in the filter. For the rest of the protocols, you need to uncomment the appropriate lines in the filter source and restart Interchange.

AVAILABILITY

liven_urls is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/liven_urls.filter
Lines: 118


# Copyright 2005 Davor Ocelic (docelic@mail.inet.hr)
# Copyright 2005-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: liven_urls.filter,v 1.3 2007-03-30 23:40:44 pajamian Exp $

CodeDef liven_urls Filter
CodeDef liven_urls Description Make URLs clickable
CodeDef liven_urls Routine <<EOR

my %regexps = (

http => <<'ENDR',
(?:https?://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)* \
(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3})) \
(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2})) \
|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{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=+])*)(?:/(?:(?:(?:[a-zA-Z\d\$\-_.!~*' \
(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*))*)?))|(?:(?: \
(?:(?:(?:[a-zA-Z\d\$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*)(?:/ \
(?:(?:(?:[a-zA-Z\d\$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*))*)?)))
#ENDR

); # my %regexps

chomp $regexps{$_} for keys %regexps;


sub {
my ($val,$tag,@arg) = @_;

@arg or @arg = (qw/http ftp mailto/);
@arg = grep { $regexps{$_} } @arg;
@arg or return $val;
my $match_url = join '|', @regexps{@arg};

$val =~ s/($match_url)/<a href="$1">$1<\/a>/gsi;
$val
}
EOR


AUTHORS

Davor Ocelic

SEE ALSO

mailto(7ic)


Name

loc — localize provided input

DESCRIPTION

The filter uses Interchange locale features to localize received input text.

EXAMPLES

Example: Filter example

[filter loc.fr_FR]January[/filter]

NOTES

AVAILABILITY

loc is available in Interchange versions:

4.8.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/loc.filter
Lines: 18


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: loc.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef loc Filter
CodeDef loc Description Localize
CodeDef loc Routine <<EOR
sub {
my $val = shift;
return errmsg($val);
}
EOR

SEE ALSO


Name

lookup — perform lookup in another database

DESCRIPTION

The filter performs a lookup in another database.

See the section called “EXAMPLES” for clarification.

EXAMPLES

Example: Filter example

Suppose we have two databases, products and support, as follows:

code	price	description
144	12	Item 144
145	84	Item 145
146	314	Item 146

and

code	product_supported
144	0
145	1
146	-1

Then, performing [filter lookup.support.product_supported]144[/filter] would yield 0.


NOTES

AVAILABILITY

lookup is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/lookup.filter
Lines: 18


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: lookup.filter,v 1.4 2007-03-30 23:40:44 pajamian Exp $

CodeDef lookup Filter
CodeDef lookup Description DB lookup
CodeDef lookup Routine <<EOR
sub {
my ($val, $tag, $table, $column) = @_;
return tag_data($table, $column, $val) || $val;
}
EOR

SEE ALSO


Name

lspace_to_nbsp — replace leading spaces (" ") with nonbreakable space ("&nbsp;") characters

DESCRIPTION

The filter replaces leading space (" ") characters with HTML's nonbreakable-space ("&nbsp;") characters.

This is similar in functionality to <filter>space_to_nbsp</filter> filter, where all space (not just leading) is converted.

EXAMPLES

Example: Filter example

</div>
[filter lspace_to_nbsp]
          Text with leading whitespace.
[/filter]
</div>

NOTES

AVAILABILITY

lspace_to_nbsp is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/lspace_to_nbsp.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: lspace_to_nbsp.filter,v 1.2 2007-03-30 23:40:44 pajamian Exp $

CodeDef lspace_to_nbsp Filter
CodeDef lspace_to_nbsp Description Leading SPACE to nbsp
CodeDef lspace_to_nbsp Routine <<EOR
sub {
my $str = shift;
$str =~ s/^( +)/'&nbsp;' x length($1)/emg;
return $str;
}
EOR



Name

mac — convert UNIX or DOS ASCII text to Apple Macintosh format

DESCRIPTION

convert UNIX or DOS ASCII newlines to Apple Macintosh format.

Unix uses LF (Line feed: \n) sequence to identify a newline.

DOS uses CRLF (Carriage return/Line feed: \r\n) sequence to identify a newline.

Mac uses CR (Carriage return: \r) sequence to identify a newline.

EXAMPLES

Example: Filter example

[filter mac]
  Input text with Unix newlines
  Input text with DOS newlines
  Input text with Max newlines
[/filter]

NOTES

AVAILABILITY

mac is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/mac.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: mac.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef mac Filter
CodeDef mac Description UNIX/DOS to Mac OS newlines
CodeDef mac Routine <<EOR
sub {
my $val = shift;
$val =~ s/\r?\n|\r\n?/\r/g;
return $val;
}
EOR


Name

mailto — enclose input in HTML <a href='mailto: ...'> link

DESCRIPTION

The filter encloses input data in HTML <a href='mailto: ...'>...</a> tag.

EXAMPLES

Example: Filter example

Mail [filter mailto]someone@mydomain.local[/filter].

NOTES

AVAILABILITY

mailto is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/mailto.filter
Lines: 23


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: mailto.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $

CodeDef mailto Filter
CodeDef mailto Description mailto: link
CodeDef mailto Routine <<EOR
sub {
my ($val,$tag,@arg) = @_;
my $out = qq{<a href="mailto:$val">};
my $anchor = $val;
if(@arg) {
  $anchor = join " ", @arg;
}
$out .= "$anchor</a>";
}
EOR


Name

md5 — calculate MD5 sum of input

DESCRIPTION

The filter outputs MD5 sum for the input text.

EXAMPLES

Example: Filter example

[filter md5][/filter]
[filter md5]One[/filter]
[filter md5]Two[/filter]
[filter md5]MyPassword[/filter]
[filter md5]Very long string[/filter]

NOTES

AVAILABILITY

md5 is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/md5.filter
Lines: 20


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: md5.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $

CodeDef md5 Filter
CodeDef md5 Description MD5 sum
CodeDef md5 Routine <<EOR

use Digest::MD5;

sub {
return Digest::MD5::md5_hex($_[0]);
}
EOR

SEE ALSO

sha1(7ic)


Name

mime_type — print file MIME type, based on file extension

DESCRIPTION

The filter takes a filename as input, determines file extension and returns the appropriate MIME type for it.

EXAMPLES

Example: Filter example

[filter mime_type]image.jpg[/filter]

NOTES

AVAILABILITY

mime_type is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/mime_type.filter
Lines: 17


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: mime_type.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef mime_type Filter
CodeDef mime_type Description Find MIME type of filename
CodeDef mime_type Routine <<EOR
sub {
return Vend::Util::mime_type(shift);
}
EOR


Name

name — transform "Last, First" name format to "First Last"

DESCRIPTION

The filter transforms "Last, First" input to "First Last". Most of the time, of course, this is used with people's names.

EXAMPLES

Example: Filter example

[filter name]Doe, John[/filter]

Example: Filter example for name and namecase correction

[filter op="name namecase"]DOE, John[/filter]

NOTES

AVAILABILITY

name is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/name.filter
Lines: 20


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: name.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef name Filter
CodeDef name Description Last, First to First Last
CodeDef name Routine <<EOR
sub {
my $val = shift;
return $val unless $val =~ /,/;
my($last, $first) = split /\s*,\s*/, $val, 2;
return "$first $last";
}
EOR


Name

namecase — transform any "NAME" to "Name"

DESCRIPTION

The filter transforms uppercase text, usually "LAST" (as in 'last name') input to "Last".

"lowercase" words are not replaced with "Lowercase", just ALL-CAPS words are "normalized".

EXAMPLES

Example: Filter example

[filter name]DOE, John[/filter]

NOTES

AVAILABILITY

namecase is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/namecase.filter
Lines: 20


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: namecase.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef namecase Filter
CodeDef namecase Description Name case
CodeDef namecase Routine <<EOR
sub {
use locale;
my $val = shift;
$val =~ s/([A-Z]\w+)/\L\u$1/g;
return $val;
}
EOR

SEE ALSO

name(7ic)


Name

next_sequential

DESCRIPTION

EXAMPLES

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

NOTES

AVAILABILITY

next_sequential is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/next_sequential.filter
Lines: 59


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: next_sequential.filter,v 1.6 2007-03-30 23:40:45 pajamian Exp $

CodeDef next_sequential Filter
CodeDef next_sequential Description Next sequential
CodeDef next_sequential Visibility  private
CodeDef next_sequential Routine <<EOR
sub {
my ($value, $field, $table, $col, $qualifier) = @_;
#::logDebug("called next_sequential filter value='$value' table=$table col=$col qual=$qualifier");
return $value if length($value);
$table ||= $CGI::values{mv_data_table};

my $val;

if(! $table) {
  return 1 if ! $field;
  return exists $CGI::values{$field}
      ? ($CGI::values{$field})
      : ($::Values->{$field});
}

$col ||= $field;

eval {
  my $db = database_exists_ref($table)
    or die errmsg("next_sequential filter: no table '%s'", $table);
  my $tname = $db->name();
  my $q = "SELECT $col FROM $tname";
  if($qualifier) {
    my $qval = $CGI::values{$qualifier};
    $qval = $db->quote($qval, $qualifier);
    $q .= " WHERE $qualifier = $qval";
  }
  $q .= " ORDER BY $col desc";
#::logDebug("constructed query $q for next_sequential");
  my $ary = $db->query($q)
    or die errmsg("next_sequential filter query failed: %s", $q);
  return 1 unless @$ary;
  $val = $ary->[0][0];
  $val++;
};

if($@) {
  logError($@);
  return undef;
}

return $val;

}
EOR

SEE ALSO


Name

no_white — eliminate all whitespace in input

DESCRIPTION

The filter eliminates all whitespace appearing in input.

EXAMPLES

Example: Filter example

"[filter no_white]  X  X  [/filter]"

NOTES

AVAILABILITY

no_white is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/no_white.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: no_white.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef no_white Filter
CodeDef no_white Description No whitespace
CodeDef no_white Routine <<EOR
sub {
my $val = shift;
$val =~ s/\s+//g;
return $val;
}
EOR

SEE ALSO

strip(7ic)


Name

null_to_colons — replace \0 (null) characters with double colon "::"

DESCRIPTION

The filter replaces \0 (null) characters with a double colon (::).

EXAMPLES

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

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

null_to_colons is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/null_to_colons.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: null_to_colons.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef null_to_colons Filter
CodeDef null_to_colons Description NULL to ::
CodeDef null_to_colons Routine <<EOR
sub {
my $val = shift;
$val =~ s/\0+/::/g;
return $val;
}
EOR


Name

null_to_comma — replace \0 (null) characters with comma ","

DESCRIPTION

The filter replaces \0 (null) characters with a comma (,).

EXAMPLES

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

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

null_to_comma is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/null_to_comma.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: null_to_comma.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef null_to_comma Filter
CodeDef null_to_comma Description NULL to COMMA
CodeDef null_to_comma Routine <<EOR
sub {
my $val = shift;
$val =~ s/\0+/,/g;
return $val;
}
EOR


Name

null_to_space — replace \0 (null) characters with space " "

DESCRIPTION

The filter replaces \0 (null) characters with a space (" ").

EXAMPLES

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

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

null_to_space is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/null_to_space.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: null_to_space.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef null_to_space Filter
CodeDef null_to_space Description NULL to SPACE
CodeDef null_to_space Routine <<EOR
sub {
my $val = shift;
$val =~ s/\0+/ /g;
return $val;
}
EOR


Name

nullselect — split input on \0 (null) characters and return first non-empty string

DESCRIPTION

The filter splits input on \0 (null) characters and returns the first non-empty string found.

The filter is suitable for retrieving values out of HTML Combo boxes.

EXAMPLES

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

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

nullselect is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/nullselect.filter
Lines: 21


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: nullselect.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef nullselect Filter
CodeDef nullselect Description Combo box
CodeDef nullselect Routine <<EOR
sub {
my @some = split /\0+/, shift;
for(@some) {
  return $_ if length $_;
}
return '';
}
EOR


Name

oneline — delete everything after first null or newline character, effectively "onelining" the input

DESCRIPTION

The filter deletes everything after the first null (\0) or newline (\r or \n) character. Effectively, it only preserves and returns the first line of input.

EXAMPLES

Example: Filter example

[filter oneline]
Have no fear,
for the first line is dear!
[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

oneline is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/oneline.filter
Lines: 19


# Copyright 2005-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: oneline.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $

CodeDef oneline Filter
CodeDef oneline Description Truncate at first newline (CR or LF) or ASCII NUL
CodeDef oneline Visibility  public
CodeDef oneline Routine <<EOR
sub {
my $val = shift;
$val =~ s/[\r\n\0].*//s;
return $val;
}
EOR

SEE ALSO


Name

option_format

DESCRIPTION

EXAMPLES

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

NOTES

AVAILABILITY

option_format is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/option_format.filter
Lines: 48


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: option_format.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef option_format Filter
CodeDef option_format Description Option format
CodeDef option_format Routine <<EOR
sub {
my ($value, $tag, $delim) = @_;

return $value unless $value =~ /\0.*\0/s;

my $scrubcommas;
if(! length($delim) ) {
  $delim = ',';
  $scrubcommas = 1;
}
else {
  $delim =~ /pipe/i and $delim = '|' 
    or
    $delim =~ /semicolon/i and $delim = ';'  
    or
    $delim =~ /colon/i and $delim = ':'  
    or
    $delim =~ /null/i and $delim = "\0"
    ;
}

my @opts = split /\0/, $value;
my @out;

while(@opts) {
  my ($v, $l, $d) = splice @opts, 0, 3;
  $l = length($l) ? "=$l" : '';
  $l =~ s/,/&#44;/g if $scrubcommas;
  $d = $d ? '*' : '';
  next unless length("$v$l");
  push @out, "$v$l$d";
}
return join $delim, @out;
}
EOR

SEE ALSO


Name

options2line — replace commas in input with newlines

DESCRIPTION

The filter replaces commas in input with newlines (\n). It also takes care of removing trailing whitespace along the way.

EXAMPLES

Example: Filter example

[filter options2line]one,two,three[/filter]

NOTES

AVAILABILITY

options2line is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/options2line.filter
Lines: 26


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: options2line.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef options2line Filter
CodeDef options2line Description options2line
CodeDef options2line Routine <<EOR
sub {
my ($value, $tag, $delim) = @_;
return $value unless length $value;
$value =~ s/\s+$//;
$value =~ s/^\s+//;
my @opts = split /\s*,\s*/, $value;
for(@opts) {
  s/&#44;/,/g;
}
$value = return join "\n", @opts;
return $value;
}
EOR


Name

pagefile — make sure the input is ready for use as an Interchange page filename

DESCRIPTION

The filter makes sure (possibly by intervening) that the input string is ready and safe to be used as an Interchange page name.

EXAMPLES

Example: Filter example

[filter pagefile]report[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

pagefile is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/pagefile.filter
Lines: 17


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: pagefile.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $

CodeDef pagefile Filter
CodeDef pagefile Routine <<EOR
sub {
$_[0] =~ s:^[./]+::;
return $_[0];
}
EOR


Name

pgbool — return "f" (false) or "t" (true), depending on input data

DESCRIPTION

The filter returns "f" (false) if the input is undefined, 0, f or false (in a case-insensitive manner). Otherwise, it returns "t" (true).

EXAMPLES

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

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

pgbool is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/pgbool.filter
Lines: 22


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: pgbool.filter,v 1.6 2007-03-30 23:40:45 pajamian Exp $

CodeDef pgbool Filter
CodeDef pgbool Description PostgreSQL Boolean (undef as false)
CodeDef pgbool Visibility  private
CodeDef pgbool Routine <<EOR
sub {
my $val = shift;
return 'f' if ! defined($val);
$val =~ s/\s+//g;
return 'f' if $val =~ /^(?:0|f(?:alse)?)?$/i;
return 't';
}
EOR

SEE ALSO

pgbooln(7ic)


Name

pgbooln — return undef (NULL), "f" (false) or "t" (true), depending on input data

DESCRIPTION

The filter returns undefined value (NULL) if the input is undefined. It returns "f" (false) if the input is 0, f or false (in a case-insensitive manner). Otherwise, it returns "t" (true).

EXAMPLES

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

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

pgbooln is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/pgbooln.filter
Lines: 22


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: pgbooln.filter,v 1.6 2007-03-30 23:40:45 pajamian Exp $

CodeDef pgbooln Filter
CodeDef pgbooln Description PostgreSQL Boolean (undef as NULL)
CodeDef pgbooln Visibility  private
CodeDef pgbooln Routine <<EOR
sub {
my $val = shift;
return if ! defined($val);
$val =~ s/\s+//g;
return 'f' if $val =~ /^(?:0|f(?:alse)?)?$/i;
return 't';
}
EOR

SEE ALSO

pgbool(7ic)


Name

pre — enclose input in HTML <pre> (preformatted) tag

DESCRIPTION

The filter encloses input data in HTML <pre> (preformatted) tag.

EXAMPLES

Example: Filter example

"[filter pre]Preformatted text[/filter]"

NOTES

AVAILABILITY

pre is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/pre.filter
Lines: 16


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: pre.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $

CodeDef pre Filter
CodeDef pre Routine <<EOR
sub {
return '<pre>' . shift(@_) . '</pre>';
}
EOR

SEE ALSO

italics(7ic)


Name

qb_safe — make input safe for QuickBooks by removing unfriendly characters

DESCRIPTION

The filter makes data safe for Intuit QuickBooks, because QB will crash at the drop of a hat.

EXAMPLES

Example: Filter example

<filter>qb_safe</filter> the input and limit it to 25 characters.

[filter op="qb_safe 25" interpolate=1][ol-param sku][/filter]

NOTES

AVAILABILITY

qb_safe is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/qb_safe.filter
Lines: 20


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: qb_safe.filter,v 1.8 2007-03-30 23:40:45 pajamian Exp $

CodeDef qb_safe Filter
CodeDef qb_safe Description Safe for Quickbooks
CodeDef qb_safe Visibility  private
CodeDef qb_safe Routine <<EOR
sub {
my $val = shift;
$val =~ s/[\"\/\\]//g;
return $val;
}
EOR

SEE ALSO


Name

restrict_html — filter out all but the restricted set of allowed HTML tags in input

DESCRIPTION

The filter restricts the set of HTML tags that can appear in the input. Tags not found among the allowed ones are filtered out.

EXAMPLES

Example: Filter example

[filter restrict_html.p.br.ul.li.b]
<ul>
<li> Item lists are allowed.
</ul>
<p>
As well as paragraphs and<br>
newlines.
</p>
Links, such as <a href="http://www.icdevgroup.org">ICDEVGROUP</a> are
<b>not</b> allowed.
[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

restrict_html is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/restrict_html.filter
Lines: 23


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: restrict_html.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $

CodeDef restrict_html Filter
CodeDef restrict_html Description Restrict HTML
CodeDef restrict_html Visibility  private
CodeDef restrict_html Routine <<EOR
sub {
my $val = shift;
shift;
my %allowed;
$allowed{lc $_} = 1 for @_;
$val =~ s{<(/?(\w[-\w]*)[\s>])}{ ($allowed{lc $2} ? '<' : '&lt;') . $1 }ge;
return $val;
}
EOR

SEE ALSO


Name

roman — transform input integer to Roman numerals

DESCRIPTION

The filter transforms input integer to Roman numerals.

EXAMPLES

Example: Filter example

[filter roman]2005[/filter]

NOTES

AVAILABILITY

roman is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/roman.filter
Lines: 37


# Copyright 2005 Cursor Software Limited (http://www.cursor.biz/)
# Copyright 2005-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: roman.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef roman Filter
CodeDef roman Description Integer to Roman numerals
CodeDef roman Visibility  private
CodeDef roman Routine     <<EOR
sub {
my $val = shift;

$val =~ s/\D+//g;
return '' unless $val;

$val =~ m/(\d*?)(\d{1,3})$/ or return '';

my $buf = 'M' x ($1 || 0);
my @digits = reverse(split('',$2));

my @numerals = (
    [ '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', ],
    [ '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', ],
    [ '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', ],
);

for (my $i = $#digits; $i >= 0; $i--) {
    $buf .= $numerals[$i]->[$digits[$i]];
}
return $buf;
}
EOR

AUTHORS

__kwalsh__

SEE ALSO


Name

round — round value in floating-point-safe way

DESCRIPTION

The filter rounds input value in a floating-point-safe way.

EXAMPLES

Example: Filter example

[filter round.4]512.78953[/filter]
[filter round.4]512.78955[/filter]
[filter round.4]512.78958[/filter]

NOTES

AVAILABILITY

round is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/round.filter
Lines: 18


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: round.filter,v 1.4 2007-11-15 01:14:14 jon Exp $

CodeDef round Filter
CodeDef round Description Round numeric value to the specified number of decimal places (default 2)
CodeDef round Routine <<EOR
sub {
my ($val, undef, $digits) = @_;
return round_to_frac_digits($val, $digits);
}
EOR

AUTHORS

Mike Heins

SEE ALSO


Name

sha1 — calculate SHA1 sum of input

DESCRIPTION

The filter outputs SHA1 sum for the input text.

EXAMPLES

Example: Filter example

[filter sha1][/filter]
[filter sha1]One[/filter]
[filter sha1]Two[/filter]
[filter sha1]MyPassword[/filter]
[filter sha1]Very long string[/filter]

NOTES

The sha1 filter uses the Digest::SHA1 module for the SHA1 calculation.

AVAILABILITY

sha1 is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/sha1.filter
Lines: 15


# Copyright 2007-2009 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. See the LICENSE file for details.

CodeDef sha1 Filter
CodeDef sha1 Description sha1 sum
CodeDef sha1 Routine <<EOR

sub {
return Vend::Util::sha1_hex($_[0]);
}
EOR

AUTHORS

Jon Jensen

SEE ALSO

md5(7ic)


Name

show_null — replace null-characters (\0) with literal "\0"

DESCRIPTION

The filter makes null characters in input visible, by escaping and making them appear as usual "\0"s.

EXAMPLES

Example: Filter example

[filter show_null] Input text \0 with \0 null \0 characters[/filter]

NOTES

AVAILABILITY

show_null is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/show_null.filter
Lines: 20


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: show_null.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $

CodeDef show_null Filter
CodeDef show_null Description Show NULL
CodeDef show_null Visibility  private
CodeDef show_null Routine <<EOR
sub {
my $val = shift;
$val =~ s/\0/\\0/g;
return $val;
}
EOR

SEE ALSO


Name

small — enclose input in HTML <small> tag

DESCRIPTION

The filter encloses input data in HTML <small> tag.

EXAMPLES

Example: Filter example

You can see that "[filter small] This text is smaller than usual. [/filter]"

NOTES

AVAILABILITY

small is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/small.filter
Lines: 16


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: small.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $

CodeDef small Filter
CodeDef small Routine <<EOR
sub {
return '<small>' . shift(@_) . '</small>';
}
EOR


Name

space_to_nbsp — replace all spaces (" ") with nonbreakable space ("&nbsp;") characters

DESCRIPTION

The filter replaces all space (" ") characters with HTML's nonbreakable-space ("&nbsp;") characters.

This is useful for places where you want strings to appear in a single line, without word-wrapping to the next line.

EXAMPLES

Example: Filter example

<div style="width: 80px;">
This is a very   small DIV and will   surely word-wrap this text to multiple lines.
With the filter applied, however, it will force the DIV to stretch and            render as single line.
</div>

<div style="width: 80px;">
[filter space_to_nbsp]
With the filter        applied, however, it will force the DIV to stretch and render as single line.
[/filter]
</div>

Example: Filter example

<div>
[filter space_to_nbsp.compress]
Multiple    spaces    in a line   will render   as just   single  space.
[/filter]
</div>

NOTES

In HTML, multiple spaces in a line render as just one space on the screen. When the spaces are converted to "&nbsp;", however, every nonbreakable space will produce one space character on the screen — it's how HTML works. Use the filter's compress when you want to preserve the behavior of only one space being visible on the screen.

AVAILABILITY

space_to_nbsp is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/space_to_nbsp.filter
Lines: 24


# Copyright 2002-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: space_to_nbsp.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $

CodeDef space_to_nbsp Filter
CodeDef space_to_nbsp Description All SPACE to nbsp
CodeDef space_to_nbsp Routine <<EOR
sub {
my ($str, $tag, $opt) = @_;

if ( $opt ) {
  $str =~ s/ +/&nbsp;/g;
} else {
  $str =~ s/ /&nbsp;/g;
}

$str;
}
EOR


Name

space_to_null — replace space " " with \0 (null) character

DESCRIPTION

The filter replaces space (" ") characters with a \0 (null) character.

EXAMPLES

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

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

space_to_null is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/space_to_null.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: space_to_null.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef space_to_null Filter
CodeDef space_to_null Description SPACE to NULL
CodeDef space_to_null Routine <<EOR
sub {
my $val = shift;
$val =~ s/\s+/\0/g;
return $val;
}
EOR


Name

sql — quote strings for use in SQL statements, without referencing a specific database

DESCRIPTION

The filter replaces single quotes (') with two single quotes (''). In addition, it replaces each backslash (\) with two backslashes (\\) to properly escape all content, but backslash escaping can be turned off by setting the pragma.

EXAMPLES

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

NOTES

The filter is intended to be used on SQL strings.

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

sql is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/sql.filter
Lines: 20


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: sql.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef sql Filter
CodeDef sql Description SQL quoting, generic
CodeDef sql Routine <<EOR
sub {
my $val = shift;
$val =~ s:':'':g;
$val =~ s:\\:\\\\:g unless $::Pragma->{filter_sql_no_backslash};
return $val;
}
EOR


Name

strftime — transform UNIX time (number of seconds) to a date/time string, according to specified format

DESCRIPTION

The filter transforms UNIX time (measured in a number of seconds since the epoch) to human-readable date/time string, according to the specified format.

If the format is unspecified, the system outputs time in the default format, such as Fri Dec 16 15:04:33 2005.

EXAMPLES

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

NOTES

AVAILABILITY

strftime is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/strftime.filter
Lines: 28


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: strftime.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef strftime Filter
CodeDef strftime Description Date from UNIX time
CodeDef strftime Routine <<EOR
sub {
my $time = shift(@_);
shift(@_);
my $fmt = shift(@_);
while(my $add = shift(@_)) {
  $fmt .= " $add";
}
if($fmt) {
  return POSIX::strftime($fmt, localtime($time));
}
else {
  return scalar localtime($time);
}
}
EOR

SEE ALSO

time(7ic)


Name

strikeout — enclose input in HTML <strike> tag

DESCRIPTION

The filter encloses input data in HTML <strike> (strikeout) tag.

EXAMPLES

Example: Filter example

"[filter strikeout] STRIKEOUT [/filter]"

NOTES

AVAILABILITY

strikeout is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/strikeout.filter
Lines: 16


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: strikeout.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $

CodeDef strikeout Filter
CodeDef strikeout Routine <<EOR
sub {
return '<strike>' . shift(@_) . '</strike>';
}
EOR

SEE ALSO

italics(7ic)


Name

strip — trim leading and trailing whitespace

DESCRIPTION

The filter eliminates whitespace appearing at the beginning or end of input.

EXAMPLES

Example: Filter example

"[filter strip]  XX  [/filter]"

NOTES

AVAILABILITY

strip is available in Interchange versions:

4.8.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/strip.filter
Lines: 20


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: strip.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef strip Filter
CodeDef strip Description Trim whitespace
CodeDef strip Routine <<EOR
sub {
my $val = shift;
$val =~ s/^\s+//;
$val =~ s/\s+$//;
return $val;
}
EOR


Name

strip_html

DESCRIPTION

EXAMPLES

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

NOTES

AVAILABILITY

strip_html is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/strip_html.filter
Lines: 34


# Copyright 2009 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. See the LICENSE file for details.

CodeDef strip_html Filter
CodeDef strip_html Description Strip HTML
CodeDef strip_html Routine <<EOR
sub {
  my $val = shift;

# get rid of HTML comments
$val =~ s/<!(?:--(?:[^-]*|-[^-]+)*--\s*)>//s;

  # replace these container tags with a space
  $val =~ s{</?(?:p|ol|ul|li|div|h[123456]|pre|dl|dd|dt|form|option|textarea \
|blockquote)(?:\s[^>]*)?>}{ }ig;

  # replace these self-closing tags with a space
  $val =~ s{<[bh]r(?:\s*/|\s[^>]*)?>}{ }ig;

  # remove all remaining tags and leave no space
  $val =~ s{</?\w[^>]*>}{}g;

  # collapse all whitespace, as HTML does when rendering anyway,
  # to facilitate truncating at a certain number of characters
  $val =~ s{\A\s+}{};
  $val =~ s{\s+\z}{};
  $val =~ s{\s+}{ }g;

  return $val;
}
EOR

SEE ALSO


Name

strip_path —

DESCRIPTION

EXAMPLES

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

NOTES

AVAILABILITY

strip_path is available in Interchange versions:

5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/strip_path.filter
Lines: 17


# Copyright 2002-2014 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.

CodeDef strip_path Filter
CodeDef strip_path Description Strip all path segments, leaving file name
CodeDef strip_path Routine <<EOR
sub {
local $_ = shift;
s{.*[/\\]}{}s;
return $_;
}
EOR

SEE ALSO


Name

tabbed — replace newlines in input with TAB characters

DESCRIPTION

The filter replaces all occurrences of a newline in the input with a TAB character.

Windows-style newlines (\r\n) are supported. "Compression" is not done — each newline is replaced by one TAB.

EXAMPLES

Example: Filter example

[filter tabbed]
One
Two
Three
[/filter]

NOTES

AVAILABILITY

tabbed is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/tabbed.filter
Lines: 20


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: tabbed.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $

CodeDef tabbed Filter
CodeDef tabbed Description Newline to TAB
CodeDef tabbed Routine <<EOR
sub {
my $val = shift;

$val =~ s/\r?\n/\t/g;
return $val;
}
EOR

SEE ALSO


Name

text2html — transform input plain-text to most basic HTML

DESCRIPTION

The filter only replaces double newline with HTML <p> tag, and single newline with <br>.

EXAMPLES

Example: Filter example

[filter text2html]
Perl is a lot of fun!
Interesting tricks with the language can be seen at MJD's 
<a href="http://perl.plover.com/">plover.com</a>.

Programming is an art.
[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

text2html is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/text2html.filter
Lines: 22


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: text2html.filter,v 1.6 2009-04-15 11:14:59 ton Exp $

CodeDef text2html Filter
CodeDef text2html Description Simple text2html
CodeDef text2html Routine <<EOR
sub {
my $val = shift;
$val =~ s!\r?\n\r?\n!<br$Vend::Xtrailer><br$Vend::Xtrailer>!g;
$val =~ s!\r\r!<br$Vend::Xtrailer><br$Vend::Xtrailer>!g;
$val =~ s!\r?\n!<br$Vend::Xtrailer>!g;
$val =~ s!\r!<br$Vend::Xtrailer>!g;
return $val;
}
EOR

SEE ALSO


Name

textarea_get — replace &amp; (ampersand) entities in input with literal &

DESCRIPTION

The filter replaces &amp; entities in input with literal &.

EXAMPLES

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

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

textarea_get is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/textarea_get.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: textarea_get.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef textarea_get Filter
CodeDef textarea_get Description Textarea GET
CodeDef textarea_get Routine <<EOR
sub {
my $val = shift;
$val =~ s/\&amp;/\&/g;
return $val;
}
EOR


Name

textarea_put — replace &, < and [ characters with their encoded representation

DESCRIPTION

The filter replaces & characters with &amp;, [ with &#91; and < with &lt; entities.

EXAMPLES

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

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

textarea_put is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/textarea_put.filter
Lines: 21


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: textarea_put.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef textarea_put Filter
CodeDef textarea_put Description Textarea PUT
CodeDef textarea_put Routine <<EOR
sub {
my $val = shift;
$val =~ s/\&/\&amp;/g;
$val =~ s/\[/&#91;/g;
$val =~ s/</&lt;/g;
return $val;
}
EOR


Name

tt — enclose input in HTML <tt> (typewriter) tag

DESCRIPTION

The filter encloses input in HTML <tt> (typewriter) tag.

EXAMPLES

Example: Filter example

R. J. Zavada's <a href="http://www.jfk-info.com/zreport.htm">report</a>:<br/>
[filter tt]Zapruder, eight millimeter, 8mm, cage print, B&H Model J Printer,<br/>
B&H 414PD Camera, NARA, ARRB[/filter] 

NOTES

AVAILABILITY

tt is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/tt.filter
Lines: 16


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: tt.filter,v 1.3 2007-03-30 23:40:45 pajamian Exp $

CodeDef tt Filter
CodeDef tt Routine <<EOR
sub {
return '<tt>' . shift(@_) . '</tt>';
}
EOR

SEE ALSO

italics(7ic)


Name

uc — transform all input to uppercase

DESCRIPTION

The filter transforms all input to uppercase.

EXAMPLES

Example: Filter example

[filter uc]You are kindly invited to the[/filter] 
<a href="http://www.j-walk.com/other/conf/">The 3rd Annual Nigerian
EMail Conference</a>.

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

uc is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/uc.filter
Lines: 24


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: uc.filter,v 1.6 2007-03-30 23:40:45 pajamian Exp $

CodeDef upper Filter
CodeDef upper Alias uc

CodeDef uc Filter
CodeDef uc Description Upper case
CodeDef uc Routine <<EOR
sub {
use locale;
if ($Scratch->{mv_locale}) {
    POSIX::setlocale(LC_CTYPE, $Scratch->{mv_locale});
}
return uc(shift);
}
EOR

SEE ALSO


Name

ucfirst — transform first character in input to uppercase

DESCRIPTION

The filter transforms first character in input to uppercase.

EXAMPLES

Example: Filter example

[filter ucfirst]abc def[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

ucfirst is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/ucfirst.filter
Lines: 20


# Copyright 2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: ucfirst.filter,v 1.1 2007-07-13 08:22:47 racke Exp $

CodeDef ucfirst Filter
CodeDef ucfirst Description First character upper case
CodeDef ucfirst Routine <<EOR
sub {
use locale;
if ($Scratch->{mv_locale}) {
    POSIX::setlocale(LC_CTYPE, $Scratch->{mv_locale});
}
return ucfirst(shift);
}
EOR

SEE ALSO


Name

unix — convert DOS or Mac ASCII text to Unix format

DESCRIPTION

convert DOS or Mac ASCII newlines to Unix format.

Unix uses LF (Line feed: \n) sequence to identify a newline.

DOS uses CRLF (Carriage return/Line feed: \r\n) sequence to identify a newline.

Mac uses CR (Carriage return: \r) sequence to identify a newline.

EXAMPLES

Example: Filter example

[filter unix]Those pesky DOS characters, we can only be lucky that there are
none hiding in this text ;-)[/filter]

Example: Filter example

[filter unix]
  Input text with Unix newlines
  Input text with DOS newlines
  Input text with Max newlines
[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

unix is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/unix.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: unix.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef unix Filter
CodeDef unix Description DOS to UNIX newlines
CodeDef unix Routine <<EOR
sub {
my $val = shift;
$val =~ s/\r\n|\r/\n/g;
return $val;
}
EOR


Name

upload

DESCRIPTION

EXAMPLES

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

NOTES

AVAILABILITY

upload is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/upload.filter
Lines: 23


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: upload.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef upload Filter
CodeDef upload Description Return uploaded file
CodeDef upload Routine <<EOR
sub {
my ($fn, $vn) = @_;
if( tag_value_extended($vn, { test => 'isfile', })) {
  return tag_value_extended($vn, { file_contents => 1 });
}
else {
  return $fn;
}
}
EOR

SEE ALSO


Name

urldecode — replace encoded (hex) characters with their unencoded representation

DESCRIPTION

The filter replaces encoded (hex) characters with their unencoded representation.

EXAMPLES

Example: Filter example

[filter op="urlencode urldecode"]http://myhost.mydomain.local/path/script.cgi?var1=val1&var2=val2[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

urldecode is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/urldecode.filter
Lines: 25


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: urldecode.filter,v 1.5 2007-09-21 16:15:48 kwalsh Exp $

CodeDef url       Filter
CodeDef url       Alias urldecode

CodeDef urld      Filter
CodeDef urld      Alias urldecode

CodeDef urldecode Filter
CodeDef urldecode Description URL decode
CodeDef urldecode Routine <<EOR
sub {
my $val = shift;
$val =~ s|\%([a-fA-F0-9][a-fA-F0-9])|chr(hex($1))|eg;
return $val;
}
EOR

SEE ALSO


Name

urlencode — replace non-word characters or a colon with encoded (hex) representation

DESCRIPTION

The filter replaces non-word characters or colons with their encoded (hex) representation.

EXAMPLES

Example: Filter example

[filter urlencode]http://myhost.mydomain.local/path/script.cgi?var1=val1&var2=val2[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

urlencode is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/urlencode.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: urlencode.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef urlencode Filter
CodeDef urlencode Description URL encode
CodeDef urlencode Routine <<EOR
sub {
my $val = shift;
$val =~ s|([^\w:])|sprintf "%%%02x", ord $1|eg;
return $val;
}
EOR

SEE ALSO


Name

value — expand to value of the UserDB variable specified in body

DESCRIPTION

The filter expands to the value of a UserDB variable. Name of the variable is specified in filter body.

EXAMPLES

Example: Filter example

[value name=online_value_test set="TEST VALUE" hide=1]

My test value is [filter value]online_value_test[/filter]

NOTES

AVAILABILITY

value is available in Interchange versions:

4.8.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/value.filter
Lines: 18


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: value.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $

CodeDef value Filter
CodeDef value Description Return $Values->{VALUE}
CodeDef value Visibility  private
CodeDef value Routine <<EOR
sub {
return $::Values->{$_[0]};
}
EOR


Name

vars_and_comments — interpolate variables and remove comments

DESCRIPTION

The filter interpolates variables and removes comments from input.

EXAMPLES

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

NOTES

AVAILABILITY

vars_and_comments is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/vars_and_comments.filter
Lines: 22


# Copyright 2004-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: vars_and_comments.filter,v 1.5 2007-03-30 23:40:45 pajamian Exp $

CodeDef vars_and_comments Filter
CodeDef vars_and_comments Description Vars/comments
CodeDef vars_and_comments Visibility  private
CodeDef vars_and_comments Routine <<EOR
sub {
my $body = shift;
my $bodyref = ref($body) ? $body : \$body;

Vend::Interpolate::vars_and_comments($bodyref);

return ref($body) ? $body: $$bodyref;
}
EOR

SEE ALSO


Name

word — eliminate any non-word characters

DESCRIPTION

The filter eliminates non-word characters in the input. (Non-word characters are those outside the [a-zA-Z0-9_] range.)

EXAMPLES

Example: Filter example

[filter word]Hello, World![/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

word is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/word.filter
Lines: 19


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: word.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef word Filter
CodeDef word Description A-Za-z_0-9
CodeDef word Routine <<EOR
sub {
my $val = shift;
$val =~ s/\W+//g;
return $val;
}
EOR

SEE ALSO


Name

yesno — return Yes for non-empty input, No otherwise

DESCRIPTION

Return Yes (or it's locale-specific variant) on non-empty input (whitespace is considered non-empty too). Return No (or it's locale-specific variant) otherwise.

EXAMPLES

Example: Filter example

OK (yes)? [filter yesno]Good input[/filter]
OK (no)? [filter yesno][/filter]

Example: Reaching "yesno" decision after any whitespace is removed first

OK (yes)? [filter yesno]Good input[/filter]
OK (yes)? [filter yesno][/filter]
OK (no)? [filter strip yesno][/filter]

NOTES

AVAILABILITY

yesno is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/yesno.filter
Lines: 20


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: yesno.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef yesno Filter
CodeDef yesno Description 1/0 to Yes/No
CodeDef yesno Routine <<EOR
sub {
my $val = shift(@_) ? 'Yes' : 'No';
return $val unless $Vend::Cfg->{Locale};
return $val unless defined $Vend::Cfg->{Locale}{$val};
return $Vend::Cfg->{Locale}{$val};
}
EOR


Name

zerofix — eliminate possible zeros at beginning of input

DESCRIPTION

The filter eliminates zeros (0) that might be present at the beginning of an input string.

EXAMPLES

Example: Filter example

[filter zerofix]000123456[/filter]

NOTES

For more information on Perl Regular Expressions, pattern matching and character classes, see perlre(1).

AVAILABILITY

zerofix is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: code/Filter/zerofix.filter
Lines: 17


# Copyright 2002-2007 Interchange Development Group and others
# Copyright 1996-2002 Red Hat, Inc.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.
# 
# $Id: zerofix.filter,v 1.4 2007-03-30 23:40:45 pajamian Exp $

CodeDef zerofix Filter
CodeDef zerofix Description Strip leading zeros
CodeDef zerofix Routine <<EOR
sub {
$_[0] =~ /^0*(.*)/; return $1;
}
EOR

SEE ALSO

DocBook!Interchange!