116 |
delete $cache->{display_data}; |
delete $cache->{display_data}; |
117 |
delete $cache->{swish_data}; |
delete $cache->{swish_data}; |
118 |
delete $cache->{swish_exact_data}; |
delete $cache->{swish_exact_data}; |
119 |
|
delete $cache->{index_data}; |
120 |
my @page_fields; # names of fields |
my @page_fields; # names of fields |
121 |
|
|
122 |
|
|
151 |
my $swish_data = ""; |
my $swish_data = ""; |
152 |
my $swish_exact_data = ""; |
my $swish_exact_data = ""; |
153 |
my $display_data = ""; |
my $display_data = ""; |
154 |
|
my @index_data; |
155 |
my $line_delimiter; |
my $line_delimiter; |
156 |
|
|
157 |
my ($swish,$display); |
my ($swish,$display); |
179 |
$d = 0 if (lc($x->{type}) eq "swish"); |
$d = 0 if (lc($x->{type}) eq "swish"); |
180 |
($s,$se,$d,$i) = (0,0,0,1) if (lc($x->{type}) eq "index"); |
($s,$se,$d,$i) = (0,0,0,1) if (lc($x->{type}) eq "index"); |
181 |
($s,$se,$d,$i) = (0,1,0,0) if (lc($x->{type}) eq "swish_exact"); |
($s,$se,$d,$i) = (0,1,0,0) if (lc($x->{type}) eq "swish_exact"); |
182 |
$il = 1 if (lc($x->{type}) =~ /^lookup/); |
($s,$se,$d,$i,$il) = (0,1,0,0,1) if (lc($x->{type}) =~ /^lookup/); |
183 |
|
|
184 |
# what will separate last line from this one? |
# what will separate last line from this one? |
185 |
if ($display_data && $x->{append} && $x->{append} eq "1") { |
if ($display_data && $x->{append}) { |
186 |
$line_delimiter = ' '; |
$line_delimiter = ' '; |
187 |
} elsif ($display_data) { |
} elsif ($display_data) { |
188 |
$line_delimiter = '<br/>'; |
$line_delimiter = '<br/>'; |
192 |
($swish,$display) = (1,1); |
($swish,$display) = (1,1); |
193 |
|
|
194 |
# placeholder for all repeatable entries for index |
# placeholder for all repeatable entries for index |
|
my @index_data; |
|
195 |
|
|
196 |
sub mkformat { |
sub mkformat { |
197 |
my $x = shift || die "mkformat needs tag reference"; |
my $x = shift || die "mkformat needs tag reference"; |
295 |
} |
} |
296 |
|
|
297 |
# type="index" ; insert into index |
# type="index" ; insert into index |
298 |
|
my $idisplay; |
299 |
if ($i && $display) { |
if ($i && $display) { |
300 |
|
$idisplay = $display; |
301 |
if ($filter) { |
if ($filter) { |
302 |
no strict 'refs'; |
no strict 'refs'; |
303 |
$display = &$filter($display); |
$idisplay = &$filter($idisplay); |
|
} |
|
|
if ($x->{append} && @index_data) { |
|
|
$index_data[$#index_data].=$display; |
|
|
} else { |
|
|
push @index_data, $display; |
|
304 |
} |
} |
305 |
|
push @index_data, $idisplay if (! $iterate_by_page); |
306 |
} |
} |
307 |
|
|
308 |
# store fields in lookup |
# store fields in lookup |
328 |
sub iterate_fld($$$$$$) { |
sub iterate_fld($$$$$$) { |
329 |
my ($cache,$what,$field,$page,$data,$append) = @_; |
my ($cache,$what,$field,$page,$data,$append) = @_; |
330 |
return if (!$data); |
return if (!$data); |
331 |
my $line_delimiter = $page_line_delimiter; |
|
332 |
$line_delimiter = " " if ($append); |
my $ldel = $page_line_delimiter; |
333 |
|
$ldel = " " if ($append); |
334 |
|
#print STDERR "line delimiter: ",Dumper($ldel) if ($ldel); |
335 |
if (! $cache->{$what}->{$field}->[$page]) { |
if (! $cache->{$what}->{$field}->[$page]) { |
336 |
$cache->{$what}->{$field}->[$page] = $data; |
$cache->{$what}->{$field}->[$page] = $data; |
337 |
} else { |
} else { |
338 |
$cache->{$what}->{$field}->[$page] .= $line_delimiter.$data; |
$cache->{$what}->{$field}->[$page] .= $ldel.$data; |
339 |
} |
} |
340 |
} |
} |
341 |
|
|
342 |
if ($display_data) { |
if ($display_data) { |
|
print STDERR "line delimiter: ",Dumper($line_delimiter) if ($line_delimiter); |
|
343 |
iterate_fld($cache,'display_data',$field,$page,$display_data,$x->{append}); |
iterate_fld($cache,'display_data',$field,$page,$display_data,$x->{append}); |
344 |
} |
} |
345 |
$display_data = ""; |
$display_data = ""; |
351 |
iterate_fld($cache,'swish_exact_data',$field,$page,$swish_exact_data,$x->{append}); |
iterate_fld($cache,'swish_exact_data',$field,$page,$swish_exact_data,$x->{append}); |
352 |
$swish_exact_data = ""; |
$swish_exact_data = ""; |
353 |
} |
} |
354 |
|
|
355 |
|
if ($idisplay) { |
356 |
|
my $ldel=$page_line_delimiter; |
357 |
|
my @index_data; |
358 |
|
if ($cache->{index_data}->{$field}->[$page]) { |
359 |
|
|
360 |
|
@index_data = @{$cache->{index_data}->{$field}->[$page]}; |
361 |
|
} |
362 |
|
if ($x->{append}) { |
363 |
|
$index_data[$#index_data] .= $idisplay; |
364 |
|
} else { |
365 |
|
push @index_data, $idisplay; |
366 |
|
} |
367 |
|
$idisplay = ""; |
368 |
|
@{$cache->{index_data}->{$field}->[$page]} = @index_data; |
369 |
|
} |
370 |
} |
} |
371 |
} |
} |
372 |
|
|
373 |
# fill data in index |
if (! $iterate_by_page) { |
374 |
foreach my $d (@index_data) { |
# fill data in index |
375 |
$index->insert($field, $d, $path); |
foreach my $d (@index_data) { |
376 |
|
$index->insert($field, $d, $path); |
377 |
|
} |
378 |
|
@index_data = (); |
379 |
} |
} |
380 |
} |
} |
381 |
|
|
454 |
# That is required to produce exact match |
# That is required to produce exact match |
455 |
$xml .= xmlify($field."_swish_exact", unac_string($codepage,'xxbxx '.$swish_exact_data.' xxexx')); |
$xml .= xmlify($field."_swish_exact", unac_string($codepage,'xxbxx '.$swish_exact_data.' xxexx')); |
456 |
} |
} |
457 |
|
|
458 |
|
foreach my $d (@{$cache->{index_data}->{$field}->[$page]}) { |
459 |
|
$index->insert($field, $d, $path); |
460 |
|
#print STDERR "index $field: $d [$path]\n"; |
461 |
|
} |
462 |
} |
} |
463 |
|
|
464 |
} |
} |