72 |
# if you are tight on memory, turn this off |
# if you are tight on memory, turn this off |
73 |
my $use_lhash_cache = 1; |
my $use_lhash_cache = 1; |
74 |
|
|
75 |
|
my $last_field_name; # cache to prevent repeated fields |
76 |
|
|
77 |
sub data2xml { |
sub data2xml { |
78 |
|
|
79 |
use xmlify; |
use xmlify; |
140 |
print STDERR "WARNING: field '$field' doesn't have 'name' attribute!"; |
print STDERR "WARNING: field '$field' doesn't have 'name' attribute!"; |
141 |
} |
} |
142 |
if ($field_name) { |
if ($field_name) { |
143 |
return x($field_name); |
if (! $last_field_name) { |
144 |
|
$last_field_name = x($field_name); |
145 |
|
return $last_field_name; |
146 |
|
} elsif ($field_name ne $last_field_name) { |
147 |
|
$last_field_name = x($field_name); |
148 |
|
return $last_field_name; |
149 |
|
} |
150 |
} |
} |
151 |
} |
} |
152 |
|
|
175 |
my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>'; |
my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>'; |
176 |
$cache->{index_delimiter}->{$field} = $config->{indexer}->{$field}->{index_delimiter}; |
$cache->{index_delimiter}->{$field} = $config->{indexer}->{$field}->{index_delimiter}; |
177 |
|
|
178 |
|
my $format_name = $config->{indexer}->{$field}->{format_name}; |
179 |
|
my $format_delimiter = $config->{indexer}->{$field}->{format_delimiter}; |
180 |
|
if ($format_name && $format_delimiter) { |
181 |
|
$cache->{format}->{$field}->{format_name} = $format_name; |
182 |
|
$cache->{format}->{$field}->{format_delimiter} = $format_delimiter; |
183 |
|
} |
184 |
|
|
185 |
foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) { |
foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) { |
186 |
|
|
187 |
my $format = x($x->{content}); |
my $format = x($x->{content}); |
210 |
|
|
211 |
# placeholder for all repeatable entries for index |
# placeholder for all repeatable entries for index |
212 |
|
|
213 |
sub mkformat { |
sub mkformat($$) { |
214 |
my $x = shift || die "mkformat needs tag reference"; |
my $x = shift || die "mkformat needs tag reference"; |
215 |
my $data = shift || return; |
my $data = shift || return; |
216 |
my $format_name = x($x->{format_name}) || return $data; |
my $format_name = x($x->{format_name}) || return $data; |
282 |
no strict 'refs'; |
no strict 'refs'; |
283 |
my $tmp = join(" ",&$filter($swish)) if ($s || $se); |
my $tmp = join(" ",&$filter($swish)) if ($s || $se); |
284 |
$swish_data .= $tmp if ($s); |
$swish_data .= $tmp if ($s); |
285 |
$swish_exact_data .= $tmp if ($se); |
if ($se) { |
286 |
|
if ($swish_exact_data) { |
287 |
|
$swish_exact_data .= "xxexx xxbxx ".$tmp; |
288 |
|
} else { |
289 |
|
$swish_exact_data .= $tmp; |
290 |
|
} |
291 |
|
} |
292 |
|
|
293 |
} else { |
} else { |
294 |
$swish_data .= $swish if ($s); |
$swish_data .= $swish if ($s); |
295 |
$swish_exact_data .= $swish if ($se); |
if ($se) { |
296 |
|
if ($swish_exact_data) { |
297 |
|
$swish_exact_data .= "xxexx xxbxx ".$swish; |
298 |
|
} else { |
299 |
|
$swish_exact_data .= $swish; |
300 |
|
} |
301 |
|
} |
302 |
} |
} |
303 |
} |
} |
304 |
|
|
389 |
@index_data = @{$cache->{index_data}->{$field}->[$page]}; |
@index_data = @{$cache->{index_data}->{$field}->[$page]}; |
390 |
} |
} |
391 |
if ($x->{append}) { |
if ($x->{append}) { |
392 |
$index_data[$#index_data] .= $idisplay; |
if (@index_data) { |
393 |
|
$index_data[$#index_data] .= $idisplay; |
394 |
|
} else { |
395 |
|
push @index_data, $idisplay; |
396 |
|
} |
397 |
} else { |
} else { |
398 |
push @index_data, $idisplay; |
push @index_data, $idisplay; |
399 |
} |
} |
461 |
#print STDERR "field '$field' iterate over ",($nr_pages || 0)," pages...\n"; |
#print STDERR "field '$field' iterate over ",($nr_pages || 0)," pages...\n"; |
462 |
#print STDERR Dumper($cache->{display_data}); |
#print STDERR Dumper($cache->{display_data}); |
463 |
for (my $page=0; $page <= $nr_pages; $page++) { |
for (my $page=0; $page <= $nr_pages; $page++) { |
464 |
|
my $display_data; |
465 |
my $display_data = $cache->{display_data}->{$field}->[$page]; |
if ($cache->{format}->{$field}) { |
466 |
|
$display_data=mkformat($cache->{format}->{$field},$cache->{display_data}->{$field}->[$page]); |
467 |
|
} else { |
468 |
|
$display_data = $cache->{display_data}->{$field}->[$page]; |
469 |
|
} |
470 |
if ($display_data) { # default |
if ($display_data) { # default |
471 |
if ($field eq "headline") { |
if ($field eq "headline") { |
472 |
$xml .= xmlify("headline", $display_data); |
$xml .= xmlify("headline", $display_data); |