102 |
} |
} |
103 |
|
|
104 |
my @sorted_tags; |
my @sorted_tags; |
105 |
if ($cache->{tags_by_order}->{$type}) { |
if ($cache->{tags_by_order}) { |
106 |
@sorted_tags = @{$cache->{tags_by_order}->{$type}}; |
@sorted_tags = @{$cache->{tags_by_order}}; |
107 |
} else { |
} else { |
108 |
@sorted_tags = sort by_order keys %{$config->{indexer}}; |
@sorted_tags = sort by_order keys %{$config->{indexer}}; |
109 |
$cache->{tags_by_order}->{$type} = \@sorted_tags; |
$cache->{tags_by_order} = \@sorted_tags; |
110 |
} |
} |
111 |
|
|
112 |
# lookup key |
# lookup key |
113 |
my $lookup_key; |
my $lookup_key; |
114 |
|
|
115 |
# cache for field in pages |
# cache for field in pages |
116 |
$cache->{display_data} = (); |
delete $cache->{display_data}; |
117 |
$cache->{swish_data} = (); |
delete $cache->{swish_data}; |
118 |
$cache->{swish_exact_data} = (); |
delete $cache->{swish_exact_data}; |
119 |
|
delete $cache->{index_data}; |
120 |
|
delete $cache->{index_delimiter}; |
121 |
my @page_fields; # names of fields |
my @page_fields; # names of fields |
122 |
|
|
123 |
|
|
152 |
my $swish_data = ""; |
my $swish_data = ""; |
153 |
my $swish_exact_data = ""; |
my $swish_exact_data = ""; |
154 |
my $display_data = ""; |
my $display_data = ""; |
155 |
|
my @index_data; |
156 |
my $line_delimiter; |
my $line_delimiter; |
157 |
|
|
158 |
my ($swish,$display); |
my ($swish,$display); |
165 |
my %page_max = (); |
my %page_max = (); |
166 |
# default line_delimiter if using |
# default line_delimiter if using |
167 |
my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>'; |
my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>'; |
168 |
|
$cache->{index_delimiter}->{$field} = $config->{indexer}->{$field}->{index_delimiter}; |
169 |
|
|
170 |
foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) { |
foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) { |
171 |
|
|
179 |
my ($s,$se,$d,$i,$il) = (1,0,1,0,0); |
my ($s,$se,$d,$i,$il) = (1,0,1,0,0); |
180 |
$s = 0 if (lc($x->{type}) eq "display"); |
$s = 0 if (lc($x->{type}) eq "display"); |
181 |
$d = 0 if (lc($x->{type}) eq "swish"); |
$d = 0 if (lc($x->{type}) eq "swish"); |
182 |
$se = 1 if (lc($x->{type}) eq "swish_exact"); |
($s,$se,$d,$i) = (0,1,0,1) if (lc($x->{type}) eq "index"); |
183 |
($s,$d,$i) = (0,0,1) if (lc($x->{type}) eq "index"); |
($s,$se,$d,$i) = (0,1,0,0) if (lc($x->{type}) eq "swish_exact"); |
184 |
$il = 1 if (lc($x->{type}) =~ /^lookup/); |
($s,$se,$d,$i,$il) = (0,1,0,0,1) if (lc($x->{type}) =~ /^lookup/); |
|
|
|
185 |
|
|
186 |
# what will separate last line from this one? |
# what will separate last line from this one? |
187 |
if ($display_data && $x->{append} && $x->{append} eq "1") { |
if ($display_data && $x->{append}) { |
188 |
$line_delimiter = ' '; |
$line_delimiter = ' '; |
189 |
} elsif ($display_data) { |
} elsif ($display_data) { |
190 |
$line_delimiter = '<br/>'; |
$line_delimiter = '<br/>'; |
194 |
($swish,$display) = (1,1); |
($swish,$display) = (1,1); |
195 |
|
|
196 |
# placeholder for all repeatable entries for index |
# placeholder for all repeatable entries for index |
|
my @index_data; |
|
197 |
|
|
198 |
sub mkformat { |
sub mkformat { |
199 |
my $x = shift || die "mkformat needs tag reference"; |
my $x = shift || die "mkformat needs tag reference"; |
297 |
} |
} |
298 |
|
|
299 |
# type="index" ; insert into index |
# type="index" ; insert into index |
300 |
|
my $idisplay; |
301 |
if ($i && $display) { |
if ($i && $display) { |
302 |
|
$idisplay = $display; |
303 |
if ($filter) { |
if ($filter) { |
304 |
no strict 'refs'; |
no strict 'refs'; |
305 |
$display = &$filter($display); |
$idisplay = &$filter($idisplay); |
|
} |
|
|
if ($x->{append} && @index_data) { |
|
|
$index_data[$#index_data].=$display; |
|
|
} else { |
|
|
push @index_data, $display; |
|
306 |
} |
} |
307 |
|
push @index_data, $idisplay if (! $iterate_by_page); |
308 |
} |
} |
309 |
|
|
310 |
# store fields in lookup |
# store fields in lookup |
330 |
sub iterate_fld($$$$$$) { |
sub iterate_fld($$$$$$) { |
331 |
my ($cache,$what,$field,$page,$data,$append) = @_; |
my ($cache,$what,$field,$page,$data,$append) = @_; |
332 |
return if (!$data); |
return if (!$data); |
333 |
my $line_delimiter = $page_line_delimiter; |
|
334 |
$line_delimiter = " " if ($append); |
my $ldel = $page_line_delimiter; |
335 |
|
$ldel = " " if ($append); |
336 |
|
#print STDERR "line delimiter: ",Dumper($ldel) if ($ldel); |
337 |
if (! $cache->{$what}->{$field}->[$page]) { |
if (! $cache->{$what}->{$field}->[$page]) { |
338 |
$cache->{$what}->{$field}->[$page] = $data; |
$cache->{$what}->{$field}->[$page] = $data; |
339 |
} else { |
} else { |
340 |
$cache->{$what}->{$field}->[$page] .= $line_delimiter.$data; |
$cache->{$what}->{$field}->[$page] .= $ldel.$data; |
341 |
} |
} |
342 |
} |
} |
343 |
|
|
344 |
if ($display_data) { |
if ($display_data) { |
|
print STDERR "line delimiter: ",Dumper($line_delimiter) if ($line_delimiter); |
|
345 |
iterate_fld($cache,'display_data',$field,$page,$display_data,$x->{append}); |
iterate_fld($cache,'display_data',$field,$page,$display_data,$x->{append}); |
346 |
} |
} |
347 |
$display_data = ""; |
$display_data = ""; |
353 |
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}); |
354 |
$swish_exact_data = ""; |
$swish_exact_data = ""; |
355 |
} |
} |
356 |
|
|
357 |
|
if ($idisplay) { |
358 |
|
my $ldel=$page_line_delimiter; |
359 |
|
my @index_data; |
360 |
|
if ($cache->{index_data}->{$field}->[$page]) { |
361 |
|
|
362 |
|
@index_data = @{$cache->{index_data}->{$field}->[$page]}; |
363 |
|
} |
364 |
|
if ($x->{append}) { |
365 |
|
$index_data[$#index_data] .= $idisplay; |
366 |
|
} else { |
367 |
|
push @index_data, $idisplay; |
368 |
|
} |
369 |
|
$idisplay = ""; |
370 |
|
@{$cache->{index_data}->{$field}->[$page]} = @index_data; |
371 |
|
} |
372 |
} |
} |
373 |
} |
} |
374 |
|
|
375 |
# fill data in index |
if (! $iterate_by_page) { |
376 |
foreach my $d (@index_data) { |
my $idel = $x->{index_delimiter}; |
377 |
$index->insert($field, $d, $path); |
# fill data in index |
378 |
|
foreach my $tmp (@index_data) { |
379 |
|
my $i = $d = $tmp; |
380 |
|
if ($idel && $tmp =~ m/$idel/) { |
381 |
|
($i,$d) = split(/$idel/,$tmp); |
382 |
|
} |
383 |
|
$index->insert($field, $i, $d, $path); |
384 |
|
} |
385 |
|
@index_data = (); |
386 |
} |
} |
387 |
} |
} |
388 |
|
|
461 |
# That is required to produce exact match |
# That is required to produce exact match |
462 |
$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')); |
463 |
} |
} |
464 |
|
|
465 |
|
my $idel = $cache->{index_delimiter}->{$field}; |
466 |
|
foreach my $tmp (@{$cache->{index_data}->{$field}->[$page]}) { |
467 |
|
my $i = $tmp; |
468 |
|
my $d = $tmp; |
469 |
|
if ($idel && $tmp =~ m/$idel/) { |
470 |
|
($i,$d) = split(/$idel/,$tmp); |
471 |
|
} |
472 |
|
$index->insert($field, $i, $d, $path); |
473 |
|
#print STDERR "index [$idel] $field: $i --> $d [$path]\n"; |
474 |
|
} |
475 |
} |
} |
476 |
|
|
477 |
} |
} |
602 |
# now read database |
# now read database |
603 |
print STDERR "using: $type...\n"; |
print STDERR "using: $type...\n"; |
604 |
|
|
605 |
|
# erase cache for tags by order in this database |
606 |
|
delete $cache->{tags_by_order}; |
607 |
|
|
608 |
if ($type_base eq "isis") { |
if ($type_base eq "isis") { |
609 |
|
|
610 |
my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!"; |
my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!"; |