X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=opac%2Fopac-tags.pl;h=267c3c024993cab98d5ac6e39d42af671a35edd1;hb=41397c855397aee9847943c2f124e0bdc8ba7eb7;hp=a856081dabd8506765f485078a34545f511b0059;hpb=a8c5497b8da7de25b7c4787ee5540e4e1b48704d;p=koha.git diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl index a856081dab..267c3c0249 100755 --- a/opac/opac-tags.pl +++ b/opac/opac-tags.pl @@ -4,18 +4,18 @@ # # 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 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 3 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. +# 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. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . =head1 NAME @@ -30,9 +30,9 @@ C4::Scrubber is used to remove all markup content from the sumitted text. =cut -use strict; -use warnings; -use CGI; +use Modern::Perl; + +use CGI qw ( -utf8 ); use CGI::Cookie; # need to check cookies before having CGI parse the POST request use C4::Auth qw(:DEFAULT check_cookie_auth); @@ -42,9 +42,12 @@ use C4::Output qw(:html :ajax pagination_bar); use C4::Scrubber; use C4::Biblio; use C4::Tags qw(add_tag get_approval_rows get_tag_rows remove_tag stratify_tags); +use C4::XSLT; use Data::Dumper; +use Koha::Biblios; + my %newtags = (); my @deltags = (); my %counts = (); @@ -56,9 +59,9 @@ my @globalErrorIndexes = (); sub ajax_auth_cgi { # returns CGI object my $needed_flags = shift; - my %cookies = fetch CGI::Cookie; + my %cookies = CGI::Cookie->fetch; my $input = CGI->new; - my $sessid = $cookies{'CGISESSID'}->value || $input->param('CGISESSID'); + my $sessid = $cookies{'CGISESSID'}->value; my ($auth_status, $auth_sessid) = check_cookie_auth($sessid, $needed_flags); $debug and print STDERR "($auth_status, $auth_sessid) = check_cookie_auth($sessid," . Dumper($needed_flags) . ")\n"; @@ -109,11 +112,11 @@ if ($is_ajax) { $debug and print STDERR "op: $loggedinuser\n"; } else { ($template, $loggedinuser, $cookie) = get_template_and_user({ - template_name => "opac-tags.tmpl", - query => $query, - type => "opac", - authnotrequired => ($add_op ? 0 : 1), # auth required to add tags - debug => 1, + template_name => "opac-tags.tt", + query => $query, + type => "opac", + authnotrequired => ($add_op ? 0 : 1), # auth required to add tags + debug => 1, }); } @@ -225,19 +228,34 @@ my $results = []; my $my_tags = []; if ($loggedinuser) { - $my_tags = get_tag_rows({borrowernumber=>$loggedinuser}); - foreach (@$my_tags) { - my $biblio = GetBiblioData($_->{biblionumber}); - $_->{bib_summary} = $biblio->{title}; - ($biblio->{author}) and $_->{bib_summary} .= " by " . $biblio->{author}; - my $date = $_->{date_created} || ''; - $date =~ /\s+(\d{2}\:\d{2}\:\d{2})/; - $_->{time_created_display} = $1; - } + $my_tags = get_tag_rows({borrowernumber=>$loggedinuser}); + my $my_approved_tags = get_approval_rows({ approved => 1 }); + foreach my $tag (@$my_tags) { + my $biblio = Koha::Biblios->find( $tag->{biblionumber} ); + my $record = &GetMarcBiblio({ biblionumber => $tag->{biblionumber} }); + $tag->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $tag->{biblionumber} ) ); + $tag->{title} = $biblio->title; + $tag->{author} = $biblio->author; + + my $xslfile = C4::Context->preference('OPACXSLTResultsDisplay'); + my $lang = $xslfile ? C4::Languages::getlanguage() : undef; + my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef; + + if ( $xslfile ) { + $tag->{XSLTBloc} = XSLTParse4Display( + $tag->{ biblionumber }, $record, "OPACXSLTResultsDisplay", + 1, undef, $sysxml, $xslfile, $lang + ); + } + + my $date = $tag->{date_created} || ''; + $date =~ /\s+(\d{2}\:\d{2}\:\d{2})/; + $tag->{time_created_display} = $1; + $tag->{approved} = ( grep { $_->{term} eq $tag->{term} and $_->{approved} } @$my_approved_tags ); + } } -$template->param(tagsview => 1, -dateformat => C4::Context->preference("dateformat")); +$template->param(tagsview => 1); if ($add_op) { my $adds = 0;