1 | ###########################################################################
|
---|
2 | #
|
---|
3 | # CICPlug.pm
|
---|
4 | # A component of the Greenstone digital library software
|
---|
5 | # from the New Zealand Digital Library Project at the
|
---|
6 | # University of Waikato, New Zealand.
|
---|
7 | #
|
---|
8 | # Copyright (C) 2005 New Zealand Digital Library Project
|
---|
9 | #
|
---|
10 | # This program is free software; you can redistribute it and/or modify
|
---|
11 | # it under the terms of the GNU General Public License as published by
|
---|
12 | # the Free Software Foundation; either version 2 of the License, or
|
---|
13 | # (at your option) any later version.
|
---|
14 | #
|
---|
15 | # This program is distributed in the hope that it will be useful,
|
---|
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | # GNU General Public License for more details.
|
---|
19 | #
|
---|
20 | # You should have received a copy of the GNU General Public License
|
---|
21 | # along with this program; if not, write to the Free Software
|
---|
22 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | #
|
---|
24 | ###########################################################################
|
---|
25 |
|
---|
26 | package CICPlug;
|
---|
27 |
|
---|
28 |
|
---|
29 | use BasPlug;
|
---|
30 | use DBI;
|
---|
31 | use strict;
|
---|
32 |
|
---|
33 |
|
---|
34 | sub BEGIN {
|
---|
35 | @CICPlug::ISA = ('BasPlug');
|
---|
36 | }
|
---|
37 |
|
---|
38 |
|
---|
39 | my $arguments =
|
---|
40 | [
|
---|
41 | { 'name' => "images_directory",
|
---|
42 | 'type' => "string",
|
---|
43 | 'deft' => "",
|
---|
44 | 'reqd' => "yes" },
|
---|
45 | { 'name' => "cache_directory",
|
---|
46 | 'type' => "string",
|
---|
47 | 'deft' => &util::filename_cat($ENV{'GSDLHOME'}, "tmp"),
|
---|
48 | 'reqd' => "no" },
|
---|
49 | { 'name' => "large_image_options",
|
---|
50 | 'type' => "string",
|
---|
51 | 'deft' => "",
|
---|
52 | 'reqd' => "no" },
|
---|
53 | { 'name' => "large_image_type",
|
---|
54 | 'type' => "string",
|
---|
55 | 'deft' => "jpg",
|
---|
56 | 'reqd' => "no" },
|
---|
57 | { 'name' => "large_image_width",
|
---|
58 | 'type' => "string",
|
---|
59 | 'deft' => "1250",
|
---|
60 | 'reqd' => "no" },
|
---|
61 | { 'name' => "medium_image_options",
|
---|
62 | 'type' => "string",
|
---|
63 | 'deft' => "",
|
---|
64 | 'reqd' => "no" },
|
---|
65 | { 'name' => "medium_image_type",
|
---|
66 | 'type' => "string",
|
---|
67 | 'deft' => "jpg",
|
---|
68 | 'reqd' => "no" },
|
---|
69 | { 'name' => "medium_image_width",
|
---|
70 | 'type' => "string",
|
---|
71 | 'deft' => "375",
|
---|
72 | 'reqd' => "no" },
|
---|
73 | { 'name' => "small_image_options",
|
---|
74 | 'type' => "string",
|
---|
75 | 'deft' => "",
|
---|
76 | 'reqd' => "no" },
|
---|
77 | { 'name' => "small_image_type",
|
---|
78 | 'type' => "string",
|
---|
79 | 'deft' => "jpg",
|
---|
80 | 'reqd' => "no" },
|
---|
81 | { 'name' => "small_image_width",
|
---|
82 | 'type' => "string",
|
---|
83 | 'deft' => "125",
|
---|
84 | 'reqd' => "no" }
|
---|
85 | ];
|
---|
86 |
|
---|
87 | my $options = { 'name' => "CICPlug",
|
---|
88 | 'desc' => "{CICPlug.desc}",
|
---|
89 | 'abstract' => "no",
|
---|
90 | 'inherits' => "yes" };
|
---|
91 |
|
---|
92 |
|
---|
93 | sub get_default_process_exp
|
---|
94 | {
|
---|
95 | return q^(?i)\.mdb$^;
|
---|
96 | }
|
---|
97 |
|
---|
98 |
|
---|
99 | sub new
|
---|
100 | {
|
---|
101 | my ($class) = shift (@_);
|
---|
102 | my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
|
---|
103 | push(@$pluginlist, $class);
|
---|
104 |
|
---|
105 | if (defined $arguments) { push(@{$hashArgOptLists->{"ArgList"}}, @{$arguments}); }
|
---|
106 | if (defined $options) { push(@{$hashArgOptLists->{"OptList"}}, $options); }
|
---|
107 |
|
---|
108 | my $self = (defined $hashArgOptLists) ? new BasPlug($pluginlist,$inputargs,$hashArgOptLists) : new BasPlug($pluginlist,$inputargs);
|
---|
109 |
|
---|
110 | return bless $self, $class;
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | my $state_abbr_to_name_mapping = {
|
---|
115 | "AL" => "Alabama",
|
---|
116 | "AK" => "Alaska",
|
---|
117 | "AZ" => "Arizona",
|
---|
118 | "AR" => "Arkansas",
|
---|
119 | "CA" => "California",
|
---|
120 | "CO" => "Colorado",
|
---|
121 | "CT" => "Connecticut",
|
---|
122 | "DE" => "Delaware",
|
---|
123 | "FL" => "Florida",
|
---|
124 | "GA" => "Georgia",
|
---|
125 | "HI" => "Hawaii",
|
---|
126 | "ID" => "Idaho",
|
---|
127 | "IL" => "Illinois",
|
---|
128 | "IN" => "Indiana",
|
---|
129 | "IA" => "Iowa",
|
---|
130 | "KS" => "Kansas",
|
---|
131 | "KY" => "Kentucky",
|
---|
132 | "LA" => "Louisiana",
|
---|
133 | "ME" => "Maine",
|
---|
134 | "MD" => "Maryland",
|
---|
135 | "MA" => "Massachusetts",
|
---|
136 | "MI" => "Michigan",
|
---|
137 | "MN" => "Minnesota",
|
---|
138 | "MS" => "Mississippi",
|
---|
139 | "MO" => "Missouri",
|
---|
140 | "MT" => "Montana",
|
---|
141 | "NE" => "Nebraska",
|
---|
142 | "NV" => "Nevada",
|
---|
143 | "NH" => "New Hampshire",
|
---|
144 | "NJ" => "New Jersey",
|
---|
145 | "NM" => "New Mexico",
|
---|
146 | "NY" => "New York",
|
---|
147 | "NC" => "North Carolina",
|
---|
148 | "ND" => "North Dakota",
|
---|
149 | "OH" => "Ohio",
|
---|
150 | "OK" => "Oklahoma",
|
---|
151 | "OR" => "Oregon",
|
---|
152 | "PA" => "Pennsylvania",
|
---|
153 | "RI" => "Rhode Island",
|
---|
154 | "SC" => "South Carolina",
|
---|
155 | "SD" => "South Dakota",
|
---|
156 | "TN" => "Tennessee",
|
---|
157 | "TX" => "Texas",
|
---|
158 | "UT" => "Utah",
|
---|
159 | "VT" => "Vermont",
|
---|
160 | "VA" => "Virginia",
|
---|
161 | "WA" => "Washington",
|
---|
162 | "WV" => "West Virginia",
|
---|
163 | "WI" => "Wisconsin",
|
---|
164 | "WY" => "Wyoming"
|
---|
165 | };
|
---|
166 |
|
---|
167 |
|
---|
168 | my $place_type_id_to_name_mapping = {
|
---|
169 | "1" => "Individual building",
|
---|
170 | "2" => "Landscape site",
|
---|
171 | "3" => "Campus arrangement",
|
---|
172 | "4" => "Building group",
|
---|
173 | };
|
---|
174 |
|
---|
175 |
|
---|
176 | sub read
|
---|
177 | {
|
---|
178 | my $self = shift (@_);
|
---|
179 | my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_;
|
---|
180 |
|
---|
181 | $self->{'filename'} = &util::filename_cat($base_dir, $file);
|
---|
182 | if ($self->{'filename'} !~ /$self->{'process_exp'}/ || !-f $self->{'filename'}) {
|
---|
183 | return undef;
|
---|
184 | }
|
---|
185 | $self->{'processor'} = $processor;
|
---|
186 | $self->{'gli'} = $gli;
|
---|
187 |
|
---|
188 | # Open connection to Access database
|
---|
189 | my $dbh = DBI->connect('dbi:ODBC:CIC-HCAP');
|
---|
190 |
|
---|
191 | $self->process_institutions($dbh);
|
---|
192 | $self->process_places($dbh);
|
---|
193 | $self->process_designers($dbh);
|
---|
194 |
|
---|
195 | return 1;
|
---|
196 | }
|
---|
197 |
|
---|
198 |
|
---|
199 | sub process_institutions
|
---|
200 | {
|
---|
201 | my $self = shift(@_);
|
---|
202 | my $dbh = shift(@_);
|
---|
203 |
|
---|
204 | # Prepare SQL statement for getting everything from the Institution table
|
---|
205 | my $institution_sql_statement = "SELECT * FROM tblInstitution"; # WHERE Institution_ID<200";
|
---|
206 | my $institution_sql_handle = $dbh->prepare($institution_sql_statement);
|
---|
207 | $institution_sql_handle->{LongReadLen} = 65536;
|
---|
208 | $institution_sql_handle->execute() or die "Could not execute SQL statement.";
|
---|
209 |
|
---|
210 | # Prepare SQL statement for getting the Institution places
|
---|
211 | my $institution_places_sql_statement = "SELECT Entry_ID,Current_name FROM tblPlace WHERE PlaceType>0 AND Institution_ID=?";
|
---|
212 | my $institution_places_sql_handle = $dbh->prepare($institution_places_sql_statement);
|
---|
213 | $institution_places_sql_handle->{LongReadLen} = 65536;
|
---|
214 |
|
---|
215 | # Prepare SQL statement for getting the Institution best place image location
|
---|
216 | my $institution_best_place_image_location_sql_statement = "SELECT Location FROM tblImages WHERE FileType=1 AND FileName=?";
|
---|
217 | my $institution_best_place_image_location_sql_handle = $dbh->prepare($institution_best_place_image_location_sql_statement);
|
---|
218 | $institution_best_place_image_location_sql_handle->{LongReadLen} = 65536;
|
---|
219 |
|
---|
220 | # Prepare SQL statement for getting the Institution places images
|
---|
221 | my $institution_places_images_sql_statement = "SELECT FileName FROM tblImages,tblPlace WHERE tblImages.FileType=1 AND tblImages.Entry_ID=tblPlace.Entry_ID AND tblPlace.Institution_ID=?";
|
---|
222 | my $institution_places_images_sql_handle = $dbh->prepare($institution_places_images_sql_statement);
|
---|
223 | $institution_places_images_sql_handle->{LongReadLen} = 65536;
|
---|
224 |
|
---|
225 | # Prepare SQL statement for getting the Institution campus plans
|
---|
226 | my $institution_campus_plans_sql_statement = "SELECT * FROM tblCampusMaps WHERE Electronic=1 AND Institution_ID=?";
|
---|
227 | my $institution_campus_plans_sql_handle = $dbh->prepare($institution_campus_plans_sql_statement);
|
---|
228 | $institution_campus_plans_sql_handle->{LongReadLen} = 65536;
|
---|
229 |
|
---|
230 | # Create a document object for each institution
|
---|
231 | my %institution_state_to_name_mapping;
|
---|
232 | my %institution_name_to_id_mapping;
|
---|
233 | while (my $row_hashref = $institution_sql_handle->fetchrow_hashref) {
|
---|
234 | # Skip any institutions that didn't respond
|
---|
235 | next if !defined($row_hashref->{"City"});
|
---|
236 |
|
---|
237 | my $institution_id = $row_hashref->{"Institution_ID"};
|
---|
238 | # print STDERR " Institution $institution_id\n";
|
---|
239 | my $institution_doc_obj = new doc($self->{'filename'} . "-", "indexed_doc");
|
---|
240 | $institution_doc_obj->set_OID("i$institution_id");
|
---|
241 | &new_metadata_entry($institution_doc_obj, "DocumentType", "Institution");
|
---|
242 |
|
---|
243 | # For some reason the hyphen seems to be lost from the Zip field, so add it back in
|
---|
244 | my $institution_zip = $row_hashref->{"Zip"};
|
---|
245 | if ($institution_zip =~ /^(\d\d\d\d\d)(\d\d\d\d)$/) {
|
---|
246 | $row_hashref->{"Zip"} = $1 . "-" . $2;
|
---|
247 | }
|
---|
248 |
|
---|
249 | # Map state to full name
|
---|
250 | $row_hashref->{"State"} = $state_abbr_to_name_mapping->{$row_hashref->{"State"}};
|
---|
251 |
|
---|
252 | # Get the places in this institution
|
---|
253 | my $institution_random_place_id;
|
---|
254 | my $institution_places_list_html = "";
|
---|
255 | $institution_places_sql_handle->execute($institution_id) or die "Could not execute SQL statement.";
|
---|
256 | while (my $institution_places_match_hashref = $institution_places_sql_handle->fetchrow_hashref) {
|
---|
257 | my $institution_place_id = $institution_places_match_hashref->{"Entry_ID"};
|
---|
258 | my $institution_place_name = $institution_places_match_hashref->{"Current_name"};
|
---|
259 | $institution_places_list_html .= "<span class=\"cictext\"><a href=\"_gwcgi_?a=d&d=p$institution_place_id\">$institution_place_name</a></span><br />\n";
|
---|
260 | }
|
---|
261 | &new_metadata_entry($institution_doc_obj, "InstitutionPlacesListHTML", $institution_places_list_html);
|
---|
262 |
|
---|
263 | # Get the best place image for this institution
|
---|
264 | my $institution_best_place_image_name = $row_hashref->{"Best_image"};
|
---|
265 | if (!defined($institution_best_place_image_name) || $institution_best_place_image_name eq "") {
|
---|
266 | # Some institutions have no electronic images, and thus have no best image
|
---|
267 | $institution_places_images_sql_handle->execute($institution_id) or die "Could not execute SQL statement.";
|
---|
268 | if (defined($institution_places_images_sql_handle->fetchrow_hashref())) {
|
---|
269 | print STDERR "<ProcessingError n='Institution $institution_id' p='CICPlug' r='No best image'>\n" if ($self->{'gli'});
|
---|
270 | print STDERR "Error: Institution $institution_id -- No best image.\n";
|
---|
271 | $self->{'num_not_processed'}++;
|
---|
272 | next;
|
---|
273 | }
|
---|
274 | &new_metadata_entry($institution_doc_obj, "InstitutionBestPlaceImageHTML", "");
|
---|
275 | }
|
---|
276 | else {
|
---|
277 | # Get the file location of the best place image for this institution
|
---|
278 | $institution_best_place_image_location_sql_handle->execute($institution_best_place_image_name) or die "Could not execute SQL statement.";
|
---|
279 | my $institution_best_place_image_location = $institution_best_place_image_location_sql_handle->fetchrow();
|
---|
280 | if (!defined($institution_best_place_image_location) || $institution_best_place_image_location eq "") {
|
---|
281 | print STDERR "<ProcessingError n='Institution $institution_id' p='CICPlug' r='Could not match best image $institution_best_place_image_name to a file'>\n" if ($self->{'gli'});
|
---|
282 | print STDERR "Error: Institution $institution_id -- Could not match best image $institution_best_place_image_name to a file.\n";
|
---|
283 | $self->{'num_not_processed'}++;
|
---|
284 | next;
|
---|
285 | }
|
---|
286 |
|
---|
287 | $self->new_place_image($institution_doc_obj, $institution_best_place_image_location, "medium");
|
---|
288 | $self->new_place_image($institution_doc_obj, $institution_best_place_image_location, "large");
|
---|
289 |
|
---|
290 | my $institution_best_place_image_large_file_name = $institution_best_place_image_name . "-large.jpg";
|
---|
291 | $institution_best_place_image_large_file_name =~ s/ /%20/g;
|
---|
292 | my $institution_best_place_image_large_file_link = "_httpcollection_/index/assoc/[assocfilepath]/$institution_best_place_image_large_file_name";
|
---|
293 | my $institution_best_place_image_medium_file_name = $institution_best_place_image_name . "-medium.jpg";
|
---|
294 | $institution_best_place_image_medium_file_name =~ s/ /%20/g;
|
---|
295 | my $institution_best_place_image_medium_file_link = "_httpcollection_/index/assoc/[assocfilepath]/$institution_best_place_image_medium_file_name";
|
---|
296 | &new_metadata_entry($institution_doc_obj, "InstitutionBestPlaceImageHTML", "<a href=\"$institution_best_place_image_large_file_link\"><img src=\"$institution_best_place_image_medium_file_link\"/><br /><span class=\"cictext\">$institution_best_place_image_name</span></a>");
|
---|
297 | }
|
---|
298 |
|
---|
299 | # Get institution campus plans
|
---|
300 | my $institution_campus_plans_list_html = "";
|
---|
301 | $institution_campus_plans_sql_handle->execute($institution_id) or die "Could not execute SQL statement.";
|
---|
302 | while (my $institution_campus_plans_match_hashref = $institution_campus_plans_sql_handle->fetchrow_hashref) {
|
---|
303 | my $institution_campus_plan_name = $institution_campus_plans_match_hashref->{"NameAndFormat"};
|
---|
304 | my $institution_campus_plan_image_location = $institution_campus_plans_match_hashref->{"Location_electronic"};
|
---|
305 |
|
---|
306 | # Deal with PDF files separately: don't convert, just associate
|
---|
307 | if ($institution_campus_plan_image_location =~ /\.pdf$/i) {
|
---|
308 | # Convert the server location of the file into the local location of the file
|
---|
309 | my $institution_campus_plan_pdf_file_path = $institution_campus_plan_image_location;
|
---|
310 | $institution_campus_plan_pdf_file_path =~ s/^[A-Z]:/$self->{'images_directory'}/;
|
---|
311 |
|
---|
312 | if (-f $institution_campus_plan_pdf_file_path) {
|
---|
313 | my $institution_campus_plan_pdf_file_name = $institution_campus_plan_name . ".pdf";
|
---|
314 | $institution_campus_plan_pdf_file_name =~ s/ /%20/g;
|
---|
315 | my $institution_campus_plan_pdf_file_link = "_httpcollection_/index/assoc/[assocfilepath]/$institution_campus_plan_pdf_file_name";
|
---|
316 | $institution_campus_plans_list_html .= "<a href=\"$institution_campus_plan_pdf_file_link\"><span class=\"cictext\">$institution_campus_plan_name (PDF)</span></a><br />";
|
---|
317 |
|
---|
318 | $institution_doc_obj->associate_file($institution_campus_plan_pdf_file_path, $institution_campus_plan_name . ".pdf", undef, $institution_doc_obj->get_top_section());
|
---|
319 | }
|
---|
320 | else {
|
---|
321 | print STDERR "<ProcessingError n='$institution_campus_plan_pdf_file_path' p='CICPlug' r='Does not exist'>\n" if ($self->{'gli'});
|
---|
322 | print STDERR "Error: File $institution_campus_plan_pdf_file_path does not exist.\n";
|
---|
323 | }
|
---|
324 | }
|
---|
325 | else {
|
---|
326 | $self->new_place_image($institution_doc_obj, $institution_campus_plan_image_location, "large");
|
---|
327 |
|
---|
328 | my $institution_campus_plan_image_large_file_name = $institution_campus_plan_name . "-large.jpg";
|
---|
329 | $institution_campus_plan_image_large_file_name =~ s/ /%20/g;
|
---|
330 | my $institution_campus_plan_image_large_file_link = "_httpcollection_/index/assoc/[assocfilepath]/$institution_campus_plan_image_large_file_name";
|
---|
331 | $institution_campus_plans_list_html .= "<a href=\"$institution_campus_plan_image_large_file_link\"><span class=\"cictext\">$institution_campus_plan_name</span></a><br />";
|
---|
332 | }
|
---|
333 | }
|
---|
334 | &new_metadata_entry($institution_doc_obj, "InstitutionCampusPlansListHTML", $institution_campus_plans_list_html);
|
---|
335 |
|
---|
336 | # Add each field from the table as metadata
|
---|
337 | foreach my $key (keys(%$row_hashref)) {
|
---|
338 | my $value = $row_hashref->{$key};
|
---|
339 | if (defined($value)) {
|
---|
340 | &new_metadata_entry($institution_doc_obj, $key, $value);
|
---|
341 | }
|
---|
342 | }
|
---|
343 |
|
---|
344 | $institution_doc_obj->add_utf8_text($institution_doc_obj->get_top_section(), "Some dummy text.");
|
---|
345 | $self->{'processor'}->process($institution_doc_obj);
|
---|
346 | $self->{'num_processed'}++;
|
---|
347 |
|
---|
348 | # Build mappings for creating the static macrofiles
|
---|
349 | my $institution_name = $row_hashref->{"Institution_Name"};
|
---|
350 | $institution_name_to_id_mapping{$institution_name} = $institution_id;
|
---|
351 | my $institution_state = $row_hashref->{"State"};
|
---|
352 | push(@{$institution_state_to_name_mapping{$institution_state}}, $institution_name);
|
---|
353 | }
|
---|
354 |
|
---|
355 | # Write the institutions.dm macrofile
|
---|
356 | &write_static_browser_macrofile("institutions", \%institution_name_to_id_mapping, "i");
|
---|
357 |
|
---|
358 | # Write the states.dm macrofile
|
---|
359 | &write_state_browser_macrofile("states", \%institution_state_to_name_mapping, \%institution_name_to_id_mapping);
|
---|
360 | }
|
---|
361 |
|
---|
362 |
|
---|
363 | sub process_places
|
---|
364 | {
|
---|
365 | my $self = shift(@_);
|
---|
366 | my $dbh = shift(@_);
|
---|
367 |
|
---|
368 | # Prepare SQL statement for getting everything from the Place table
|
---|
369 | my $place_sql_statement = "SELECT * FROM tblPlace";
|
---|
370 | my $place_sql_handle = $dbh->prepare($place_sql_statement);
|
---|
371 | $place_sql_handle->{LongReadLen} = 65536;
|
---|
372 | $place_sql_handle->execute() or die "Could not execute SQL statement.";
|
---|
373 |
|
---|
374 | # Prepare SQL statement for getting the Place institution
|
---|
375 | my $place_institution_sql_statement = "SELECT Institution_Name FROM tblInstitution,tblPlace WHERE tblInstitution.Institution_ID=tblPlace.Institution_ID and tblPlace.Entry_ID=?";
|
---|
376 | my $place_institution_sql_handle = $dbh->prepare($place_institution_sql_statement);
|
---|
377 |
|
---|
378 | # Prepare SQL statement for getting the Place "date of construction"
|
---|
379 | my $place_construction_date_sql_statement = "SELECT Date FROM tblConstruction_and_Dates WHERE Entry_ID=?";
|
---|
380 | my $place_construction_date_sql_handle = $dbh->prepare($place_construction_date_sql_statement);
|
---|
381 |
|
---|
382 | # Prepare SQL statement for getting the Place images
|
---|
383 | my $place_images_sql_statement = "SELECT FileName,Location FROM tblImages WHERE FileType=1 AND Entry_ID=?";
|
---|
384 | my $place_images_sql_handle = $dbh->prepare($place_images_sql_statement);
|
---|
385 | $place_images_sql_handle->{LongReadLen} = 65536;
|
---|
386 |
|
---|
387 | # Prepare SQL statement for getting the Place materials
|
---|
388 | my $place_materials_sql_statement = "SELECT * FROM tblDescription_building WHERE Entry_ID=?";
|
---|
389 | my $place_materials_sql_handle = $dbh->prepare($place_materials_sql_statement);
|
---|
390 | $place_materials_sql_handle->{LongReadLen} = 65536;
|
---|
391 |
|
---|
392 | # Prepare SQL statement for getting the Place building styles
|
---|
393 | my $place_styles_sql_statement = "SELECT Architectural_Classification FROM tblArchTypes,jnxtblArchPlace WHERE tblArchTypes.ArchType_ID=jnxtblArchPlace.ArchType_ID AND Entry_ID=?";
|
---|
394 | my $place_styles_sql_handle = $dbh->prepare($place_styles_sql_statement);
|
---|
395 | $place_styles_sql_handle->{LongReadLen} = 65536;
|
---|
396 |
|
---|
397 | # Prepare SQL statement for getting the Place functions
|
---|
398 | my $place_functions_sql_statement = "SELECT Function,Year,Prefix FROM tblFunction_and_dates WHERE Entry_ID=?";
|
---|
399 | my $place_functions_sql_handle = $dbh->prepare($place_functions_sql_statement);
|
---|
400 | $place_functions_sql_handle->{LongReadLen} = 65536;
|
---|
401 |
|
---|
402 | # Prepare SQL statement for getting the Place significance
|
---|
403 | my $place_significance_sql_statement = "SELECT SigType FROM tblSigTypes,SigPlace WHERE tblSigTypes.SigTypes_ID=SigPlace.SigType_ID+1 AND SigPlace.Entry_ID=?";
|
---|
404 | my $place_significance_sql_handle = $dbh->prepare($place_significance_sql_statement);
|
---|
405 | $place_significance_sql_handle->{LongReadLen} = 65536;
|
---|
406 |
|
---|
407 | # Prepare SQL statement for getting the Place references
|
---|
408 | my $place_references_sql_statement = "SELECT Bibliography FROM tblReferences WHERE Entry_ID=?";
|
---|
409 | my $place_references_sql_handle = $dbh->prepare($place_references_sql_statement);
|
---|
410 | $place_references_sql_handle->{LongReadLen} = 65536;
|
---|
411 |
|
---|
412 | # Prepare SQL statement for getting the Place narrative
|
---|
413 | my $place_narrative_sql_statement = "SELECT Narrative FROM tblSignificance_Narrative WHERE Entry_ID=?";
|
---|
414 | my $place_narrative_sql_handle = $dbh->prepare($place_narrative_sql_statement);
|
---|
415 | $place_narrative_sql_handle->{LongReadLen} = 65536;
|
---|
416 |
|
---|
417 | # Prepare SQL statement for getting the Place state
|
---|
418 | my $place_state_sql_statement = "SELECT State FROM tblInstitution,tblPlace WHERE tblInstitution.Institution_ID=tblPlace.Institution_ID AND Entry_ID=?";
|
---|
419 | my $place_state_sql_handle = $dbh->prepare($place_state_sql_statement);
|
---|
420 | $place_state_sql_handle->{LongReadLen} = 65536;
|
---|
421 |
|
---|
422 | # Create a document object for each place
|
---|
423 | my %place_type_to_names_mapping;
|
---|
424 | my %place_style_to_names_mapping;
|
---|
425 | my %place_date_to_names_mapping;
|
---|
426 | my %place_function_to_names_mapping;
|
---|
427 | my %place_name_to_id_mapping;
|
---|
428 | my %place_id_to_institution_name_mapping;
|
---|
429 | while (my $row_hashref = $place_sql_handle->fetchrow_hashref) {
|
---|
430 | my $place_id = $row_hashref->{"Entry_ID"};
|
---|
431 | # print STDERR " Place $place_id\n";
|
---|
432 | my $place_doc_obj = new doc($self->{'filename'} . "-", "indexed_doc");
|
---|
433 | $place_doc_obj->set_OID("p$place_id");
|
---|
434 | &new_metadata_entry($place_doc_obj, "DocumentType", "Place");
|
---|
435 |
|
---|
436 | # Convert the place type ID into a name
|
---|
437 | $row_hashref->{"PlaceType"} = $place_type_id_to_name_mapping->{$row_hashref->{"PlaceType"}};
|
---|
438 |
|
---|
439 | # Add each field from the table as metadata
|
---|
440 | foreach my $key (keys(%$row_hashref)) {
|
---|
441 | my $value = $row_hashref->{$key};
|
---|
442 | if (defined($value)) {
|
---|
443 | &new_metadata_entry($place_doc_obj, $key, $value);
|
---|
444 | }
|
---|
445 | }
|
---|
446 |
|
---|
447 | # Get place name
|
---|
448 | my $place_name = $row_hashref->{"Current_name"};
|
---|
449 | if (!defined($place_name)) {
|
---|
450 | print STDERR "<ProcessingError n='Place $place_id' p='CICPlug' r='Missing place name'>\n" if ($self->{'gli'});
|
---|
451 | print STDERR "Error: Place $place_id -- Missing place name.\n";
|
---|
452 | $self->{'num_not_processed'}++;
|
---|
453 | next;
|
---|
454 | }
|
---|
455 |
|
---|
456 | # Get place type
|
---|
457 | my $place_type = $row_hashref->{"PlaceType"};
|
---|
458 | if (!defined($place_type)) {
|
---|
459 | print STDERR "<ProcessingError n='Place $place_id' p='CICPlug' r='Missing place type'>\n" if ($self->{'gli'});
|
---|
460 | print STDERR "Error: Place $place_id -- Missing place type.\n";
|
---|
461 | $self->{'num_not_processed'}++;
|
---|
462 | next;
|
---|
463 | }
|
---|
464 |
|
---|
465 | # Get place date of construction, except for landscape sites which have no date
|
---|
466 | $place_construction_date_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
|
---|
467 | my $place_construction_date_value = $place_construction_date_sql_handle->fetchrow();
|
---|
468 | if (!defined($place_construction_date_value) && $place_type eq "Landscape site") {
|
---|
469 | # Landscape sites may not have a construction date
|
---|
470 | $place_construction_date_value = "";
|
---|
471 | }
|
---|
472 | if (!defined($place_construction_date_value)) {
|
---|
473 | print STDERR "<ProcessingError n='Place $place_id' p='CICPlug' r='Missing construction date'>\n" if ($self->{'gli'});
|
---|
474 | print STDERR "Error: Place $place_id -- Missing construction date.\n";
|
---|
475 | $self->{'num_not_processed'}++;
|
---|
476 | next;
|
---|
477 | }
|
---|
478 | &new_metadata_entry($place_doc_obj, "Construction_date", $place_construction_date_value);
|
---|
479 |
|
---|
480 | # Create place styles mapping
|
---|
481 | $place_styles_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
|
---|
482 | while (my $place_styles_match_hashref = $place_styles_sql_handle->fetchrow_hashref()) {
|
---|
483 | my $place_style = $place_styles_match_hashref->{"Architectural_Classification"};
|
---|
484 | push(@{$place_style_to_names_mapping{$place_style}}, $place_name);
|
---|
485 | &new_metadata_entry($place_doc_obj, "Style", $place_style);
|
---|
486 | }
|
---|
487 |
|
---|
488 | # Get place institution
|
---|
489 | $place_institution_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
|
---|
490 | my $place_institution = $place_institution_sql_handle->fetchrow();
|
---|
491 | &new_metadata_entry($place_doc_obj, "Institution_name", $place_institution);
|
---|
492 | $place_id_to_institution_name_mapping{$place_id} = ", " . $place_institution;
|
---|
493 |
|
---|
494 | # Get place state (for searching)
|
---|
495 | $place_state_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
|
---|
496 | my $place_state_abbr = $place_state_sql_handle->fetchrow();
|
---|
497 | &new_metadata_entry($place_doc_obj, "State", $place_state_abbr . " " . $state_abbr_to_name_mapping->{$place_state_abbr});
|
---|
498 |
|
---|
499 | # Create place dates mapping
|
---|
500 | my $place_time_period = $place_construction_date_value;
|
---|
501 | if ($place_construction_date_value =~ /^(\d\d\d\d).*$/) {
|
---|
502 | $place_construction_date_value =~ s/^(\d\d\d\d).*$/$1/;
|
---|
503 | if ($place_construction_date_value < 1800) { $place_time_period = "pre-1800"; }
|
---|
504 | elsif ($place_construction_date_value < 1850) { $place_time_period = "1800-1850"; }
|
---|
505 | elsif ($place_construction_date_value < 1900) { $place_time_period = "1850-1900"; }
|
---|
506 | elsif ($place_construction_date_value < 1945) { $place_time_period = "1900-1945"; }
|
---|
507 | elsif ($place_construction_date_value < 1995) { $place_time_period = "1945-1995"; }
|
---|
508 | else { $place_time_period = "post-1995"; }
|
---|
509 | push(@{$place_date_to_names_mapping{$place_time_period}}, $place_name);
|
---|
510 | }
|
---|
511 | &new_metadata_entry($place_doc_obj, "Time_period", $place_time_period);
|
---|
512 |
|
---|
513 | # Get place materials (individual buildings only)
|
---|
514 | if ($row_hashref->{"PlaceType"} eq "Individual building") {
|
---|
515 | $place_materials_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
|
---|
516 | my $place_materials_match_hashref = $place_materials_sql_handle->fetchrow_hashref();
|
---|
517 | &new_metadata_entry($place_doc_obj, "MaterialFoundation", $place_materials_match_hashref->{"foundation"} || "");
|
---|
518 | &new_metadata_entry($place_doc_obj, "MaterialRoof", $place_materials_match_hashref->{"roof"} || "");
|
---|
519 | &new_metadata_entry($place_doc_obj, "MaterialWalls", $place_materials_match_hashref->{"walls"} || "");
|
---|
520 | }
|
---|
521 |
|
---|
522 | # Get place functions
|
---|
523 | my $place_functions = "";
|
---|
524 | my $place_functions_table_html = "";
|
---|
525 | $place_functions_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
|
---|
526 | while (my $place_functions_match_hashref = $place_functions_sql_handle->fetchrow_hashref()) {
|
---|
527 | my $place_function = $place_functions_match_hashref->{"Function"};
|
---|
528 | if (!defined($place_function)) {
|
---|
529 | print STDERR "<ProcessingError n='Place $place_id' p='CICPlug' r='Missing function'>\n" if ($self->{'gli'});
|
---|
530 | print STDERR "Error: Place $place_id -- Missing function.\n";
|
---|
531 | next;
|
---|
532 | }
|
---|
533 | my $place_year = $place_functions_match_hashref->{"Year"};
|
---|
534 | if (!defined($place_year)) {
|
---|
535 | print STDERR "<ProcessingError n='Place $place_id' p='CICPlug' r='Missing function year'>\n" if ($self->{'gli'});
|
---|
536 | print STDERR "Error: Place $place_id -- Missing function year.\n";
|
---|
537 | next;
|
---|
538 | }
|
---|
539 | my $place_year_prefix = $place_functions_match_hashref->{"Prefix"} || "";
|
---|
540 | $place_functions .= "$place_function ";
|
---|
541 | $place_functions_table_html .= "<tr><td valign=\"top\"><nobr>$place_year_prefix $place_year</nobr> </td><td valign=\"top\">$place_function</td></tr>";
|
---|
542 |
|
---|
543 | # Create place functions mapping
|
---|
544 | $place_function =~ s/\(.*?\)//g;
|
---|
545 | $place_function =~ s/^\s*//;
|
---|
546 | $place_function =~ s/\s*$//;
|
---|
547 | next if ($place_function eq "");
|
---|
548 | push(@{$place_function_to_names_mapping{$place_function}}, $place_name);
|
---|
549 | }
|
---|
550 | &new_metadata_entry($place_doc_obj, "Functions", $place_functions);
|
---|
551 | &new_metadata_entry($place_doc_obj, "PlaceFunctionsTableHTML", "<table cellpadding=\"0\" cellspacing=\"0\">" . $place_functions_table_html . "</table>");
|
---|
552 |
|
---|
553 | # Get place significance
|
---|
554 | $place_significance_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
|
---|
555 | while (my $place_significance_match_hashref = $place_significance_sql_handle->fetchrow_hashref()) {
|
---|
556 | my $place_significance = $place_significance_match_hashref->{"SigType"};
|
---|
557 | &new_metadata_entry($place_doc_obj, "Significance", lc($place_significance));
|
---|
558 | }
|
---|
559 |
|
---|
560 | # Get place references
|
---|
561 | $place_references_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
|
---|
562 | my $place_references = $place_references_sql_handle->fetchrow();
|
---|
563 | if (defined($place_references)) {
|
---|
564 | &new_metadata_entry($place_doc_obj, "References", &rtf_to_html($place_references));
|
---|
565 | }
|
---|
566 |
|
---|
567 | # Get place narrative
|
---|
568 | $place_narrative_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
|
---|
569 | my $place_narrative = $place_narrative_sql_handle->fetchrow();
|
---|
570 | if (defined($place_narrative)) {
|
---|
571 | $place_narrative = &rtf_to_html($place_narrative);
|
---|
572 | $place_narrative =~ s/<br \/>(\s|\n)*$//; # Remove any trailing <br /> tags
|
---|
573 | &new_metadata_entry($place_doc_obj, "Narrative", $place_narrative);
|
---|
574 | }
|
---|
575 |
|
---|
576 | # Get place images
|
---|
577 | my $place_images_html = "";
|
---|
578 | $place_images_sql_handle->execute($place_id) or die "Could not execute SQL statement.";
|
---|
579 | while (my $place_images_match_hashref = $place_images_sql_handle->fetchrow_hashref) {
|
---|
580 | my $place_image_location = $place_images_match_hashref->{"Location"};
|
---|
581 | $self->new_place_image($place_doc_obj, $place_image_location, "small");
|
---|
582 | $self->new_place_image($place_doc_obj, $place_image_location, "large");
|
---|
583 |
|
---|
584 | my $place_image_name = $place_images_match_hashref->{"FileName"};
|
---|
585 | my $place_image_large_file_name = $place_image_name . "-large.jpg";
|
---|
586 | $place_image_large_file_name =~ s/ /%20/g;
|
---|
587 | my $place_image_large_file_link = "_httpcollection_/index/assoc/[assocfilepath]/$place_image_large_file_name";
|
---|
588 | my $place_image_small_file_name = $place_image_name . "-small.jpg";
|
---|
589 | $place_image_small_file_name =~ s/ /%20/g;
|
---|
590 | my $place_image_small_file_link = "_httpcollection_/index/assoc/[assocfilepath]/$place_image_small_file_name";
|
---|
591 | $place_images_html .= "<tr><td valign=\"top\"><a href=\"$place_image_large_file_link\"><img src=\"$place_image_small_file_link\"/></a></td><td valign=\"top\"><a href=\"$place_image_large_file_link\"><span class=\"cictext\">$place_image_name</span></a></td></tr>\n";
|
---|
592 | }
|
---|
593 |
|
---|
594 | &new_metadata_entry($place_doc_obj, "PlaceImagesHTML", "<table>" . $place_images_html . "</table>");
|
---|
595 |
|
---|
596 | $place_doc_obj->add_utf8_text($place_doc_obj->get_top_section(), "Some dummy text.");
|
---|
597 | $self->{'processor'}->process($place_doc_obj);
|
---|
598 | $self->{'num_processed'}++;
|
---|
599 |
|
---|
600 | # Build mappings for creating the static macrofiles
|
---|
601 | $place_name_to_id_mapping{$place_name} = $place_id;
|
---|
602 | push(@{$place_type_to_names_mapping{$place_type}}, $place_name);
|
---|
603 | }
|
---|
604 |
|
---|
605 | &write_bilevel_static_browser_macrofile("types", \%place_type_to_names_mapping, \%place_name_to_id_mapping, \%place_id_to_institution_name_mapping, "p", 2);
|
---|
606 | &write_bilevel_static_browser_macrofile("styles", \%place_style_to_names_mapping, \%place_name_to_id_mapping, \%place_id_to_institution_name_mapping, "p", 2);
|
---|
607 | &write_bilevel_static_browser_macrofile("dates", \%place_date_to_names_mapping, \%place_name_to_id_mapping, \%place_id_to_institution_name_mapping, "p", 2);
|
---|
608 | &write_bilevel_static_browser_macrofile("functions", \%place_function_to_names_mapping, \%place_name_to_id_mapping, \%place_id_to_institution_name_mapping, "p", 2);
|
---|
609 | }
|
---|
610 |
|
---|
611 |
|
---|
612 | sub process_designers
|
---|
613 | {
|
---|
614 | my $self = shift(@_);
|
---|
615 | my $dbh = shift(@_);
|
---|
616 |
|
---|
617 | # Prepare SQL statement for getting all the Architects from the Place table
|
---|
618 | my $designer_sql_statement = "SELECT Architect_Name,Entry_ID FROM tblConstruction_and_dates";
|
---|
619 | my $designer_sql_handle = $dbh->prepare($designer_sql_statement);
|
---|
620 | $designer_sql_handle->{LongReadLen} = 65536;
|
---|
621 | $designer_sql_handle->execute() or die "Could not execute SQL statement.";
|
---|
622 |
|
---|
623 | # Prepare SQL statement for getting the Place images
|
---|
624 | my $place_images_sql_statement = "SELECT FileName,Location FROM tblImages WHERE FileType=1 AND Entry_ID=?";
|
---|
625 | my $place_images_sql_handle = $dbh->prepare($place_images_sql_statement);
|
---|
626 | $place_images_sql_handle->{LongReadLen} = 65536;
|
---|
627 |
|
---|
628 | # Get a list of all the designers, and the places they worked on
|
---|
629 | my %designer_name_to_place_ids_mapping;
|
---|
630 | my %designer_name_to_id_mapping;
|
---|
631 | my $designer_count = 0;
|
---|
632 | while (my $designer_hashref = $designer_sql_handle->fetchrow_hashref) {
|
---|
633 | my $designer_names_string = $designer_hashref->{"Architect_Name"};
|
---|
634 | next if !defined($designer_names_string);
|
---|
635 | foreach my $designer_name (split(/;/, $designer_names_string)) {
|
---|
636 | $designer_name =~ s/\(.*?\)//g;
|
---|
637 | $designer_name =~ s/^\s*//;
|
---|
638 | $designer_name =~ s/\s*$//;
|
---|
639 |
|
---|
640 | if (!defined($designer_name_to_id_mapping{$designer_name})) {
|
---|
641 | $designer_count++;
|
---|
642 | $designer_name_to_id_mapping{$designer_name} = "$designer_count";
|
---|
643 | }
|
---|
644 |
|
---|
645 | push(@{$designer_name_to_place_ids_mapping{$designer_name}}, $designer_hashref->{"Entry_ID"});
|
---|
646 | }
|
---|
647 | }
|
---|
648 |
|
---|
649 | # Create a document object for each designer
|
---|
650 | foreach my $designer_name (keys %designer_name_to_place_ids_mapping) {
|
---|
651 | my $designer_id = $designer_name_to_id_mapping{$designer_name};
|
---|
652 | # print STDERR " Designer $designer_id\n";
|
---|
653 | my $designer_doc_obj = new doc($self->{'filename'} . "-", "indexed_doc");
|
---|
654 | $designer_doc_obj->set_OID("d$designer_id");
|
---|
655 | &new_metadata_entry($designer_doc_obj, "DocumentType", "Designer");
|
---|
656 |
|
---|
657 | &new_metadata_entry($designer_doc_obj, "Designer_name", $designer_name);
|
---|
658 |
|
---|
659 | my $designer_places_image_html = "";
|
---|
660 | foreach my $designer_place_id (@{$designer_name_to_place_ids_mapping{$designer_name}}) {
|
---|
661 | # Get the first image for this place
|
---|
662 | $place_images_sql_handle->execute($designer_place_id) or die "Could not execute SQL statement.";
|
---|
663 | my $designer_place_image_match_hashref = $place_images_sql_handle->fetchrow_hashref();
|
---|
664 | if (defined($designer_place_image_match_hashref)) {
|
---|
665 | my $designer_place_image_location = $designer_place_image_match_hashref->{"Location"};
|
---|
666 | $self->new_place_image($designer_doc_obj, $designer_place_image_location, "small");
|
---|
667 |
|
---|
668 | my $designer_place_image_name = $designer_place_image_match_hashref->{"FileName"};
|
---|
669 | my $designer_place_image_small_file_name = $designer_place_image_name . "-small.jpg";
|
---|
670 | $designer_place_image_small_file_name =~ s/ /%20/g;
|
---|
671 | my $designer_place_image_small_file_link = "_httpcollection_/index/assoc/[assocfilepath]/$designer_place_image_small_file_name";
|
---|
672 | $designer_places_image_html .= "<tr><td valign=\"top\"><a href=\"_gwcgi_?a=d&d=p$designer_place_id\"><img src=\"$designer_place_image_small_file_link\"/></a></td><td valign=\"top\"><a href=\"_gwcgi_?a=d&d=p$designer_place_id\"><span class=\"cictext\">$designer_place_image_name</span></a></td></tr>\n";
|
---|
673 | }
|
---|
674 | }
|
---|
675 |
|
---|
676 | &new_metadata_entry($designer_doc_obj, "DesignerPlacesImageHTML", "<table>" . $designer_places_image_html . "</table>");
|
---|
677 |
|
---|
678 | $designer_doc_obj->add_utf8_text($designer_doc_obj->get_top_section(), "Some dummy text.");
|
---|
679 | $self->{'processor'}->process($designer_doc_obj);
|
---|
680 | $self->{'num_processed'}++;
|
---|
681 | }
|
---|
682 |
|
---|
683 | # Write the designers.dm macrofile
|
---|
684 | &write_static_browser_macrofile("designers", \%designer_name_to_id_mapping, "d", 2);
|
---|
685 | }
|
---|
686 |
|
---|
687 |
|
---|
688 | sub new_metadata_entry
|
---|
689 | {
|
---|
690 | my ($doc_obj, $metadata_name, $metadata_value) = (@_);
|
---|
691 |
|
---|
692 | # Don't bother with empty metadata
|
---|
693 | return if ($metadata_value eq "");
|
---|
694 |
|
---|
695 | # Spaces aren't allowed in metadata names
|
---|
696 | $metadata_name =~ s/ /_/g;
|
---|
697 |
|
---|
698 | # Anything from the database is ISO 8859-1 encoded, so convert to UTF-8
|
---|
699 | $metadata_value = &unicode::ascii2utf8(\$metadata_value);
|
---|
700 |
|
---|
701 | # Remove '#' characters around links
|
---|
702 | if ($metadata_value =~ /\#(.*?)\#/) {
|
---|
703 | $metadata_value = $1;
|
---|
704 | }
|
---|
705 |
|
---|
706 | $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), $metadata_name, $metadata_value);
|
---|
707 | }
|
---|
708 |
|
---|
709 |
|
---|
710 | sub rtf_to_html
|
---|
711 | {
|
---|
712 | my $rtf_string = shift(@_);
|
---|
713 | $rtf_string =~ s/\{(.*?)\}//g;
|
---|
714 | $rtf_string =~ s/\\rquote /'/g; # ' # (for Emacs)
|
---|
715 | $rtf_string =~ s/\\pard//g;
|
---|
716 | $rtf_string =~ s/\\par/<br \/>/g;
|
---|
717 | $rtf_string =~ s/\\i0 /<\/i>/g;
|
---|
718 | $rtf_string =~ s/\\i /<i>/g;
|
---|
719 | $rtf_string =~ s/\\~/ /g;
|
---|
720 | $rtf_string =~ s/\\([A-Za-z0-9]+)//g;
|
---|
721 | $rtf_string =~ s/\}//g;
|
---|
722 |
|
---|
723 | # Assume non-ASCII is ISO 8859-1, and convert into HTML entities
|
---|
724 | while ($rtf_string =~ /\\'([a-z0-9][a-z0-9])/) {
|
---|
725 | my $dec = hex($1);
|
---|
726 | $rtf_string =~ s/\\'$1/&#$dec\;/;
|
---|
727 | }
|
---|
728 |
|
---|
729 | return $rtf_string;
|
---|
730 | }
|
---|
731 |
|
---|
732 |
|
---|
733 | sub new_place_image
|
---|
734 | {
|
---|
735 | my $self = shift(@_);
|
---|
736 | my ($doc_obj, $place_image_location, $place_image_size) = (@_);
|
---|
737 |
|
---|
738 | # Don't bother with empty values
|
---|
739 | return if ($place_image_location eq "");
|
---|
740 |
|
---|
741 | # Convert the server location of the file into the local location of the file
|
---|
742 | my $place_image_file_path = $place_image_location;
|
---|
743 | $place_image_file_path =~ s/^[A-Z]:/$self->{'images_directory'}/;
|
---|
744 |
|
---|
745 | # Create a new section for each image of the place
|
---|
746 | my $place_image_section = $doc_obj->insert_section($doc_obj->get_end_child($doc_obj->get_top_section()));
|
---|
747 | $doc_obj->add_utf8_text($place_image_section, "Some dummy text.");
|
---|
748 | $doc_obj->add_utf8_metadata($place_image_section, "Title", "1");
|
---|
749 |
|
---|
750 | if (!-f $place_image_file_path) {
|
---|
751 | print STDERR "<ProcessingError n='$place_image_file_path' p='CICPlug' r='Does not exist'>\n" if ($self->{'gli'});
|
---|
752 | print STDERR "Error: Image $place_image_file_path does not exist.\n";
|
---|
753 | return;
|
---|
754 | }
|
---|
755 |
|
---|
756 | my $place_image_file_name = $place_image_file_path;
|
---|
757 | $place_image_file_name =~ s/^.*?([^\\]+)$/$1/;
|
---|
758 | my ($image_file_root) = ($place_image_file_name =~ /^(.+)\./);
|
---|
759 |
|
---|
760 | # Scale the original image to make the place image
|
---|
761 | my $image_width = $self->{$place_image_size . '_image_width'};
|
---|
762 | my $image_options = "-scale $image_width " . $self->{$place_image_size . '_image_options'};
|
---|
763 | my $image_file_name = $image_file_root . "-$place_image_size." . $self->{$place_image_size . '_image_type'};
|
---|
764 |
|
---|
765 | my $original_image_file_path = $place_image_file_path;
|
---|
766 | my $image_type = $place_image_size;
|
---|
767 |
|
---|
768 | my $original_image_file_date = (stat($original_image_file_path))[9];
|
---|
769 | my $image_file_path = &util::filename_cat($self->{'cache_directory'}, $image_file_name);
|
---|
770 | my $image_command = "convert -verbose $image_options \"$original_image_file_path\" \"$image_file_path\"";
|
---|
771 | my $image_height;
|
---|
772 |
|
---|
773 | # Check if this image has already been generated by looking for a ".inf" file in the tmp directory
|
---|
774 | $image_file_name =~ /^(.*?)\.[^\.]+$/;
|
---|
775 | my $image_info_file_name = $1 . ".inf";
|
---|
776 | my $image_info_file_path = &util::filename_cat($self->{'cache_directory'}, $image_info_file_name);
|
---|
777 | if (-e $image_info_file_path) {
|
---|
778 | open(IMAGE_INFO_FILE, "<$image_info_file_path");
|
---|
779 | my @image_info = <IMAGE_INFO_FILE>;
|
---|
780 | close(IMAGE_INFO_FILE);
|
---|
781 |
|
---|
782 | # Read the original image file date and image command from the file and check they match
|
---|
783 | my $old_original_image_file_date = $image_info[0];
|
---|
784 | $old_original_image_file_date =~ s/\n$//;
|
---|
785 | my $old_image_command = $image_info[1];
|
---|
786 | $old_image_command =~ s/\n$//;
|
---|
787 | if ($old_original_image_file_date eq $original_image_file_date && lc($old_image_command) eq lc($image_command)) {
|
---|
788 | # print STDERR "Already generated $image_file_name...\n";
|
---|
789 | $image_width = $image_info[2];
|
---|
790 | $image_width =~ s/\n$//;
|
---|
791 | $image_height = $image_info[3];
|
---|
792 | $image_height =~ s/\n$//;
|
---|
793 | }
|
---|
794 | }
|
---|
795 |
|
---|
796 | # Generate the image if it doesn't already exist
|
---|
797 | if (!defined($image_width) || !defined($image_height)) {
|
---|
798 | print STDERR "Generating place image file: $image_file_name...\n";
|
---|
799 | my $outhandle = $self->{'outhandle'};
|
---|
800 | print $outhandle "$image_command\n" if ($self->{'verbosity'} > 2);
|
---|
801 | my $image_result = `$image_command` || "";
|
---|
802 | print $outhandle "RESULT = $image_result\n" if ($self->{'verbosity'} > 2);
|
---|
803 |
|
---|
804 | # Check that the converted image exists
|
---|
805 | if (!-f $image_file_path) {
|
---|
806 | print STDERR "<ProcessingError n='$image_file_path' p='CICPlug' r='Could not be created'>\n" if ($self->{'gli'});
|
---|
807 | print STDERR "Error: Image $image_file_path could not be created.\n";
|
---|
808 | return;
|
---|
809 | }
|
---|
810 |
|
---|
811 | # Get image dimensions
|
---|
812 | if ($image_command !~ /\-scale / && $image_result =~ m/([0-9]+)x([0-9]+)/) {
|
---|
813 | $image_width = $1;
|
---|
814 | $image_height = $2;
|
---|
815 | }
|
---|
816 | elsif ($image_result =~ m/[0-9]+x[0-9]+=>([0-9]+)x([0-9]+)/) {
|
---|
817 | $image_width = $1;
|
---|
818 | $image_height = $2;
|
---|
819 | }
|
---|
820 | elsif ($image_result =~ m/Image Width: (\d+) Image Length: (\d+)/) {
|
---|
821 | $image_width = $1;
|
---|
822 | $image_height = $2;
|
---|
823 | }
|
---|
824 | elsif ($image_result =~ m/JPEG (\d+)x(\d+)/) {
|
---|
825 | $image_width = $1;
|
---|
826 | $image_height = $2;
|
---|
827 | }
|
---|
828 | else {
|
---|
829 | print STDERR "Error: Could not parse image width and height for $original_image_file_path\n";
|
---|
830 | return;
|
---|
831 | }
|
---|
832 | }
|
---|
833 |
|
---|
834 | # Associate the image file
|
---|
835 | $doc_obj->associate_file($image_file_path, $image_file_name, undef, $self->{'section'});
|
---|
836 |
|
---|
837 | # Add various bits of metadata for the image
|
---|
838 | my $image_metadata_value = $image_file_name;
|
---|
839 | $image_metadata_value =~ s/ /%20/g;
|
---|
840 | $doc_obj->add_utf8_metadata($self->{'section'}, $image_type . "Image", $image_metadata_value);
|
---|
841 | $doc_obj->add_metadata($self->{'section'}, $image_type . "ImageWidth", $image_width);
|
---|
842 | $doc_obj->add_metadata($self->{'section'}, $image_type . "ImageHeight", $image_height);
|
---|
843 | $doc_obj->add_metadata($self->{'section'}, $image_type . "ImagePath", "_httpcollection_/index/assoc/[parent(Top):assocfilepath]/[${image_type}Image]");
|
---|
844 |
|
---|
845 | # Write the image info file so we don't have to regenerate this exact image again in the future
|
---|
846 | open(IMAGE_INFO_FILE, ">$image_info_file_path");
|
---|
847 | print IMAGE_INFO_FILE "$original_image_file_date\n";
|
---|
848 | print IMAGE_INFO_FILE "$image_command\n";
|
---|
849 | print IMAGE_INFO_FILE "$image_width\n";
|
---|
850 | print IMAGE_INFO_FILE "$image_height\n";
|
---|
851 | close(IMAGE_INFO_FILE);
|
---|
852 | }
|
---|
853 |
|
---|
854 |
|
---|
855 | sub write_static_browser_macrofile
|
---|
856 | {
|
---|
857 | my $static_browser_package_name = shift(@_);
|
---|
858 | my $name_to_id_mapping = shift(@_);
|
---|
859 | my $id_prefix = shift(@_);
|
---|
860 | my $table_columns = 2;
|
---|
861 |
|
---|
862 | my $static_browser_macrofile_path = "$ENV{'GSDLHOME'}\\collect\\cic-hcap\\macros\\$static_browser_package_name.dm";
|
---|
863 | print STDERR "Writing $static_browser_macrofile_path...\n";
|
---|
864 | open(BROWSER_MACROFILE, ">$static_browser_macrofile_path") or die "Error: Could not write to $static_browser_macrofile_path.\n";
|
---|
865 | print BROWSER_MACROFILE "package $static_browser_package_name\n\n";
|
---|
866 | print BROWSER_MACROFILE "_cicstaticbrowser_ {\n";
|
---|
867 |
|
---|
868 | my %letter_to_name_mapping;
|
---|
869 | foreach my $name (keys %$name_to_id_mapping) {
|
---|
870 | my ($letter) = ($name =~ /^(.)/);
|
---|
871 | push(@{$letter_to_name_mapping{$letter}}, $name);
|
---|
872 | }
|
---|
873 |
|
---|
874 | print BROWSER_MACROFILE "<center><b>";
|
---|
875 | foreach my $letter (split(//, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) {
|
---|
876 | if (defined($letter_to_name_mapping{$letter})) {
|
---|
877 | print BROWSER_MACROFILE "<a href=\"#$letter\">$letter</a> ";
|
---|
878 | }
|
---|
879 | else {
|
---|
880 | print BROWSER_MACROFILE "$letter ";
|
---|
881 | }
|
---|
882 | }
|
---|
883 | print BROWSER_MACROFILE "</b></center>\n";
|
---|
884 |
|
---|
885 | print BROWSER_MACROFILE "<table cellpadding=\"0\" cellspacing=\"0\" width=\"_pagewidth_\">\n";
|
---|
886 |
|
---|
887 | foreach my $letter (sort(keys %letter_to_name_mapping)) {
|
---|
888 | print BROWSER_MACROFILE "<tr><td width=\"50%\"><br /><a name=\"$letter\"/><span style=\"color: black;\"><b>$letter</b></span></td><td width=\"50%\"></td></tr>\n";
|
---|
889 |
|
---|
890 | my @letter_names = sort(@{$letter_to_name_mapping{$letter}});
|
---|
891 | my $half_point = ((scalar(@letter_names) % 2 == 0) ? scalar(@letter_names) / 2 : (scalar(@letter_names) + 1) / 2);
|
---|
892 | for (my $i = 0; $i < $half_point; $i++) {
|
---|
893 | print BROWSER_MACROFILE "<tr>";
|
---|
894 |
|
---|
895 | my $name = $letter_names[$i];
|
---|
896 | my $id = $id_prefix . $name_to_id_mapping->{$name};
|
---|
897 | print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id\">$name</a></td>";
|
---|
898 |
|
---|
899 | $name = $letter_names[$i+$half_point];
|
---|
900 | if (defined($name)) {
|
---|
901 | $id = $id_prefix . $name_to_id_mapping->{$name};
|
---|
902 | print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id\">$name</a></td>";
|
---|
903 | }
|
---|
904 | else {
|
---|
905 | print BROWSER_MACROFILE "<td></td>";
|
---|
906 | }
|
---|
907 |
|
---|
908 | print BROWSER_MACROFILE "</tr>\n";
|
---|
909 | }
|
---|
910 | }
|
---|
911 |
|
---|
912 | print BROWSER_MACROFILE "}\n";
|
---|
913 | close(BROWSER_MACROFILE);
|
---|
914 | }
|
---|
915 |
|
---|
916 | sub write_bilevel_static_browser_macrofile
|
---|
917 | {
|
---|
918 | my $static_browser_package_root = shift(@_);
|
---|
919 | my $category_to_names_mapping = shift(@_);
|
---|
920 | my $name_to_id_mapping = shift(@_);
|
---|
921 | my $id_to_extra_mapping = shift(@_);
|
---|
922 | my $id_prefix = shift(@_);
|
---|
923 | my $table_columns = shift(@_);
|
---|
924 |
|
---|
925 | my $static_browser_macrofile_path = "$ENV{'GSDLHOME'}\\collect\\cic-hcap\\macros\\$static_browser_package_root.dm";
|
---|
926 | print STDERR "Writing $static_browser_macrofile_path...\n";
|
---|
927 | open(BROWSER_MACROFILE, ">$static_browser_macrofile_path") or die "Error: Could not write to $static_browser_macrofile_path.\n";
|
---|
928 |
|
---|
929 | foreach my $category (keys(%{$category_to_names_mapping})) {
|
---|
930 | # print STDERR "Category: $category\n";
|
---|
931 |
|
---|
932 | my $static_browser_package_name = $static_browser_package_root . $category;
|
---|
933 | $static_browser_package_name =~ s/\W//g;
|
---|
934 |
|
---|
935 | print BROWSER_MACROFILE "package $static_browser_package_name\n\n";
|
---|
936 | print BROWSER_MACROFILE "_cicstaticbrowser_ {\n";
|
---|
937 |
|
---|
938 | print BROWSER_MACROFILE "<center><b>";
|
---|
939 | foreach my $letter (split(//, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) {
|
---|
940 | print BROWSER_MACROFILE "<a href=\"#$letter\">$letter</a> ";
|
---|
941 | }
|
---|
942 | print BROWSER_MACROFILE "</b></center>\n";
|
---|
943 |
|
---|
944 | print BROWSER_MACROFILE "<table cellpadding=\"0\" cellspacing=\"0\" width=\"_pagewidth_\">\n";
|
---|
945 |
|
---|
946 | my $last_name = "";
|
---|
947 | my $current_letter = "";
|
---|
948 | my $current_position = 0;
|
---|
949 | foreach my $name (sort(@{$category_to_names_mapping->{$category}})) {
|
---|
950 | # Ignore duplicates
|
---|
951 | next if ($name eq $last_name);
|
---|
952 |
|
---|
953 | $name =~ /^(.)/;
|
---|
954 | if ($1 ne $current_letter) {
|
---|
955 | if ($current_position > 0) {
|
---|
956 | while ($current_position > 0) {
|
---|
957 | print BROWSER_MACROFILE "<td></td>";
|
---|
958 | $current_position--;
|
---|
959 | }
|
---|
960 | print BROWSER_MACROFILE "</tr>\n";
|
---|
961 | }
|
---|
962 | if ($table_columns == 2) {
|
---|
963 | print BROWSER_MACROFILE "<tr><td width=\"50%\"><br /><a name=\"$1\"/><span style=\"color: black;\"><b>$1</b></span></td><td width=\"50%\"></td></tr>\n";
|
---|
964 | }
|
---|
965 | else {
|
---|
966 | print BROWSER_MACROFILE "<tr><td width=\"33%\"><br /><a name=\"$1\"/><span style=\"color: black;\"><b>$1</b></span></td><td style=\"padding-left: 3px; padding-right: 3px;\" width=\"34%\"></td><td width=\"33%\"></td></tr>\n";
|
---|
967 | }
|
---|
968 | $current_letter = $1;
|
---|
969 | }
|
---|
970 |
|
---|
971 | my $id = $name_to_id_mapping->{$name};
|
---|
972 | my $extra = "";
|
---|
973 | if (defined($id_to_extra_mapping)) {
|
---|
974 | $extra = $id_to_extra_mapping->{$id};
|
---|
975 | }
|
---|
976 |
|
---|
977 | if ($current_position == 0) {
|
---|
978 | print BROWSER_MACROFILE "<tr>";
|
---|
979 | }
|
---|
980 | print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id_prefix$id\">$name</a>$extra</td>";
|
---|
981 | $current_position++;
|
---|
982 | if ($current_position == $table_columns) {
|
---|
983 | print BROWSER_MACROFILE "</tr>\n";
|
---|
984 | $current_position = 0;
|
---|
985 | }
|
---|
986 |
|
---|
987 | $last_name = $name;
|
---|
988 | }
|
---|
989 |
|
---|
990 | print BROWSER_MACROFILE "}\n\n";
|
---|
991 | }
|
---|
992 |
|
---|
993 | close(BROWSER_MACROFILE);
|
---|
994 | }
|
---|
995 |
|
---|
996 |
|
---|
997 | sub write_bilevel_static_browser_macrofile_new
|
---|
998 | {
|
---|
999 | my $static_browser_package_root = shift(@_);
|
---|
1000 | my $category_to_names_mapping = shift(@_);
|
---|
1001 | my $name_to_id_mapping = shift(@_);
|
---|
1002 | my $id_to_extra_mapping = shift(@_);
|
---|
1003 | my $id_prefix = shift(@_);
|
---|
1004 | my $table_columns = shift(@_);
|
---|
1005 |
|
---|
1006 | my $static_browser_macrofile_path = "$ENV{'GSDLHOME'}\\collect\\cic-hcap\\macros\\$static_browser_package_root.dm";
|
---|
1007 | print STDERR "Writing $static_browser_macrofile_path...\n";
|
---|
1008 | open(BROWSER_MACROFILE, ">$static_browser_macrofile_path") or die "Error: Could not write to $static_browser_macrofile_path.\n";
|
---|
1009 |
|
---|
1010 | foreach my $category (keys(%{$category_to_names_mapping})) {
|
---|
1011 | # print STDERR "Category: $category\n";
|
---|
1012 |
|
---|
1013 | my $static_browser_package_name = $static_browser_package_root . $category;
|
---|
1014 | $static_browser_package_name =~ s/\W//g;
|
---|
1015 |
|
---|
1016 | print BROWSER_MACROFILE "package $static_browser_package_name\n\n";
|
---|
1017 | print BROWSER_MACROFILE "_cicstaticbrowser_ {\n";
|
---|
1018 |
|
---|
1019 | my %letter_to_name_mapping;
|
---|
1020 | foreach my $name (@{$category_to_names_mapping->{$category}}) {
|
---|
1021 | my ($letter) = ($name =~ /^(.)/);
|
---|
1022 | push(@{$letter_to_name_mapping{$letter}}, $name);
|
---|
1023 | }
|
---|
1024 |
|
---|
1025 | print BROWSER_MACROFILE "<center><b>";
|
---|
1026 | foreach my $letter (split(//, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) {
|
---|
1027 | if (defined($letter_to_name_mapping{$letter})) {
|
---|
1028 | print BROWSER_MACROFILE "<a href=\"#$letter\">$letter</a> ";
|
---|
1029 | }
|
---|
1030 | else {
|
---|
1031 | print BROWSER_MACROFILE "$letter ";
|
---|
1032 | }
|
---|
1033 | }
|
---|
1034 | print BROWSER_MACROFILE "</b></center>\n";
|
---|
1035 |
|
---|
1036 | print BROWSER_MACROFILE "<table cellpadding=\"0\" cellspacing=\"0\" width=\"_pagewidth_\">\n";
|
---|
1037 |
|
---|
1038 | foreach my $letter (sort(keys %letter_to_name_mapping)) {
|
---|
1039 | print BROWSER_MACROFILE "<tr><td width=\"50%\"><br /><a name=\"$letter\"/><span style=\"color: black;\"><b>$letter</b></span></td><td width=\"50%\"></td></tr>\n";
|
---|
1040 |
|
---|
1041 | my @letter_names = sort(@{$letter_to_name_mapping{$letter}});
|
---|
1042 | my $half_point = ((scalar(@letter_names) % 2 == 0) ? scalar(@letter_names) / 2 : (scalar(@letter_names) + 1) / 2);
|
---|
1043 | for (my $i = 0; $i < $half_point; $i++) {
|
---|
1044 | print BROWSER_MACROFILE "<tr>";
|
---|
1045 |
|
---|
1046 | my $name = $letter_names[$i];
|
---|
1047 | my $id = $name_to_id_mapping->{$name};
|
---|
1048 | my $extra = $id_to_extra_mapping->{$id};
|
---|
1049 | print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id_prefix$id\">$name</a>$extra</td>";
|
---|
1050 |
|
---|
1051 | $name = $letter_names[$i+$half_point];
|
---|
1052 | if (defined($name)) {
|
---|
1053 | $id = $name_to_id_mapping->{$name};
|
---|
1054 | $extra = $id_to_extra_mapping->{$id};
|
---|
1055 | print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id_prefix$id\">$name</a>$extra</td>";
|
---|
1056 | }
|
---|
1057 | else {
|
---|
1058 | print BROWSER_MACROFILE "<td></td>";
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | print BROWSER_MACROFILE "</tr>\n";
|
---|
1062 | }
|
---|
1063 | }
|
---|
1064 |
|
---|
1065 | # my $last_name = "";
|
---|
1066 | # my $current_letter = "";
|
---|
1067 | # my $current_position = 0;
|
---|
1068 | # foreach my $name (sort(@{$category_to_names_mapping->{$category}})) {
|
---|
1069 | # # Ignore duplicates
|
---|
1070 | # next if ($name eq $last_name);
|
---|
1071 |
|
---|
1072 | # $name =~ /^(.)/;
|
---|
1073 | # if ($1 ne $current_letter) {
|
---|
1074 | # if ($current_position > 0) {
|
---|
1075 | # while ($current_position > 0) {
|
---|
1076 | # print BROWSER_MACROFILE "<td></td>";
|
---|
1077 | # $current_position--;
|
---|
1078 | # }
|
---|
1079 | # print BROWSER_MACROFILE "</tr>\n";
|
---|
1080 | # }
|
---|
1081 | # if ($table_columns == 2) {
|
---|
1082 | # print BROWSER_MACROFILE "<tr><td width=\"50%\"><br /><a name=\"$1\"/><span style=\"color: black;\"><b>$1</b></span></td><td width=\"50%\"></td></tr>\n";
|
---|
1083 | # }
|
---|
1084 | # else {
|
---|
1085 | # print BROWSER_MACROFILE "<tr><td width=\"33%\"><br /><a name=\"$1\"/><span style=\"color: black;\"><b>$1</b></span></td><td style=\"padding-left: 3px; padding-right: 3px;\" width=\"34%\"></td><td width=\"33%\"></td></tr>\n";
|
---|
1086 | # }
|
---|
1087 | # $current_letter = $1;
|
---|
1088 | # }
|
---|
1089 |
|
---|
1090 | # my $id = $name_to_id_mapping->{$name};
|
---|
1091 | # my $extra = "";
|
---|
1092 | # if (defined($id_to_extra_mapping)) {
|
---|
1093 | # $extra = $id_to_extra_mapping->{$id};
|
---|
1094 | # }
|
---|
1095 |
|
---|
1096 | # if ($current_position == 0) {
|
---|
1097 | # print BROWSER_MACROFILE "<tr>";
|
---|
1098 | # }
|
---|
1099 | # if (!defined($name) || !defined($id_prefix) || !defined($id) || !defined($extra)) {
|
---|
1100 | # print STDERR "Name: $name\n";
|
---|
1101 | # print STDERR "ID prefix: $id_prefix\n";
|
---|
1102 | # print STDERR "ID: $id\n";
|
---|
1103 | # print STDERR "Extra: $extra\n";
|
---|
1104 | # }
|
---|
1105 | # print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=$id_prefix$id\">$name</a>$extra</td>";
|
---|
1106 | # $current_position++;
|
---|
1107 | # if ($current_position == $table_columns) {
|
---|
1108 | # print BROWSER_MACROFILE "</tr>\n";
|
---|
1109 | # $current_position = 0;
|
---|
1110 | # }
|
---|
1111 |
|
---|
1112 | # $last_name = $name;
|
---|
1113 | # }
|
---|
1114 |
|
---|
1115 | print BROWSER_MACROFILE "}\n\n";
|
---|
1116 | }
|
---|
1117 |
|
---|
1118 | close(BROWSER_MACROFILE);
|
---|
1119 | }
|
---|
1120 |
|
---|
1121 |
|
---|
1122 | sub write_state_browser_macrofile
|
---|
1123 | {
|
---|
1124 | my $static_browser_package_name = shift(@_);
|
---|
1125 | my $state_to_name_mapping = shift(@_);
|
---|
1126 | my $name_to_id_mapping = shift(@_);
|
---|
1127 |
|
---|
1128 | my $static_browser_macrofile_path = "$ENV{'GSDLHOME'}\\collect\\cic-hcap\\macros\\$static_browser_package_name.dm";
|
---|
1129 | print STDERR "Writing $static_browser_macrofile_path...\n";
|
---|
1130 | open(BROWSER_MACROFILE, ">$static_browser_macrofile_path") or die "Error: Could not write to $static_browser_macrofile_path.\n";
|
---|
1131 | print BROWSER_MACROFILE "package $static_browser_package_name\n\n";
|
---|
1132 | print BROWSER_MACROFILE "_cicstaticbrowser_ {\n";
|
---|
1133 |
|
---|
1134 | print BROWSER_MACROFILE "<center><b>";
|
---|
1135 | foreach my $letter (split(//, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) {
|
---|
1136 | # if ($letter !~ /[BEJQXYZ]/) {
|
---|
1137 | print BROWSER_MACROFILE "<a href=\"#$letter\">$letter</a> ";
|
---|
1138 | # }
|
---|
1139 | # else {
|
---|
1140 | # print BROWSER_MACROFILE "<span style=\"color: #999999\">$letter</span> ";
|
---|
1141 | # }
|
---|
1142 | }
|
---|
1143 | print BROWSER_MACROFILE "</b></center>\n";
|
---|
1144 |
|
---|
1145 | print BROWSER_MACROFILE "<table cellpadding=\"0\" cellspacing=\"0\" width=\"_pagewidth_\">\n";
|
---|
1146 |
|
---|
1147 | my $current_letter = "";
|
---|
1148 | my $current_position = 0;
|
---|
1149 | foreach my $state (sort(keys %$state_to_name_mapping)) {
|
---|
1150 | if ($current_position > 0) {
|
---|
1151 | while ($current_position > 0) {
|
---|
1152 | print BROWSER_MACROFILE "<td></td>";
|
---|
1153 | $current_position--;
|
---|
1154 | }
|
---|
1155 | print BROWSER_MACROFILE "</tr>\n";
|
---|
1156 | }
|
---|
1157 |
|
---|
1158 | print BROWSER_MACROFILE "<tr><td width=\"33%\"><br />";
|
---|
1159 | $state =~ /^(.)/;
|
---|
1160 | if ($1 ne $current_letter) {
|
---|
1161 | print BROWSER_MACROFILE "<a name=\"$1\"/>";
|
---|
1162 | $current_letter = $1;
|
---|
1163 | }
|
---|
1164 | print BROWSER_MACROFILE "<span style=\"color: black;\"><b>$state</b></span></td><td style=\"padding-left: 3px; padding-right: 3px;\" width=\"34%\"></td><td width=\"33%\"></td></tr>\n";
|
---|
1165 |
|
---|
1166 | foreach my $name (sort(@{$state_to_name_mapping->{$state}})) {
|
---|
1167 | my $id = $name_to_id_mapping->{$name};
|
---|
1168 |
|
---|
1169 | if ($current_position == 0) {
|
---|
1170 | print BROWSER_MACROFILE "<tr>";
|
---|
1171 | }
|
---|
1172 | print BROWSER_MACROFILE "<td valign=\"top\"><a href=\"_gwcgi_?a=d&d=i$id\">$name</a></td>";
|
---|
1173 | $current_position++;
|
---|
1174 | if ($current_position == 3) {
|
---|
1175 | print BROWSER_MACROFILE "</tr>\n";
|
---|
1176 | $current_position = 0;
|
---|
1177 | }
|
---|
1178 | }
|
---|
1179 | }
|
---|
1180 |
|
---|
1181 | print BROWSER_MACROFILE "}\n";
|
---|
1182 | close(BROWSER_MACROFILE);
|
---|
1183 | }
|
---|
1184 |
|
---|
1185 |
|
---|
1186 | 1;
|
---|