[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Koha-devel] Where we should add this function ?
From: |
Ernesto Silva - Webmaster |
Subject: |
Re: [Koha-devel] Where we should add this function ? |
Date: |
Mon Jan 17 06:29:08 2005 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 |
Paul,
Here goes the function mentioned by Andrés. I'm not sure in which
module should be included.
I'm using this function in the opac-ISBDdetail.pl and it's called for
every displayed value so it may slow down the execution, specially if
the $tagslib variable is not global and must be calculated in every call.
I think this function can become part of some module (Biblio.pm?) but,
as I said, be carefull with the $tagslib variable.
I´m attaching the full patch for opac-ISBDdetail.pl.
The file "intranet/cgi-bin/ISBDdetail.pl" should be modified too, I
haven't done this yet because I don't want to re-insert the function
there too (and our librarians doesn't complain yet ;)
Anyway, here it is.
#*****************************************************************************
# global variable in the opac-ISBDdetail.pl
my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
#-----------------------------------------------------------------------------
sub get_authorised_value_desc ($$$$$) {
my($tag, $subfield, $value, $framework, $dbh) = @_;
#---- branch
if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq
"branches" ) {
return getbranchname($value);
}
#---- itemtypes
if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq
"itemtypes" ) {
return ItemType($value);
}
#---- "true" authorized value
my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
if ($category ne "") {
my $sth = $dbh->prepare("select lib from authorised_values where
category = ? and authorised_value = ?");
$sth->execute($category, $value);
my $data = $sth->fetchrow_hashref;
return $data->{'lib'};
} else {
return $value; # if nothing is found return the original value
}
}
#*****************************************************************************
Andrés Tarallo wrote:
Our Librarians discovered that: when you're in the OPAC Search, when you
enter in the ISBD detail (at least in the OPAC) those fields that have
authorized values aren't displayed propoerly. To clarify this: When you
display a certain field that has an authorized valued you get the key,
not the value.
We developed a function that "notices" that a field has authorized
values and returns the proper value or does nothing. We want to to
contribute back this function to the project, In which module should we
add this function?
Thanks
Andres
PD: We'll be on leave till Janury 17th.
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Koha-devel mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/koha-devel
--- opac-ISBDdetail.pl.RC4 2004-12-21 11:47:07.000000000 -0300
+++ opac-ISBDdetail.pl 2005-01-17 11:58:39.312199256 -0300
@@ -58,6 +58,8 @@
use C4::Acquisition;
use HTML::Template;
+#use vars qw( $tagslib);
+
my $query=new CGI;
my $dbh=C4::Context->dbh;
@@ -69,6 +71,34 @@
my $itemtype = &MARCfind_frameworkcode($dbh,$bibid);
my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
+
+sub get_authorised_value_desc ($$$$$) {
+ my($tag, $subfield, $value, $framework, $dbh) = @_;
+
+ #---- branch
+ if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
+ return getbranchname($value);
+ }
+
+ #---- itemtypes
+ if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
+ return ItemType($value);
+ }
+
+ #---- "true" authorized value
+ my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
+
+ if ($category ne "") {
+ my $sth = $dbh->prepare("select lib from authorised_values where
category = ? and authorised_value = ?");
+ $sth->execute($category, $value);
+ my $data = $sth->fetchrow_hashref;
+ return $data->{'lib'};
+ } else {
+ return $value; # if nothing is found return the original value
+ }
+}
+
+
my $record =MARCgetbiblio($dbh,$bibid);
# open template
my ($template, $loggedinuser, $cookie)
@@ -80,26 +110,17 @@
});
my $ISBD = C4::Context->preference('ISBD');
-# my @blocs = split /\@/,$ISBD;
-# my @fields = $record->fields();
my $res;
-# foreach my $bloc (@blocs) {
-# $bloc =~ s/\n//g;
my $bloc = $ISBD;
my $blocres;
foreach my $isbdfield (split /#/,$bloc) {
- warn "ISBDFIELD : $isbdfield";
-# $isbdfield= /(.?.?.?)/;
+# warn "ISBDFIELD : $isbdfield";
$isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/;
my $fieldvalue=$1;
my $textbefore=$2;
my $analysestring=$3;
my $textafter=$4;
-# warn "==> $1 / $2 / $3 / $4";
-# my $fieldvalue=substr($isbdfield,0,3);
if ($fieldvalue>0) {
- # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless
$fieldvalue;
-# warn "FV : $fieldvalue";
my $hasputtextbefore=0;
foreach my $field ($record->field($fieldvalue)) {
my $calculated = $analysestring;
@@ -110,6 +131,7 @@
for my $i (0..$#subf) {
my $subfieldcode = $subf[$i][0];
my $subfieldvalue =
$subf[$i][1];
+ $subfieldvalue =
get_authorised_value_desc($tag, $subfieldcode, $subfieldvalue, $itemtype, $dbh);
my $tagsubf =
$tag.$subfieldcode;
$calculated =~
s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue\{$1$tagsubf$2\}$2/g;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Koha-devel] Where we should add this function ?,
Ernesto Silva - Webmaster <=