From 31dbbb993db4a32d0797d818d802c860be43d937 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Thu, 28 Jan 2010 10:13:08 -0500 Subject: [PATCH] 4074 Bugfix: The 'Subject(s)' link(s) are malformed resulting in no search results These links are rendered with the wrong syntax. ie. 'q=su:foo' This results in a search for 'su:foo' rather than a search for 'foo' with an index of 'su.' This patch corrects the code so that the syntax conforms to current parsing methods. ie. 'idx=su&q=foo' NOTE: The change to the underlying C4::Biblio->GetMarcSubjects() does not need to be ported to any other calling code. NOTE: This patch should be back-ported to 3.0.x. --- C4/Biblio.pm | 68 ++++++++++--------- .../prog/en/modules/basket/basket.tmpl | 46 +++++++------- .../opac-tmpl/prog/en/modules/opac-detail.tmpl | 70 ++++++++++---------- opac/opac-detail.pl | 32 +++++----- 4 files changed, 109 insertions(+), 107 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 7b17981..41af817 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -456,10 +456,10 @@ Links bib headings to authority records by checking each authority-controlled field in the C object C<$marc>, looking for a matching authority record, and setting the linking subfield $9 to the ID of that -authority record. +authority record. If no matching authority exists, or if multiple -authorities match, no $9 will be added, and any +authorities match, no $9 will be added, and any existing one inthe field will be deleted. Returns the number of heading links changed in the @@ -739,7 +739,7 @@ sub GetBiblioFromItemNumber { my $sth; if ($itemnumber) { $sth = $dbh->prepare( - "SELECT * FROM items + "SELECT * FROM items LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber WHERE items.itemnumber = ?" @@ -747,7 +747,7 @@ sub GetBiblioFromItemNumber { $sth->execute($itemnumber); } else { $sth = $dbh->prepare( - "SELECT * FROM items + "SELECT * FROM items LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber WHERE items.barcode = ?" @@ -759,7 +759,7 @@ sub GetBiblioFromItemNumber { return ($data); } -=head2 GetISBDView +=head2 GetISBDView =over 4 @@ -963,9 +963,9 @@ sub GetMarcStructure { # my ($total) = $sth->fetchrow; # $frameworkcode = "" unless ( $total > 0 ); my $sth = $dbh->prepare( - "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable - FROM marc_tag_structure - WHERE frameworkcode=? + "SELECT tagfield,liblibrarian,libopac,mandatory,repeatable + FROM marc_tag_structure + WHERE frameworkcode=? ORDER BY tagfield" ); $sth->execute($frameworkcode); @@ -979,9 +979,9 @@ sub GetMarcStructure { } $sth = $dbh->prepare( - "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue - FROM marc_subfield_structure - WHERE frameworkcode=? + "SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue + FROM marc_subfield_structure + WHERE frameworkcode=? ORDER BY tagfield,tagsubfield " ); @@ -1029,14 +1029,14 @@ sub GetMarcStructure { the same function as GetMarcStructure except it just takes field in tab 0-9. (used field) - + my $results = GetUsedMarcStructure($frameworkcode); - + L<$results> is a ref to an array which each case containts a ref to a hash which each keys is the columns from marc_subfield_structure - - L<$frameworkcode> is the framework code. - + + L<$frameworkcode> is the framework code. + =cut sub GetUsedMarcStructure($) { @@ -1044,7 +1044,7 @@ sub GetUsedMarcStructure($) { my $query = qq/ SELECT * FROM marc_subfield_structure - WHERE tab > -1 + WHERE tab > -1 AND frameworkcode = ? ORDER BY tagfield, tagsubfield /; @@ -1058,7 +1058,7 @@ sub GetUsedMarcStructure($) { =over 4 ($MARCfield,$MARCsubfield)=GetMarcFromKohaField($kohafield,$frameworkcode); -Returns the MARC fields & subfields mapped to the koha field +Returns the MARC fields & subfields mapped to the koha field for the given frameworkcode =back @@ -1399,23 +1399,25 @@ sub GetMarcSubjects { my $code = $subject_subfield->[0]; my $value = $subject_subfield->[1]; my $linkvalue = $value; + my $limit = ''; $linkvalue =~ s/(\(|\))//g; my $operator = " and " unless $counter == 0; if ( $code eq 9 ) { $found9 = 1; - @link_loop = ( { 'limit' => 'an', link => "$linkvalue" } ); + $limit = 'an'; + @link_loop = ( {link => "$linkvalue" } ); } if ( not $found9 ) { - push @link_loop, { 'limit' => 'su', link => $linkvalue, operator => $operator }; + $limit = 'su'; + push @link_loop, {link => $linkvalue, operator => $operator }; } my $separator = C4::Context->preference("authoritysep") unless $counter == 0; # ignore $9 my @this_link_loop = @link_loop; - push @subfields_loop, { code => $code, value => $value, link_loop => \@this_link_loop, separator => $separator } unless ( $subject_subfield->[0] eq 9 ); + push @subfields_loop, { code => $code, value => $value, link_loop => \@this_link_loop, separator => $separator, limit => $limit} unless ( $subject_subfield->[0] eq 9 ); $counter++; } - push @marcsubjects, { MARCSUBJECT_SUBFIELDS_LOOP => \@subfields_loop }; } @@ -1500,7 +1502,7 @@ sub GetMarcAuthors { $marcurls = GetMarcUrls($record,$marcflavour); Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop. -Assumes web resources (not uncommon in MARC21 to omit resource type ind) +Assumes web resources (not uncommon in MARC21 to omit resource type ind) =back @@ -1998,7 +2000,7 @@ our $inverted_field_map; =back Extract data from a MARC bib record into a hashref representing -Koha biblio, biblioitems, and items fields. +Koha biblio, biblioitems, and items fields. =cut @@ -2131,7 +2133,7 @@ name with the table name would require changing lots of code and templates, and exposing more of the DB structure than is good to the UI templates, particularly since biblio and bibloitems may well merge in a future -version. In the future, it would also be good to +version. In the future, it would also be good to separate DB access and UI presentation field names more. @@ -2447,11 +2449,11 @@ ModZebra( $biblionumber, $op, $server, $oldRecord, $newRecord ); $biblionumber is the biblionumber we want to index $op is specialUpdate or delete, and is used to know what we want to do $server is the server that we want to update - $oldRecord is the MARC::Record containing the previous version of the record. This is used only when + $oldRecord is the MARC::Record containing the previous version of the record. This is used only when NoZebra=1, as NoZebra indexing needs to know the previous version of a record in order to do an update. $newRecord is the MARC::Record containing the new record. It is usefull only when NoZebra=1, and is used to know what to add to the nozebra database. (the record in mySQL being, if it exist, the previous record, the one just before the modif. We need both : the previous and the new one. - + =back =cut @@ -2503,7 +2505,7 @@ sub ModZebra { # # we use zebra, just fill zebraqueue table # - my $check_sql = "SELECT COUNT(*) FROM zebraqueue + my $check_sql = "SELECT COUNT(*) FROM zebraqueue WHERE server = ? AND biblio_auth_number = ? AND operation = ? @@ -2523,7 +2525,7 @@ sub ModZebra { =head2 GetNoZebraIndexes %indexes = GetNoZebraIndexes; - + return the data from NoZebraIndexes syspref. =cut @@ -3067,7 +3069,7 @@ sub _koha_modify_biblioitem_nonmarc { # re-calculate the cn_sort, it may have changed my ($cn_sort) = GetClassSort( $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'}, $biblioitem->{'cn_item'} ); - my $query = "UPDATE biblioitems + my $query = "UPDATE biblioitems SET biblionumber = ?, volume = ?, number = ?, @@ -3290,9 +3292,9 @@ sub _koha_delete_biblioitems { =head2 ModBiblioMarc &ModBiblioMarc($newrec,$biblionumber,$frameworkcode); - - Add MARC data for a biblio to koha - + + Add MARC data for a biblio to koha + Function exported, but should NOT be used, unless you really know what you're doing =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tmpl index 4580103..1fb1616 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tmpl @@ -5,7 +5,7 @@ /includes/favicon.ico" type="image/x-icon" /> - @@ -14,14 +14,14 @@ @@ -234,7 +234,7 @@ function tagAdded() { - + Publisher @@ -254,7 +254,7 @@ function tagAdded() { - + Subject(s) @@ -265,13 +265,13 @@ function tagAdded() { - + Copyright - + Notes @@ -281,7 +281,7 @@ function tagAdded() { - + Unified title @@ -312,20 +312,20 @@ function tagAdded() { - + URL(s)

-
- +
+

- + Location(s) @@ -345,10 +345,10 @@ function tagAdded() {

- Select All + Select All Clear All | Selected items : - + Remove @@ -386,7 +386,7 @@ function tagAdded() { " name="bib" id="bib" onclick="selRecord(value,checked);" /> - + ',)"> @@ -403,7 +403,7 @@ function tagAdded() { &rft.btitle=&rft.date=&rft.tpages=&rft.isbn=&rft.aucorp=&rft.place=&rft.pub=&rft.edition=&rft.series=&rft.genre=">
_status" class="tagstatus results_summary" style="display:none">Tag status here.
- + diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl index e861027..cfc914f 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl @@ -3,7 +3,7 @@ @@ -70,7 +70,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
- /gp/reader//ref=sib_dp_pt/002-7879865-0184864#reader-link" target="_blank">.01.MZZZZZZZ.jpg" alt="Cover Image" />/gp/reader//ref=sib_dp_pt/002-7879865-0184864#reader-link">.01.MZZZZZZZ.jpg" alt="Cover Image" /> + /gp/reader//ref=sib_dp_pt/002-7879865-0184864#reader-link" target="_blank">.01.MZZZZZZZ.jpg" alt="Cover Image" />/gp/reader//ref=sib_dp_pt/002-7879865-0184864#reader-link">.01.MZZZZZZZ.jpg" alt="Cover Image" /> /.GIF&client=&type=xw10&upc=&oclc=" alt="" class="thumbnail" />No cover image available
" class="" id="gbs-thumbnail-preview">
" target="_blank">See Baker & Taylor" />">See Baker & Taylor" /> @@ -86,7 +86,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {

-
by ">
+
by ">
@@ -104,7 +104,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { Authors: - :"> + :"> | @@ -126,11 +126,11 @@ YAHOO.util.Event.onContentReady("furtherm", function () { Published by : "> - + () , - + Physical details: @@ -144,7 +144,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { , ISSN ; - + @@ -152,19 +152,19 @@ YAHOO.util.Event.onContentReady("furtherm", function () { ; - + - Subject(s): + Subject(s): - " href="/cgi-bin/koha/opac-search.pl?q=:"> + " href="/cgi-bin/koha/opac-search.pl?idx=&q="> | - Subject(s): "> | + Subject(s): "> | @@ -183,11 +183,11 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
Online Resources: @@ -207,21 +207,21 @@ YAHOO.util.Event.onContentReady("furtherm", function () { -
-
-
+
+
+
- Reviews from LibraryThing.com: + Reviews from LibraryThing.com: - + List(s) this item appears in: - &sortfield=title"> + &sortfield=title"> | @@ -234,7 +234,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { Tags from this library:
No tags from this library for this title.
+ Tags from this library:
No tags from this library for this title.
@@ -285,7 +285,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
-
- + - +
@@ -712,7 +712,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { "> by © -

+

() ,

@@ -823,7 +823,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { - + " /> @@ -838,7 +838,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
- - - + + + diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index f0a7288..8f743ba 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -77,7 +77,7 @@ if (C4::Context->preference("XSLTDetailsDisplay") ) { 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail'),'opac' ); } -$template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); +$template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); # change back when ive fixed request.pl my @all_items = &GetItemsInfo( $biblionumber, 'opac' ); my @items; @@ -187,7 +187,7 @@ for my $itm (@items) { if( $itm->{'count_reserves'} eq "Waiting"){ $itm->{'waiting'} = 1; } if( $itm->{'count_reserves'} eq "Reserved"){ $itm->{'onhold'} = 1; } } - + my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber}); if ( defined( $transfertwhen ) && $transfertwhen ne '' ) { $itm->{transfertwhen} = format_date($transfertwhen); @@ -307,7 +307,7 @@ foreach my $sc_field (@sc_fields) { $row_data{text} = $sc_field->subfield('r'); $row_data{branch} = $sc_field->subfield('9'); - if ($row_data{text} && $row_data{branch}) { + if ($row_data{text} && $row_data{branch}) { push (@serialcollections, \%row_data); } } @@ -425,18 +425,18 @@ if ( C4::Context->preference("SyndeticsEnabled") } # LibraryThingForLibraries ID Code and Tabbed View Option -if( C4::Context->preference('LibraryThingForLibrariesEnabled') ) -{ +if( C4::Context->preference('LibraryThingForLibrariesEnabled') ) +{ $template->param(LibraryThingForLibrariesID => -C4::Context->preference('LibraryThingForLibrariesID') ); +C4::Context->preference('LibraryThingForLibrariesID') ); $template->param(LibraryThingForLibrariesTabbedView => C4::Context->preference('LibraryThingForLibrariesTabbedView') ); -} +} # Babelthèque if ( C4::Context->preference("Babeltheque") ) { - $template->param( + $template->param( Babeltheque => 1, ); } @@ -456,9 +456,9 @@ if (C4::Context->preference("OPACShelfBrowser")) { $starting_homebranch->{description} = $branches->{$result->{'homebranch'}}{branchname}; $starting_location->{code} = $result->{'location'}; $starting_location->{description} = GetAuthorisedValueDesc('','', $result->{'location'} ,'','','LOC', 'opac'); - + } - + ## List of Previous Items # order by cn_sort, which should include everything we need for ordering purposes (though not # for limits, those need to be handled separately @@ -497,7 +497,7 @@ if (C4::Context->preference("OPACShelfBrowser")) { } unshift @previous_items, $this_item; } - + ## List of Next Items; this also intentionally catches the current item my $sth_shelfbrowse_next; if (defined $starting_location->{code}) { @@ -534,11 +534,11 @@ if (C4::Context->preference("OPACShelfBrowser")) { } push @next_items, $this_item; } - + # alas, these won't auto-vivify, see http://www.perlmonks.org/?node_id=508481 my $shelfbrowser_next_itemnumber = $next_items[-1]->{itemnumber} if @next_items; my $shelfbrowser_next_biblionumber = $next_items[-1]->{biblionumber} if @next_items; - + $template->param( starting_homebranch => $starting_homebranch->{description}, starting_location => $starting_location->{description}, @@ -597,13 +597,13 @@ my $defaulttab; switch (C4::Context->preference('opacSerialDefaultTab')) { # If the user wants subscriptions by default - case "subscriptions" { + case "subscriptions" { # And there are subscriptions, we display them if ($subscriptionsnumber) { $defaulttab = 'subscriptions'; } else { # Else, we try next option - next; + next; } } @@ -617,7 +617,7 @@ switch (C4::Context->preference('opacSerialDefaultTab')) { case "holdings" { if ($dat->{'count'} > 0) { - $defaulttab = 'holdings'; + $defaulttab = 'holdings'; } else { # As this is the last option, we try other options if there are no items if ($subscriptionsnumber) { -- 1.6.0.4