koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/value_builder unimarc_field_60X.pl,NONE,1.1


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/value_builder unimarc_field_60X.pl,NONE,1.1
Date: Fri, 14 Nov 2003 14:00:46 -0800

Update of /cvsroot/koha/koha/value_builder
In directory sc8-pr-cvs1:/tmp/cvs-serv26385/value_builder

Added Files:
        unimarc_field_60X.pl 
Log Message:
minor fixes in thesaurus_popup & authorities.pm
NEW plugin : the plugin that manages 60X field in UNIMARC (i think it's the 
same in marc21). Used to search a thesaurus entry & parse bibliothesaurus table 
for category NC (Common Name in french).
The user can enter a search term, and see entries corresponding. If the search 
is a real entry in the thesaurus, and this entry has dependencies, they are 
shown too.
For example, if the thesaurus contains :
Geo -- Europe -- France -- Marseille
Geo -- Europe -- France -- Paris
Hist -- Europe -- France -- Revolution

A search on "France"
shows
Geo --Europe --France and Hist -- Europe -- France on the left panel
When the user clic on Geo -- Europe -- France,
Marseille & Paris are shown on the right panel.

When the user selects a value, it's reported to the MARC editor.

NOTE : template ONLY IN FRENCH (but it's 11PM for instance, & i plan to go to 
bed :-) )

--- NEW FILE ---
#!/usr/bin/perl

# $Id: unimarc_field_60X.pl,v 1.1 2003/11/14 22:00:43 tipaul Exp $

# 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;
use C4::Auth;
use CGI;
use C4::Context;
use HTML::Template;
use C4::Search;
use C4::Output;
use C4::Authorities;

sub plugin_javascript {
my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
my $function_name= "100".(int(rand(100000))+1);
my $res="
<script>
function Focus$function_name(subfield_managed) {
return 1;
}

function Blur$function_name(subfield_managed) {
        return 1;
}

function Clic$function_name(index) {
        defaultvalue=document.f.field_value[index].value;
        
newin=window.open(\"../plugin_launcher.pl?plugin_name=unimarc_field_60X.pl&index=\"+index+\"&result=\"+defaultvalue,\"unimarc
 700\",'width=700,height=300,toolbar=false,scrollbars=yes');

}
</script>
";

return ($function_name,$res);
}
sub plugin {
        my ($input) = @_;
        my %env;
        my $dbh = C4::Context->dbh;
        my $index= $input->param('index');
        my $result= $input->param('result');
        warn "RES : $result";
        my $search_string= $input->param('search_string');
        my $op = $input->param('op');
        my $id = $input->param('id');
        my $insert = $input->param('insert');
        my %stdlib;
        my $select_list;
        if ($op eq "add") {
                newauthority($dbh,'NC',$insert,$insert,'',1,'');
                $search_string=$insert;
        }
        if ($op eq "select") {
                my $sti = $dbh->prepare("select stdlib from bibliothesaurus 
where id=?");
                $sti->execute($id);
                my ($freelib_text) = $sti->fetchrow_array;
                $result = $freelib_text;
        }
        my $Rsearch_string="$search_string%";
        my $authoritysep = C4::Context->preference('authoritysep');
        my @splitted = /$authoritysep/,$search_string;
        my $level = $#splitted+1;
        my $query;
        if ($search_string) { # if no search pattern, returns only the 50 1st 
top level values
                $query = "select distinct freelib,father,level from 
bibliothesaurus where category='NC' and freelib like ? order by father,freelib";
        } else {
                $query = "select distinct freelib,father,level from 
bibliothesaurus where category='NC' and level=0 and freelib like ? order by 
father,freelib limit 0,50";
        }
        my $sti=$dbh->prepare($query);
        $sti->execute($Rsearch_string);
        my @results;
        while (my ($freelib,$father,$level)=$sti->fetchrow) {
                my %line;
                if ($father) {
                        $line{value} = "$father $freelib";
                } else {
                        $line{value} = "$freelib";
                }
                $line{level} = $level+1;
                $line{father} = $father;
                push @results, \%line;
        }
        my @DeeperResults = SearchDeeper('NC',$search_string);
        my ($template, $loggedinuser, $cookie)
        = get_template_and_user({template_name => 
"value_builder/unimarc_field_60X.tmpl",
                                        query => $input,
                                        type => "intranet",
                                        authnotrequired => 0,
                                        flagsrequired => {parameters => 1},
                                        debug => 1,
                                        });
# builds collection list : search isbn and editor, in parent, then load 
collections from bibliothesaurus table
        $template->param(index => $index,
                                                        result =>$result,
                                                        search_string => 
$search_string?$search_string:$result,
                                                        results => 
address@hidden,
                                                        deeper => 
address@hidden,
                                );
        print $input->header(-cookie => $cookie),$template->output;
}

1;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]