+ elsif ( $op && $op eq 'choosemarc' ) {
+ #
+ #
+ # 1ST install, 2nd sub-step : show the user the marcflavour available.
+ #
+ #
+
+ #Choose Marc Flavour
+ #sql data are supposed to be located in installer/data/<dbms>/<language>/marcflavour/marcflavourname
+ # Where <dbms> is database type according to DBD syntax
+ # Where <language> is en|fr or any international abbreviation (provided language hash is updated... This will be a problem with internationlisation.)
+ # Where <level> is a category of requirement : required, recommended optional
+ # level should contain :
+ # SQL File for import With a readable name.
+ # txt File taht explains what this SQL File is meant for.
+ # Could be VERY useful to have A Big file for a kind of library.
+ # But could also be useful to have some Authorised values data set prepared here.
+ # Marcflavour Selection is achieved through radiobuttons.
+ my $langchoice = $query->param('fwklanguage');
+ $langchoice = $query->cookie('KohaOpacLanguage') unless ($langchoice);
+ my $dir =
+ C4::Context->config('intranetdir') . "/installer/data/$info{dbms}/$langchoice/marcflavour";
+ opendir( MYDIR, $dir ) || warn "no open $dir";
+ my @listdir = grep { !/^\./ && -d "$dir/$_" } readdir(MYDIR);
+ closedir MYDIR;
+ my $marcflavour=C4::Context->preference("marcflavour");
+ my @flavourlist;
+ foreach my $marc (@listdir) {
+ my %cell=(
+ "label"=> ucfirst($marc),
+ "code"=>uc($marc),
+ "checked"=>uc($marc) eq $marcflavour);
+# $cell{"description"}= do { local $/ = undef; open INPUT "<$dir/$marc.txt"||"";<INPUT> };
+ push @flavourlist, \%cell;
+ }
+ $template->param( "flavourloop" => \@flavourlist );
+ $template->param( "$op" => 1 );
+ }
+ elsif ( $op && $op eq 'importdatastructure' ) {
+ #
+ #
+ # 1st install, 1st "sub-step" : import kohastructure
+ #
+ #
+ my $datadir = C4::Context->config('intranetdir') . "/installer/data/$info{dbms}";
+ my $error;
+ if ( $info{dbms} eq 'mysql' ) {
+ my $strcmd = "mysql "
+ . ( $info{hostname} ? " -h $info{hostname} " : "" )
+ . ( $info{port} ? " -P $info{port} " : "" )
+ . ( $info{user} ? " -u $info{user} " : "" )
+ . ( $info{password} ? " -p$info{password}" : "" )
+ . " $info{dbname} ";
+ $error = qx($strcmd <$datadir/kohastructure.sql 2>&1 1>/dev/null);
+ }
+ elsif ( $info{dbms} eq 'Pg' ) {
+ my $strcmd = "psql "
+ . ( $info{hostname} ? " -h $info{hostname} " : "" )
+ . ( $info{port} ? " -p $info{port} " : "" )
+ . ( $info{user} ? " -U $info{user} " : "" )
+# . ( $info{password} ? " -W $info{password}" : "" ) # psql will NOT accept a password, but prompts...
+ . " $info{dbname} "; # Therefore, be sure to run 'trust' on localhost in pg_hba.conf -fbcit
+ $error = qx($strcmd -f $datadir/kohastructure.sql 2>&1 1>/dev/null);# Be sure to set 'client_min_messages = error' in postgresql.conf
+ # so that only true errors are returned to stderr or else the installer will
+ # report the import a failure although it really succeded -fbcit
+ }
+ $template->param(
+ "error" => $error,
+ "$op" => 1,
+ );
+ }