From c406fb83473961b206502a98eda285a088d4ce6e Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Tue, 21 Oct 2014 12:52:54 -0400
Subject: [PATCH] Bug 13119 - Use XSLT to display tagged titles in the OPAC

This patch updates the display of a logged-in user's tagged titles to
use the same XSLT stylesheet used by search results and Lists. This
would make for a more consistent display of information.

Unrelated change: Corrected "My tags" header to read "Your tags,"
consistent with sidebar navigation.

To test you should have multiple titles in your catalog which you have
tagged in the OPAC.

- Set the OPACXSLTResultsDisplay system preference to 'default'
- Log in to the OPAC and view the "your tags" page.
- Confirm that title information is displayed correctly. Compare to
  search results.
- Empty the OPACXSLTResultsDisplay system preference and reload the
  "your tags" page. The display should revert to the old view, showing
  title, subtitle (if any) and author (if any).
- Set the OPACXSLTResultsDisplay to a custom path pointing to a custom
  XSL file and confirm that the list of your tagged titles changes
  accordingly.

Note: A follow-up will add "action" links ("place hold," "add to cart,"
etc) consistent with other pages.

Signed-off-by: Frederic Demians <f.demians@tamil.fr>

Works as described. opac-tag.pl page displays tagged titles the same way as
result & list pages.
---
 .../opac-tmpl/bootstrap/en/modules/opac-tags.tt    | 22 ++++++++++++++++++----
 opac/opac-tags.pl                                  |  4 ++++
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt
index 2811bd0..b9a7072 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt
@@ -113,7 +113,7 @@
 
                         [% IF ( MY_TAGS ) %]
                         <form method="post" action="opac-tags.pl">
-                            <h2>My Tags</h2>
+                            <h2>Your tags</h2>
                             <table id="mytagst" class="table table-bordered table-striped">
                                 <thead><tr><th>Term</th><th>Title</th><th>Date added</th><th>Delete</th></tr></thead>
                                 <tbody>
@@ -124,9 +124,23 @@
                                                 <a href="/cgi-bin/koha/opac-search.pl?tag=[% MY_TAG.term |url %]&amp;q=[% MY_TAG.term |url %]">
                                             [% MY_TAG.term |html %]</a></td>
                                             <td>
-                                                <span class="tdlabel">Title:</span>
-                                                <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% MY_TAG.biblionumber %]">
-                                                [% MY_TAG.title |html %][% IF ( MY_TAG.subtitle ) %][% FOREACH subtitle IN MY_TAG.subtitle %] [% subtitle.subfield |html %][% END %][% END %]</a> [% IF ( MY_TAG.author ) %]by [% MY_TAG.author %][% END %]</td>
+                                                [% IF ( MY_TAG.XSLTBloc ) %]
+                                                    [% MY_TAG.XSLTBloc %]
+                                                [% ELSE %]
+                                                    <span class="tdlabel">Title:</span>
+                                                    <a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% MY_TAG.biblionumber %]">
+                                                        [% MY_TAG.title |html %]
+                                                        [% IF ( MY_TAG.subtitle ) %]
+                                                            [% FOREACH subtitle IN MY_TAG.subtitle %]
+                                                                [% subtitle.subfield |html %]
+                                                            [% END %]
+                                                        [% END %]
+                                                    </a>
+                                                    [% IF ( MY_TAG.author ) %]
+                                                        by [% MY_TAG.author %]
+                                                    [% END %]
+                                                [% END # /IF MY_TAG.XSLTBloc %]
+                                            </td>
                                             <td>
                                                 <span title="[% MY_TAG.date_created %]">
                                                     <span class="tdlabel">Date added:</span>
diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl
index 6c402a5..5a058d2 100755
--- a/opac/opac-tags.pl
+++ b/opac/opac-tags.pl
@@ -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;
 
@@ -232,6 +233,9 @@ if ($loggedinuser) {
         $_->{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;
-- 
2.1.2