line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Widget::Path; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.005; |
4
|
3
|
|
|
3
|
|
45763
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
179
|
|
5
|
3
|
|
|
3
|
|
17
|
use vars qw($VERSION); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
4001
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.01'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
2
|
|
|
2
|
1
|
534
|
my $proto = shift; |
11
|
2
|
|
33
|
|
|
16
|
my $class = ref($proto) || $proto; |
12
|
2
|
50
|
|
|
|
19
|
my $self = ($#_ == 0) ? shift : { @_ }; |
13
|
2
|
50
|
|
|
|
9
|
$self->{'separator'} = '>' unless defined $self->{'separator'}; |
14
|
2
|
100
|
66
|
|
|
23
|
$self->{'link_last'} = 0 unless ( defined $self->{'link_last'} and $self->{'link_last'} =~ /^(0|1)$/ ); |
15
|
2
|
50
|
33
|
|
|
13
|
$self->{'link'} = 1 unless ( defined $self->{'link'} and $self->{'link'} =~ /^(0|1)$/ ); |
16
|
2
|
|
|
|
|
5
|
bless $self,$class; |
17
|
2
|
100
|
|
|
|
19
|
if ( $self->{'path'} ) { |
18
|
1
|
|
|
|
|
2
|
eval { require File::Spec}; |
|
1
|
|
|
|
|
12
|
|
19
|
1
|
|
|
|
|
23
|
foreach ( File::Spec->splitdir($self->{'path'}) ) { |
20
|
1
|
|
|
|
|
15
|
$self->addElem( elems => [ |
21
|
|
|
|
|
|
|
{ name => $_, wrap => [ { tag => 'a', attr => { 'href' => "$_/" } } ], append => 1 }, |
22
|
|
|
|
|
|
|
] ); |
23
|
|
|
|
|
|
|
} |
24
|
0
|
|
0
|
|
|
0
|
$self->{elems}->[0]->{'name'} ||= 'root'; |
25
|
|
|
|
|
|
|
} |
26
|
1
|
|
|
|
|
5
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub asHTML { |
30
|
0
|
|
|
0
|
1
|
0
|
my ($self,%args) = @_; |
31
|
0
|
|
|
|
|
0
|
my $str; |
32
|
0
|
0
|
|
|
|
0
|
my $tree_path = "$self->{'base_url'}" if $self->{'base_url'}; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i <= $#{@{$self->{'elems'}}}; $i++) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
35
|
|
|
|
|
|
|
#next if ( ! exists ${@{$self->{'elems'}}}[$i]{'name'} or ${@{$self->{'elems'}}}[$i]{'name'} eq '' ) ; |
36
|
0
|
0
|
0
|
|
|
0
|
next unless ( exists ${@{$self->{'elems'}}}[$i]{'name'} and ${@{$self->{'elems'}}}[$i]{'name'} ne '' ) ; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
37
|
0
|
|
|
|
|
0
|
my $element = ${@{$self->{'elems'}}}[$i]{'name'}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
38
|
0
|
0
|
|
|
|
0
|
$str .= $self->{'separator'} if $i > 0; |
39
|
0
|
|
|
|
|
0
|
foreach my $wrap( @{${@{$self->{'elems'}}}[$i]{'wrap'}} ) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
40
|
0
|
0
|
0
|
|
|
0
|
unless ( $wrap->{'tag'} =~ /^a$/i and ( ($i == $#{@{$self->{'elems'}}} and ! $self->{'link_last'}) || ! $self->{'link'} ) ) { |
|
|
|
0
|
|
|
|
|
41
|
0
|
0
|
|
|
|
0
|
$element = '<' . $wrap->{'tag'} . ($wrap->{'attr'} ? ' ' . join ' ', map {"$_=\"" . ($_ =~ /^href$/i ? (${@{$self->{'elems'}}}[$i]{'append'} ? ($tree_path .= $wrap->{'attr'}{$_}) : "$self->{'base_url'}$wrap->{'attr'}{$_}") : "$wrap->{'attr'}{$_}") . '"'} keys %{$wrap->{'attr'}} : '' ) . '>' . $element . '' . $wrap->{'tag'} . '>'; |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
0
|
$str .= $element; |
45
|
|
|
|
|
|
|
} |
46
|
0
|
|
|
|
|
0
|
$self->{'out'} = $str; |
47
|
0
|
|
|
|
|
0
|
return $self->{'out'}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub addElem { |
51
|
2
|
|
|
2
|
1
|
8
|
my ($self,%args) = @_; |
52
|
2
|
50
|
|
|
|
10
|
$args{'position'} = ($#{@{$self->{'elems'}}} + 1) if ! defined $args{'position'}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
391
|
|
53
|
0
|
|
|
|
|
|
splice(@{$self->{'elems'}}, $args{'position'}, 0, @{$args{'elems'}}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return scalar @{$self->{'elems'}}; |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub deleteElem { |
58
|
0
|
|
|
0
|
1
|
|
my ($self,%args) = @_; |
59
|
0
|
0
|
|
|
|
|
$args{'position'} = $#{@{$self->{'elems'}}} if ! defined $args{'position'}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
60
|
0
|
|
0
|
|
|
|
$args{'lenght'} ||= 1; |
61
|
0
|
|
|
|
|
|
splice(@{$self->{'elems'}}, $args{'position'}, $args{'lenght'}); |
|
0
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return scalar @{$self->{'elems'}}; |
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub errstr { |
66
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
67
|
0
|
|
|
|
|
|
$self->{'errstr'}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |