From fe631a8205c2d18a6838dd6f0e7a37aff05176a2 Mon Sep 17 00:00:00 2001 From: tgarip1957 Date: Fri, 19 May 2006 17:58:40 +0000 Subject: [PATCH] Authority tables are modified to be compatible with new MARC frameworks. This change is part of Authority Linking & Zebra authorities. Requires change in Mysql database. It will break head unless all changes regarding this is implemented. This warning will take place on all commits regarding this --- admin/auth_subfields_structure.pl | 243 +++++++++++-- admin/auth_tag_structure.pl | 16 +- authorities/auth_linker.pl | 169 ++++++++++ authorities/authorities.pl | 318 +++++++++++------- authorities/blinddetail-linker.pl | 127 +++++++ .../prog/en/authorities/auth_linker.tmpl | 58 ++++ .../en/authorities/blinddetail-linker.tmpl | 67 ++++ .../en/authorities/linkresultlist-auth.tmpl | 94 ++++++ 8 files changed, 926 insertions(+), 166 deletions(-) create mode 100644 authorities/auth_linker.pl create mode 100644 authorities/blinddetail-linker.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/authorities/auth_linker.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/authorities/blinddetail-linker.tmpl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/authorities/linkresultlist-auth.tmpl diff --git a/admin/auth_subfields_structure.pl b/admin/auth_subfields_structure.pl index 50425351d3..0fdb0be869 100755 --- a/admin/auth_subfields_structure.pl +++ b/admin/auth_subfields_structure.pl @@ -33,13 +33,15 @@ sub StringSearch { $searchstring=~ s/\'/\\\'/g; my @data=split(' ',$searchstring); my $count=@data; - my $sth=$dbh->prepare("Select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,seealso,authorised_value,value_builder from auth_subfield_structure where (tagfield like ? and authtypecode=?) order by tagfield"); + my $sth=$dbh->prepare("Select * from auth_subfield_structure where (tagfield like ? and authtypecode=?) order by tagfield"); $sth->execute("$searchstring%",$authtypecode); my @results; my $cnt=0; + my $u=1; while (my $data=$sth->fetchrow_hashref){ push(@results,$data); $cnt ++; + $u++; } $sth->finish; $dbh->disconnect; @@ -84,9 +86,18 @@ if ($op eq 'add_form') { my $data; my $dbh = C4::Context->dbh; my $more_subfields = $input->param("more_subfields")+1; + # builds kohafield tables + my @kohafields; + push @kohafields, ""; + my $sth2=$dbh->prepare("SHOW COLUMNS from auth_header"); + $sth2->execute; + while ((my $field) = $sth2->fetchrow_array) { + push @kohafields, "auth_header.".$field; + } # build authorised value list - my $sth2 = $dbh->prepare("select distinct category from authorised_values"); + $sth2->finish; + $sth2 = $dbh->prepare("select distinct category from authorised_values"); $sth2->execute; my @authorised_values; push @authorised_values,""; @@ -95,9 +106,19 @@ if ($op eq 'add_form') { } push (@authorised_values,"branches"); push (@authorised_values,"itemtypes"); + # build value_builder list my @value_builder=(''); - opendir(DIR, "../value_builder") || die "can't opendir ../value_builder: $!"; + + # read value_builder directory. + # 2 cases here : on CVS install, $cgidir does not need a /cgi-bin + # on a standard install, /cgi-bin need to be added. + # test one, then the other + my $cgidir = C4::Context->intranetdir ."/cgi-bin"; + unless (opendir(DIR, "$cgidir/value_builder")) { + $cgidir = C4::Context->intranetdir; + opendir(DIR, "$cgidir/value_builder") || die "can't opendir $cgidir/value_builder: $!"; + } while (my $line = readdir(DIR)) { if ($line =~ /\.pl$/) { push (@value_builder,$line); @@ -106,45 +127,108 @@ if ($op eq 'add_form') { closedir DIR; # build values list - my $sth=$dbh->prepare("select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,seealso,authorised_value,value_builder from auth_subfield_structure where tagfield=? and authtypecode=?"); # and tagsubfield='$tagsubfield'"); + my $sth=$dbh->prepare("select * from auth_subfield_structure where tagfield=? and authtypecode=?"); # and tagsubfield='$tagsubfield'"); $sth->execute($tagfield,$authtypecode); my @loop_data = (); - my $toggle="white"; + my $toggle=1; my $i=0; while ($data =$sth->fetchrow_hashref) { + my %row_data; # get a fresh hash for the row data - if ($toggle eq 'white'){ - $toggle="#ffffcc"; + if ($toggle eq 1){ + $toggle=0; } else { - $toggle="white"; + $toggle=1; } $row_data{tab} = CGI::scrolling_list(-name=>'tab', + -id=>"tab$i", -values=>['-1','0'], - -labels => {'-1' =>'No (ignore)','0'=>'yes' + -labels => {'-1' =>'ignore','0'=>'0', }, -default=>$data->{'tab'}, -size=>1, -multiple=>0, ); - $row_data{tagsubfield} =$data->{'tagsubfield'}.""; + $row_data{ohidden} = CGI::scrolling_list(-name=>'ohidden', + -id=>"ohidden$i", + -values=>['0','1','2'], + -labels => {'0'=>'Show','1'=>'Show Collapsed', + '2' =>'Hide', + }, + -default=>substr($data->{'hidden'},0,1), + -size=>1, + -multiple=>0, + ); + $row_data{ihidden} = CGI::scrolling_list(-name=>'ihidden', + -id=>"ihidden$i", + -values=>['0','1','2'], + -labels => {'0'=>'Show','1'=>'Show Collapsed', + '2' =>'Hide', + }, + -default=>substr($data->{'hidden'},1,1), + -size=>1, + -multiple=>0, + ); + $row_data{ehidden} = CGI::scrolling_list(-name=>'ehidden', + -id=>"ehidden$i", + -values=>['0','1','2'], + -labels => {'0'=>'Show','1'=>'Show Collapsed', + '2' =>'Hide', + }, + -default=>substr($data->{'hidden'},2,1), + -size=>1, + -multiple=>0, + ); + $row_data{tagsubfield} =$data->{'tagsubfield'}."{'tagsubfield'}."\" id=\"tagsubfield\">"; $row_data{liblibrarian} = CGI::escapeHTML($data->{'liblibrarian'}); $row_data{libopac} = CGI::escapeHTML($data->{'libopac'}); $row_data{seealso} = CGI::escapeHTML($data->{'seealso'}); + $row_data{kohafield}= CGI::scrolling_list( -name=>"kohafield", + -id=>"kohafield$i", + -values=> \@kohafields, + -default=> "$data->{'kohafield'}", + -size=>1, + -multiple=>0, + ); $row_data{authorised_value} = CGI::scrolling_list(-name=>'authorised_value', + -id=>'authorised_value', -values=> \@authorised_values, -default=>$data->{'authorised_value'}, -size=>1, -multiple=>0, ); $row_data{value_builder} = CGI::scrolling_list(-name=>'value_builder', + -id=>'value_builder', -values=> \@value_builder, -default=>$data->{'value_builder'}, -size=>1, -multiple=>0, ); - $row_data{repeatable} = CGI::checkbox("repeatable$i",$data->{'repeatable'}?'checked':'',1,''); - $row_data{mandatory} = CGI::checkbox("mandatory$i",$data->{'mandatory'}?'checked':'',1,''); - $row_data{bgcolor} = $toggle; + + $row_data{repeatable} = CGI::checkbox(-name=>"repeatable$i", + -checked => $data->{'repeatable'}?'checked':'', + -value => 1, + -label => '', + -id => "repeatable$i"); + $row_data{mandatory} = CGI::checkbox(-name => "mandatory$i", + -checked => $data->{'mandatory'}?'checked':'', + -value => 1, + -label => '', + -id => "mandatory$i"); + $row_data{hidden} = CGI::escapeHTML($data->{hidden}) ; + $row_data{isurl} = CGI::checkbox( -name => "isurl$i", + -id => "isurl$i", + -checked => $data->{'isurl'}?'checked':'', + -value => 1, + -label => ''); + $row_data{link} = CGI::checkbox( -name => "link$i", + -id => "link$i", + -checked => $data->{'link'}?'checked':'', + -value => 1, + -label => ''); + $row_data{row} = $i; + $row_data{toggle} = $toggle; + # $row_data{link} = CGI::escapeHTML($data->{'link'}); push(@loop_data, \%row_data); $i++; } @@ -152,25 +236,86 @@ if ($op eq 'add_form') { for (my $i=1;$i<=$more_subfields;$i++) { my %row_data; # get a fresh hash for the row data $row_data{tab} = CGI::scrolling_list(-name=>'tab', + -id => "tab$i", -values=>['-1','0'], - -labels => {'-1' =>'no (ignore)','0'=>'yes', + -labels => {'-1' =>'ignore','0'=>'0', }, -default=>"", -size=>1, -multiple=>0, ); - $row_data{tagsubfield} = "{'tagsubfield'}."\" size=\"3\" maxlength=\"1\">"; + $row_data{ohidden} = CGI::scrolling_list(-name=>'ohidden', + -id=>"ohidden$i", + -values=>['0','1','2'], + -labels => {'0'=>'Show','1'=>'Show Collapsed', + '2' =>'Hide', + }, + -default=>"0", + -size=>1, + -multiple=>0, + ); + + $row_data{ihidden} = CGI::scrolling_list(-name=>'ihidden', + -id=>"ihidden$i", + -values=>['0','1','2'], + -labels => {'0'=>'Show','1'=>'Show Collapsed', + '2' =>'Hide', + }, + -default=>"0", + -size=>1, + -multiple=>0, + ); + $row_data{ehidden} = CGI::scrolling_list(-name=>'ehidden', + -id=>"ehidden$i", + -values=>['0','1','2'], + -labels => {'0'=>'Show','1'=>'Show Collapsed', + '2' =>'Hide', + }, + -default=>"0", + -size=>1, + -multiple=>0, + ); + $row_data{tagsubfield} = "{'tagsubfield'}."\" size=\"1\" id=\"tagsubfield\" maxlength=\"1\">"; $row_data{liblibrarian} = ""; $row_data{libopac} = ""; $row_data{seealso} = ""; - $row_data{repeatable} = CGI::checkbox('repeatable','',1,''); - $row_data{mandatory} = CGI::checkbox('mandatory','',1,''); + $row_data{hidden} = "000"; + $row_data{repeatable} = CGI::checkbox( -name=> 'repeatable', + -id => "repeatable$i", + -checked => '', + -value => 1, + -label => ''); + $row_data{mandatory} = CGI::checkbox( -name=> 'mandatory', + -id => "mandatory$i", + -checked => '', + -value => 1, + -label => ''); + $row_data{isurl} = CGI::checkbox(-name => 'isurl', + -id => "isurl$i", + -checked => '', + -value => 1, + -label => ''); + $row_data{kohafield}= CGI::scrolling_list( -name=>'kohafield', + -id => "kohafield$i", + -values=> \@kohafields, + -default=> "", + -size=>1, + -multiple=>0, + ); $row_data{authorised_value} = CGI::scrolling_list(-name=>'authorised_value', + -id => 'authorised_value', -values=> \@authorised_values, -size=>1, -multiple=>0, ); - $row_data{bgcolor} = $toggle; + $row_data{link} = CGI::checkbox( -name => "link", + -id => "link$i", + -checked => '', + -value => 1, + -label => ''); + # $row_data{link} = CGI::escapeHTML($data->{'link'}); + $row_data{toggle} = $toggle; + $row_data{row} = $i; push(@loop_data, \%row_data); } $template->param('use-heading-flags-p' => 1); @@ -187,15 +332,23 @@ if ($op eq 'add_form') { } elsif ($op eq 'add_validate') { my $dbh = C4::Context->dbh; $template->param(tagfield => "$input->param('tagfield')"); - my $sth=$dbh->prepare("replace auth_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,seealso,authorised_value,value_builder,authtypecode) - values (?,?,?,?,?,?,?,?,?,?,?)"); + my $sth=$dbh->prepare("replace auth_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,authtypecode,value_builder,hidden,isurl, link) + values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); my @tagsubfield = $input->param('tagsubfield'); my @liblibrarian = $input->param('liblibrarian'); my @libopac = $input->param('libopac'); + my @kohafield = $input->param('kohafield'); my @tab = $input->param('tab'); my @seealso = $input->param('seealso'); + #my @hidden = $input->param('hidden'); + my @hidden; + my @ohidden = $input->param('ohidden'); + my @ihidden = $input->param('ihidden'); + my @ehidden = $input->param('ehidden'); my @authorised_values = $input->param('authorised_value'); +# my $authtypecodes = $input->param('authtypecode'); my @value_builder =$input->param('value_builder'); + my @link =$input->param('link'); for (my $i=0; $i<= $#tagsubfield ; $i++) { my $tagfield =$input->param('tagfield'); my $tagsubfield =$tagsubfield[$i]; @@ -204,10 +357,15 @@ if ($op eq 'add_form') { my $libopac =$libopac[$i]; my $repeatable =$input->param("repeatable$i")?1:0; my $mandatory =$input->param("mandatory$i")?1:0; + my $kohafield =$kohafield[$i]; my $tab =$tab[$i]; my $seealso =$seealso[$i]; my $authorised_value =$authorised_values[$i]; +# my $authtypecode =$authtypecodes; my $value_builder=$value_builder[$i]; + my $hidden = $ohidden[$i].$ihidden[$i].$ehidden[$i]; #collate from 3 hiddens; + my $isurl = $input->param("isurl$i")?1:0; + my $link = $input->param("link$i")?1:0; if ($liblibrarian) { unless (C4::Context->config('demo') eq 1) { $sth->execute ($tagfield, @@ -216,10 +374,18 @@ if ($op eq 'add_form') { $libopac, $repeatable, $mandatory, + $kohafield, $tab, $seealso, $authorised_value, - $value_builder,$authtypecode); + $authtypecode, + $value_builder, + $hidden, + $isurl, + + + $link, + ); } } } @@ -232,8 +398,9 @@ if ($op eq 'add_form') { # called by default form, used to confirm deletion of data in DB } elsif ($op eq 'delete_confirm') { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,authorised_value,value_builder from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?"); - $sth->execute($tagfield,$tagsubfield,$authtypecode); + my $sth=$dbh->prepare("select * from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?"); + #FIXME : called with 2 bind variables when 3 are needed + $sth->execute($tagfield,$tagsubfield); my $data=$sth->fetchrow_hashref; $sth->finish; $template->param(liblibrarian => $data->{'liblibrarian'}, @@ -251,7 +418,6 @@ if ($op eq 'add_form') { unless (C4::Context->config('demo') eq 1) { my $sth=$dbh->prepare("delete from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?"); $sth->execute($tagfield,$tagsubfield,$authtypecode); - warn "DEL : $tagfield,$tagsubfield,$authtypecode"; $sth->finish; } print "Content-Type: text/html\n\n"; @@ -262,41 +428,52 @@ if ($op eq 'add_form') { } else { # DEFAULT my $env; my ($count,$results)=StringSearch($env,$tagfield,$authtypecode); - my $toggle="white"; + my $toggle=1; my @loop_data = (); for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ - if ($toggle eq 'white'){ - $toggle="#ffffcc"; + if ($toggle eq 1){ + $toggle=0; } else { - $toggle="white"; + $toggle=1; } my %row_data; # get a fresh hash for the row data $row_data{tagfield} = $results->[$i]{'tagfield'}; $row_data{tagsubfield} = $results->[$i]{'tagsubfield'}; $row_data{liblibrarian} = $results->[$i]{'liblibrarian'}; + $row_data{kohafield} = $results->[$i]{'kohafield'}; $row_data{repeatable} = $results->[$i]{'repeatable'}; $row_data{mandatory} = $results->[$i]{'mandatory'}; $row_data{tab} = $results->[$i]{'tab'}; $row_data{seealso} = $results->[$i]{'seealso'}; $row_data{authorised_value} = $results->[$i]{'authorised_value'}; + $row_data{authtypecode} = $results->[$i]{'authtypecode'}; $row_data{value_builder} = $results->[$i]{'value_builder'}; + $row_data{hidden} = $results->[$i]{'hidden'} if($results->[$i]{'hidden'} gt "000") ; + $row_data{isurl} = $results->[$i]{'isurl'}; + $row_data{link} = $results->[$i]{'link'}; $row_data{delete} = "$script_name?op=delete_confirm&tagfield=$tagfield&tagsubfield=".$results->[$i]{'tagsubfield'}."&authtypecode=$authtypecode"; - $row_data{bgcolor} = $toggle; + $row_data{toggle} = $toggle; if ($row_data{tab} eq -1) { $row_data{subfield_ignored} = 1; } + push(@loop_data, \%row_data); } $template->param(loop => \@loop_data); - $template->param(edit => ""); + $template->param(edit_tagfield => $tagfield, + edit_authtypecode => $authtypecode); + if ($offset>0) { my $prevpage = $offset-$pagesize; - $template->param(prev =>""); + $template->param(prev =>""); } if ($offset+$pagesize<$count) { my $nextpage =$offset+$pagesize; - $template->param(next => ""); + $template->param(next => ""); } } #---- END $OP eq DEFAULT - +$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), + ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/admin/auth_tag_structure.pl b/admin/auth_tag_structure.pl index f69b6a591c..ea96e165ee 100755 --- a/admin/auth_tag_structure.pl +++ b/admin/auth_tag_structure.pl @@ -73,7 +73,7 @@ foreach my $thisauthtype (keys %$authtypes) { my $sth; # check that authtype framework is defined in auth_tag_structure if we are on a default action if (!$op or $op eq 'authtype_create_confirm') { -warn "IN"; +#warn "IN"; $sth=$dbh->prepare("select count(*) from auth_tag_structure where authtypecode=?"); $sth->execute($authtypecode); my ($authtypeexist) = $sth->fetchrow; @@ -204,7 +204,7 @@ if ($op eq 'add_form') { ################## DEFAULT ################################## } else { # DEFAULT # here, $op can be unset or set to "authtype_create_confirm". - warn "authtype : $authtypecode"; +# warn "authtype : $authtypecode"; if ($searchfield ne '') { $template->param(searchfield => $searchfield); } @@ -279,19 +279,19 @@ sub StringSearch { # sub duplicate_auth_framework { my ($newauthtype,$oldauthtype) = @_; - warn "TO $newauthtype FROM $oldauthtype"; +# warn "TO $newauthtype FROM $oldauthtype"; my $sth = $dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from auth_tag_structure where authtypecode=?"); $sth->execute($oldauthtype); - my $sth_insert = $dbh->prepare("insert into auth_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, authtypecode) values (?,?,?,?,?,?,?)"); + my $sth_insert = $dbh->prepare("insert into auth_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, authtypecode) values (?,?,?,?,?,?,?)"); while ( my ($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value) = $sth->fetchrow) { $sth_insert->execute($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value,$newauthtype); } - $sth = $dbh->prepare("select authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,authorised_value,seealso from auth_subfield_structure where authtypecode=?"); + $sth = $dbh->prepare("select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,value_builder,seealso,hidden,link from auth_subfield_structure where authtypecode=?"); $sth->execute($oldauthtype); - $sth_insert = $dbh->prepare("insert into auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,tab,authorised_value,value_builder,seealso) values (?,?,?,?,?,?,?,?,?,?,?)"); - while ( my ($authtypecode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $tab, $authorised_value, $thesaurus_category, $seealso) = $sth->fetchrow) { - $sth_insert->execute($newauthtype, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $tab, $authorised_value, $thesaurus_category, $seealso); + $sth_insert = $dbh->prepare("insert into auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,value_builder,seealso,hidden,link) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); + while ( my ( $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield,$tab, $authorised_value, $thesaurus_category, $seealso,$hidden,$link) = $sth->fetchrow) { + $sth_insert->execute($newauthtype, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory,$kohafield, $tab, $authorised_value, $thesaurus_category, $seealso,$hidden,$link); } } diff --git a/authorities/auth_linker.pl b/authorities/auth_linker.pl new file mode 100644 index 0000000000..6f495dedc5 --- /dev/null +++ b/authorities/auth_linker.pl @@ -0,0 +1,169 @@ +#!/usr/bin/perl +# WARNING: 4-character tab stops here + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +require Exporter; +use CGI; +use C4::Auth; +use HTML::Template; +use C4::Context; +use C4::Search; +use C4::Auth; +use C4::Output; +use C4::Interface::CGI::Output; +use C4::AuthoritiesMarc; +#use C4::Biblio; +use C4::Acquisition; +use C4::Koha; # XXX subfield_is_koha_internal_p + +my $query=new CGI; +my $op = $query->param('op'); +my $authtypecode = $query->param('authtypecode'); +my $index = $query->param('index'); +# my $category = $query->param('category'); +my $resultstring = $query->param('result'); +my $dbh = C4::Context->dbh; + +my $startfrom=$query->param('startfrom'); +$startfrom=0 if(!defined $startfrom); +my ($template, $loggedinuser, $cookie); +my $resultsperpage; + +my $authtypes = getauthtypes; +my @authtypesloop; +foreach my $thisauthtype (keys %$authtypes) { + my $selected = 1 if $thisauthtype eq $authtypecode; + my %row =(value => $thisauthtype, + selected => $selected, + authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, + index => $index, + ); + push @authtypesloop, \%row; +} + +if ($op eq "do_search") { + my @marclist = $query->param('marclist'); + my @and_or = $query->param('and_or'); + my @excluding = $query->param('excluding'); + my @operator = $query->param('operator'); + my @value = $query->param('value'); + + $resultsperpage= $query->param('resultsperpage'); + $resultsperpage = 19 if(!defined $resultsperpage); + + my ($results,$total) = authoritysearch($dbh, \@marclist,\@and_or, + \@excluding, \@operator, \@value, + $startfrom*$resultsperpage, $resultsperpage,$authtypecode);# $orderby); + + ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "authorities/linkresultlist-auth.tmpl", + query => $query, + type => 'intranet', + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + + # multi page display gestion + my $displaynext=0; + my $displayprev=$startfrom; + if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) { + $displaynext = 1; + } + + my @field_data = (); + + + my @marclist_ini = $query->param('marclist'); # get marclist again, as the previous one has been modified by catalogsearch (mainentry replaced by field name + for(my $i = 0 ; $i <= $#marclist ; $i++) { + push @field_data, { term => "marclist", val=>$marclist_ini[$i] }; + push @field_data, { term => "and_or", val=>$and_or[$i] }; + push @field_data, { term => "excluding", val=>$excluding[$i] }; + push @field_data, { term => "operator", val=>$operator[$i] }; + push @field_data, { term => "value", val=>$value[$i] }; + } + + my @numbers = (); + + if ($total>$resultsperpage) { + for (my $i=1; $i<$total/$resultsperpage+1; $i++) { + if ($i<16) { + my $highlight=0; + ($startfrom==($i-1)) && ($highlight=1); + push @numbers, { number => $i, + highlight => $highlight , + searchdata=> \@field_data, + startfrom => ($i-1)}; + } + } + } + + my $from = $startfrom*$resultsperpage+1; + my $to; + + if($total < (($startfrom+1)*$resultsperpage)) { + $to = $total; + } else { + $to = (($startfrom+1)*$resultsperpage); + } + $template->param(result => $results) if $results; + $template->param(index => $query->param('index').""); + $template->param(startfrom=> $startfrom, + displaynext=> $displaynext, + displayprev=> $displayprev, + resultsperpage => $resultsperpage, + startfromnext => $startfrom+1, + startfromprev => $startfrom-1, + index => $index, + searchdata=>\@field_data, + total=>$total, + from=>$from, + to=>$to, + numbers=>\@numbers, + authtypecode =>$authtypecode, + resultstring =>$value[0], + ); +} else { + ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "authorities/auth_linker.tmpl", + query => $query, + type => 'intranet', + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + + $template->param(index=>$query->param('index')."", + resultstring => $resultstring, + + ); +} + +$template->param(authtypesloop => \@authtypesloop, + authtypecode => $authtypecode, + nonav=>"1",); + +# Print the page +output_html_with_http_headers $query, $cookie, $template->output; + +# Local Variables: +# tab-width: 4 +# End: diff --git a/authorities/authorities.pl b/authorities/authorities.pl index 00a3bcf461..9f456dc915 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -29,10 +29,15 @@ use C4::Context; use C4::Koha; # XXX subfield_is_koha_internal_p use HTML::Template; use MARC::File::USMARC; - +use MARC::File::XML; +use C4::Biblio; use vars qw( $tagslib); use vars qw( $authorised_values_sth); use vars qw( $is_a_modif ); +my $input = new CGI; +my $z3950 = $input->param('z3950'); +my $logstatus=C4::Context->preference('Activate_log'); +my $itemtype; # created here because it can be used in build_authorized_values_list sub =item find_value @@ -60,8 +65,8 @@ sub find_value { my @subfields = $field->subfields(); foreach my $subfield (@subfields) { if (@$subfield[0] eq $insubfield) { - push @result,char_decode(@$subfield[1],$encoding); - $indicator = $field->indicator(1).$field->indicator(2); + push @result,@$subfield[1]; + $indicator = $field->indicator(1).$field->indicator(2); } } } @@ -104,7 +109,7 @@ sub build_authorized_values_list ($$$$$) { push @authorised_values, $itemtype; $authorised_lib{$itemtype}=$description; } -# $value=$itemtype unless ($value); + $value=$itemtype unless ($value); #---- "true" authorised value } else { @@ -121,39 +126,64 @@ sub build_authorized_values_list ($$$$$) { -values => \@authorised_values, -default => $value, -labels => \%authorised_lib, + -override => 1, -size => 1, -multiple => 0 ); } + =item create_input builds the entry for a subfield. =cut sub create_input () { - my ($tag,$subfield,$value,$i,$rec,$authorised_values_sth) = @_; + my ($tag,$subfield,$value,$i,$tabloop,$rec,$authorised_values_sth) = @_; + # must be encoded as utf-8 before it reaches the editor + my $dbh=C4::Context->dbh; $value =~ s/"/"/g; - my $dbh = C4::Context->dbh; my %subfield_data; $subfield_data{tag}=$tag; $subfield_data{subfield}=$subfield; $subfield_data{marc_lib}="".$tagslib->{$tag}->{$subfield}->{lib}.""; + $subfield_data{marc_lib_plain}=$tagslib->{$tag}->{$subfield}->{lib}; $subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory}; $subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory}; $subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable}; + $subfield_data{kohafield}=$tagslib->{$tag}->{$subfield}->{kohafield}; $subfield_data{index} = $i; + $subfield_data{visibility} = "display:none" if (substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) gt "0") ; #check parity + # it's an authorised field if ($tagslib->{$tag}->{$subfield}->{authorised_value}) { $subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh,$authorised_values_sth); - } elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) { - $subfield_data{marc_value}=" {$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">..."; + # it's a thesaurus / authority field + } elsif ($tagslib->{$tag}->{$subfield}->{link}) { + $subfield_data{marc_value}=" ..."; + + # it's a plugin field } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) { - my $plugin="../value_builder/".$tagslib->{$tag}->{$subfield}->{'value_builder'}; + # opening plugin. Just check wether we are on a developper computer on a production one + # (the cgidir differs) + my $cgidir = C4::Context->intranetdir ."/cgi-bin/value_builder"; + unless (opendir(DIR, "$cgidir")) { + $cgidir = C4::Context->intranetdir."/value_builder"; + } + my $plugin=$cgidir."/".$tagslib->{$tag}->{$subfield}->{'value_builder'}; require $plugin; - my $extended_param = plugin_parameters($dbh,$rec,$tagslib,$i,0); - my ($function_name,$javascript) = plugin_javascript($dbh,$rec,$tagslib,$i,0); - $subfield_data{marc_value}=" ... $javascript"; + my $extended_param = plugin_parameters($dbh,$rec,$tagslib,$i,$tabloop); + my ($function_name,$javascript) = plugin_javascript($dbh,$rec,$tagslib,$i,$tabloop); + $subfield_data{marc_value}=" ... $javascript"; + # it's an hidden field } elsif ($tag eq '') { - $subfield_data{marc_value}=""; #" + $subfield_data{marc_value}=""; + } elsif (substr($tagslib->{$tag}->{$subfield}->{'hidden'},2,1) gt "1") { + + $subfield_data{marc_value}=""; + # it's a standard field } else { - $subfield_data{marc_value}=""; #" + if (length($value) >100) { + $subfield_data{marc_value}=""; + } else { + $subfield_data{marc_value}=""; #" + } } return \%subfield_data; } @@ -168,40 +198,93 @@ sub build_tabs ($$$$) { from authorised_values where category=? order by lib"); - my @loop_data = (); - foreach my $tag (sort(keys (%{$tagslib}))) { - my $indicator; -# warn "TAG : $tag => ".$tagslib->{$tag}->{lib}."//"; -# if MARC::Record is not empty => use it as master loop, then add missing subfields that should be in the tab. -# if MARC::Record is empty => use tab as master loop. - if ($record ne -1 && $record->field($tag)) { - my @fields = $record->field($tag); - foreach my $field (@fields) { - my @subfields_data; - if ($tag<10) { - my $value=$field->data(); - my $subfield="@"; - next if ($tagslib->{$tag}->{$subfield}->{tab} eq -1); - push(@subfields_data, &create_input($tag,$subfield,char_decode($value,$encoding),$i,$record,$authorised_values_sth)); - $i++; +# loop through each tab 0 through 9 + for (my $tabloop = 0; $tabloop <= 9; $tabloop++) { + my @loop_data = (); + foreach my $tag (sort(keys (%{$tagslib}))) { + my $indicator; + # if MARC::Record is not empty => use it as master loop, then add missing subfields that should be in the tab. + # if MARC::Record is empty => use tab as master loop. + if ($record ne -1 && ($record->field($tag) || $tag eq '000')) { + my @fields; + if ($tag ne '000') { + @fields = $record->field($tag); } else { - my @subfields=$field->subfields(); - foreach my $subfieldcount (0..$#subfields) { - my $subfield=$subfields[$subfieldcount][0]; - my $value=$subfields[$subfieldcount][1]; + push @fields,$record->leader(); + } + foreach my $field (@fields) { + my @subfields_data; + if ($tag<10) { + my ($value,$subfield); + if ($tag ne '000') { + $value=$field->data(); + $subfield="@"; + } else { + $value = $field; + $subfield='@'; + } + next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop); + # next if ($tagslib->{$tag}->{$subfield}->{kohafield} eq 'auth_header.authid'); + push(@subfields_data, &create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth)); + $i++; + } else { + my @subfields=$field->subfields(); + foreach my $subfieldcount (0..$#subfields) { + my $subfield=$subfields[$subfieldcount][0]; + my $value=$subfields[$subfieldcount][1]; + next if (length $subfield !=1); + next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop); + push(@subfields_data, &create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth)); + $i++; + } + } +# now, loop again to add parameter subfield that are not in the MARC::Record + foreach my $subfield (sort( keys %{$tagslib->{$tag}})) { next if (length $subfield !=1); - next if ($tagslib->{$tag}->{$subfield}->{tab} eq -1); - push(@subfields_data, &create_input($tag,$subfield,char_decode($value,$encoding),$i,$record,$authorised_values_sth)); + next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop); + next if ($tag<10); + next if ((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) gt "1") ); #check for visibility flag + next if (defined($field->subfield($subfield))); + push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth)); + $i++; + } + if ($#subfields_data >= 0) { + my %tag_data; + $tag_data{tag} = $tag; + $tag_data{tag_lib} = $tagslib->{$tag}->{lib}; + $tag_data{repeatable} = $tagslib->{$tag}->{repeatable}; + $tag_data{indicator} = $record->field($tag)->indicator(1). $record->field($tag)->indicator(2) if ($tag>=10); + $tag_data{subfield_loop} = \@subfields_data; + if ($tag<10) { + $tag_data{fixedfield} = 1; + } + + push (@loop_data, \%tag_data); + } +# If there is more than 1 field, add an empty hidden field as separator. + if ($#fields >=1 && $#loop_data >=0 && $loop_data[$#loop_data]->{'tag'} eq $tag) { + my @subfields_data; + my %tag_data; + push(@subfields_data, &create_input('','','',$i,$tabloop,$record,$authorised_values_sth)); + $tag_data{tag} = ''; + $tag_data{tag_lib} = ''; + $tag_data{indicator} = ''; + $tag_data{subfield_loop} = \@subfields_data; + if ($tag<10) { + $tag_data{fixedfield} = 1; + } + push (@loop_data, \%tag_data); $i++; } } -# now, loop again to add parameter subfield that are not in the MARC::Record - foreach my $subfield (sort( keys %{$tagslib->{$tag}})) { + + } else { + my @subfields_data; + foreach my $subfield (sort(keys %{$tagslib->{$tag}})) { next if (length $subfield !=1); - next if ($tagslib->{$tag}->{$subfield}->{tab} eq -1); - next if ($tag<10); - next if (defined($record->field($tag)->subfield($subfield))); - push(@subfields_data, &create_input($tag,$subfield,'',$i,$record,$authorised_values_sth)); + next if ((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) gt "1") ); #check for visibility flag + next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop); + push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth)); $i++; } if ($#subfields_data >= 0) { @@ -209,44 +292,18 @@ sub build_tabs ($$$$) { $tag_data{tag} = $tag; $tag_data{tag_lib} = $tagslib->{$tag}->{lib}; $tag_data{repeatable} = $tagslib->{$tag}->{repeatable}; - $tag_data{indicator} = $record->field($tag)->indicator(1). $record->field($tag)->indicator(2) if ($tag>=10); - $tag_data{subfield_loop} = \@subfields_data; - push (@loop_data, \%tag_data); - } -# If there is more than 1 field, add an empty hidden field as separator. - if ($#fields >=1) { - my @subfields_data; - my %tag_data; - push(@subfields_data, &create_input('','','',$i,$record,$authorised_values_sth)); - $tag_data{tag} = ''; - $tag_data{tag_lib} = ''; - $tag_data{indicator} = ''; + $tag_data{indicator} = $indicator; $tag_data{subfield_loop} = \@subfields_data; + $tag_data{tagfirstsubfield} = $tag_data{subfield_loop}[0]; + if ($tag<10) { + $tag_data{fixedfield} = 1; + } push (@loop_data, \%tag_data); - $i++; } } -# if breeding is empty - } else { - my @subfields_data; - foreach my $subfield (sort(keys %{$tagslib->{$tag}})) { - next if (length $subfield !=1); - next if ($tagslib->{$tag}->{$subfield}->{tab} eq -1); - push(@subfields_data, &create_input($tag,$subfield,'',$i,$record,$authorised_values_sth)); - $i++; - } - if ($#subfields_data >= 0) { - my %tag_data; - $tag_data{tag} = $tag; - $tag_data{tag_lib} = $tagslib->{$tag}->{lib}; - $tag_data{repeatable} = $tagslib->{$tag}->{repeatable}; - $tag_data{indicator} = $indicator; - $tag_data{subfield_loop} = \@subfields_data; - push (@loop_data, \%tag_data); - } } + $template->param($tabloop."XX" =>\@loop_data); } - $template->param("0XX" =>\@loop_data); } @@ -277,7 +334,6 @@ sub build_hidden_data () { } } - # ======================== # MAIN #========================= @@ -286,11 +342,15 @@ my $error = $input->param('error'); my $authid=$input->param('authid'); # if authid exists, it's a modif, not a new authority. my $z3950 = $input->param('z3950'); my $op = $input->param('op'); -# warn "OP : $op"; +my $nonav = $input->param('nonav'); +my $myindex = $input->param('index'); +my $linkid=$input->param('linkid'); my $authtypecode = $input->param('authtypecode'); + my $dbh = C4::Context->dbh; -$authtypecode = &AUTHfind_authtypecode($dbh,$authid) if $authid; -# warn "authtypecode : $authtypecode && authid = $authid"; +$authtypecode = &AUTHfind_authtypecode($dbh,$authid) if !$authtypecode; + + my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "authorities/authorities.tmpl", query => $input, @@ -299,28 +359,24 @@ my ($template, $loggedinuser, $cookie) flagsrequired => {editcatalogue => 1}, debug => 1, }); - +$template->param(nonav => $nonav,index=>$myindex,authtypecode=>$authtypecode,); $tagslib = AUTHgettagslib($dbh,1,$authtypecode); my $record=-1; my $encoding=""; $record = AUTHgetauthority($dbh,$authid) if ($authid); - +my ($oldauthnumtagfield,$oldauthnumtagsubfield); +my ($oldauthtypetagfield,$oldauthtypetagsubfield); $is_a_modif=0; -# my ($oldbiblionumtagfield,$oldbiblionumtagsubfield); -# my ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield,$bibitem,$oldbiblioitemnumber); if ($authid) { $is_a_modif=1; - # if it's a modif, retrieve old biblio and bibitem numbers for the future modification of old-DB. -# ($oldbiblionumtagfield,$oldbiblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber"); -# ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblioitems.biblioitemnumber"); -# # search biblioitems value -# my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?"); -# $sth->execute($oldbiblionumber); -# ($oldbiblioitemnumber) = $sth->fetchrow; + ($oldauthnumtagfield,$oldauthnumtagsubfield) = &AUTHfind_marc_from_kohafield($dbh,"auth_header.authid",$authtypecode); + ($oldauthtypetagfield,$oldauthtypetagsubfield) = &AUTHfind_marc_from_kohafield($dbh,"auth_header.authtypecode",$authtypecode); } + #------------------------------------------------------------------------------------------------------------------------------ if ($op eq "add") { #------------------------------------------------------------------------------------------------------------------------------ + # rebuild my @tags = $input->param('tag'); my @subfields = $input->param('subfield'); @@ -328,30 +384,39 @@ if ($op eq "add") { # build indicator hash. my @ind_tag = $input->param('ind_tag'); my @indicator = $input->param('indicator'); - my %indicators; - for (my $i=0;$i<=$#ind_tag;$i++) { - $indicators{$ind_tag[$i]} = $indicator[$i]; - } - my $record = AUTHhtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); -# MARC::Record built => now, record in DB + my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag); + #warn $xml; + my $record=MARC::Record->new_from_xml($xml,'UTF-8'); + $record->encoding('UTF-8'); + #warn $record->as_formatted; + #warn "IN ADDBIB"; # check for a duplicate - my ($duplicateauthid,$duplicateauthvalue) = FindDuplicate($record,$authtypecode) if ($op eq "add") && (!$is_a_modif); + my ($duplicateauthid,$duplicateauthvalue) = C4::AuthoritiesMarc::FindDuplicate($record,$authtypecode) if ($op eq "add") && (!$is_a_modif); +#warn "duplicate:$duplicateauthid,$duplicateauthvalue"; my $confirm_not_duplicate = $input->param('confirm_not_duplicate'); # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate) if (!$duplicateauthid or $confirm_not_duplicate) { - if ($is_a_modif) { - AUTHmodauthority($dbh,$authid,$record,$authtypecode); +# warn "noduplicate"; + if ($is_a_modif ) { + $authid=AUTHmodauthority($dbh,$authid,$record,$authtypecode,1); } else { - ($authid) = AUTHaddauthority($dbh,$record,$authid,$authtypecode); + ($authid) = AUTHaddauthority($dbh,$record,$authid,$authtypecode); + } # now, redirect to detail page - print $input->redirect("detail.pl?authid=$authid"); + if ($nonav){ +#warn ($myindex,$nonav); + print $input->redirect("auth_finder.pl?index=$myindex&nonav=$nonav&authtypecode=$authtypecode"); + }else{ + print $input->redirect("detail.pl?nonav=$nonav&authid=$authid"); + } exit; } else { +#warn "duplicate"; # it may be a duplicate, warn the user and do nothing build_tabs ($template, $record, $dbh,$encoding); build_hidden_data; - $template->param( + $template->param(authid =>$authid, duplicateauthid => $duplicateauthid, duplicateauthvalue => $duplicateauthvalue, ); @@ -360,50 +425,54 @@ if ($op eq "add") { } elsif ($op eq "addfield") { #------------------------------------------------------------------------------------------------------------------------------ my $addedfield = $input->param('addfield_field'); + my $tagaddfield_subfield = $input->param('addfield_subfield'); my @tags = $input->param('tag'); my @subfields = $input->param('subfield'); my @values = $input->param('field_value'); # build indicator hash. my @ind_tag = $input->param('ind_tag'); my @indicator = $input->param('indicator'); - my %indicators; - for (my $i=0;$i<=$#ind_tag;$i++) { - $indicators{$ind_tag[$i]} = $indicator[$i]; - } - my $record = AUTHhtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); - my $field = MARC::Field->new("$addedfield",'','','a'=> ""); + my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag); + my $record=MARC::Record->new_from_xml($xml,'UTF-8'); + $record->encoding('UTF-8'); + # adding an empty field + my $field = MARC::Field->new("$addedfield",'','','$tagaddfield_subfield' => ""); $record->append_fields($field); - build_tabs ($template, $record, $dbh,$encoding); build_hidden_data; $template->param( authid => $authid,); -# oldbiblionumtagfield => $oldbiblionumtagfield, -# oldbiblionumtagsubfield => $oldbiblionumtagsubfield, -# oldbiblioitemnumtagfield => $oldbiblioitemnumtagfield, -# oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield, -# oldbiblioitemnumber => $oldbiblioitemnumber ); + } elsif ($op eq "delete") { #------------------------------------------------------------------------------------------------------------------------------ &AUTHdelauthority($dbh,$authid); + if ($nonav){ + print $input->redirect("auth_finder.pl"); + }else{ + print $input->redirect("authorities-home.pl?authid=0"); + } + exit; } else { +if ($op eq "duplicate") + { + $authid = ""; + } build_tabs ($template, $record, $dbh,$encoding); build_hidden_data; + $template->param(oldauthtypetagfield=>$oldauthtypetagfield, oldauthtypetagsubfield=>$oldauthtypetagsubfield, + oldauthnumtagfield=>$oldauthnumtagfield, oldauthnumtagsubfield=>$oldauthnumtagsubfield, + authid => $authid , authtypecode=>$authtypecode, ); } -unless ($op) { -# warn "BUILDING"; - build_tabs ($template, $record, $dbh,$encoding); - build_hidden_data; -} +#unless ($op) { +# warn "BUILDING"; +# build_tabs ($template, $record, $dbh,$encoding); +# build_hidden_data; +#} $template->param( authid => $authid, -# oldbiblionumtagfield => $oldbiblionumtagfield, -# oldbiblionumtagsubfield => $oldbiblionumtagsubfield, -# oldbiblioitemnumtagfield => $oldbiblioitemnumtagfield, -# # oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield, -# oldbiblioitemnumber => $oldbiblioitemnumber, authtypecode => $authtypecode, + linkid=>$linkid, ); my $authtypes = getauthtypes; @@ -419,6 +488,5 @@ foreach my $thisauthtype (keys %$authtypes) { $template->param(authtypesloop => \@authtypesloop, authtypetext => $authtypes->{$authtypecode}{'authtypetext'}, - hide_marc => C4::Context->preference('hide_marc'), - ); + nonav=>$nonav,); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/authorities/blinddetail-linker.pl b/authorities/blinddetail-linker.pl new file mode 100644 index 0000000000..5b40090533 --- /dev/null +++ b/authorities/blinddetail-linker.pl @@ -0,0 +1,127 @@ +#!/usr/bin/perl + +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +=head1 NAME + +etail.pl : script to show an authority in MARC format + +=head1 SYNOPSIS + + +=head1 DESCRIPTION + +This script needs an authid + +It shows the authority in a (nice) MARC format depending on authority MARC +parameters tables. + +=head1 FUNCTIONS + +=over 2 + +=cut + + +use strict; +require Exporter; +use C4::AuthoritiesMarc; +use C4::Auth; +use C4::Context; +use C4::Output; +use C4::Interface::CGI::Output; +use CGI; +use C4::Search; +use MARC::Record; +use C4::Koha; +use HTML::Template; + +my $query=new CGI; + +my $dbh=C4::Context->dbh; + +my $authid = $query->param('authid'); +my $index = $query->param('index'); +my $authtypecode=$query->param('authtypecode'); + $authtypecode = &AUTHfind_authtypecode($dbh,$authid) if !$authtypecode; +my $tagslib = &AUTHgettagslib($dbh,1,$authtypecode); +my ($linkidfield,$linkidsubfield)=AUTHfind_marc_from_kohafield($dbh,"auth_header.linkid",$authtypecode); +my $auth_type = AUTHgetauth_type($authtypecode); + +my $record =AUTHgetauthority($dbh,$authid); +# open template +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "authorities/blinddetail-linker.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + +# fill arrays +my @loop_data =(); +my $tag; +my @loop_data =(); +if ($authid) { + + foreach my $field ($record->field($auth_type->{auth_tag_to_report})) { + my @subfields_data; + my @subf=$field->subfields; + # loop through each subfield + for my $i (0..$#subf) { + $subf[$i][0] = "@" unless $subf[$i][0]; + my %subfield_data; + $subfield_data{marc_value}=$subf[$i][1]; + $subfield_data{marc_subfield}=$subf[$i][0]; + $subfield_data{marc_tag}=$field->tag(); + push(@subfields_data, \%subfield_data); + } + if ($#subfields_data>=0) { + my %tag_data; + $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib}; + $tag_data{subfield} = \@subfields_data; + push (@loop_data, \%tag_data); + } + } +} else { +# authid is empty => the user want to empty the entry. + my @subfields_data; + foreach my $subfield ('a'..'z') { + my %subfield_data; + $subfield_data{marc_value}=''; + $subfield_data{marc_subfield}=$subfield; + push(@subfields_data, \%subfield_data); + + } + +# if ($#subfields_data>=0) { + my %tag_data; +# $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib}; + $tag_data{subfield} = \@subfields_data; + push (@loop_data, \%tag_data); +# } +} + +$template->param("0XX" =>\@loop_data); + + + +$template->param(authid => $authid?$authid:"",linkidsubfield=>$linkidsubfield, linkidfield=>$linkidfield,index => $index); +output_html_with_http_headers $query, $cookie, $template->output; + diff --git a/koha-tmpl/intranet-tmpl/prog/en/authorities/auth_linker.tmpl b/koha-tmpl/intranet-tmpl/prog/en/authorities/auth_linker.tmpl new file mode 100644 index 0000000000..278bed9588 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/authorities/auth_linker.tmpl @@ -0,0 +1,58 @@ +Koha -- Authorities + + + +
+ +

Authority search

+ +
+ "> + + + "> +
+

Search on

+

+ + + +

+

+ "> + + + + + "> +

+

+ + + + + + "> +

+

+ +

+
+
+
+ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/authorities/blinddetail-linker.tmpl b/koha-tmpl/intranet-tmpl/prog/en/authorities/blinddetail-linker.tmpl new file mode 100644 index 0000000000..1fa973319e --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/authorities/blinddetail-linker.tmpl @@ -0,0 +1,67 @@ + + + + + + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/authorities/linkresultlist-auth.tmpl b/koha-tmpl/intranet-tmpl/prog/en/authorities/linkresultlist-auth.tmpl new file mode 100644 index 0000000000..a0dfcfddf5 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/authorities/linkresultlist-auth.tmpl @@ -0,0 +1,94 @@ +Koha -- Authorities + + +
+

Authority search results

+ +
+ + + + + + + + + + + + + + + + + + +
SummaryUsedGet It!
Clear any entry  + &authtypecode=')" class="button authority"> + Clear + +
times + &index=')">//images/arrow.gif" width="16" height="16" hspace="0" vspace="0" border="0"> +
+ +
+ + ">Search again +
+ + + + -- 2.39.5