From: <mp...@kr...> - 2009-06-12 22:32:09
|
Revision: 6173 Author: mpeters Date: 2009-06-12 18:28:45 -0400 (Fri, 12 Jun 2009) Log Message: ----------- adding a new_window param to Krang::Widget::format_url() Modified Paths: -------------- trunk/krang/lib/Krang/Widget.pm Modified: trunk/krang/lib/Krang/Widget.pm =================================================================== --- trunk/krang/lib/Krang/Widget.pm 2009-06-12 22:24:49 UTC (rev 6172) +++ trunk/krang/lib/Krang/Widget.pm 2009-06-12 22:28:45 UTC (rev 6173) @@ -738,14 +738,18 @@ as number of characters after which a new line should be created. If not specified, the default length of 15 will be used. +The optional C<new_window> parameter, when combined with the C<linkto> +parameter will open the link in a new window/tab. + =cut sub format_url { my %args = @_; # Validate calling input - my ($url, $linkto, $length, $name, $class) = @args{qw/url linkto length name class/}; + my ($url, $linkto, $length, $name, $class, $new_window) = + @args{qw/url linkto length name class new_window/}; croak("Missing required argument 'url'") unless ($url); $length = 15 unless ($length); @@ -763,9 +767,10 @@ my $format_url_html; my @url_lines = split("\n", $url); if ($linkto) { + my $target = $new_window ? 'target="_blank"' : ''; # URL with links - $format_url_html = qq{<a href="$linkto">} . join('<wbr>', @url_lines) . qq{</a>}; + $format_url_html = qq{<a href="$linkto" $target>} . join('<wbr>', @url_lines) . qq{</a>}; } elsif ($name) { # DOM2 event handling $format_url_html = qq{<a href="" name="$name" class="$class">} . join('<wbr>', @url_lines) . qq{</a>}; |