line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#url.pm
|
2
|
|
|
|
|
|
|
#Last Change: 2009-01-19
|
3
|
|
|
|
|
|
|
#Copyright (c) 2009 Marc-Seabstian "Maluku" Lucksch
|
4
|
|
|
|
|
|
|
#Version 0.8
|
5
|
|
|
|
|
|
|
####################
|
6
|
|
|
|
|
|
|
#This file is part of the Dotiac::DTL project.
|
7
|
|
|
|
|
|
|
#http://search.cpan.org/perldoc?Dotiac::DTL
|
8
|
|
|
|
|
|
|
#
|
9
|
|
|
|
|
|
|
#url.pm is published under the terms of the MIT license, which basically
|
10
|
|
|
|
|
|
|
#means "Do with it whatever you want". For more information, see the
|
11
|
|
|
|
|
|
|
#license.txt file that should be enclosed with libsofu distributions. A copy of
|
12
|
|
|
|
|
|
|
#the license is (at the time of writing) also available at
|
13
|
|
|
|
|
|
|
#http://www.opensource.org/licenses/mit-license.php .
|
14
|
|
|
|
|
|
|
###############################################################################
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Dotiac::DTL::Tag::url;
|
17
|
11
|
|
|
11
|
|
58
|
use base qw/Dotiac::DTL::Tag/;
|
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
821
|
|
18
|
11
|
|
|
11
|
|
77
|
use strict;
|
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
331
|
|
19
|
11
|
|
|
11
|
|
55
|
use warnings;
|
|
11
|
|
|
|
|
39
|
|
|
11
|
|
|
|
|
30516
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = 0.8;
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#Bugs: Url in var (as) must be marked safe manually
|
24
|
|
|
|
|
|
|
sub new {
|
25
|
4
|
|
|
4
|
1
|
10
|
my $class=shift;
|
26
|
4
|
|
|
|
|
13
|
my $self={p=>shift()};
|
27
|
4
|
|
|
|
|
17
|
my %name=Dotiac::DTL::get_variables(shift(),"as");
|
28
|
4
|
|
|
|
|
9
|
my $name=join(",",@{$name{""}});
|
|
4
|
|
|
|
|
10
|
|
29
|
4
|
100
|
|
|
|
13
|
if ($name{"as"}) {
|
30
|
2
|
|
|
|
|
8
|
$self->{var}=$name{"as"}->[0];
|
31
|
|
|
|
|
|
|
}
|
32
|
4
|
|
|
|
|
17
|
my @url=split /\,/,$name;
|
33
|
4
|
|
|
|
|
5
|
my $var=0;
|
34
|
4
|
|
|
|
|
6
|
my @path;
|
35
|
|
|
|
|
|
|
my @query;
|
36
|
4
|
|
|
|
|
8
|
foreach my $u (@url) {
|
37
|
16
|
100
|
|
|
|
42
|
if ($u =~/\=/) {
|
|
|
50
|
|
|
|
|
|
38
|
8
|
|
|
|
|
9
|
$var=1;
|
39
|
8
|
|
|
|
|
35
|
push @query,[split /=/,$u,2];
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
elsif ($var) {
|
42
|
0
|
|
|
|
|
0
|
push @query,$u;
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
else {
|
45
|
8
|
|
|
|
|
15
|
push @path,$u;
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
}
|
48
|
4
|
|
|
|
|
27
|
$self->{path}=[@path];
|
49
|
4
|
|
|
|
|
16
|
$self->{query}=[@query];
|
50
|
4
|
|
|
|
|
14
|
bless $self,$class;
|
51
|
4
|
|
|
|
|
23
|
return $self;
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
sub print {
|
54
|
4
|
|
|
4
|
1
|
8
|
my $self=shift;
|
55
|
4
|
|
|
|
|
6
|
my $vars=shift;
|
56
|
4
|
|
|
|
|
7
|
my $escape=shift;
|
57
|
4
|
|
|
|
|
9
|
print $self->{p};
|
58
|
|
|
|
|
|
|
#print join("/",map {Dotiac::DTL::devar($_,@_)} @{$self->{path}}),(@{$self->{query}}?"?".join("&",map {join "=",map {Dotiac::DTL::devar($_,@_)} @{$_}} @{$self->{query}}:"");
|
59
|
4
|
100
|
|
|
|
12
|
if ($self->{var}) {
|
60
|
2
|
50
|
|
|
|
6
|
$vars->{$self->{var}} = join("/",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw($_,$vars,0,@_),":/")->repr()} @{$self->{path}}).(@{$self->{query}}?"?".join("&",map {join "=",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw($_,$vars,0,@_),"")->repr()} @{$_}} @{$self->{query}}):"");
|
|
4
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
25
|
|
|
4
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
6
|
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
else {
|
63
|
2
|
50
|
|
|
|
5
|
print Dotiac::DTL::Escape(join("/",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw($_,$vars,0,@_),":/")->repr()} @{$self->{path}}).(@{$self->{query}}?"?".join("&",map {join "=",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw($_,$vars,0,@_),"")->repr()} @{$_}} @{$self->{query}}):""),$escape);
|
|
4
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
6
|
|
|
8
|
|
|
|
|
26
|
|
|
4
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
6
|
|
64
|
|
|
|
|
|
|
}
|
65
|
4
|
|
|
|
|
32
|
$self->{n}->print($vars,$escape,@_);
|
66
|
|
|
|
|
|
|
}
|
67
|
|
|
|
|
|
|
sub string {
|
68
|
4
|
|
|
4
|
1
|
8
|
my $self=shift;
|
69
|
4
|
|
|
|
|
5
|
my $vars=shift;
|
70
|
4
|
|
|
|
|
9
|
my $escape=shift;
|
71
|
4
|
100
|
|
|
|
12
|
if ($self->{var}) {
|
72
|
2
|
50
|
|
|
|
5
|
$vars->{$self->{var}} = join("/",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw($_,$vars,0,@_),":/")->repr()} @{$self->{path}}).(@{$self->{query}}?"?".join("&",map {join "=",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw($_,$vars,0,@_),"")->repr()} @{$_}} @{$self->{query}}):"");
|
|
4
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
30
|
|
|
4
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
6
|
|
73
|
2
|
|
|
|
|
18
|
return $self->{p}.$self->{n}->string($vars,$escape,@_);
|
74
|
|
|
|
|
|
|
}
|
75
|
2
|
50
|
|
|
|
6
|
return $self->{p}.Dotiac::DTL::Escape(join("/",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw($_,$vars,0,@_),":/")->repr()} @{$self->{path}}).(@{$self->{query}}?"?".join("&",map {join "=",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw($_,$vars,0,@_),"")->repr()} @{$_}} @{$self->{query}}):""),$escape).$self->{n}->string($vars,$escape,@_);
|
|
4
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
25
|
|
|
4
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
6
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
sub perl {
|
79
|
4
|
|
|
4
|
1
|
8
|
my $self=shift;
|
80
|
4
|
|
|
|
|
6
|
my $fh=shift;
|
81
|
4
|
|
|
|
|
7
|
my $id=shift;
|
82
|
4
|
|
|
|
|
21
|
$self->SUPER::perl($fh,$id,@_);
|
83
|
4
|
|
|
|
|
10
|
print $fh "my ";
|
84
|
4
|
|
|
|
|
30
|
print $fh (Data::Dumper->Dump([$self->{path}],["\$path$id"]));
|
85
|
4
|
|
|
|
|
226
|
print $fh "my ";
|
86
|
4
|
|
|
|
|
26
|
print $fh (Data::Dumper->Dump([$self->{query}],["\$query$id"]));
|
87
|
4
|
100
|
|
|
|
273
|
if ($self->{var}) {
|
88
|
2
|
|
|
|
|
5
|
print $fh "my ";
|
89
|
2
|
|
|
|
|
14
|
print $fh (Data::Dumper->Dump([$self->{var}],["\$var$id"]));
|
90
|
|
|
|
|
|
|
}
|
91
|
4
|
50
|
|
|
|
105
|
return $self->{n}->perl($fh,$id+1,@_) if $self->{n};
|
92
|
0
|
|
|
|
|
0
|
return $id;
|
93
|
|
|
|
|
|
|
}
|
94
|
|
|
|
|
|
|
sub perlprint {
|
95
|
4
|
|
|
4
|
1
|
6
|
my $self=shift;
|
96
|
4
|
|
|
|
|
5
|
my $fh=shift;
|
97
|
4
|
|
|
|
|
16
|
my $id=shift;
|
98
|
4
|
|
|
|
|
10
|
my $level=shift;
|
99
|
4
|
|
|
|
|
20
|
$self->SUPER::perlprint($fh,$id,$level,@_);
|
100
|
4
|
100
|
|
|
|
11
|
if ($self->{var}) {
|
101
|
2
|
|
|
|
|
12
|
print $fh "\t" x $level,"\$vars->{\$var$id}=join(\"/\",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw(\$_,\$vars,\$escape,\@_),\":/\")->repr()} \@{\$path$id}).(\@{\$query$id}?\"?\".join(\"&\",map {join \"=\",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw(\$_,\$vars,0,\@_),\"\")->repr()} \@{\$_}} \@{\$query$id}):\"\");\n";
|
102
|
|
|
|
|
|
|
}
|
103
|
|
|
|
|
|
|
else {
|
104
|
2
|
|
|
|
|
9
|
print $fh "\t" x $level,"print Dotiac::DTL::Escape(join(\"/\",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw(\$_,\$vars,\$escape,\@_),\":/\")->repr()} \@{\$path$id}).(\@{\$query$id}?\"?\".join(\"&\",map {join \"=\",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw(\$_,\$vars,0,\@_),\"\")->repr()} \@{\$_}} \@{\$query$id}):\"\"),\$escape);\n";
|
105
|
|
|
|
|
|
|
}
|
106
|
4
|
|
|
|
|
19
|
return $self->{n}->perlprint($fh,$id+1,$level,@_);
|
107
|
|
|
|
|
|
|
}
|
108
|
|
|
|
|
|
|
sub perlstring {
|
109
|
4
|
|
|
4
|
1
|
6
|
my $self=shift;
|
110
|
4
|
|
|
|
|
4
|
my $fh=shift;
|
111
|
4
|
|
|
|
|
6
|
my $id=shift;
|
112
|
4
|
|
|
|
|
5
|
my $level=shift;
|
113
|
4
|
|
|
|
|
19
|
$self->SUPER::perlstring($fh,$id,$level,@_);
|
114
|
4
|
100
|
|
|
|
10
|
if ($self->{var}) {
|
115
|
2
|
|
|
|
|
20
|
print $fh "\t" x $level,"\$vars->{\$var$id}=join(\"/\",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw(\$_,\$vars,0,\@_),\":/\")->repr()} \@{\$path$id}).(\@{\$query$id}?\"?\".join(\"&\",map {join \"=\",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw(\$_,\$vars,0,\@_),\"\")->repr()} \@{\$_}} \@{\$query$id}):\"\");\n";
|
116
|
|
|
|
|
|
|
}
|
117
|
|
|
|
|
|
|
else {
|
118
|
2
|
|
|
|
|
9
|
print $fh "\t" x $level,"\$r.=Dotiac::DTL::Escape(join(\"/\",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw(\$_,\$vars,0,\@_),\":/\")->repr()} \@{\$path$id}).(\@{\$query$id}?\"?\".join(\"&\",map {join \"=\",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw(\$_,\$vars,0,\@_),\"\")->repr()} \@{\$_}} \@{\$query$id}):\"\"),\$escape);\n";
|
119
|
|
|
|
|
|
|
}
|
120
|
4
|
|
|
|
|
37
|
return $self->{n}->perlstring($fh,$id+1,$level,@_);
|
121
|
|
|
|
|
|
|
}
|
122
|
|
|
|
|
|
|
sub perlcount {
|
123
|
0
|
|
|
0
|
1
|
0
|
my $self=shift;
|
124
|
0
|
|
|
|
|
0
|
my $id=shift;
|
125
|
0
|
|
|
|
|
0
|
return $self->{n}->perlcount($id+1);
|
126
|
|
|
|
|
|
|
}
|
127
|
|
|
|
|
|
|
sub perleval {
|
128
|
4
|
|
|
4
|
1
|
8
|
my $self=shift;
|
129
|
4
|
|
|
|
|
7
|
my $fh=shift;
|
130
|
4
|
|
|
|
|
6
|
my $id=shift;
|
131
|
4
|
|
|
|
|
6
|
my $level=shift;
|
132
|
4
|
100
|
|
|
|
13
|
if ($self->{var}) {
|
133
|
2
|
|
|
|
|
10
|
print $fh "\t" x $level,"\$vars->{\$var$id}=join(\"/\",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw(\$_,\$vars,\$escape,\@_),\":/\")->repr()} \@{\$path$id}).(\@{\$query$id}?\"?\".join(\"&\",map {join \"=\",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw(\$_,\$vars,0,\@_),\"\")->repr()} \@{\$_}} \@{\$query$id}):\"\");\n";
|
134
|
|
|
|
|
|
|
}
|
135
|
4
|
|
|
|
|
17
|
return $self->{n}->perleval($fh,$id+1,$level,@_);
|
136
|
|
|
|
|
|
|
}
|
137
|
|
|
|
|
|
|
sub perlinit {
|
138
|
4
|
|
|
4
|
1
|
6
|
my $self=shift;
|
139
|
4
|
|
|
|
|
5
|
my $fh=shift;
|
140
|
4
|
|
|
|
|
6
|
my $id=shift;
|
141
|
4
|
|
|
|
|
18
|
return $self->{n}->perlinit($fh,$id+1,@_);
|
142
|
|
|
|
|
|
|
}
|
143
|
|
|
|
|
|
|
sub next {
|
144
|
4
|
|
|
4
|
1
|
9
|
my $self=shift;
|
145
|
4
|
|
|
|
|
23
|
$self->{n}=shift;
|
146
|
|
|
|
|
|
|
}
|
147
|
|
|
|
|
|
|
sub eval {
|
148
|
0
|
|
|
0
|
1
|
|
my $self=shift;
|
149
|
0
|
|
|
|
|
|
my $vars=shift;
|
150
|
0
|
|
|
|
|
|
my $escape=shift;
|
151
|
0
|
0
|
|
|
|
|
if ($self->{var}) {
|
152
|
0
|
0
|
|
|
|
|
$vars->{$self->{var}} = join("/",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw($_,$vars,0,@_),":/")->repr()} @{$self->{path}}).(@{$self->{query}}?"?".join("&",map {join "=",map {Dotiac::DTL::Filter::urlencode(Dotiac::DTL::devar_raw($_,$vars,0,@_),"")->repr()} @{$_}} @{$self->{query}}):"");
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
}
|
154
|
0
|
|
|
|
|
|
$self->{n}->eval($vars,$escape,@_);
|
155
|
|
|
|
|
|
|
}
|
156
|
|
|
|
|
|
|
1;
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
__END__
|