| blib/lib/Data/Report/Plugin/Html.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 56 | 64 | 87.5 |
| branch | 22 | 28 | 78.5 |
| condition | 7 | 9 | 77.7 |
| subroutine | 9 | 9 | 100.0 |
| pod | 0 | 3 | 0.0 |
| total | 94 | 113 | 83.1 |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | # Data::Report::Plugin::Html.pm -- HTML plugin for Data::Report | ||||||
| 2 | # RCS Info : $Id: Html.pm,v 1.8 2008/08/18 09:51:23 jv Exp $ | ||||||
| 3 | # Author : Johan Vromans | ||||||
| 4 | # Created On : Thu Dec 29 15:46:47 2005 | ||||||
| 5 | # Last Modified By: Johan Vromans | ||||||
| 6 | # Last Modified On: Mon Aug 18 11:45:39 2008 | ||||||
| 7 | # Update Count : 83 | ||||||
| 8 | # Status : Unknown, Use with caution! | ||||||
| 9 | |||||||
| 10 | package Data::Report::Plugin::Html; | ||||||
| 11 | |||||||
| 12 | 8 | 8 | 3967 | use strict; | |||
| 8 | 18 | ||||||
| 8 | 313 | ||||||
| 13 | 8 | 8 | 51 | use warnings; | |||
| 8 | 14 | ||||||
| 8 | 526 | ||||||
| 14 | 8 | 8 | 45 | use base qw(Data::Report::Base); | |||
| 8 | 18 | ||||||
| 8 | 5534 | ||||||
| 15 | |||||||
| 16 | ################ API ################ | ||||||
| 17 | |||||||
| 18 | my $html_use_entities = 0; | ||||||
| 19 | |||||||
| 20 | sub start { | ||||||
| 21 | 7 | 7 | 0 | 81 | my ($self) = @_; | ||
| 22 | 7 | 24 | $self->_argcheck(0); | ||||
| 23 | 7 | 13 | eval { | ||||
| 24 | 7 | 6986 | require HTML::Entities; | ||||
| 25 | 7 | 68143 | $html_use_entities = 1; | ||||
| 26 | }; | ||||||
| 27 | 7 | 114 | $self->SUPER::start(); | ||||
| 28 | 7 | 58 | $self->{used} = 0; | ||||
| 29 | } | ||||||
| 30 | |||||||
| 31 | sub finish { | ||||||
| 32 | 7 | 7 | 0 | 37 | my ($self) = @_; | ||
| 33 | 7 | 65 | $self->_argcheck(0); | ||||
| 34 | 7 | 100 | 50 | if ( $self->{used} ) { | |||
| 35 | 6 | 23 | $self->_print(" |
| 89 | ||||||||
| 90 | 6 | 23 | $self->_print(" | |||||
| 91 | 6 | 9 | foreach ( @{$self->_get_fields} ) { | |||||
| 6 | 94 | |||||||
| 92 | ||||||||
| 93 | # Examine style mods. | |||||||
| 94 | 26 | 93 | my $t = $self->_getstyle("_head", $_->{name}); | |||||
| 95 | 26 | 100 | 71 | next if $t->{ignore}; | ||||
| 96 | ||||||||
| 97 | 24 | 66 | 150 | my $class = $t->{class} || "h_" . $_->{name}; | ||||
| 98 | ||||||||
| 99 | 24 | 61 | $self->_print(" | {align}), | ||||
|---|---|---|---|---|---|---|---|---|
| 100 | "class=\"$class\">", | |||||||
| 101 | $self->_html($_->{title}), "\n"); | |||||||
| 102 | } | |||||||
| 103 | 6 | 23 | $self->_print(" | |||||
| 104 | ||||||||
| 105 | } | |||||||
| 106 | ||||||||
| 107 | ################ Internal methods ################ | |||||||
| 108 | ||||||||
| 109 | sub _align { | |||||||
| 110 | 98 | 100 | 98 | 284 | return 'align="right" ' if $_[0] eq '>'; | |||
| 111 | 77 | 100 | 353 | return 'align="left" ' if $_[0] eq '<'; | ||||
| 112 | 26 | 50 | 145 | return 'align="center" ' if $_[0] eq '|'; | ||||
| 113 | 0 | 0 | "" | |||||
| 114 | } | |||||||
| 115 | ||||||||
| 116 | sub _html { | |||||||
| 117 | 110 | 110 | 305 | shift; | ||||
| 118 | 110 | 50 | 205 | if ( $html_use_entities ) { | ||||
| 119 | 110 | 270 | return HTML::Entities::encode(shift); | |||||
| 120 | } | |||||||
| 121 | ||||||||
| 122 | 0 | my ($t) = @_; | ||||||
| 123 | 0 | $t =~ s/&/&/g; | ||||||
| 124 | 0 | $t =~ s/</g; | ||||||
| 125 | 0 | $t =~ s/>/>/g; | ||||||
| 126 | 0 | $t =~ s/\240/ /g; | ||||||
| 127 | 0 | $t =~ s/\x{eb}/ë/g; # for IVP. | ||||||
| 128 | 0 | $t; | ||||||
| 129 | } | |||||||
| 130 | ||||||||
| 131 | 1; |