126 |
delete $cache->{swish_exact_data}; |
delete $cache->{swish_exact_data}; |
127 |
delete $cache->{index_data}; |
delete $cache->{index_data}; |
128 |
delete $cache->{index_delimiter}; |
delete $cache->{index_delimiter}; |
129 |
|
delete $cache->{distinct}; |
130 |
my @page_fields; # names of fields |
my @page_fields; # names of fields |
131 |
|
|
132 |
|
|
235 |
# default line_delimiter if using |
# default line_delimiter if using |
236 |
my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>'; |
my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>'; |
237 |
$cache->{index_delimiter}->{$field} = $config->{indexer}->{$field}->{index_delimiter}; |
$cache->{index_delimiter}->{$field} = $config->{indexer}->{$field}->{index_delimiter}; |
238 |
|
my $distinct = $config->{indexer}->{$field}->{distinct}; |
239 |
|
if ($distinct && !$iterate_by_page) { |
240 |
|
warn "WARNING: distinct is currently not supported without iterate_by_page!\n"; |
241 |
|
$distinct = 0; |
242 |
|
} |
243 |
|
|
244 |
my $format_name = $config->{indexer}->{$field}->{format_name}; |
my $format_name = $config->{indexer}->{$field}->{format_name}; |
245 |
my $format_delimiter = $config->{indexer}->{$field}->{format_delimiter}; |
my $format_delimiter = $config->{indexer}->{$field}->{format_delimiter}; |
418 |
$ldel = " " if ($append); |
$ldel = " " if ($append); |
419 |
#print STDERR "line delimiter: ",Dumper($ldel) if ($ldel); |
#print STDERR "line delimiter: ",Dumper($ldel) if ($ldel); |
420 |
if (! $cache->{$what}->{$field}->[$page]) { |
if (! $cache->{$what}->{$field}->[$page]) { |
421 |
$cache->{$what}->{$field}->[$page] = $data; |
push @{$cache->{$what}->{$field}->[$page]}, { |
422 |
} else { |
data => $data, |
423 |
$cache->{$what}->{$field}->[$page] .= $ldel.$data; |
delimiter => $ldel, |
424 |
|
}; |
425 |
} |
} |
426 |
} |
} |
427 |
|
|
496 |
# on first page!!! |
# on first page!!! |
497 |
my $page = 0; |
my $page = 0; |
498 |
if ($display_data) { |
if ($display_data) { |
499 |
$cache->{display_data}->{$field}->[$page] = $display_data; |
push @{$cache->{display_data}->{$field}->[$page]}, { data => $display_data }; |
500 |
$display_data = ""; |
$display_data = ""; |
501 |
} |
} |
502 |
if ($swish_data) { |
if ($swish_data) { |
503 |
$cache->{swish_data}->{$field}->[$page] = $swish_data; |
push @{$cache->{swish_data}->{$field}->[$page]}, { data => $swish_data }; |
504 |
$swish_data = ""; |
$swish_data = ""; |
505 |
} |
} |
506 |
if ($swish_exact_data) { |
if ($swish_exact_data) { |
507 |
$cache->{swish_exact_data}->{$field}->[$page] = $swish_exact_data; |
push @{$cache->{swish_exact_data}->{$field}->[$page]}, { data => $swish_exact_data }; |
508 |
$swish_exact_data = ""; |
$swish_exact_data = ""; |
509 |
} |
} |
510 |
} |
} |
515 |
my $nr_pages = $page_max{$field} || next; |
my $nr_pages = $page_max{$field} || next; |
516 |
#print STDERR "field '$field' iterate over ",($nr_pages || 0)," pages...\n"; |
#print STDERR "field '$field' iterate over ",($nr_pages || 0)," pages...\n"; |
517 |
#print STDERR Dumper($cache->{display_data}); |
#print STDERR Dumper($cache->{display_data}); |
518 |
|
my $seen; # used for distinct |
519 |
for (my $page=0; $page <= $nr_pages; $page++) { |
for (my $page=0; $page <= $nr_pages; $page++) { |
520 |
my $display_data; |
my $display_data; |
521 |
if ($cache->{format}->{$field}) { |
my $delimiter = ''; |
522 |
my $tmp = mkformat($cache->{format}->{$field},$cache->{display_data}->{$field}->[$page]); |
foreach my $element (@{ $cache->{display_data}->{$field}->[$page] }) { |
523 |
$display_data=$tmp if ($tmp); |
my $data = $element->{data}; |
524 |
} else { |
die "BUG! no data in element?" unless ($data); |
525 |
$display_data = $cache->{display_data}->{$field}->[$page]; |
|
526 |
|
if ($distinct) { |
527 |
|
next if ($cache->{distinct}->{$field}->{ $data }); |
528 |
|
$cache->{distinct}->{$field}->{ $data } = 1; |
529 |
|
} |
530 |
|
|
531 |
|
if ($cache->{format}->{$field}) { |
532 |
|
my $tmp = mkformat($cache->{format}->{$field},$data); |
533 |
|
$display_data .= $delimiter . $tmp if ($tmp); |
534 |
|
} else { |
535 |
|
$display_data .= $delimiter . $data; |
536 |
|
} |
537 |
|
$delimiter = $element->{delimiter} if ($element->{delimiter}); |
538 |
} |
} |
539 |
|
|
540 |
if ($display_data) { # default |
if ($display_data) { # default |
541 |
if ($field eq "headline") { |
if ($field eq "headline") { |
542 |
$xml .= xmlify("headline", $display_data); |
$xml .= xmlify("headline", $display_data); |
548 |
} |
} |
549 |
} |
} |
550 |
|
|
551 |
my $swish_data = $cache->{swish_data}->{$field}->[$page]; |
my $swish_data = join(" ",map { $_->{data} } @{ $cache->{swish_data}->{$field}->[$page] }); |
552 |
if ($swish_data) { |
if ($swish_data) { |
553 |
# remove extra spaces |
# remove extra spaces |
554 |
$swish_data =~ s/ +/ /g; |
$swish_data =~ s/ +/ /g; |
557 |
$xml .= xmlify($field."_swish", my_unac_string($codepage,$swish_data)); |
$xml .= xmlify($field."_swish", my_unac_string($codepage,$swish_data)); |
558 |
} |
} |
559 |
|
|
560 |
my $swish_exact_data = $cache->{swish_exact_data}->{$field}->[$page]; |
my $swish_exact_data = join(" ", map { $_->{data} } @{ $cache->{swish_exact_data}->{$field}->[$page] }); |
561 |
if ($swish_exact_data) { |
if ($swish_exact_data) { |
562 |
$swish_exact_data =~ s/ +/ /g; |
$swish_exact_data =~ s/ +/ /g; |
563 |
$swish_exact_data =~ s/ +$//g; |
$swish_exact_data =~ s/ +$//g; |
816 |
my $excel_file = $cfg -> val($database, 'excel_file') || die "$database doesn't have 'excel_file' defined!"; |
my $excel_file = $cfg -> val($database, 'excel_file') || die "$database doesn't have 'excel_file' defined!"; |
817 |
|
|
818 |
my $sheet = x($config->{sheet}) || die "no sheet in $type.xml"; |
my $sheet = x($config->{sheet}) || die "no sheet in $type.xml"; |
819 |
my $start_row = x($config->{start_row}) - 1 || die "no start_row in $type.xml"; |
my $start_row = x($config->{start_row}) || die "no start_row in $type.xml"; |
820 |
|
$start_row--; |
821 |
|
|
822 |
my $oBook = Spreadsheet::ParseExcel::Workbook->Parse($excel_file) || die "can't open Excel file '$excel_file'"; |
my $oBook = Spreadsheet::ParseExcel::Workbook->Parse($excel_file) || die "can't open Excel file '$excel_file'"; |
823 |
|
|