| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::LBI; |
|
2
|
|
|
|
|
|
|
############################################################# |
|
3
|
|
|
|
|
|
|
# HTML::LBI |
|
4
|
|
|
|
|
|
|
# Whyte.Wolf DreamWeaver HTML Library Module |
|
5
|
|
|
|
|
|
|
# Version 2.00 |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Copyright (c) 2002 by S.D. Campbell |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Created 03 February 2002; Revised 12 February 2002 by SDC |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# Description: |
|
12
|
|
|
|
|
|
|
# A perl module for use with CGI scripts that opens a |
|
13
|
|
|
|
|
|
|
# Macromedia Dreamweaver library file (.lbi) and returns |
|
14
|
|
|
|
|
|
|
# the resulting HTML code snippet. |
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
############################################################# |
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
# Construction: |
|
19
|
|
|
|
|
|
|
# use HTML::LBI; |
|
20
|
|
|
|
|
|
|
# |
|
21
|
|
|
|
|
|
|
# $html = new HTML::LBI("file.lbi"); |
|
22
|
|
|
|
|
|
|
# |
|
23
|
|
|
|
|
|
|
# Use: |
|
24
|
|
|
|
|
|
|
# Create a new instance of HTML::LBI as above by passing |
|
25
|
|
|
|
|
|
|
# a pathname to the library file (absolute or relative) |
|
26
|
|
|
|
|
|
|
# to the constructor. The constructor will return |
|
27
|
|
|
|
|
|
|
# the HTML from the .lbi file, which can then be printed out. |
|
28
|
|
|
|
|
|
|
# |
|
29
|
|
|
|
|
|
|
# Errors: |
|
30
|
|
|
|
|
|
|
# Should the library file fail to open an error will be set |
|
31
|
|
|
|
|
|
|
# in $HTML::LBI::errmsg |
|
32
|
|
|
|
|
|
|
# |
|
33
|
|
|
|
|
|
|
############################################################# |
|
34
|
|
|
|
|
|
|
# |
|
35
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
|
36
|
|
|
|
|
|
|
# modify it under the terms of the GNU General Public License |
|
37
|
|
|
|
|
|
|
# as published by the Free Software Foundation; either version 2 |
|
38
|
|
|
|
|
|
|
# of the License, or (at your option) any later version. |
|
39
|
|
|
|
|
|
|
# |
|
40
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
41
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
42
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
43
|
|
|
|
|
|
|
# GNU General Public License for more details. |
|
44
|
|
|
|
|
|
|
# |
|
45
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
46
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
|
47
|
|
|
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
48
|
|
|
|
|
|
|
############################################################# |
|
49
|
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
25573
|
use Exporter; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
49
|
|
|
51
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
67
|
|
|
52
|
1
|
|
|
1
|
|
6
|
use File::Find; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
76
|
|
|
53
|
1
|
|
|
1
|
|
6
|
use File::Basename; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
160
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
56
|
|
|
|
|
|
|
@EXPORT = qw(); |
|
57
|
|
|
|
|
|
|
@EXPORT_OK = qw($errmsg); |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
60
|
1
|
|
|
1
|
|
6
|
use vars qw($errmsg $VERSION @ISA @EXPORT @EXPORT_OK $filepath $fname); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
815
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$VERSION = '2.00'; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$errmsg = ""; |
|
65
|
|
|
|
|
|
|
$filepath =''; |
|
66
|
|
|
|
|
|
|
$fname = ''; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
############################################################# |
|
69
|
|
|
|
|
|
|
# new |
|
70
|
|
|
|
|
|
|
# |
|
71
|
|
|
|
|
|
|
# The constructor for the class. Requires a HTML Library |
|
72
|
|
|
|
|
|
|
# filename. Returns a reference to the new object or undef |
|
73
|
|
|
|
|
|
|
# on error. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub new { |
|
76
|
3
|
|
|
3
|
0
|
1252
|
my $class = shift; |
|
77
|
3
|
|
|
|
|
10
|
my %params = @_; |
|
78
|
3
|
|
|
|
|
5
|
my @search = (); |
|
79
|
|
|
|
|
|
|
|
|
80
|
3
|
|
|
|
|
6
|
my $self = {}; |
|
81
|
|
|
|
|
|
|
|
|
82
|
3
|
100
|
|
|
|
9
|
if (!$params{filename}){ |
|
83
|
1
|
|
|
|
|
4
|
$params{filename} = $_[0]; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
3
|
|
|
|
|
6
|
$$self{filename} = $params{filename}; |
|
87
|
3
|
|
|
|
|
9
|
$$self{lbi} = _beginLbi($$self{filename}); |
|
88
|
|
|
|
|
|
|
|
|
89
|
3
|
100
|
|
|
|
10
|
if (exists($params{path})){ |
|
90
|
1
|
50
|
|
|
|
7
|
if (ref($params{path}) ne 'ARRAY') { |
|
91
|
1
|
|
|
|
|
4
|
$$self{path} = [ $params{path} ]; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
1
|
|
|
|
|
3
|
$$self{path} = $params{path}; |
|
94
|
|
|
|
|
|
|
} else { |
|
95
|
2
|
|
|
|
|
6
|
$$self{path} = './'; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
3
|
|
|
|
|
5
|
foreach my $path ($$self{path}){ |
|
99
|
3
|
|
|
|
|
8
|
push @search, $path; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
3
|
50
|
|
|
|
8
|
if ($ENV{'HTML_TEMPLATE_ROOT'}) { |
|
103
|
0
|
|
|
|
|
0
|
my $temproot = $ENV{'HTML_TEMPLATE_ROOT'}; |
|
104
|
0
|
|
|
|
|
0
|
push @search, $temproot; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
3
|
50
|
|
|
|
8
|
if ($ENV{'DOCUMENT_ROOT'}) { |
|
108
|
0
|
|
|
|
|
0
|
my $docroot = $ENV{'DOCUMENT_ROOT'}; |
|
109
|
0
|
|
|
|
|
0
|
push @search, $docroot; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
3
|
50
|
|
|
|
11
|
if (substr($$self{filename}, 0, 1) ne '/') { |
|
|
|
0
|
|
|
|
|
|
|
114
|
3
|
|
|
|
|
4
|
$fname = $$self{filename}; |
|
115
|
3
|
|
|
|
|
6
|
foreach my $dir (@search){ |
|
116
|
3
|
|
|
|
|
196
|
find(\&_wanted, $dir); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
3
|
100
|
|
|
|
9
|
if (!$filepath) { |
|
119
|
1
|
|
|
|
|
4
|
$filepath = $$self{filename}; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
} elsif (substr($$self{filename}, 0, 8) eq '/Library') { |
|
122
|
0
|
|
|
|
|
0
|
my ($name, $path, $suffix) = fileparse($$self{filename}, '\.lbi'); |
|
123
|
0
|
|
|
|
|
0
|
$fname = $name . $suffix; |
|
124
|
0
|
|
|
|
|
0
|
foreach my $dir (@search){ |
|
125
|
0
|
|
|
|
|
0
|
find(\&_wanted, $dir); |
|
126
|
|
|
|
|
|
|
} |
|
127
|
0
|
0
|
|
|
|
0
|
if (!$filepath) { |
|
128
|
0
|
|
|
|
|
0
|
$filepath = $$self{filename}; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} else { |
|
131
|
0
|
|
|
|
|
0
|
$filepath = $$self{filename}; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
3
|
50
|
|
|
|
121
|
unless(open(LBI_FILE, $filepath)){ |
|
135
|
0
|
|
|
|
|
0
|
$errmsg = "Library File $filepath not opened: $!\n"; |
|
136
|
0
|
|
|
|
|
0
|
return undef; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
3
|
|
|
|
|
46
|
while(){ |
|
140
|
18
|
|
|
|
|
55
|
$$self{lbi} .= $_; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
3
|
|
|
|
|
8
|
$$self{lbi} .= _endLbi(); |
|
144
|
|
|
|
|
|
|
|
|
145
|
3
|
|
|
|
|
10
|
bless $self, $class; |
|
146
|
3
|
|
|
|
|
25
|
return $$self{lbi}; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
############################################################# |
|
150
|
|
|
|
|
|
|
# _beginLbi |
|
151
|
|
|
|
|
|
|
# |
|
152
|
|
|
|
|
|
|
# Returns the begin library string and file name back into |
|
153
|
|
|
|
|
|
|
# the parsed HTML. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub _beginLbi { |
|
156
|
3
|
|
|
3
|
|
4
|
my $filename = shift; |
|
157
|
3
|
|
|
|
|
10
|
return "\n\n"; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
############################################################# |
|
162
|
|
|
|
|
|
|
# _endLbi |
|
163
|
|
|
|
|
|
|
# |
|
164
|
|
|
|
|
|
|
# Returns the end library string back into the parsed HTML. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub _endLbi { |
|
167
|
3
|
|
|
3
|
|
7
|
return "\n\n"; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
############################################################# |
|
171
|
|
|
|
|
|
|
# _wanted |
|
172
|
|
|
|
|
|
|
# |
|
173
|
|
|
|
|
|
|
# Returns the path to a file (if it exists). |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub _wanted { |
|
176
|
|
|
|
|
|
|
|
|
177
|
114
|
100
|
|
114
|
|
4220
|
/$fname$/ or return; |
|
178
|
1
|
|
|
|
|
26
|
$filepath = $File::Find::name; |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
1; |
|
184
|
|
|
|
|
|
|
__END__ |