Bug 6679: Fixing code so it passes basic Perl:::Critic tests
[koha.git] / opac / opac-tags.pl
index a856081..f41fae7 100755 (executable)
@@ -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 <http://www.gnu.org/licenses>.
 
 
 =head1 NAME
@@ -32,7 +32,7 @@ C4::Scrubber is used to remove all markup content from the sumitted text.
 
 use strict;
 use warnings;
-use CGI;
+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,6 +42,7 @@ 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;
 
@@ -58,7 +59,7 @@ sub ajax_auth_cgi {     # returns CGI object
        my $needed_flags = shift;
        my %cookies = fetch CGI::Cookie;
        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 +110,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,
        });
 }
 
@@ -228,16 +229,20 @@ 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 $record = &GetMarcBiblio( $_->{biblionumber} );
+        $_->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $_->{biblionumber} ) );
+        $_->{title} = $biblio->{title};
+        $_->{author} = $biblio->{author};
+        if (C4::Context->preference("OPACXSLTResultsDisplay")) {
+            $_->{XSLTBloc} = XSLTParse4Display($_->{biblionumber}, $record, "OPACXSLTResultsDisplay");
+        }
                my $date = $_->{date_created} || '';
                $date =~ /\s+(\d{2}\:\d{2}\:\d{2})/;
                $_->{time_created_display} = $1;
        }
 }
 
-$template->param(tagsview => 1,
-dateformat => C4::Context->preference("dateformat"));
+$template->param(tagsview => 1);
 
 if ($add_op) {
        my $adds = 0;