2 # script that rebuild thesaurus from biblio table.
4 # delete FROM `marc_subfield_table` WHERE tag = "606" AND subfieldcode = 9;
10 use C4::AuthoritiesMarc;
11 use Time::HiRes qw(gettimeofday);
14 my ( $fields, $number,$language) = ('',0);
15 my ($version, $verbose, $test_parameter, $field,$delete,$subfields);
19 't' => \$test_parameter,
25 if ($version or !$fields) {
27 Small script to recreate the LANG list in authorised values from existing langs in the catalogue.
28 This script is useful when you migrate your datas with bulkmarcimport.pl as it populates parameters tables that are not modified by bulkmarcimport.
31 \th : this version/help screen
32 \ts : the field or field list where the lang codes are stored.
33 \td : delete every entry of LANG category before doing work.
34 \tl : the language of the language list (fr or en for instance)
36 The table is populated with iso codes and meaning (in french).
37 If the complete language name is unknown, the code is used instead and you will be warned by the script
40 ./buildLANG -d -s "('101a','101b')"
56 'mul' => 'multilingue',
62 'ang' => 'anglo-saxon (ca. 450-1100)',
76 'dum' => 'néerlandais moyen (ca. 1050-1350)',
77 'dut' => 'néerlandais',
82 'fra' => 'français ancien',
84 'frm' => 'français moyen (ca. 1400-1600)',
85 'fro' => 'français ancien (842-ca. 1400)',
86 'gmh' => 'allemand, moyen haut (ca. 1050-1500)',
88 'grc' => 'grec classique',
89 'gre' => 'grec moderne',
93 'ind' => 'indonésien',
94 'ine' => 'indo-européennes, autres',
99 'lan' => 'occitan (post 1500)',
101 'map' => 'malayo-polynésiennes, autres',
103 'nic' => 'nigéro-congolaises, autres',
104 'nor' => 'norvégien',
106 'pro' => 'provencal ancien (jusqu\'à 1500)',
108 'por' => 'portugais',
112 'sam' => 'samaritain',
114 'scr' => 'serbo-croate',
115 'sem' => 'sémitique, autres langues',
117 'sla' => 'slave, autres langues',
123 'uga' => 'ougaritique',
127 ) if $language eq 'fr';
129 my $dbh = C4::Context->dbh;
131 print "deleting lang list\n";
132 $dbh->do("delete from authorised_values where category='LANG'");
135 if ($test_parameter) {
136 print "TESTING MODE ONLY\n DOING NOTHING\n===============\n";
138 my $starttime = gettimeofday;
140 my $sth = $dbh->prepare("SELECT DISTINCT subfieldvalue FROM marc_subfield_table WHERE tag + subfieldcode IN $fields order by subfieldvalue");
145 print "=========================\n";
146 my $sth2 = $dbh->prepare("insert into authorised_values (category, authorised_value, lib) values (?,?,?)");
147 while (my ($langue) = $sth->fetchrow) {
148 $sth2->execute('LANG',$langue,$langue?$codesiso{$langue}:$langue);
149 print "lang : $langue is unknown is iso list\n" unless $codesiso{$langue};
151 print "=========================\n";