From cd6f87a689811016219bced489637f8fb69366ca Mon Sep 17 00:00:00 2001 From: tipaul Date: Mon, 3 Jan 2005 12:59:49 +0000 Subject: [PATCH] Auto-build LANG authorized values --- misc/migration_tools/buildLANG.pl | 122 ++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100755 misc/migration_tools/buildLANG.pl diff --git a/misc/migration_tools/buildLANG.pl b/misc/migration_tools/buildLANG.pl new file mode 100755 index 0000000000..0e28493b55 --- /dev/null +++ b/misc/migration_tools/buildLANG.pl @@ -0,0 +1,122 @@ +#!/usr/bin/perl +# script that rebuild thesaurus from biblio table. + +# delete FROM `marc_subfield_table` WHERE tag = "606" AND subfieldcode = 9; +use strict; + +# Koha modules used +# use MARC::File::USMARC; +# use MARC::Record; +# use MARC::Batch; +use C4::Context; +use C4::Biblio; +use C4::AuthoritiesMarc; +use Time::HiRes qw(gettimeofday); + +use Getopt::Long; +my ( $fields, $number,$language) = ('',0); +my ($version, $verbose, $test_parameter, $field,$delete,$subfields); +GetOptions( + 'h' => \$version, + 'd' => \$delete, + 't' => \$test_parameter, + 's:s' => \$fields, + 'v' => \$verbose, + 'l:s' => \$language, +); + +if ($version or !$fields) { + print < 'english', + 'fre' => 'french' + ); + +%codesiso = ( + 'mis' => 'diverses', + 'und' => 'inconnue', + 'mul' => 'multilingue', + 'ger' => 'allemand', + 'eng' => 'anglais', + 'ara' => 'arabe', + 'arm' => 'arménien', + 'baq' => 'basque', + 'ber' => 'berbere', + 'bre' => 'breton', + 'bul' => 'bulgare', + 'cat' => 'catalan', + 'chi' => 'chinois', + 'cro' => 'croate', + 'dan' => 'danois', + 'spa' => 'espagnol', + 'esp' => 'espéranto', + 'fin' => 'finnois', + 'fra' => 'français ancien', + 'fre' => 'français', + 'wel' => 'gallois', + 'grc' => 'grec classique', + 'gre' => 'grec moderne', + 'heb' => 'hébreu', + 'hun' => 'hongrois', + 'ita' => 'italien', + 'jap' => 'japonais', + 'lat' => 'latin', + 'dut' => 'néerlandais', + 'nor' => 'norvégien', + 'pol' => 'polonais', + 'por' => 'portugais', + 'rum' => 'roumain', + 'rus' => 'russe', + 'ser' => 'serbe', + 'swe' => 'suedois', + 'cze' => 'tchèque', + 'tur' => 'turc', + 'ukr' => 'ukraine', + 'slo' => 'slovène', + 'scr' => 'serbo-croate', + ) if $language eq 'fr'; + +my $dbh = C4::Context->dbh; +if ($delete) { + print "deleting lang list\n"; + $dbh->do("delete from authorised_values where category='LANG'"); +} + +if ($test_parameter) { + print "TESTING MODE ONLY\n DOING NOTHING\n===============\n"; +} +my $starttime = gettimeofday; + +my $sth = $dbh->prepare("SELECT DISTINCT subfieldvalue FROM marc_subfield_table WHERE tag + subfieldcode IN $fields order by subfieldvalue"); + +$sth->execute; +my $i=1; + +print "=========================\n"; +my $sth2 = $dbh->prepare("insert into authorised_values (category, authorised_value, lib) values (?,?,?)"); +while (my ($langue) = $sth->fetchrow) { + $sth2->execute('LANG',$langue,$langue?$codesiso{$langue}:$langue); + print "lang : $langue is unknown is iso list\n" unless $codesiso{$langue}; +} +print "=========================\n"; -- 2.39.5