2 # script that rebuild thesaurus from biblio table.
4 # delete FROM `marc_subfield_table` WHERE tag = "606" AND subfieldcode = 9;
8 # use MARC::File::USMARC;
13 use C4::AuthoritiesMarc;
14 use Time::HiRes qw(gettimeofday);
17 my ( $fields, $number,$language) = ('',0);
18 my ($version, $verbose, $test_parameter, $field,$delete,$subfields);
22 't' => \$test_parameter,
28 if ($version or !$fields) {
30 Small script to recreate the LANG list in authorised values from existing langs in the catalogue.
31 This script is useful when you migrate your datas with bulkmarcimport.pl as it populates parameters tables that are not modified by bulkmarcimport.
34 \th : this version/help screen
35 \ts : the field or field list where the lang codes are stored.
36 \td : delete every entry of LANG category before doing work.
37 \tl : the language of the language list (fr or en for instance)
39 The table is populated with iso codes and meaning (in french).
40 If the complete language name is unknown, the code is used instead and you will be warned by the script
43 ./buildLANG -d -s "('101a','101b')"
59 'mul' => 'multilingue',
65 'ang' => 'anglo-saxon (ca. 450-1100)',
79 'dum' => 'néerlandais moyen (ca. 1050-1350)',
80 'dut' => 'néerlandais',
85 'fra' => 'français ancien',
87 'frm' => 'français moyen (ca. 1400-1600)',
88 'fro' => 'français ancien (842-ca. 1400)',
89 'gmh' => 'allemand, moyen haut (ca. 1050-1500)',
91 'grc' => 'grec classique',
92 'gre' => 'grec moderne',
96 'ind' => 'indonésien',
97 'ine' => 'indo-européennes, autres',
102 'lan' => 'occitan (post 1500)',
104 'map' => 'malayo-polynésiennes, autres',
106 'nic' => 'nigéro-congolaises, autres',
107 'nor' => 'norvégien',
109 'pro' => 'provencal ancien (jusqu\'à 1500)',
111 'por' => 'portugais',
115 'sam' => 'samaritain',
117 'scr' => 'serbo-croate',
118 'sem' => 'sémitique, autres langues',
120 'sla' => 'slave, autres langues',
126 'uga' => 'ougaritique',
130 ) if $language eq 'fr';
132 my $dbh = C4::Context->dbh;
134 print "deleting lang list\n";
135 $dbh->do("delete from authorised_values where category='LANG'");
138 if ($test_parameter) {
139 print "TESTING MODE ONLY\n DOING NOTHING\n===============\n";
141 my $starttime = gettimeofday;
143 my $sth = $dbh->prepare("SELECT DISTINCT subfieldvalue FROM marc_subfield_table WHERE tag + subfieldcode IN $fields order by subfieldvalue");
148 print "=========================\n";
149 my $sth2 = $dbh->prepare("insert into authorised_values (category, authorised_value, lib) values (?,?,?)");
150 while (my ($langue) = $sth->fetchrow) {
151 $sth2->execute('LANG',$langue,$langue?$codesiso{$langue}:$langue);
152 print "lang : $langue is unknown is iso list\n" unless $codesiso{$langue};
154 print "=========================\n";