add } that slipped out because of bad merge
[koha.git] / opac / opac-detail.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20
21 use strict;
22 use warnings;
23
24 use CGI;
25 use C4::Auth;
26 use C4::Branch;
27 use C4::Koha;
28 use C4::Serials;    #uses getsubscriptionfrom biblionumber
29 use C4::Output;
30 use C4::Biblio;
31 use C4::Items;
32 use C4::Circulation;
33 use C4::Tags qw(get_tags);
34 use C4::Dates qw/format_date/;
35 use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn get_biblio_from_xisbn);
36 use C4::External::Amazon;
37 use C4::Review;
38 use C4::Serials;
39 use C4::Members;
40 use C4::XSLT;
41
42 BEGIN {
43         if (C4::Context->preference('BakerTaylorEnabled')) {
44                 require C4::External::BakerTaylor;
45                 import C4::External::BakerTaylor qw(&image_url &link_url);
46         }
47 }
48
49 my $query = new CGI;
50 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
51     {
52         template_name   => "opac-detail.tmpl",
53         query           => $query,
54         type            => "opac",
55         authnotrequired => 1,
56         flagsrequired   => { borrow => 1 },
57     }
58 );
59
60 my $biblionumber = $query->param('biblionumber') || $query->param('bib');
61 my $record       = GetMarcBiblio($biblionumber);
62 $template->param( biblionumber => $biblionumber );
63 # XSLT processing of some stuff
64 if (C4::Context->preference("XSLTDetailsDisplay") ) {
65     my $newxmlrecord = XSLTParse4Display($biblionumber,C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACDetail.xsl");
66     $template->param('XSLTBloc' => $newxmlrecord);
67 }
68
69 # change back when ive fixed request.pl
70 my @all_items = &GetItemsInfo( $biblionumber, 'opac' );
71 my @items;
72 @items = @all_items unless C4::Context->preference('hidelostitems');
73
74 if (C4::Context->preference('hidelostitems')) {
75     # Hide host items
76     for my $itm (@all_items) {
77         push @items, $itm unless $itm->{itemlost};
78     }
79 }
80 my $dat = &GetBiblioData($biblionumber);
81
82 if (!$dat) {
83     print $query->redirect("/cgi-bin/koha/errors/404.pl");
84     exit;
85 }
86 my $itemtypes = GetItemTypes();
87 # imageurl:
88 my $itemtype = $dat->{'itemtype'};
89 if ( $itemtype ) {
90     $dat->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
91     $dat->{'description'} = $itemtypes->{$itemtype}->{'description'};
92 }
93 my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'});
94 my $collections =  GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'} );
95
96 #coping with subscriptions
97 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
98 my @subscriptions       = GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );
99 my @subs;
100 $dat->{'serial'}=1 if $subscriptionsnumber;
101 foreach my $subscription (@subscriptions) {
102     my %cell;
103     $cell{subscriptionid}    = $subscription->{subscriptionid};
104     $cell{subscriptionnotes} = $subscription->{notes};
105     $cell{branchcode}        = $subscription->{branchcode};
106     $cell{hasalert}          = $subscription->{hasalert};
107     #get the three latest serials.
108     $cell{latestserials} =
109       GetLatestSerials( $subscription->{subscriptionid}, 3 );
110     push @subs, \%cell;
111 }
112
113 $dat->{'count'} = scalar(@items);
114
115 my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) );
116
117 my $norequests = 1;
118 my $branches = GetBranches();
119 my %itemfields;
120 for my $itm (@items) {
121     $norequests = 0
122        if ( (not $itm->{'wthdrawn'} )
123          && (not $itm->{'itemlost'} )
124          && ($itm->{'itemnotforloan'}<0 || not $itm->{'itemnotforloan'} )
125                  && (not $itemtypes->{$itm->{'itype'}}->{notforloan} )
126          && ($itm->{'itemnumber'} ) );
127
128     if ( defined $itm->{'publictype'} ) {
129         # I can't actually find any case in which this is defined. --amoore 2008-12-09
130         $itm->{ $itm->{'publictype'} } = 1;
131     }
132     $itm->{datedue}      = format_date($itm->{datedue});
133     $itm->{datelastseen} = format_date($itm->{datelastseen});
134
135     # get collection code description, too
136     if ( my $ccode = $itm->{'ccode'} ) {
137         $itm->{'ccode'} = $collections->{$ccode} if ( defined($collections) && exists( $collections->{$ccode} ) );
138     }
139     if ( defined $itm->{'location'} ) {
140         $itm->{'location_description'} = $shelflocations->{ $itm->{'location'} };
141     }
142     if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
143         $itm->{'imageurl'}    = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
144         $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{'description'};
145     }
146     foreach (qw(ccode enumchron copynumber itemnotes)) {
147         $itemfields{$_} = 1 if ($itm->{$_});
148     }
149
150      # walk through the item-level authorised values and populate some images
151      my $item_authorised_value_images = C4::Items::get_authorised_value_images( C4::Items::get_item_authorised_values( $itm->{'itemnumber'} ) );
152      # warn( Data::Dumper->Dump( [ $item_authorised_value_images ], [ 'item_authorised_value_images' ] ) );
153
154      if ( $itm->{'itemlost'} ) {
155          my $lostimageinfo = List::Util::first { $_->{'category'} eq 'LOST' } @$item_authorised_value_images;
156          $itm->{'lostimageurl'}   = $lostimageinfo->{ 'imageurl' };
157          $itm->{'lostimagelabel'} = $lostimageinfo->{ 'label' };
158      }
159
160      if( $itm->{'count_reserves'}){
161           if( $itm->{'count_reserves'} eq "Waiting"){ $itm->{'waiting'} = 1; }
162           if( $itm->{'count_reserves'} eq "Reserved"){ $itm->{'onhold'} = 1; }
163      }
164     
165      my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
166      if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
167         $itm->{transfertwhen} = format_date($transfertwhen);
168         $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
169         $itm->{transfertto}   = $branches->{$transfertto}{branchname};
170      }
171 }
172
173 ## get notes and subjects from MARC record
174 my $dbh              = C4::Context->dbh;
175 my $marcflavour      = C4::Context->preference("marcflavour");
176 my $marcnotesarray   = GetMarcNotes   ($record,$marcflavour);
177 my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour);
178 my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour);
179 my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
180 my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
181 my $subtitle         = C4::Biblio::get_koha_field_from_marc('bibliosubtitle', 'subtitle', $record, '');
182
183     $template->param(
184                      MARCNOTES               => $marcnotesarray,
185                      MARCSUBJCTS             => $marcsubjctsarray,
186                      MARCAUTHORS             => $marcauthorsarray,
187                      MARCSERIES              => $marcseriesarray,
188                      MARCURLS                => $marcurlsarray,
189                      norequests              => $norequests,
190                      RequestOnOpac           => C4::Context->preference("RequestOnOpac"),
191                      itemdata_ccode          => $itemfields{ccode},
192                      itemdata_enumchron      => $itemfields{enumchron},
193                      itemdata_copynumber     => $itemfields{copynumber},
194                      itemdata_itemnotes          => $itemfields{itemnotes},
195                      authorised_value_images => $biblio_authorised_value_images,
196                      subtitle                => $subtitle,
197     );
198
199 foreach ( keys %{$dat} ) {
200     $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' );
201 }
202
203 # COinS format FIXME: for books Only
204 $template->param(
205     ocoins => GetCOinSBiblio($biblionumber),
206 );
207
208 my $reviews = getreviews( $biblionumber, 1 );
209 my $loggedincommenter;
210 foreach ( @$reviews ) {
211     my $borrowerData   = GetMember($_->{borrowernumber},'borrowernumber');
212     # setting some borrower info into this hash
213     $_->{title}     = $borrowerData->{'title'};
214     $_->{surname}   = $borrowerData->{'surname'};
215     $_->{firstname} = $borrowerData->{'firstname'};
216     $_->{userid}    = $borrowerData->{'userid'};
217     $_->{datereviewed} = format_date($_->{datereviewed});
218     if ($borrowerData->{'borrowernumber'} eq $borrowernumber) {
219                 $_->{your_comment} = 1;
220                 $loggedincommenter = 1;
221         }
222 }
223
224
225 if(C4::Context->preference("ISBD")) {
226         $template->param(ISBD => 1);
227 }
228
229 $template->param(
230     ITEM_RESULTS        => \@items,
231     subscriptionsnumber => $subscriptionsnumber,
232     biblionumber        => $biblionumber,
233     subscriptions       => \@subs,
234     subscriptionsnumber => $subscriptionsnumber,
235     reviews             => $reviews,
236     loggedincommenter   => $loggedincommenter
237 );
238
239 sub isbn_cleanup ($) {
240         my $isbn=shift;
241     ($isbn) = $isbn =~ /([\d-]*[X]*)/;
242     $isbn =~ s/-//g;
243         if (
244                 $isbn =~ /\b(\d{13})\b/ or
245                 $isbn =~ /\b(\d{10})\b/ or 
246                 $isbn =~ /\b(\d{9}X)\b/i
247         ) {
248                 return $1;
249         }
250         return undef;
251 }
252
253 # XISBN Stuff
254 my $xisbn=$dat->{'isbn'};
255 (my $aisbn) = $xisbn =~ /([\d-]*[X]*)/;
256 $aisbn =~ s/-//g;
257 $template->param(amazonisbn => $aisbn);         # FIXME: so it is OK if the ISBN = 'XXXXX' ?
258 my ($clean,$clean2);
259 # these might be overkill, but they are better than the regexp above.
260 if ($clean = isbn_cleanup($xisbn)){
261         $template->param(clean_isbn => $clean);
262 }
263
264 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
265     eval {
266         $template->param(
267             xisbn => $xisbn,
268             XISBNS => get_xisbns($xisbn)
269         );
270     };
271     if ($@) { warn "XISBN Failed $@"; }
272 }
273 # Amazon.com Stuff
274 if ( C4::Context->preference("OPACAmazonEnabled") ) {
275     $template->param( AmazonTld => get_amazon_tld() );
276 }
277 if ( C4::Context->preference("OPACAmazonEnabled") && C4::Context->preference("OPACAmazonSimilarItems") ) {
278     my $similar_products_exist;
279     my $amazon_details = &get_amazon_details( $xisbn, $record, $marcflavour );
280     my $item_attributes = \%{$amazon_details->{Items}->{Item}->{ItemAttributes}};
281     my $customer_reviews = \@{$amazon_details->{Items}->{Item}->{CustomerReviews}->{Review}};
282     for my $one_review (@$customer_reviews) {
283         $one_review->{Date} = format_date($one_review->{Date});
284     }
285     my @similar_products;
286     for my $similar_product (@{$amazon_details->{Items}->{Item}->{SimilarProducts}->{SimilarProduct}}) {
287         # do we have any of these isbns in our collection?
288         my $similar_biblionumbers = get_biblionumber_from_isbn($similar_product->{ASIN});
289         # verify that there is at least one similar item
290         if (scalar(@$similar_biblionumbers)){
291             $similar_products_exist++ if ($similar_biblionumbers && $similar_biblionumbers->[0]);
292             push @similar_products, +{ similar_biblionumbers => $similar_biblionumbers, title => $similar_product->{Title}, ASIN => $similar_product->{ASIN}  };
293         }
294     }
295     my $editorial_reviews = \@{$amazon_details->{Items}->{Item}->{EditorialReviews}->{EditorialReview}};
296     my $average_rating = $amazon_details->{Items}->{Item}->{CustomerReviews}->{AverageRating} || 0;
297     $template->param( OPACAmazonSimilarItems => $similar_products_exist );
298     $template->param( amazon_average_rating => $average_rating * 20);
299     $template->param( AMAZON_CUSTOMER_REVIEWS    => $customer_reviews );
300     $template->param( AMAZON_SIMILAR_PRODUCTS => \@similar_products );
301     $template->param( AMAZON_EDITORIAL_REVIEWS    => $editorial_reviews );
302 }
303
304 my $syndetics_elements;
305
306 if ( C4::Context->preference("SyndeticsEnabled") ) {
307         eval {
308     $syndetics_elements = &get_syndetics_index($isbn,$upc,$oclc);
309         for my $element (values %$syndetics_elements) {
310                 $template->param("Syndetics$element"."Exists" => 1 );
311                 #warn "Exists: "."Syndetics$element"."Exists";
312         }
313     };
314     warn $@ if $@;
315 }
316
317 if ( C4::Context->preference("SyndeticsEnabled")
318         && C4::Context->preference("SyndeticsSummary")
319         && $syndetics_elements->{'SUMMARY'} =~ /SUMMARY/) {
320         eval {
321         my $syndetics_summary = &get_syndetics_summary($isbn,$upc,$oclc);
322         $template->param( SYNDETICS_SUMMARY => $syndetics_summary );
323         };
324         warn $@ if $@;
325
326 }
327
328 if ( C4::Context->preference("SyndeticsEnabled")
329         && C4::Context->preference("SyndeticsTOC")
330         && $syndetics_elements->{'TOC'} =~ /TOC/) {
331         eval {
332     my $syndetics_toc = &get_syndetics_toc($isbn,$upc,$oclc);
333     $template->param( SYNDETICS_TOC => $syndetics_toc );
334         };
335         warn $@ if $@;
336 }
337
338 if ( C4::Context->preference("SyndeticsEnabled")
339     && C4::Context->preference("SyndeticsExcerpt")
340     && $syndetics_elements->{'DBCHAPTER'} =~ /DBCHAPTER/ ) {
341     eval {
342     my $syndetics_excerpt = &get_syndetics_excerpt($isbn,$upc,$oclc);
343     $template->param( SYNDETICS_EXCERPT => $syndetics_excerpt );
344     };
345         warn $@ if $@;
346 }
347
348 if ( C4::Context->preference("SyndeticsEnabled")
349     && C4::Context->preference("SyndeticsReviews")) {
350     eval {
351     my $syndetics_reviews = &get_syndetics_reviews($isbn,$upc,$oclc,$syndetics_elements);
352     $template->param( SYNDETICS_REVIEWS => $syndetics_reviews );
353     };
354         warn $@ if $@;
355 }
356
357 if ( C4::Context->preference("SyndeticsEnabled")
358     && C4::Context->preference("SyndeticsAuthorNotes")
359         && $syndetics_elements->{'ANOTES'} =~ /ANOTES/ ) {
360     eval {
361     my $syndetics_anotes = &get_syndetics_anotes($isbn,$upc,$oclc);
362     $template->param( SYNDETICS_ANOTES => $syndetics_anotes );
363     };
364     warn $@ if $@;
365 }
366
367 # Babelthèque
368 if ( C4::Context->preference("Babeltheque") ) {
369     $template->param( 
370         Babeltheque => 1,
371     );
372 }
373
374 # Shelf Browser Stuff
375 if (C4::Context->preference("OPACShelfBrowser")) {
376     # pick the first itemnumber unless one was selected by the user
377     my $starting_itemnumber = $query->param('shelfbrowse_itemnumber'); # || $items[0]->{itemnumber};
378     $template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
379     # find the right cn_sort value for this item
380     my ($starting_cn_sort, $starting_homebranch, $starting_location);
381     my $sth_get_cn_sort = $dbh->prepare("SELECT cn_sort,homebranch,location from items where itemnumber=?");
382     $sth_get_cn_sort->execute($starting_itemnumber);
383     while (my $result = $sth_get_cn_sort->fetchrow_hashref()) {
384         $starting_cn_sort = $result->{'cn_sort'};
385         $starting_homebranch->{code} = $result->{'homebranch'};
386         $starting_homebranch->{description} = $branches->{$result->{'homebranch'}}{branchname};
387         $starting_location->{code} = $result->{'location'};
388         $starting_location->{description} = GetAuthorisedValueDesc('','',   $result->{'location'} ,'','','LOC');
389     
390     }
391     
392     ## List of Previous Items
393     # order by cn_sort, which should include everything we need for ordering purposes (though not
394     # for limits, those need to be handled separately
395     my $sth_shelfbrowse_previous;
396     if (defined $starting_location->{code}) {
397       $sth_shelfbrowse_previous = $dbh->prepare("
398         SELECT *
399         FROM items
400         WHERE
401             ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) AND
402             homebranch = ? AND location = ?
403         ORDER BY cn_sort DESC, itemnumber LIMIT 3
404         ");
405       $sth_shelfbrowse_previous->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code});
406     } else {
407       $sth_shelfbrowse_previous = $dbh->prepare("
408         SELECT *
409         FROM items
410         WHERE
411             ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) AND
412             homebranch = ?
413         ORDER BY cn_sort DESC, itemnumber LIMIT 3
414         ");
415       $sth_shelfbrowse_previous->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code});
416     }
417     my @previous_items;
418     while (my $this_item = $sth_shelfbrowse_previous->fetchrow_hashref()) {
419         my $sth_get_biblio = $dbh->prepare("SELECT biblio.*,biblioitems.isbn AS isbn FROM biblio LEFT JOIN biblioitems ON biblio.biblionumber=biblioitems.biblionumber WHERE biblio.biblionumber=?");
420         $sth_get_biblio->execute($this_item->{biblionumber});
421         while (my $this_biblio = $sth_get_biblio->fetchrow_hashref()) {
422             $this_item->{'title'} = $this_biblio->{'title'};
423             if ($clean2 = isbn_cleanup($this_biblio->{'isbn'})) {
424                 $this_item->{'isbn'} = $clean2;
425             } else { 
426                 $this_item->{'isbn'} = $this_biblio->{'isbn'};
427             }
428         }
429         unshift @previous_items, $this_item;
430     }
431     
432     ## List of Next Items; this also intentionally catches the current item
433     my $sth_shelfbrowse_next;
434     if (defined $starting_location->{code}) {
435       $sth_shelfbrowse_next = $dbh->prepare("
436         SELECT *
437         FROM items
438         WHERE
439             ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) AND
440             homebranch = ? AND location = ?
441         ORDER BY cn_sort, itemnumber LIMIT 3
442       $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code});
443     } else {
444       $sth_shelfbrowse_next = $dbh->prepare("
445         SELECT *
446         FROM items
447         WHERE
448             ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) AND
449             homebranch = ?
450         ORDER BY cn_sort, itemnumber LIMIT 3
451         ");
452       $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code});
453     }
454     my @next_items;
455     while (my $this_item = $sth_shelfbrowse_next->fetchrow_hashref()) {
456         my $sth_get_biblio = $dbh->prepare("SELECT biblio.*,biblioitems.isbn AS isbn FROM biblio LEFT JOIN biblioitems ON biblio.biblionumber=biblioitems.biblionumber WHERE biblio.biblionumber=?");
457         $sth_get_biblio->execute($this_item->{biblionumber});
458         while (my $this_biblio = $sth_get_biblio->fetchrow_hashref()) {
459             $this_item->{'title'} = $this_biblio->{'title'};
460             if ($clean2 = isbn_cleanup($this_biblio->{'isbn'})) {
461                 $this_item->{'isbn'} = $clean2;
462             } else { 
463                 $this_item->{'isbn'} = $this_biblio->{'isbn'};
464             }
465         }
466         push @next_items, $this_item;
467     }
468
469
470     # alas, these won't auto-vivify, see http://www.perlmonks.org/?node_id=508481
471     my $shelfbrowser_next_itemnumber = $next_items[-1]->{itemnumber} if @next_items;
472     my $shelfbrowser_next_biblionumber = $next_items[-1]->{biblionumber} if @next_items;
473     
474     $template->param(
475         starting_homebranch => $starting_homebranch->{description},
476         starting_location => $starting_location->{description},
477         starting_itemnumber => $starting_itemnumber,
478         shelfbrowser_prev_itemnumber => (@previous_items ? $previous_items[0]->{itemnumber} : 0),
479         shelfbrowser_next_itemnumber => $shelfbrowser_next_itemnumber,
480         shelfbrowser_prev_biblionumber => (@previous_items ? $previous_items[0]->{biblionumber} : 0),
481         shelfbrowser_next_biblionumber => $shelfbrowser_next_biblionumber,
482         PREVIOUS_SHELF_BROWSE => \@previous_items,
483         NEXT_SHELF_BROWSE => \@next_items,
484     );
485 }
486
487 if (C4::Context->preference("BakerTaylorEnabled")) {
488         $template->param(
489                 BakerTaylorEnabled  => 1,
490                 BakerTaylorImageURL => &image_url(),
491                 BakerTaylorLinkURL  => &link_url(),
492                 BakerTaylorBookstoreURL => C4::Context->preference('BakerTaylorBookstoreURL'),
493         );
494         my ($bt_user, $bt_pass);
495         if ($clean and
496                 $bt_user = C4::Context->preference('BakerTaylorUsername') and
497                 $bt_pass = C4::Context->preference('BakerTaylorPassword')    )
498         {
499                 $template->param(
500                 BakerTaylorContentURL   =>
501                 sprintf("http://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=%s&Password=%s&ItemKey=%s&Options=Y",
502                                 $bt_user,$bt_pass,$clean)
503                 );
504         }
505 }
506
507 my $tag_quantity;
508 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnDetail')) {
509         $template->param(
510                 TagsEnabled => 1,
511                 TagsShowOnDetail => $tag_quantity,
512                 TagsInputOnDetail => C4::Context->preference('TagsInputOnDetail')
513         );
514         $template->param(TagLoop => get_tags({biblionumber=>$biblionumber, approved=>1,
515                                                                 'sort'=>'-weight', limit=>$tag_quantity}));
516 }
517
518 output_html_with_http_headers $query, $cookie, $template->output;