@@ -, +, @@ It removes hyphens from isbn and issn when zebra operations are executed and with rebuild_zebra.pl --- C4/Search.pm | 2 +- admin/systempreferences.pl | 1 + installer/data/mysql/de-DE/mandatory/sysprefs.sql | 1 + installer/data/mysql/en/mandatory/sysprefs.sql | 1 + .../1-Obligatoire/unimarc_standard_systemprefs.sql | 1 + installer/data/mysql/it-IT/necessari/sysprefs.sql | 1 + .../data/mysql/nb-NO/1-Obligatorisk/sysprefs.sql | 1 + installer/data/mysql/pl-PL/mandatory/sysprefs.sql | 1 + ...m_preferences_full_optimal_for_install_only.sql | 1 + ...m_preferences_full_optimal_for_install_only.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 ++ .../en/modules/admin/preferences/cataloguing.pref | 6 ++ misc/bin/zebraqueue_daemon.pl | 33 ++++++++++ misc/cronjobs/zebraqueue_start.pl | 33 ++++++++++ misc/migration_tools/rebuild_zebra.pl | 63 ++++++++++++++++++++ .../xsl/RemoveISBN-ISSNHyphensMARC21.xsl | 56 +++++++++++++++++ .../xsl/RemoveISBN-ISSNHyphensUNIMARC.xsl | 56 +++++++++++++++++ 17 files changed, 264 insertions(+), 1 deletions(-) create mode 100644 misc/migration_tools/xsl/RemoveISBN-ISSNHyphensMARC21.xsl create mode 100644 misc/migration_tools/xsl/RemoveISBN-ISSNHyphensUNIMARC.xsl --- a/C4/Search.pm +++ a/C4/Search.pm @@ -1164,7 +1164,7 @@ sub buildQuery { $weight_fields, $fuzzy_enabled, $remove_stopwords ) = ( 0, 0, 0, 0, 0 ); - + $operand =~ s/-//g if (C4::Context->preference("IsbnIssnRemoveHyphens")); } if(not $index){ --- a/admin/systempreferences.pl +++ a/admin/systempreferences.pl @@ -153,6 +153,7 @@ $tabsysprefs{'item-level_itypes'} = "Cataloging"; $tabsysprefs{OpacSuppression} = "Cataloging"; $tabsysprefs{SpineLabelFormat} = "Cataloging"; $tabsysprefs{SpineLabelAutoPrint} = "Cataloging"; +$tabsysprefs{IsbnIssnRemoveHyphens} = "Cataloging"; # Circulation $tabsysprefs{maxoutstanding} = "Circulation"; --- a/installer/data/mysql/de-DE/mandatory/sysprefs.sql +++ a/installer/data/mysql/de-DE/mandatory/sysprefs.sql @@ -314,3 +314,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHiddenItems' ,'','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/O pacHiddenItems.txt for more informations.','','Textarea'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('numSearchRSSResults',50,'Specify the maximum number of results to display on a RSS page of results',NULL,'Integer'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC renewal is recorded in statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice'); +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '0', '', 'Remove or not hyphens from ISBN and ISSN', 'YesNo'); --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ a/installer/data/mysql/en/mandatory/sysprefs.sql @@ -314,3 +314,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHiddenItems','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','','Textarea'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('numSearchRSSResults',50,'Specify the maximum number of results to display on a RSS page of results',NULL,'Integer'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC renewal is recorded in statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice'); +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '0', '', 'Remove or not hyphens from ISBN and ISSN', 'YesNo'); --- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql +++ a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql @@ -315,3 +315,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHiddenItems','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','','Textarea'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('numSearchRSSResults',50,'Specify the maximum number of results to display on a RSS page of results',NULL,'Integer'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC renewal is recorded in statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice'); +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '0', '', 'Remove or not hyphens from ISBN and ISSN', 'YesNo'); --- a/installer/data/mysql/it-IT/necessari/sysprefs.sql +++ a/installer/data/mysql/it-IT/necessari/sysprefs.sql @@ -301,3 +301,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHiddenItems','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/O pacHiddenItems.txt for more informations.','','Textarea'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('numSearchRSSResults',50,'Specify the maximum number of results to display on a RSS page of results',NULL,'Integer'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC renewal is recorded in statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice'); +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '0', '', 'Remove or not hyphens from ISBN and ISSN', 'YesNo'); --- a/installer/data/mysql/nb-NO/1-Obligatorisk/sysprefs.sql +++ a/installer/data/mysql/nb-NO/1-Obligatorisk/sysprefs.sql @@ -321,3 +321,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacFavicon','','Enter a complete URL to an image to replace the default Koha favicon on the OPAC','','free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetFavicon','','Enter a complete URL to an image to replace the default Koha favicon on the Staff client','','free'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('TraceSubjectSubdivisions', '0', 'Create searches on all subdivisions for subject tracings.','1','YesNo'); +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '0', '', 'Remove or not hyphens from ISBN and ISSN', 'YesNo'); --- a/installer/data/mysql/pl-PL/mandatory/sysprefs.sql +++ a/installer/data/mysql/pl-PL/mandatory/sysprefs.sql @@ -313,3 +313,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHiddenItems','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','','Textarea'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('numSearchRSSResults',50,'Specify the maximum number of results to display on a RSS page of results',NULL,'Integer'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC renewal is recorded in statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice'); +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '0', '', 'Remove or not hyphens from ISBN and ISSN', 'YesNo'); --- a/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql +++ a/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql @@ -368,3 +368,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHiddenItems','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','','Textarea'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('numSearchRSSResults',50,'Specify the maximum number of results to display on a RSS page of results',NULL,'Integer'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC renewal is recorded in statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice'); +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '0', '', 'Remove or not hyphens from ISBN and ISSN', 'YesNo'); --- a/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql +++ a/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql @@ -393,3 +393,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHiddenItems','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/O pacHiddenItems.txt for more informations.','','Textarea'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('numSearchRSSResults',50,'Specify the maximum number of results to display on a RSS page of results',NULL,'Integer'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC renewal is recorded in statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice'); +INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '0', '', 'Remove or not hyphens from ISBN and ISSN', 'YesNo'); --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -4370,6 +4370,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion($DBversion); } +$DBversion = "3.05.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '0', '', 'Remove or not hyphens from ISBN and ISSN', 'YesNo');"); + print "Upgrade to $DBversion done (Add SysPref to remove hyphens or not into isbn and issn)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -84,6 +84,12 @@ Cataloging: annual: generated in the form <year>-0001, <year>-0002. hbyymmincr: generated in the form <branchcode>yymm0001. "OFF": not generated automatically. + - + - pref: IsbnIssnRemoveHyphens + choices: + yes: "Remove" + no: "Don't remove" + - hyphens from ISBN and ISSN Display: - - 'Separate multiple displayed authors, series or subjects with ' --- a/misc/bin/zebraqueue_daemon.pl +++ a/misc/bin/zebraqueue_daemon.pl @@ -227,6 +227,39 @@ sub process_update { my $marcxml; if ($server eq "biblioserver") { my $marc = GetMarcBiblio($record_number); + # + if ($marc && C4::Context->preference("IsbnIssnRemoveHyphens")){ + my $isbn; + my $issn; + my $encoding = C4::Context->preference("marcflavour"); + if ( $encoding eq 'UNIMARC' ) { + foreach my $f010 ($marc->field('010')) { + if ( $f010->subfield('a') ) { + $isbn = $f010->subfield('a'); + $isbn =~ s/-//g; + $f010->update( 'a' => $isbn ); + } + } + foreach my $f011 ($marc->field('011')) { + if ( $f011->subfield('a') ) { + $issn = $f011->subfield('a'); + $issn =~ s/-//g; + $f011->update( 'a' => $issn ); + } + } + } elsif ($encoding eq 'MARC21' || $encoding eq 'NORMARC') { + foreach my $f020 ($marc->field('020')) { + $isbn = $f020->subfield('a'); + $isbn =~ s/-//g; + $f020->update( 'a' => $isbn ); + } + foreach my $f022 ($marc->field('022')) { + $issn = $f022->subfield('a'); + $issn =~ s/-//g; + $f022->update( 'a' => $issn ); + } + } + } $marcxml = $marc->as_xml_record() if $marc; } elsif ($server eq "authorityserver") { --- a/misc/cronjobs/zebraqueue_start.pl +++ a/misc/cronjobs/zebraqueue_start.pl @@ -58,6 +58,39 @@ while (($id,$biblionumber,$operation,$server)=$readsth->fetchrow){ # get the XML if ($server eq "biblioserver") { my $marc = GetMarcBiblio($biblionumber); + # + if ($marc && C4::Context->preference("IsbnIssnRemoveHyphens")){ + my $isbn; + my $issn; + my $encoding = C4::Context->preference("marcflavour"); + if ( $encoding eq 'UNIMARC' ) { + foreach my $f010 ($marc->field('010')) { + if ( $f010->subfield('a') ) { + $isbn = $f010->subfield('a'); + $isbn =~ s/-//g; + $f010->update( 'a' => $isbn ); + } + } + foreach my $f011 ($marc->field('011')) { + if ( $f011->subfield('a') ) { + $issn = $f011->subfield('a'); + $issn =~ s/-//g; + $f011->update( 'a' => $issn ); + } + } + } elsif ($encoding eq 'MARC21' || $encoding eq 'NORMARC') { + foreach my $f020 ($marc->field('020')) { + $isbn = $f020->subfield('a'); + $isbn =~ s/-//g; + $f020->update( 'a' => $isbn ); + } + foreach my $f022 ($marc->field('022')) { + $issn = $f022->subfield('a'); + $issn =~ s/-//g; + $f022->update( 'a' => $issn ); + } + } + } $marcxml = $marc->as_xml_record() if $marc; } elsif ($server eq "authorityserver") { $marcxml =C4::AuthoritiesMarc::GetAuthorityXML($biblionumber); --- a/misc/migration_tools/rebuild_zebra.pl +++ a/misc/migration_tools/rebuild_zebra.pl @@ -320,6 +320,7 @@ sub export_marc_records_from_sth { ? GetXmlBiblio( $record_number ) : GetAuthorityXML( $record_number ); if ($record_type eq 'biblio'){ + $marcxml = fix_isbn_hyphens($marcxml, 1) if C4::Context->preference("IsbnIssnRemoveHyphens"); my @items = GetItemsInfo($record_number); if (@items){ my $record = MARC::Record->new; @@ -433,6 +434,7 @@ sub get_corrected_marc_record { if (defined $marc) { fix_leader($marc); + $marc = fix_isbn_hyphens($marc, 0) if C4::Context->preference("IsbnIssnRemoveHyphens"); if ($record_type eq 'biblio') { my $succeeded = fix_biblio_ids($marc, $record_number); return unless $succeeded; @@ -572,6 +574,67 @@ sub fix_unimarc_100 { } } +sub fix_isbn_hyphens { + my $data = shift; + my $isxml = shift; + + my $isbn; + my $issn; + my $encoding = C4::Context->preference("marcflavour"); + + if ( $encoding eq 'UNIMARC' ) { + unless ($isxml){ + foreach my $f010 ($data->field('010')) { + $isbn = $f010->subfield('a'); + $isbn =~ s/-//g; + $f010->update( 'a' => $isbn ); + } + foreach my $f011 ($data->field('011')) { + if ( $f011->subfield('a') ) { + $issn = $f011->subfield('a'); + $issn =~ s/-//g; + $f011->update( 'a' => $issn ); + } + } + }else{ + my $parser = XML::LibXML->new(); + $parser->recover_silently(1); + my $xslt = XML::LibXSLT->new(); + my $source = $parser->parse_string($data); + + my $style_doc = $parser->parse_file("$kohadir/misc/migration_tools/xsl/RemoveISBN-ISSNHyphensUNIMARC.xsl"); + my $stylesheet = $xslt->parse_stylesheet($style_doc); + my $result_parse = $stylesheet->transform($source); + $data = $stylesheet->output_string($result_parse); + } + } elsif ($encoding eq 'MARC21' || $encoding eq 'NORMARC') { + unless ($isxml){ + foreach my $f020 ($data->field('020')) { + $isbn = $f020->subfield('a'); + $isbn =~ s/-//g; + $f020->update( 'a' => $isbn ); + } + foreach my $f022 ($data->field('022')) { + $issn = $f022->subfield('a'); + $issn =~ s/-//g; + $f022->update( 'a' => $issn ); + } + }else{ + my $parser = XML::LibXML->new(); + $parser->recover_silently(1); + my $xslt = XML::LibXSLT->new(); + my $source = $parser->parse_string($data); + + my $style_doc = $parser->parse_file("$kohadir/misc/migration_tools/xsl/RemoveISBN-ISSNHyphensMARC21.xsl"); + my $stylesheet = $xslt->parse_stylesheet($style_doc); + my $result_parse = $stylesheet->transform($source); + $data = $stylesheet->output_string($result_parse); + } + } + + return $data; +} + sub do_indexing { my ($record_type, $op, $record_dir, $reset_index, $noshadow, $record_format, $zebraidx_log_opt) = @_; --- a/misc/migration_tools/xsl/RemoveISBN-ISSNHyphensMARC21.xsl +++ a/misc/migration_tools/xsl/RemoveISBN-ISSNHyphensMARC21.xsl @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + a + + + + + + + + + + + a + + + + + + + + --- a/misc/migration_tools/xsl/RemoveISBN-ISSNHyphensUNIMARC.xsl +++ a/misc/migration_tools/xsl/RemoveISBN-ISSNHyphensUNIMARC.xsl @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + a + + + + + + + + + + + a + + + + + + + + --