Bugzilla – Attachment 173524 Details for
Bug 14670
Add 'cite' option to detail page in OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14670: (QA follow-up) Tidy new code
Bug-14670-QA-follow-up-Tidy-new-code.patch (text/plain), 7.22 KB, created by
Martin Renvoize (ashimema)
on 2024-10-28 11:43:28 UTC
(
hide
)
Description:
Bug 14670: (QA follow-up) Tidy new code
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-10-28 11:43:28 UTC
Size:
7.22 KB
patch
obsolete
>From d3cbef17ce240971b94b44a54d7274e905b025a5 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 28 Oct 2024 11:33:48 +0000 >Subject: [PATCH] Bug 14670: (QA follow-up) Tidy new code > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Record.pm | 84 +++++++++++++++++++++++++++------------------------- > 1 file changed, 44 insertions(+), 40 deletions(-) > >diff --git a/C4/Record.pm b/C4/Record.pm >index f4c78dbcb94..789dd581a2c 100644 >--- a/C4/Record.pm >+++ b/C4/Record.pm >@@ -847,6 +847,7 @@ sub marc2bibtex { > return $tex; > } > >+ > =head2 marc2cites - Convert from MARC21 and UNIMARC to citations > > my $cites = marc2cites($record); >@@ -859,81 +860,84 @@ C<$record> - a MARC::Record object > =cut > > sub marc2cites { >- my $record = shift; >+ my $record = shift; > my $marcflavour = C4::Context->preference("marcflavour"); >- my %cites = (); >- my @authors = (); >- my $re_clean = qr/(^[\.,:;\/\-\s]+|[\.,:;\/\-\s]+$)/; >+ my %cites = (); >+ my @authors = (); >+ my $re_clean = qr/(^[\.,:;\/\-\s]+|[\.,:;\/\-\s]+$)/; > >- my @authorFields = ('100','110','111','700','710','711'); >- @authorFields = ('700','701','702','710','711','721') if ( $marcflavour eq "UNIMARC" ); >+ my @authorFields = ( '100', '110', '111', '700', '710', '711' ); >+ @authorFields = ( '700', '701', '702', '710', '711', '721' ) if ( $marcflavour eq "UNIMARC" ); > >- foreach my $ftag ( @authorFields ) { >- foreach my $field ($record->field($ftag)) { >+ foreach my $ftag (@authorFields) { >+ foreach my $field ( $record->field($ftag) ) { > my $author = ''; > if ( $marcflavour eq "UNIMARC" ) { > $author = join ', ', >- ( $field->subfield("a"), $field->subfield("b") ); >+ ( $field->subfield("a"), $field->subfield("b") ); > } else { > $author = $field->subfield("a"); > } >- if($author =~ /([^,]+),?(.*)/) { >+ if ( $author =~ /([^,]+),?(.*)/ ) { > my %a; >- ($a{'surname'} = $1) =~ s/$re_clean//g; >- $a{'forenames'} = [map {my $t=$_;$t=~s/$re_clean//g;$t} split ' ', $2]; >- push(@authors, \%a); >+ ( $a{'surname'} = $1 ) =~ s/$re_clean//g; >+ $a{'forenames'} = [ map { my $t = $_; $t =~ s/$re_clean//g; $t } split ' ', $2 ]; >+ push( @authors, \%a ); > } > } > } > > my %publication; > if ( $marcflavour eq "UNIMARC" ) { >- %publication = ( >- title => $record->subfield("200", "a") || "", >- place => $record->subfield("210", "a") || "", >- publisher => $record->subfield("210", "c") || "", >- date => $record->subfield("210", "d") || $record->subfield("210", "h") || "" >- ); >+ %publication = ( >+ title => $record->subfield( "200", "a" ) || "", >+ place => $record->subfield( "210", "a" ) || "", >+ publisher => $record->subfield( "210", "c" ) || "", >+ date => $record->subfield( "210", "d" ) || $record->subfield( "210", "h" ) || "" >+ ); > } else { >- %publication = ( >- title => $record->subfield("245", "a") || "", >- place => $record->subfield("264", "a") || $record->subfield("260", "a") || "", >- publisher => $record->subfield("264", "b") || $record->subfield("260", "b") || "", >- date => $record->subfield("264", "c") || $record->subfield("260", "c") || $record->subfield("260", "g") || "" >- ); >+ %publication = ( >+ title => $record->subfield( "245", "a" ) || "", >+ place => $record->subfield( "264", "a" ) || $record->subfield( "260", "a" ) || "", >+ publisher => $record->subfield( "264", "b" ) || $record->subfield( "260", "b" ) || "", >+ date => $record->subfield( "264", "c" ) >+ || $record->subfield( "260", "c" ) >+ || $record->subfield( "260", "g" ) >+ || "" >+ ); > } > > $publication{$_} =~ s/$re_clean//g for keys %publication; > $publication{'date'} =~ s/[\D-]//g; > >- my $i = $#authors; >- my $last = 0; >+ my $i = $#authors; >+ my $last = 0; > my $seclast = 0; > for my $author (@authors) { > $cites{'Harvard'} .= $author->{'surname'} . ' '; >- $cites{'Harvard'} .= substr($_, 0, 1) . '. ' for @{$author->{'forenames'}}; >+ $cites{'Harvard'} .= substr( $_, 0, 1 ) . '. ' for @{ $author->{'forenames'} }; > $cites{'Harvard'} =~ s/\s+$//; >- $cites{'Harvard'} .= $last ? '' : ($seclast ? ' and ' : ', '); >+ $cites{'Harvard'} .= $last ? '' : ( $seclast ? ' and ' : ', ' ); > $cites{'Chicago'} .= $author->{'surname'} . ' '; >- $cites{'Chicago'} .= $_ . ' ' for @{$author->{'forenames'}}; >+ $cites{'Chicago'} .= $_ . ' ' for @{ $author->{'forenames'} }; > $cites{'Chicago'} =~ s/\s+$//; >- $cites{'Chicago'} .= $last ? '' : ($seclast ? ' and ' : ', '); >- $cites{'MLA'} .= $author->{'surname'} . ' '; >- $cites{'MLA'} .= $_ . ' ' for @{$author->{'forenames'}}; >+ $cites{'Chicago'} .= $last ? '' : ( $seclast ? ' and ' : ', ' ); >+ $cites{'MLA'} .= $author->{'surname'} . ' '; >+ $cites{'MLA'} .= $_ . ' ' for @{ $author->{'forenames'} }; > $cites{'MLA'} =~ s/\s+$//; >- $cites{'MLA'} .= $last ? '' : ($seclast ? ' and ' : ', '); >+ $cites{'MLA'} .= $last ? '' : ( $seclast ? ' and ' : ', ' ); > $cites{'APA'} .= $author->{'surname'} . ' '; >- $cites{'APA'} .= substr($_, 0, 1) . '. ' for @{$author->{'forenames'}}; >+ $cites{'APA'} .= substr( $_, 0, 1 ) . '. ' for @{ $author->{'forenames'} }; > $cites{'APA'} =~ s/\s+$//; >- $cites{'APA'} .= $last ? '' : ($seclast ? ' & ' : ', '); >+ $cites{'APA'} .= $last ? '' : ( $seclast ? ' & ' : ', ' ); > $seclast = $#authors > 1 && $i-- == 2; >- $last = $i == 0; >+ $last = $i == 0; > } > $cites{$_} =~ s/([^\.])$/$1./ for keys %cites; > > if ( $publication{date} ) { > $cites{'Harvard'} .= ' (' . $publication{'date'} . '). '; >- $cites{'Chicago'} .= ' ' . $publication{'date'} . '. '; >+ $cites{'Chicago'} .= ' ' . $publication{'date'} . '. '; > $cites{'MLA'} .= ' ' . $publication{'title'} . '. '; > $cites{'APA'} .= ' (' . $publication{'date'} . '). '; > } >@@ -943,13 +947,13 @@ sub marc2cites { > $cites{'APA'} .= $publication{'title'} . '. '; > $cites{'Harvard'} .= $publication{'place'} . ': '; > $cites{'Chicago'} .= $publication{'place'} . ': '; >- $cites{'MLA'} .= $publication{'publisher'} . '. '; >+ $cites{'MLA'} .= $publication{'publisher'} . '. '; > $cites{'APA'} .= $publication{'place'} . ': '; > $cites{'Harvard'} .= $publication{'publisher'}; > $cites{'Chicago'} .= $publication{'publisher'}; > $cites{'MLA'} .= $publication{'date'}; > $cites{'APA'} .= $publication{'publisher'}; >- $cites{$_} =~ s/ +/ / for keys %cites; >+ $cites{$_} =~ s/ +/ / for keys %cites; > $cites{$_} =~ s/([^\.])$/$1./ for keys %cites; > > return \%cites; >-- >2.47.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14670
:
41441
|
42971
|
43508
|
43770
|
43771
|
43828
|
43829
|
43919
|
43920
|
43921
|
43922
|
43923
|
43924
|
75679
|
75680
|
75681
|
75682
|
75683
|
161600
|
161601
|
161602
|
161603
|
161604
|
161605
|
161606
|
161607
|
166474
|
167528
|
167529
|
167530
|
167531
|
167532
|
167533
|
167534
|
167535
|
173515
|
173516
|
173517
|
173518
|
173519
|
173520
|
173521
|
173522
|
173523
| 173524 |
174453