From 30e6a5526883879bfd580f2b98085f2ad3265703 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Mon, 29 Oct 2007 17:15:40 -0500 Subject: [PATCH] Changes to install.pl Changing structure : adding a marcflavour directory to data/language/ This directory shall have the same subdirectory structure as /data/language This allows for instance adding optionals CD-Framework or Serials Frameworks keeping default frameworks mandatory. install.pl was changed in order to manage those changes. Could be changed in order to skip marcflavour selection if marcflavour directory is not found. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- .../mandatory/authorities_normal_marc21.sql | 0 .../mandatory/authorities_normal_marc21.txt | 0 .../mandatory/marc21_framework_DEFAULT.sql | 0 .../mandatory/marc21_framework_DEFAULT.txt | 0 installer/install.pl | 136 ++++++++++++++---- .../prog/en/modules/installer/step3.tmpl | 51 +++++-- 6 files changed, 149 insertions(+), 38 deletions(-) rename installer/data/en/{ => marcflavour/marc21}/mandatory/authorities_normal_marc21.sql (100%) rename installer/data/en/{ => marcflavour/marc21}/mandatory/authorities_normal_marc21.txt (100%) rename installer/data/en/{ => marcflavour/marc21}/mandatory/marc21_framework_DEFAULT.sql (100%) rename installer/data/en/{ => marcflavour/marc21}/mandatory/marc21_framework_DEFAULT.txt (100%) diff --git a/installer/data/en/mandatory/authorities_normal_marc21.sql b/installer/data/en/marcflavour/marc21/mandatory/authorities_normal_marc21.sql similarity index 100% rename from installer/data/en/mandatory/authorities_normal_marc21.sql rename to installer/data/en/marcflavour/marc21/mandatory/authorities_normal_marc21.sql diff --git a/installer/data/en/mandatory/authorities_normal_marc21.txt b/installer/data/en/marcflavour/marc21/mandatory/authorities_normal_marc21.txt similarity index 100% rename from installer/data/en/mandatory/authorities_normal_marc21.txt rename to installer/data/en/marcflavour/marc21/mandatory/authorities_normal_marc21.txt diff --git a/installer/data/en/mandatory/marc21_framework_DEFAULT.sql b/installer/data/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql similarity index 100% rename from installer/data/en/mandatory/marc21_framework_DEFAULT.sql rename to installer/data/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql diff --git a/installer/data/en/mandatory/marc21_framework_DEFAULT.txt b/installer/data/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.txt similarity index 100% rename from installer/data/en/mandatory/marc21_framework_DEFAULT.txt rename to installer/data/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.txt diff --git a/installer/install.pl b/installer/install.pl index 1afe245651..ede3ecca84 100755 --- a/installer/install.pl +++ b/installer/install.pl @@ -163,7 +163,7 @@ if ( $step && $step == 1 ) { } elsif ( $step && $step == 2 ) { # -#STEP 2 Check Database conn~ection and access +#STEP 2 Check Database connection and access # $template->param(%info); my $checkmysql = $query->param("checkmysql"); @@ -372,29 +372,23 @@ elsif ( $step && $step == 3 ) { # Framework Selection is achieved through checking boxes. my $langchoice = $query->param('fwklanguage'); $langchoice = $query->cookie('KohaOpacLanguage') unless ($langchoice); - my $dir = C4::Context->config('intranetdir') . "/installer/data/"; - opendir( MYDIR, $dir ); - my @listdir = grep { !/^\.|CVS/ && -d "$dir/$_" } readdir(MYDIR); - closedir MYDIR; - my $frmwklangs = getFrameworkLanguages(); - my @languages; - map { - push @languages, - { - 'dirname' => $_->{'language_code'}, - 'languagedescription' => $_->{'language_name'}, - 'checked' => ( $_->{'language_code'} eq $langchoice ) - } - if ( $_->{'language_code'} ); - } @$frmwklangs; - $template->param( "languagelist" => \@languages ); + my $marcflavour = $query->param('marcflavour'); + $marcflavour = C4::Context->preference('marcflavour') unless ($marcflavour); + #Insert into database the selected marcflavour + my $request = + $dbh->prepare( + "INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('marcflavour','$marcflavour','Define global MARC flavor (MARC21 or UNIMARC) used for character encoding','MARC21|UNIMARC','Choice');" + ); + $request->execute; + undef $/; - $dir = - C4::Context->config('intranetdir') . "/installer/data/$langchoice"; + my $dir = + C4::Context->config('intranetdir') . "/installer/data/$langchoice/marcflavour/".lc($marcflavour); opendir( MYDIR, $dir ) || warn "no open $dir"; - @listdir = sort grep { !/^\.|CVS/ && -d "$dir/$_" } readdir(MYDIR); + my @listdir = sort grep { !/^\.|CVS|marcflavour/ && -d "$dir/$_" } readdir(MYDIR); closedir MYDIR; - my @levellist; + + my @fwklist; my $request = $dbh->prepare( "SELECT value FROM systempreferences WHERE variable='FrameworksLoaded'" @@ -407,19 +401,66 @@ elsif ( $step && $step == 3 ) { $frameworksloaded{$_} = 1; } foreach my $requirelevel (@listdir) { - $dir = - C4::Context->config('intranetdir') - . "/installer/data/$langchoice/$requirelevel"; - opendir( MYDIR, $dir ); + opendir( MYDIR, "$dir/$requirelevel" ); + my @listname = + grep { !/^\.|CVS/ && -f "$dir/$requirelevel/$_" && $_ =~ m/\.sql$/ } + readdir(MYDIR); + closedir MYDIR; + my %cell; + my @frameworklist; + map { + my $name = substr( $_, 0, -4 ); + open FILE, "< $dir/$requirelevel/$name.txt"; + my $lines = ; + $lines =~ s/\n|\r/
/g; + use utf8; + utf8::encode($lines) unless ( utf8::is_utf8($lines) ); + push @frameworklist, + { + 'fwkname' => $name, + 'fwkfile' => "$dir/$requirelevel/$_", + 'fwkdescription' => $lines, + 'checked' => ( + ( + $frameworksloaded{$_} + || ( $requirelevel =~ + /(mandatory|requi|oblig|necess)/i ) + ) ? 1 : 0 + ) + }; + } @listname; + my @fwks = + sort { $a->{'fwkname'} lt $b->{'fwkname'} } @frameworklist; + +# $cell{"mandatory"}=($requirelevel=~/(mandatory|requi|oblig|necess)/i); + $cell{"frameworks"} = \@fwks; + $cell{"label"} = ucfirst($requirelevel); + $cell{"code"} = lc($requirelevel); + push @fwklist, \%cell; + } + $template->param( "frameworksloop" => \@fwklist ); + $template->param( "marcflavour" => ucfirst($marcflavour)); + + $dir = + C4::Context->config('intranetdir') . "/installer/data/$langchoice"; + opendir( MYDIR, $dir ) || warn "no open $dir"; + @listdir = sort grep { !/^\.|CVS|marcflavour/ && -d "$dir/$_" } readdir(MYDIR); + closedir MYDIR; + my @levellist; + foreach ( split( /\|/, $frameworksloaded ) ) { + $frameworksloaded{$_} = 1; + } + foreach my $requirelevel (@listdir) { + opendir( MYDIR, "$dir/$requirelevel" ); my @listname = - grep { !/^\.|CVS/ && -f "$dir/$_" && $_ =~ m/\.sql$/ } + grep { !/^\.|CVS/ && -f "$dir/$requirelevel/$_" && $_ =~ m/\.sql$/ } readdir(MYDIR); closedir MYDIR; my %cell; my @frameworklist; map { my $name = substr( $_, 0, -4 ); - open FILE, "< $dir/$name.txt"; + open FILE, "< $dir/$requirelevel/$name.txt"; my $lines = ; $lines =~ s/\n|\r/
/g; use utf8; @@ -427,7 +468,7 @@ elsif ( $step && $step == 3 ) { push @frameworklist, { 'fwkname' => $name, - 'fwkfile' => "$dir/$_", + 'fwkfile' => "$dir/$requirelevel/$_", 'fwkdescription' => $lines, 'checked' => ( ( @@ -441,7 +482,7 @@ elsif ( $step && $step == 3 ) { my @fwks = sort { $a->{'fwkname'} lt $b->{'fwkname'} } @frameworklist; - # $cell{"mandatory"}=($requirelevel=~/(mandatory|requi|oblig|necess)/i); +# $cell{"mandatory"}=($requirelevel=~/(mandatory|requi|oblig|necess)/i); $cell{"frameworks"} = \@fwks; $cell{"label"} = ucfirst($requirelevel); $cell{"code"} = lc($requirelevel); @@ -450,6 +491,43 @@ elsif ( $step && $step == 3 ) { $template->param( "levelloop" => \@levellist ); $template->param( "$op" => 1 ); } + 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//marcflavour/marcflavourname + # Where is en|fr or any international abbreviation (provided language hash is updated... This will be a problem with internationlisation.) + # Where 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/$langchoice/marcflavour"; + opendir( MYDIR, $dir ) || warn "no open $dir"; + my @listdir = grep { !/^\.|CVS/ && -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"||""; }; + push @flavourlist, \%cell; + } + $template->param( "flavourloop" => \@flavourlist ); + $template->param( "$op" => 1 ); + } elsif ( $op && $op eq 'importdatastructure' ) { # # diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tmpl index a60a4663bb..b291822235 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tmpl @@ -80,23 +80,56 @@

Congratulations, Installation complete

If this page does not redirect in 5 seconds, click here.

+ +

Select your MARC flavour

+
+ + +

+ +

+ + " checked />
+ + " />
+ +
+ +

+

Click Next to continue

+
+

Selecting Default Settings

-

Each language has a set of default settings that cover a wide range of configuration options. Please select a language from the dropdown or use the default lanaguage already selected.

-

" checked="checked" /> + + " /> + + + + + () + + - +

-

+ +

Other data

@@ -211,7 +244,7 @@

We are ready to do some basic configuration. Please - install basic configuration settings + install basic configuration settings to continue the installation.

-- 2.39.5