line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WordPress::Base; |
2
|
|
|
|
|
|
|
# DEPRECATED |
3
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
110
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
212
|
|
5
|
2
|
|
|
2
|
|
40
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
207
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
9
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
747
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
0
|
|
|
0
|
0
|
|
my ($class,$self) = @_; |
12
|
0
|
0
|
|
|
|
|
ref $self eq 'HASH' or croak('expected hash ref arg to constructor'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
bless $self, $class; |
16
|
0
|
|
|
|
|
|
return $self; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#required params/methods for a connection |
22
|
|
|
|
|
|
|
for my $param (qw(proxy username password)){ |
23
|
|
|
|
|
|
|
#my $method = "_$param"; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
*{$param} = sub { |
26
|
0
|
|
|
0
|
|
|
my $self = shift; |
27
|
0
|
|
|
|
|
|
my $val = shift; |
28
|
0
|
0
|
|
|
|
|
if( defined $val ){ |
29
|
0
|
|
|
|
|
|
$self->{$param} = $val; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
return $self->{$param}; |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# i know it doesnt cache it in object, this is just the raw method |
42
|
|
|
|
|
|
|
sub _categories { |
43
|
0
|
|
|
0
|
|
|
my $self = shift; |
44
|
0
|
|
|
|
|
|
my $call = $self->server->call( |
45
|
|
|
|
|
|
|
'metaWeblog.getCategories', |
46
|
|
|
|
|
|
|
1, # blogid ignored |
47
|
|
|
|
|
|
|
$self->username, |
48
|
|
|
|
|
|
|
$self->password, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my @categories = map { $_->{categoryName} } @{ $call->result }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return @categories; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
# may return undef |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# yes this one caches. always returns array ref |
61
|
|
|
|
|
|
|
sub categories { |
62
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
63
|
0
|
|
0
|
|
|
|
$self->{_categories} ||= [ $self->_categories ]; |
64
|
0
|
|
|
|
|
|
return $self->{_categories}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub server { |
73
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
74
|
0
|
0
|
|
|
|
|
unless( $self->{_server} ){ |
75
|
0
|
0
|
|
|
|
|
$self->proxy or croak('missing proxy'); |
76
|
0
|
|
|
|
|
|
require XMLRPC::Lite; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
0
|
|
|
|
$self->{_server} ||= XMLRPC::Lite->proxy( $self->proxy ); |
79
|
|
|
|
|
|
|
} |
80
|
0
|
|
|
|
|
|
return $self->{_server}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |