Added searchAndReplace functionality

This commit is contained in:
Len Kranendonk 2003-05-13 11:38:51 +00:00
parent 07aa610a8f
commit 12a35c8db6
4 changed files with 52 additions and 2 deletions

View file

@ -211,6 +211,7 @@ sub formatHeader {
sub formatMessage {
my $output;
$output = WebGUI::HTML::filter($_[0],$_[1]);
$output = WebGUI::HTML::searchAndReplace($output);
unless ($output =~ /\<div\>/ig || $output =~ /\<br\>/ig || $output =~ /\<p\>/ig) {
$output =~ s/\n/\<br\>/g;
}

View file

@ -32,6 +32,7 @@ A package for manipulating and massaging HTML.
use WebGUI::HTML;
$html = WebGUI::HTML::cleanSegment($html);
$html = WebGUI::HTML::filter($html);
$html = WebGUI::HTML::searchAndReplace($html);
=head1 METHODS
@ -127,6 +128,31 @@ sub filter {
}
}
#-------------------------------------------------------------------
=head2 searchAndReplace ( html )
Replaces all occurrences of strings specified in the config file.
=over
=item html
The HTML segment you want to have search and replaced.
=back
=cut
sub searchAndReplace {
my $content = shift;
foreach my $search (keys %{$session{config}{searchAndReplace}}) {
my $replace = $session{config}{searchAndReplace}{$search};
$content =~ s/\Q$search/$replace/g;
}
return $content;
}
1;