| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bookmarks::XML; |
|
2
|
5
|
|
|
5
|
|
118
|
use base 'Bookmarks::Parser'; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
384
|
|
|
3
|
5
|
|
|
5
|
|
29
|
use strict; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
149
|
|
|
4
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
134
|
|
|
5
|
5
|
|
|
5
|
|
4824
|
use XML::Simple; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new |
|
8
|
|
|
|
|
|
|
{ |
|
9
|
|
|
|
|
|
|
my ($class, %opts) = @_; |
|
10
|
|
|
|
|
|
|
# %opts = check_options(%opts); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $self = bless({%opts}, ref($class) || $class); |
|
13
|
|
|
|
|
|
|
return $self; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub parse_file |
|
17
|
|
|
|
|
|
|
{ |
|
18
|
|
|
|
|
|
|
my ($sel, $filename) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return if(!$filename || !-e $filename); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $bookmarks = XMLin($filename, ForceArray => ['folder']); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub get_header_as_string |
|
27
|
|
|
|
|
|
|
{ |
|
28
|
|
|
|
|
|
|
my ($self) = @_; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $now = scalar localtime; |
|
31
|
|
|
|
|
|
|
my $title = $self->{_title} || 'Bookmarks'; |
|
32
|
|
|
|
|
|
|
my $header = << "XML"; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
XML |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
return $header; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_item_as_string |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
|
|
|
|
|
|
my ($self, $item) = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
if(!defined $item->{id} || !$self->{_items}{$item->{id}}) |
|
50
|
|
|
|
|
|
|
{ |
|
51
|
|
|
|
|
|
|
warn "No such item in get_item_as_string"; |
|
52
|
|
|
|
|
|
|
return; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $string = ''; |
|
56
|
|
|
|
|
|
|
my ($id, $url, $name, $visited, $created, $modified, $icon, $desc, $expand, $trash, $order) = |
|
57
|
|
|
|
|
|
|
($item->{id} || 0, |
|
58
|
|
|
|
|
|
|
$item->{url} || '', |
|
59
|
|
|
|
|
|
|
$item->{name} || '', |
|
60
|
|
|
|
|
|
|
$item->{visited} || 0, |
|
61
|
|
|
|
|
|
|
$item->{created} || time(), |
|
62
|
|
|
|
|
|
|
$item->{modified} || 0, |
|
63
|
|
|
|
|
|
|
$item->{icon} || '', |
|
64
|
|
|
|
|
|
|
$item->{description} || '', |
|
65
|
|
|
|
|
|
|
$item->{expanded} || '', |
|
66
|
|
|
|
|
|
|
$item->{trash} || '', |
|
67
|
|
|
|
|
|
|
$item->{order} || ''); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
if($item->{type} eq 'folder') |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
|
|
|
|
|
|
$string .= << "XML"; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
XML |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$string .= $self->get_item_as_string($self->{_items}{$_}) |
|
76
|
|
|
|
|
|
|
foreach(@{$item->{children}}); |
|
77
|
|
|
|
|
|
|
$string .= " \n"; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
elsif($item->{type} eq 'url') |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
|
|
|
|
|
|
$string .= << "XML"; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
XML |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return $string; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub get_footer_as_string |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
|
|
|
|
|
|
my ($self) = @_; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $footer = << "XML"; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
XML |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
return $footer; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 NAME |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Bookmarks::Parser::XML - Backend for XML format |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This backend is completely untested, and probably does not work yet. use at own risk. |
|
110
|
|
|
|
|
|
|
It will probably be replaced with an XBEL based backend in a future release. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 METHODS |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 get_footer_as_string |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 get_header_as_string |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 get_item_as_string |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 new |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 parse_file |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
For these methods, consult L documentation. |
|
125
|
|
|
|
|
|
|
They are overridden because of the XML behaviour here. |
|
126
|
|
|
|
|
|
|
Interface remains the same. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |