/[webpac]/trunk2/all2all.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk2/all2all.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 218 by dpavlin, Thu Feb 5 10:55:58 2004 UTC revision 263 by dpavlin, Fri Mar 12 15:06:58 2004 UTC
# Line 210  sub data2xml { Line 210  sub data2xml {
210    
211                          # placeholder for all repeatable entries for index                          # placeholder for all repeatable entries for index
212    
                         sub chk_eval($) {  
                                 my $data = shift;  
                                 if ($data =~ s/eval{([^}]+)}//) {  
                                         if (eval "$1") {  
                                                 return $data;  
                                         } else {  
                                                 return undef;  
                                         }  
                                 } else {  
                                         return $data;  
                                 }  
                         }  
   
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 chk_eval($data);                                  my $format_name = x($x->{format_name}) || return $data;
217                                  my $fmt = x($config->{format}->{$format_name}->{content}) || die "<format name=\"$format_name\"> is not defined!";                                  my $fmt = x($config->{format}->{$format_name}->{content}) || die "<format name=\"$format_name\"> is not defined!";
218                                  my $format_delimiter = x($x->{format_delimiter});                                  my $format_delimiter = x($x->{format_delimiter});
219                                  my @data;                                  my @data;
# Line 239  sub data2xml { Line 226  sub data2xml {
226                                  if ($fmt) {                                  if ($fmt) {
227                                          my $nr = scalar $fmt =~ s/%s/%s/g;                                          my $nr = scalar $fmt =~ s/%s/%s/g;
228                                          if (($#data+1) == $nr) {                                          if (($#data+1) == $nr) {
229                                                  return chk_eval(sprintf($fmt,@data));                                                  return sprintf($fmt,@data);
230                                          } else {                                          } else {
231                                                  #print STDERR "mkformat: [$data] can't be split on [$format_delimiter] to $nr fields!\n";                                                  #print STDERR "mkformat: [$data] can't be split on [$format_delimiter] to $nr fields!\n";
232                                                  return chk_eval($data);                                                  return $data;
233                                          }                                          }
234                                  } else {                                  } else {
235                                          print STDERR "usage of link '$format_name' without defined format (<link> tag)\n";                                          print STDERR "usage of link '$format_name' without defined format (<link> tag)\n";
# Line 270  sub data2xml { Line 257  sub data2xml {
257                                                                  $display = $new_display;                                                                  $display = $new_display;
258                                                                  $cache->{lhash}->{$display} = $new_display;                                                                  $cache->{lhash}->{$display} = $new_display;
259                                                          } else {                                                          } else {
260                                                                  print STDERR "WARNING: lookup for '$display' didn't find anything.\n";  #                                                               print STDERR "WARNING: lookup for '$display' didn't find anything.\n";
261                                                                  $display = "";                                                                  $display = "";
262                                                                  $cache->{lhash}->{$display} = $null;                                                                  $cache->{lhash}->{$display} = $null;
263                                                          }                                                          }
# Line 291  sub data2xml { Line 278  sub data2xml {
278                                  }                                  }
279                                  # type="swish" ; field for swish                                  # type="swish" ; field for swish
280                                  if ($swish) {                                  if ($swish) {
281                                            my $tmp = $swish;
282                                          if ($filter && ($s || $se)) {                                          if ($filter && ($s || $se)) {
283                                                  no strict 'refs';                                                  no strict 'refs';
284                                                  my $tmp = join(" ",&$filter($swish)) if ($s || $se);                                                  $tmp = join(" ",&$filter($tmp)) if ($s || $se);
                                                 $swish_data .= $tmp if ($s);  
                                                 $swish_exact_data .= "xxbxx $tmp xxexx " if ($se && $tmp ne "");  
   
                                         } else {  
                                                 $swish_data .= $swish if ($s);  
                                                 $swish_exact_data .= "xxbxx $swish xxexx " if ($se && $swish ne "");  
285                                          }                                          }
286    
287                                            $swish_data .= $tmp if ($s && $tmp);
288                                            $swish_exact_data .= "xxbxx $tmp xxexx " if ($tmp && $tmp ne "" && $se);
289                                  }                                  }
290    
291                                  # type="display" ; field for display                                  # type="display" ; field for display
# Line 321  sub data2xml { Line 306  sub data2xml {
306                                          } else {                                          } else {
307                                                  $display_data .= $ldel if ($display_data);                                                  $display_data .= $ldel if ($display_data);
308                                                  my $tmp = mkformat($x,$display);                                                  my $tmp = mkformat($x,$display);
309                                                  $display_data = $tmp if ($tmp);                                                  $display_data .= $tmp if ($tmp);
310                                          }                                          }
311                                  }                                  }
312                                                                                                    
# Line 333  sub data2xml { Line 318  sub data2xml {
318                                                  no strict 'refs';                                                  no strict 'refs';
319                                                  $idisplay = &$filter($idisplay);                                                  $idisplay = &$filter($idisplay);
320                                          }                                          }
321                                          push @index_data, $idisplay if (! $iterate_by_page);                                          push @index_data, $idisplay if ($idisplay && !$iterate_by_page);
322                                  }                                  }
323    
324                                  # store fields in lookup                                  # store fields in lookup
# Line 342  sub data2xml { Line 327  sub data2xml {
327                                                  if ($lookup_key) {                                                  if ($lookup_key) {
328                                                          print STDERR "WARNING: try to redefine lookup_key (keys shouldn't be repeatable fields!)";                                                          print STDERR "WARNING: try to redefine lookup_key (keys shouldn't be repeatable fields!)";
329                                                  } else {                                                  } else {
330                                                          $lookup_key = $display;                                                          if ($filter) {
331                                                                    no strict 'refs';
332                                                                    $lookup_key = &$filter($display);
333                                                            } else {
334                                                                    $lookup_key = $display;
335                                                            }
336                                                  }                                                  }
337                                          } elsif (lc($x->{type}) eq "lookup_val") {                                          } elsif (lc($x->{type}) eq "lookup_val") {
338                                                  if ($lookup_key) {                                                  if ($lookup_key) {
339                                                          $lhash{$lookup_key} = $display;                                                          if ($filter) {
340                                                                    no strict 'refs';
341                                                                    $lhash{$lookup_key} = &$filter($display);
342                                                            } else {
343                                                                    $lhash{$lookup_key} = $display;
344                                                            }
345                                                  } else {                                                  } else {
346                                                          print STDERR "WARNING: no lookup_key defined for  '$display'?";                                                          print STDERR "WARNING: no lookup_key defined for  '$display'?";
347                                                  }                                                  }
# Line 592  foreach my $database ($cfg->Sections) { Line 587  foreach my $database ($cfg->Sections) {
587                  #tie %lhash, 'GDBM_File', $lookup_file, &GDBM_NEWDB, 0644;                  #tie %lhash, 'GDBM_File', $lookup_file, &GDBM_NEWDB, 0644;
588                  tie %lhash, 'TDB_File', $lookup_file, TDB_CLEAR_IF_FIRST, O_RDWR, 0644;                  tie %lhash, 'TDB_File', $lookup_file, TDB_CLEAR_IF_FIRST, O_RDWR, 0644;
589                  print STDERR "creating lookup file '$lookup_file'\n";                  print STDERR "creating lookup file '$lookup_file'\n";
590                    # delete memory cache for lookup file
591                    delete $cache->{lhash};
592          }          }
593    
594          # open existing lookup file          # open existing lookup file
# Line 728  print STDERR "using: $type...\n"; Line 725  print STDERR "using: $type...\n";
725                  print STDERR "\n";                  print STDERR "\n";
726    
727          } elsif ($type_base eq "excel") {          } elsif ($type_base eq "excel") {
728                  use Spreadsheet::ParseExcel;                  require Spreadsheet::ParseExcel;
729                  use Spreadsheet::ParseExcel::Utility qw(int2col);                  require Spreadsheet::ParseExcel::Utility;
730                    import Spreadsheet::ParseExcel::Utility qw(int2col);
731                                    
732                  $import2cp = Text::Iconv->new($config->{excel_codepage},$codepage);                  $import2cp = Text::Iconv->new($config->{excel_codepage},$codepage);
733                  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!";
# Line 783  print STDERR "using: $type...\n"; Line 781  print STDERR "using: $type...\n";
781                  }                  }
782          } elsif ($type_base eq "marc") {          } elsif ($type_base eq "marc") {
783    
784                  use MARC;                  require MARC;
785                                    
786                  $import2cp = Text::Iconv->new($config->{marc_codepage},$codepage);                  $import2cp = Text::Iconv->new($config->{marc_codepage},$codepage);
787                  my $marc_file = $cfg -> val($database, 'marc_file') || die "$database doesn't have 'marc_file' defined!";                  my $marc_file = $cfg -> val($database, 'marc_file') || die "$database doesn't have 'marc_file' defined!";

Legend:
Removed from v.218  
changed lines
  Added in v.263

  ViewVC Help
Powered by ViewVC 1.1.26