From fd75507a55ceebdbdc06fc62ead9cf376b90d570 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Mon, 28 Sep 2009 17:47:41 +0200 Subject: [PATCH] (bug #3370) add keyword to MARC field mapping This add the support of keyword => MARC field mapping, ton abstract the relation between human readable fields like subtitle, title, authors, location, ... and MARC fields in each framework. This will allow to koha developper to be more flexible with each framework and don't care about the MARC flavour, just require some "keywords" to the user. Conflicts solved : C4/Biblio.pm installer/data/mysql/kohastructure.sql installer/data/mysql/updatedatabase30.pl kohaversion.pl Signed-off-by: Henri-Damien LAURENT --- C4/Biblio.pm | 1 + admin/fieldmapping.pl | 77 ++++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 15 +++++ installer/data/mysql/updatedatabase.pl | 17 +++++ .../prog/en/modules/admin/admin-home.tmpl | 2 + .../prog/en/modules/admin/fieldmapping.tmpl | 77 ++++++++++++++++++++++ 6 files changed, 189 insertions(+) create mode 100755 admin/fieldmapping.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/fieldmapping.tmpl diff --git a/C4/Biblio.pm b/C4/Biblio.pm index e15b93fbe8..a0c325a19c 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -50,6 +50,7 @@ BEGIN { # to get something push @EXPORT, qw( + &Get &GetBiblio &GetBiblioData &GetBiblioItemData diff --git a/admin/fieldmapping.pl b/admin/fieldmapping.pl new file mode 100755 index 0000000000..bd3ca1bf3c --- /dev/null +++ b/admin/fieldmapping.pl @@ -0,0 +1,77 @@ +#!/usr/bin/perl +# Copyright 2009 SARL BibLibre +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# 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 + +use strict; +use warnings; +use CGI; +use C4::Auth; +use C4::Biblio; +use C4::Koha; +use C4::Output; + +my $query = new CGI; + +my $framework = $query->param('framework') || ""; + +my $field = $query->param('fieldname'); +my $fieldcode = $query->param('marcfield'); +my $subfieldcode = $query->param('marcsubfield'); +my $op = $query->param('op'); +my $id = $query->param('id'); + +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "admin/fieldmapping.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); + +# get framework list +my $frameworks = getframeworks(); +my @frameworkloop; +foreach my $thisframeworkcode (keys %$frameworks) { + my $selected = 1 if $thisframeworkcode eq $framework; + my %row =(value => $thisframeworkcode, + selected => $selected, + frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'}, + ); + push @frameworkloop, \%row; +} + +if($op eq "delete" and $id){ + DeleteFieldMapping($id); + print $query->redirect("/cgi-bin/koha/admin/fieldmapping.pl?framework=".$framework); + exit; +} + +# insert operation +if($field and $fieldcode){ + SetFieldMapping($framework, $field, $fieldcode, $subfieldcode); +} + +my $fieldloop = GetFieldMapping($framework); +warn Data::Dumper::Dumper($fieldloop->[1]); + +$template->param( frameworkloop => \@frameworkloop, + framework => $framework, + fields => $fieldloop, + ); + +output_html_with_http_headers $query, $cookie, $template->output; \ No newline at end of file diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index fcc15ca89b..2abb197736 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2482,6 +2482,21 @@ CREATE TABLE `aqorders_items` ( KEY `ordernumber` (`ordernumber`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `fieldmapping` +-- + +DROP TABLE IF EXISTS `fieldmapping`; +CREATE TABLE `fieldmapping` ( + `id` int(11) NOT NULL auto_increment, + `field` varchar(255) NOT NULL, + `frameworkcode` char(4) NOT NULL default '', + `fieldcode` char(3) NOT NULL, + `subfieldcode` char(1) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index e2f4583a51..6c552f6df5 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -2704,6 +2704,23 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { print "Upgrade to $DBversion done (added csv export profiles)\n"; } +#$DBversion = "3.01.00.040"; +$DBversion = "3.01.00.063"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do(" + CREATE TABLE `fieldmapping` ( + `id` int(11) NOT NULL auto_increment, + `field` varchar(255) NOT NULL, + `frameworkcode` char(4) NOT NULL default '', + `fieldcode` char(3) NOT NULL, + `subfieldcode` char(1) NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + "); + SetVersion ($DBversion); +} + + =item Acquisitions update diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tmpl index 32324c8b9b..25d43b667d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tmpl @@ -64,6 +64,8 @@
Create and manage Bibliographic frameworks that define the characteristics of your MARC Records (field and subfield definitions) as well as templates for the MARC editor.
Koha to MARC mapping
Define the mapping between the Koha transactional database (SQL) and the MARC Bibliographic records. Note that the mapping can be defined through MARC Bibliographic Framework. This tool is just a shortcut to speed up linkage.
+
Keywords to MARC mapping
+
Define the mapping between keywords and MARC fields, those keywords are used to find some datas independently of the framework.
MARC Bibliographic framework test
Checks the MARC structure. If you change your MARC Bibliographic framework it's recommended that you run this tool to test for errors in your definition.
Authority types
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/fieldmapping.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/fieldmapping.tmpl new file mode 100644 index 0000000000..fc9b2e3b18 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/fieldmapping.tmpl @@ -0,0 +1,77 @@ + +Koha › Administration › Keyword to MARC Mapping + + + + + + + + + + + +
+
+
+

Keyword to MARC Mapping

+
+ + +
+ + +
+ " /> + + + + + + + + + + + + + + + + + + + + + +
FieldMARC FieldMARC Subfield 
&framework=">Delete
+
+ + +
+
+ +
+ +
+
+ -- 2.11.0