[Koha-patches] [PATCH 09/17] update some unimarc plugins
paul.poulain at biblibre.com
paul.poulain at biblibre.com
Thu Dec 16 15:11:15 CET 2010
From: Paul Poulain <paul.poulain at biblibre.com>
- 010 (isbn) now don't care wether you've - or no in the isbn
- 210 just documented & reindented
- 210c_bis: Adds an alternative cataloguing plugin for 210$c
- 225 : popup window larger
---
cataloguing/value_builder/unimarc_field_010.pl | 3 +-
cataloguing/value_builder/unimarc_field_210c.pl | 217 ++++++++++----------
.../value_builder/unimarc_field_210c_bis.pl | 109 ++++++++++
cataloguing/value_builder/unimarc_field_225a.pl | 2 +-
cataloguing/ysearchzebra.pl | 52 +++++
5 files changed, 274 insertions(+), 109 deletions(-)
create mode 100755 cataloguing/value_builder/unimarc_field_210c_bis.pl
create mode 100644 cataloguing/ysearchzebra.pl
diff --git a/cataloguing/value_builder/unimarc_field_010.pl b/cataloguing/value_builder/unimarc_field_010.pl
index 19dbb9f..681df31 100755
--- a/cataloguing/value_builder/unimarc_field_010.pl
+++ b/cataloguing/value_builder/unimarc_field_010.pl
@@ -67,6 +67,7 @@ sub plugin_javascript {
}
function Clic$field_number() {
+ Blur$field_number();
return 1;
}
</script>
@@ -91,7 +92,7 @@ sub plugin {
my $dbh = C4::Context->dbh;
my $len = 0;
- my $sth = $dbh->prepare('SELECT publishercode FROM biblioitems WHERE isbn LIKE ? OR isbn LIKE ? LIMIT 1');
+ my $sth = $dbh->prepare('SELECT publishercode FROM biblioitems WHERE REPLACE(isbn, "-", "") LIKE ? OR REPLACE(isbn, "-", "") LIKE ? LIMIT 1');
$isbn =~ s/-//g;
if (length ($isbn) == 13){
diff --git a/cataloguing/value_builder/unimarc_field_210c.pl b/cataloguing/value_builder/unimarc_field_210c.pl
index 8ecaeab..0f896b8 100755
--- a/cataloguing/value_builder/unimarc_field_210c.pl
+++ b/cataloguing/value_builder/unimarc_field_210c.pl
@@ -1,6 +1,5 @@
#!/usr/bin/perl
-
# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
@@ -37,9 +36,10 @@ use C4::Koha;
plugin_parameters : other parameters added when the plugin is called by the dopop function
=cut
+
sub plugin_parameters {
-my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
-return "";
+ my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_;
+ return "";
}
=head1
@@ -56,18 +56,19 @@ returns :
the 3 scripts are inserted after the <input> in the html code
=cut
+
sub plugin_javascript {
-my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
-my $function_name= $field_number;
-#---- build editors list.
-#---- the editor list is built from the "EDITORS" thesaurus
-#---- this thesaurus category must be filled as follow :
-#---- 200$a for isbn
-#---- 200$b for editor
-#---- 200$c (repeated) for collections
+ my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
+ my $function_name = $field_number;
+ #---- build editors list.
+ #---- the editor list is built from the "EDITORS" thesaurus
+ #---- this thesaurus category must be filled as follow :
+ #---- 200$a for isbn
+ #---- 200$b for editor
+ #---- 200$c (repeated) for collections
-my $res = "
+ my $res = "
<script type=\"text/javascript\">
function Focus$function_name(index) {
@@ -79,11 +80,11 @@ function Blur$function_name(subfield_managed) {
function Clic$function_name(subfield_managed) {
defaultvalue=escape(document.getElementById(\"$field_number\").value);
- newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_210c.pl&index=\"+subfield_managed,\"unimarc_225a\",'width=500,height=600,toolbar=false,scrollbars=yes');
+ newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_210c.pl&index=\"+subfield_managed,\"unimarc 225a\",'width=500,height=600,toolbar=false,scrollbars=yes');
}
</script>
";
-return ($function_name,$res);
+ return ( $function_name, $res );
}
=head1
@@ -93,136 +94,138 @@ plugin : the true value_builded. The screen that is open in the popup window.
=cut
sub plugin {
-my ($input) = @_;
- my $query=new CGI;
- my $op = $query->param('op');
+ my ($input) = @_;
+ 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 $index = $query->param('index');
+ my $category = $query->param('category');
my $resultstring = $query->param('result');
- my $dbh = C4::Context->dbh;
+ my $dbh = C4::Context->dbh;
- my $startfrom=$query->param('startfrom');
- $startfrom=0 if(!defined $startfrom);
- my ($template, $loggedinuser, $cookie);
+ 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) {
+ foreach my $thisauthtype ( keys %$authtypes ) {
my $selected = 1 if $thisauthtype eq $authtypecode;
- my %row =(value => $thisauthtype,
- selected => $selected,
- authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
- index => $index,
- );
+ 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');
+ 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');
+ my @operator = $query->param('operator');
+ my @value = $query->param('value');
my $orderby = $query->param('orderby');
- $resultsperpage= $query->param('resultsperpage');
- $resultsperpage = 19 if(!defined $resultsperpage);
+ $resultsperpage = $query->param('resultsperpage');
+ $resultsperpage = 19 if ( !defined $resultsperpage );
# builds tag and subfield arrays
my @tags;
- my ($results,$total) = SearchAuthorities( \@tags,\@and_or,
- \@excluding, \@operator, \@value,
- $startfrom*$resultsperpage, $resultsperpage,$authtypecode, $orderby);
-
- # Getting the $b if it exists
- for (@$results) {
- my $authority = GetAuthority($_->{authid});
- if ($authority->field('200') and $authority->subfield('200','b')) {
- $_->{to_report} = $authority->subfield('200','b');
- }
- }
-
- ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "cataloguing/value_builder/unimarc_field_210c.tmpl",
- query => $query,
- type => 'intranet',
- authnotrequired => 0,
- flagsrequired => {editcatalogue => '*'},
- debug => 1,
- });
+ my ( $results, $total ) = SearchAuthorities( \@tags, \@and_or, \@excluding, \@operator, \@value, $startfrom * $resultsperpage, $resultsperpage, $authtypecode, $orderby );
+
+ for (@$results) {
+ my $authority = GetAuthority($_->{authid});
+ if ($authority->field('200') and $authority->subfield('200','b')) {
+ $_->{to_report} = $authority->subfield('200','b');
+ }
+ }
+
+ ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ { template_name => "cataloguing/value_builder/unimarc_field_210c.tmpl",
+ query => $query,
+ type => 'intranet',
+ authnotrequired => 0,
+ flagsrequired => { editcatalogue => '*' },
+ debug => 1,
+ }
+ );
# multi page display gestion
- my $displaynext=0;
- my $displayprev=$startfrom;
- if(($total - (($startfrom+1)*($resultsperpage))) > 0 ) {
+ my $displaynext = 0;
+ my $displayprev = $startfrom;
+ if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
$displaynext = 1;
}
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 ,
- startfrom => ($i-1)};
+ 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,
+ startfrom => ( $i - 1 )
+ };
}
}
}
- my $from = $startfrom*$resultsperpage+1;
+ my $from = $startfrom * $resultsperpage + 1;
my $to;
- if($total < (($startfrom+1)*$resultsperpage)) {
+ if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
$to = $total;
} else {
- $to = (($startfrom+1)*$resultsperpage);
+ $to = ( ( $startfrom + 1 ) * $resultsperpage );
}
- my $link="../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_210c.pl&authtypecode=EDITORS&and_or=$and_or&marclist=$marclist&operator=$operator&orderby=$orderby&excluding=$excluding&".join("&",map {"value=".$_} @value)."&op=do_search&type=intranet&index=$index";
-
- $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,
- total=>$total,
- from=>$from,
- to=>$to,
- numbers=>\@numbers,
- authtypecode =>$authtypecode,
- resultstring =>$value[0],
- pagination_bar => pagination_bar(
- $link,
- getnbpages($total, $resultsperpage),
- $startfrom,
- 'startfrom'
- ),
- );
+ my $link =
+"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_210c.pl&authtypecode=EDITORS&and_or=$and_or&marclist=$marclist&operator=$operator&orderby=$orderby&excluding=$excluding&"
+ . join( "&", map { "value=" . $_ } @value )
+ . "&op=do_search&type=intranet&index=$index";
+
+ $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,
+ total => $total,
+ from => $from,
+ to => $to,
+ numbers => \@numbers,
+ authtypecode => $authtypecode,
+ resultstring => $value[0],
+ pagination_bar => pagination_bar( $link, getnbpages( $total, $resultsperpage ), $startfrom, 'startfrom' ),
+ );
} else {
- ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "cataloguing/value_builder/unimarc_field_210c.tmpl",
- query => $query,
- type => 'intranet',
- authnotrequired => 0,
- flagsrequired => {editcatalogue => '*'},
- debug => 1,
- });
-
- $template->param(index => $index,
- resultstring => $resultstring
- );
+ ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ { template_name => "cataloguing/value_builder/unimarc_field_210c.tmpl",
+ query => $query,
+ type => 'intranet',
+ authnotrequired => 0,
+ flagsrequired => { editcatalogue => '*' },
+ debug => 1,
+ }
+ );
+
+ $template->param(
+ index => $index,
+ resultstring => $resultstring
+ );
}
- $template->param(authtypesloop => \@authtypesloop);
- $template->param(category => $category);
+ $template->param( authtypesloop => \@authtypesloop );
+ $template->param( category => $category );
# Print the page
output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/cataloguing/value_builder/unimarc_field_210c_bis.pl b/cataloguing/value_builder/unimarc_field_210c_bis.pl
new file mode 100755
index 0000000..5ecaf83
--- /dev/null
+++ b/cataloguing/value_builder/unimarc_field_210c_bis.pl
@@ -0,0 +1,109 @@
+#!/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.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+=head1 SYNOPSIS
+
+This plugin is used to map isbn/editor with collection.
+It need :
+ in thesaurus, a category named EDITORS
+ in this category, datas must be entered like following :
+ isbn separator editor separator collection.
+ for example :
+ 2204 -- Cerf -- Cogitatio fidei
+ 2204 -- Cerf -- Le Magistere de l'Eglise
+ 2204 -- Cerf -- Lectio divina
+ 2204 -- Cerf -- Lire la Bible
+ 2204 -- Cerf -- Pour lire
+ 2204 -- Cerf -- Sources chretiennes
+
+ when the user clic on ... on 225a line, the popup shows the list of collections from the selected editor
+ if the biblio has no isbn, then the search if done on editor only
+ If the biblio ha an isbn, the search is done on isbn and editor. It's faster.
+
+=over 2
+
+=cut
+
+use strict;
+
+#use warnings; FIXME - Bug 2505
+use C4::Auth;
+use CGI;
+use C4::Context;
+
+use C4::AuthoritiesMarc;
+use C4::Output;
+
+=head1
+
+plugin_parameters : other parameters added when the plugin is called by the dopop function
+
+=cut
+
+sub plugin_parameters {
+ my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_;
+ return "";
+}
+
+sub plugin_javascript {
+ my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
+ my $function_name = $field_number;
+ my $res = "
+ <script type=\"text/javascript\">
+ function Focus$function_name(subfield_managed) {
+ return 1;
+ }
+
+ function Blur$function_name(subfield_managed) {
+ return 1;
+ }
+
+ function Clic$function_name(index) {
+ window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_210c_bis.pl&index=\"+index,\"unimarc210c\",'width=500,height=400,toolbar=false,scrollbars=no');
+ }
+ </script>
+";
+
+ return ( $function_name, $res );
+}
+
+sub plugin {
+ my ($input) = @_;
+ my $index = $input->param('index');
+ my $result = $input->param('result');
+ my $editor_found = $input->param('editor_found');
+ my $authoritysep = C4::Context->preference("authoritysep");
+
+ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ { template_name => "cataloguing/value_builder/unimarc_field_210c_bis.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { editcatalogue => '*' },
+ debug => 1,
+ }
+ );
+
+ $template->param(
+ index => $index,
+ );
+ output_html_with_http_headers $input, $cookie, $template->output;
+}
+
+1;
diff --git a/cataloguing/value_builder/unimarc_field_225a.pl b/cataloguing/value_builder/unimarc_field_225a.pl
index acd02e1..daba32e 100755
--- a/cataloguing/value_builder/unimarc_field_225a.pl
+++ b/cataloguing/value_builder/unimarc_field_225a.pl
@@ -94,7 +94,7 @@ sub plugin_javascript {
}
defaultvalue = document.getElementById(\"$field_number\").value;
- window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_225a.pl&index=\"+index+\"&result=\"+defaultvalue+\"&editor_found=\"+editor_found,\"unimarc225a\",'width=500,height=200,toolbar=false,scrollbars=no');
+ window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_225a.pl&index=\"+index+\"&result=\"+defaultvalue+\"&editor_found=\"+editor_found,\"unimarc225a\",'width=500,height=400,toolbar=false,scrollbars=no');
}
</script>
diff --git a/cataloguing/ysearchzebra.pl b/cataloguing/ysearchzebra.pl
new file mode 100644
index 0000000..3a626fd
--- /dev/null
+++ b/cataloguing/ysearchzebra.pl
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+
+# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
+
+# Copyright 2010 BibLibre
+#
+# 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.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+=head1 ysearch.pl
+
+
+=cut
+
+use strict;
+
+use CGI;
+use C4::Context;
+use C4::Search;
+use C4::Auth qw/check_cookie_auth/;
+
+my $input = new CGI;
+my $query = $input->param('query');
+my $index = $input->param('index');
+
+#binmode STDOUT, ":utf8";
+print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
+
+my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { cataloguing => '*' } );
+if ( $auth_status ne "ok" ) {
+ exit 0;
+}
+
+my $results = GetDistinctValues($index, $query);
+
+foreach (@$results) {
+ print $_->{'value'} . "\n";
+
+}
+
--
1.7.1
More information about the Koha-patches
mailing list