Bug 10572: Add phone to message_transport_types table for new installs
[koha.git] / C4 / Record.pm
index f75195f..9d72d5a 100644 (file)
@@ -310,9 +310,9 @@ sub _transformWithStylesheet {
     my $xslt = XML::LibXSLT->new();
     my $source = $parser->parse_string($xmlrecord);
     my $style_doc = $parser->parse_file($xslfile);
-    my $stylesheet = $xslt->parse_stylesheet($style_doc);
-    my $results = $stylesheet->transform($source);
-    my $newxmlrecord = $stylesheet->output_string($results);
+    my $style_sheet = $xslt->parse_stylesheet($style_doc);
+    my $results = $style_sheet->transform($source);
+    my $newxmlrecord = $style_sheet->output_string($results);
     return ($newxmlrecord);
 }
 
@@ -461,7 +461,7 @@ sub marcrecord2csv {
     $csv->sep_char($csvseparator);
 
     # Getting the marcfields
-    my $marcfieldslist = $profile->{marcfields};
+    my $marcfieldslist = $profile->{content};
 
     # Getting the marcfields as an array
     my @marcfieldsarray = split('\|', $marcfieldslist);
@@ -647,18 +647,30 @@ C<$id> - an id for the BibTex record (might be the biblionumber)
 sub marc2bibtex {
     my ($record, $id) = @_;
     my $tex;
+    my $marcflavour = C4::Context->preference("marcflavour");
 
     # Authors
-    my $marcauthors = GetMarcAuthors($record,C4::Context->preference("marcflavour"));
     my $author;
-    for my $authors ( map { map { @$_ } values %$_  } @$marcauthors  ) {  
-       $author .= " and " if ($author && $$authors{value});
-       $author .= $$authors{value} if ($$authors{value}); 
+    my @texauthors;
+    my @authorFields = ('100','110','111','700','710','711');
+    @authorFields = ('700','701','702','710','711','721') if ( $marcflavour eq "UNIMARC" );
+
+    foreach my $field ( @authorFields ) {
+        # author formatted surname, firstname
+        my $texauthor = '';
+        if ( $marcflavour eq "UNIMARC" ) {
+           $texauthor = join ', ',
+           ( $record->subfield($field,"a"), $record->subfield($field,"b") );
+       } else {
+           $texauthor = $record->subfield($field,"a");
+       }
+       push @texauthors, $texauthor if $texauthor;
     }
+    $author = join ' and ', @texauthors;
 
     # Defining the conversion hash according to the marcflavour
     my %bh;
-    if (C4::Context->preference("marcflavour") eq "UNIMARC") {
+    if ( $marcflavour eq "UNIMARC" ) {
        
        # FIXME, TODO : handle repeatable fields
        # TODO : handle more types of documents
@@ -704,7 +716,7 @@ sub marc2bibtex {
     }
 
     $tex .= "\@book{";
-    $tex .= join(",\n", $id, map { $bh{$_} ? qq(\t$_ = "$bh{$_}") : () } keys %bh);
+    $tex .= join(",\n", $id, map { $bh{$_} ? qq(\t$_ = {$bh{$_}}) : () } keys %bh);
     $tex .= "\n}\n";
 
     return $tex;