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',
75 'fra' => 'français ancien',
78 'grc' => 'grec classique',
79 'gre' => 'grec moderne',
85 'dut' => 'néerlandais',
97 'scr' => 'serbo-croate',
98 ) if $language eq 'fr';
100 my $dbh = C4::Context->dbh;
102 print "deleting lang list\n";
103 $dbh->do("delete from authorised_values where category='LANG'");
106 if ($test_parameter) {
107 print "TESTING MODE ONLY\n DOING NOTHING\n===============\n";
109 my $starttime = gettimeofday;
111 my $sth = $dbh->prepare("SELECT DISTINCT subfieldvalue FROM marc_subfield_table WHERE tag + subfieldcode IN $fields order by subfieldvalue");
116 print "=========================\n";
117 my $sth2 = $dbh->prepare("insert into authorised_values (category, authorised_value, lib) values (?,?,?)");
118 while (my ($langue) = $sth->fetchrow) {
119 $sth2->execute('LANG',$langue,$langue?$codesiso{$langue}:$langue);
120 print "lang : $langue is unknown is iso list\n" unless $codesiso{$langue};
122 print "=========================\n";