X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FRecord.pm;h=8e09adf2c384c3e2c9827ff141990a75a1a54d6d;hb=fe99800a2e39fba1c6369bdfe3f600119308514a;hp=1acad7a8e8b1be9ff24245c0d035d1b84ea183ed;hpb=64b79bf6207cd1d98e2885e026375d94142474d6;p=koha_fer diff --git a/C4/Record.pm b/C4/Record.pm index 1acad7a8e8..8e09adf2c3 100644 --- a/C4/Record.pm +++ b/C4/Record.pm @@ -14,12 +14,13 @@ package C4::Record; # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # -use strict;# use warnings; #FIXME: turn off warnings before release +use strict; +#use warnings; FIXME - Bug 2505 # please specify in which methods a given module is used use MARC::Record; # marc2marcxml, marcxml2marc, html2marc, changeEncoding @@ -70,14 +71,10 @@ New in Koha 3.x. This module handles all record-related management functions. =head2 marc2marc - Convert from one flavour of ISO-2709 to another -=over 4 - -my ($error,$newmarc) = marc2marc($marc,$to_flavour,$from_flavour,$encoding); + my ($error,$newmarc) = marc2marc($marc,$to_flavour,$from_flavour,$encoding); Returns an ISO-2709 scalar -=back - =cut sub marc2marc { @@ -88,14 +85,10 @@ sub marc2marc { =head2 marc2marcxml - Convert from ISO-2709 to MARCXML -=over 4 - -my ($error,$marcxml) = marc2marcxml($marc,$encoding,$flavour); + my ($error,$marcxml) = marc2marcxml($marc,$encoding,$flavour); Returns a MARCXML scalar -=over 2 - C<$marc> - an ISO-2709 scalar or MARC::Record object C<$encoding> - UTF-8 or MARC-8 [UTF-8] @@ -104,10 +97,6 @@ C<$flavour> - MARC21 or UNIMARC C<$dont_entity_encode> - a flag that instructs marc2marcxml not to entity encode the xml before returning (optional) -=back - -=back - =cut sub marc2marcxml { @@ -174,24 +163,16 @@ sub marc2marcxml { =head2 marcxml2marc - Convert from MARCXML to ISO-2709 -=over 4 - -my ($error,$marc) = marcxml2marc($marcxml,$encoding,$flavour); + my ($error,$marc) = marcxml2marc($marcxml,$encoding,$flavour); Returns an ISO-2709 scalar -=over 2 - C<$marcxml> - a MARCXML record C<$encoding> - UTF-8 or MARC-8 [UTF-8] C<$flavour> - MARC21 or UNIMARC -=back - -=back - =cut sub marcxml2marc { @@ -214,24 +195,16 @@ sub marcxml2marc { =head2 marc2dcxml - Convert from ISO-2709 to Dublin Core -=over 4 - -my ($error,$dcxml) = marc2dcxml($marc,$qualified); + my ($error,$dcxml) = marc2dcxml($marc,$qualified); Returns a DublinCore::Record object, will eventually return a Dublin Core scalar FIXME: should return actual XML, not just an object -=over 2 - C<$marc> - an ISO-2709 scalar or MARC::Record object C<$qualified> - specify whether qualified Dublin Core should be used in the input or output [0] -=back - -=back - =cut sub marc2dcxml { @@ -268,16 +241,13 @@ sub marc2dcxml { $dcxmlfinal .= "\n"; return ($error,$dcxmlfinal); } -=head2 marc2modsxml - Convert from ISO-2709 to MODS -=over 4 +=head2 marc2modsxml - Convert from ISO-2709 to MODS -my ($error,$modsxml) = marc2modsxml($marc); + my ($error,$modsxml) = marc2modsxml($marc); Returns a MODS scalar -=back - =cut sub marc2modsxml { @@ -329,25 +299,19 @@ sub marc2endnote { } =head2 marc2csv - Convert several records from UNIMARC to CSV -Pre and postprocessing can be done through a YAML file -=over 4 + my ($csv) = marc2csv($biblios, $csvprofileid); -my ($csv) = marc2csv($biblios, $csvprofileid); +Pre and postprocessing can be done through a YAML file Returns a CSV scalar -=over 2 - C<$biblio> - a list of biblionumbers C<$csvprofileid> - the id of the CSV profile to use for the export (see export_format.export_format_id and the GetCsvProfiles function in C4::Csv) -=back - -=back - =cut + sub marc2csv { my ($biblios, $id) = @_; my $output; @@ -360,7 +324,6 @@ sub marc2csv { ($preprocess,$postprocess, $fieldprocessing) = YAML::LoadFile($configfile); } - warn $fieldprocessing; # Preprocessing eval $preprocess if ($preprocess); @@ -378,14 +341,10 @@ sub marc2csv { =head2 marcrecord2csv - Convert a single record from UNIMARC to CSV -=over 4 - -my ($csv) = marcrecord2csv($biblio, $csvprofileid, $header); + my ($csv) = marcrecord2csv($biblio, $csvprofileid, $header); Returns a CSV scalar -=over 2 - C<$biblio> - a biblionumber C<$csvprofileid> - the id of the CSV profile to use for the export (see export_format.export_format_id and the GetCsvProfiles function in C4::Csv) @@ -394,10 +353,6 @@ C<$header> - true if the headers are to be printed (typically at first pass) C<$csv> - an already initialised Text::CSV object -=back - -=back - =cut @@ -407,7 +362,7 @@ sub marcrecord2csv { # Getting the record my $record = GetMarcBiblio($biblio); - + next unless $record; # Getting the framework my $frameworkcode = GetFrameworkCode($biblio); @@ -538,9 +493,7 @@ sub marcrecord2csv { =head2 html2marcxml -=over 4 - -my ($error,$marcxml) = html2marcxml($tags,$subfields,$values,$indicator,$ind_tag); + my ($error,$marcxml) = html2marcxml($tags,$subfields,$values,$indicator,$ind_tag); Returns a MARCXML scalar @@ -549,8 +502,6 @@ the form submission. FIXME: this could use some better code documentation -=back - =cut sub html2marcxml { @@ -627,12 +578,8 @@ sub html2marcxml { =head2 html2marc -=over 4 - Probably best to avoid using this ... it has some rather striking problems: -=over 2 - * saves blank subfields * subfield order is hardcoded to always start with 'a' for repeatable tags (because it is hardcoded in the addfield routine). @@ -641,12 +588,8 @@ Probably best to avoid using this ... it has some rather striking problems: * the underlying routines didn't support subfield reordering or subfield repeatability. -=back - I've left it in here because it could be useful if someone took the time to fix it. -- kados -=back - =cut sub html2marc { @@ -716,14 +659,10 @@ sub html2marc { =head2 changeEncoding - Change the encoding of a record -=over 4 - -my ($error, $newrecord) = changeEncoding($record,$format,$flavour,$to_encoding,$from_encoding); + my ($error, $newrecord) = changeEncoding($record,$format,$flavour,$to_encoding,$from_encoding); Changes the encoding of a record -=over 2 - C<$record> - the record itself can be in ISO-2709, a MARC::Record object, or MARCXML for now (required) C<$format> - MARC or MARCXML (required) @@ -734,16 +673,12 @@ C<$to_encoding> - the encoding you want the record to end up in (optional) [UTF- C<$from_encoding> - the encoding the record is currently in (optional, it will probably be able to tell unless there's a problem with the record) -=back - FIXME: the from_encoding doesn't work yet FIXME: better handling for UNIMARC, it should allow management of 100 field FIXME: shouldn't have to convert to and from xml/marc just to change encoding someone needs to re-write MARC::Record's 'encoding' method to actually alter the encoding rather than just changing the leader -=back - =cut sub changeEncoding { @@ -779,22 +714,14 @@ sub changeEncoding { =head2 marc2bibtex - Convert from MARC21 and UNIMARC to BibTex -=over 4 - -my ($bibtex) = marc2bibtex($record, $id); + my ($bibtex) = marc2bibtex($record, $id); Returns a BibTex scalar -=over 2 - C<$record> - a MARC::Record object C<$id> - an id for the BibTex record (might be the biblionumber) -=back - -=back - =cut @@ -869,18 +796,14 @@ sub marc2bibtex { =head2 _entity_encode - Entity-encode an array of strings -=over 4 - -my ($entity_encoded_string) = _entity_encode($string); + my ($entity_encoded_string) = _entity_encode($string); or -my (@entity_encoded_strings) = _entity_encode(@strings); + my (@entity_encoded_strings) = _entity_encode(@strings); Entity-encode an array of strings -=back - =cut sub _entity_encode {