Bug 13388: Add library pages to the OPAC
authorOwen Leonard <oleonard@myacpl.org>
Tue, 28 Apr 2020 19:23:55 +0000 (19:23 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 4 May 2020 08:11:03 +0000 (09:11 +0100)
This patch adds a script and a template for showing library information
pages in the OPAC. A "libraries" page lists all the libraries in the
system, linking to individual pages for each library showing more
information..

If there is only one library in the system the page shows all of that
library's information.

To test, apply the patch and rebuild the OPAC CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

 - Go to /cgi-bin/koha/opac-library.pl in the OPAC.
 - Verify that all the correct information is displayed for the
   libraries in your system.
 - Verify that page title and breadcrumbs look correct.
 - Click to view details for a library.
   - The details page should show the full contents of
     branches.opac_info
   - A menu should show links to other libraries' detail pages.

EDIT: This revised patch adds a "Libraries" link to the links under the
search bar; Corrects encoding in the breadcrumb link; Makes the page
title more specific when viewing an individual library.

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss
koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt [new file with mode: 0644]
opac/opac-library.pl [new file with mode: 0755]

index d78fd16..8babc17 100644 (file)
@@ -1649,6 +1649,28 @@ div {
 }
 
 /* nav */
+
+nav {
+    &.libraries {
+        li {
+            list-style-type: none;
+            padding: .3em .5em;
+
+            a {
+                display: block;
+            }
+        }
+
+        i.fa {
+            color:  #7cbc0f;
+        }
+
+        .fa-li {
+            top:  unset;
+        }
+    }
+}
+
 .nav_pages {
     border-top: 1px solid #DDD;
     padding: .6em;
index 9084597..efe0551 100644 (file)
                                             <li><a href="/cgi-bin/koha/opac-suggestions.pl?suggested_by_anyone=1">Purchase suggestions</a></li>
                                         [% END %]
                                     [% END %]
+                                    <li><a href="/cgi-bin/koha/opac-library.pl">Libraries</a></li>
                                     [% Koha.Preference('OpacMoreSearches') | $raw %]
                                 </ul>
                             </div> <!-- /#moresearches -->
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-library.tt
new file mode 100644 (file)
index 0000000..8d9680c
--- /dev/null
@@ -0,0 +1,149 @@
+[% USE raw %]
+[% USE Asset %]
+[% USE Koha %]
+[% INCLUDE 'doc-head-open.inc' %]
+<title>
+    [% IF ( LibraryNameTitle ) %]
+        [% LibraryNameTitle | html %]
+    [% ELSE %]
+        Koha online
+    [% END %] catalog &rsaquo; Libraries
+    [% IF ( library ) %]
+        &rsaquo; [% library.branchname | html %]
+    [% END %]
+</title>
+[% INCLUDE 'doc-head-close.inc' %]
+[% BLOCK cssinclude %][% END %]
+</head>
+
+[% INCLUDE 'bodytag.inc' bodyid='opac-library' bodyclass='scrollto' %]
+[% INCLUDE 'masthead.inc' %]
+
+[% BLOCK library_description %]
+    <div property="description">
+        [% library.opac_info | $raw %]
+    </div>
+[% END %]
+
+[% BLOCK library_info %]
+    <div property="address" typeof="PostalAddress">
+        <p>
+            <span property="streetAddress">
+                [% IF ( library.branchaddress1 ) %]
+                    [% library.branchaddress1 | html %]
+                [% END %]
+                [% IF ( library.branchaddress2 ) %]
+                    <br />[% library.branchaddress2 | html %]
+                [% END %]
+                [% IF ( library.branchaddress3 ) %]
+                    <br />[% library.branchaddress3 | html %]
+                [% END %]
+            </span><br>
+            [% IF ( library.branchcity ) %]
+                <span property="addressLocality">[% library.branchcity | html %]</span>
+            [% END %]
+            [% IF ( library.branchstate ) %]
+                <span property="addressRegion">[% library.branchstate | html %]</span>
+            [% END %]
+            [% IF ( library.branchzip ) %]
+                <span property="postalCode">[% library.branchzip | html %]</span>
+            [% END %]
+            [% IF ( library.branchcountry ) %]
+                <br /><span property="addressCountry">[% library.branchcountry | html %]</span>
+            [% END %]
+            [% IF ( library.branchphone ) %]
+                <p>Phone: <a href="tel:[% library.branchphone | url %]" property="telephone">[% library.branchphone | html %]</a></p>
+            [% END %]
+            [% IF ( library.branchfax ) %]
+                <p>Fax: <span property="faxNumber">[% library.branchfax | html %]</span></p>
+            [% END %]
+            [% IF ( library.branchemail ) %]
+                <p>Email: <a href="mailto:[% library.branchemail | url %]" property="email">[% library.branchemail | html %]</a></p>
+            [% END %]
+            [% IF ( library.branchurl ) %]
+                <p><a href="[% library.branchurl | url %]" property="url">[% library.branchurl | html %]</a></p>
+            [% END %]
+        </p>
+    </div> <!-- /div property=address -->
+[% END %]
+
+<div class="main">
+    <ul class="breadcrumb">
+        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
+        <li><a href="/cgi-bin/koha/opac-library.pl">Libraries</a>
+        [% IF ( library ) %]
+            <span class="divider">&rsaquo;</span></li>
+            <li><a href="#">[% library.branchname | html %]</a></li>
+        [% ELSE %]
+            </li>
+        [% END %]
+    </ul>
+
+    <div class="container-fluid">
+        <div class="row-fluid">
+            <div class="span12">
+
+                [% IF ( library ) %]
+
+                    <div id="library_info" class="maincontent" vocab="http://schema.org/" typeof="Library">
+                        <h3 property="name">[% library.branchname | html %]</h3>
+
+                        <div class="row-fluid">
+                            <div class="span8">
+                                [% PROCESS library_info %]
+                                [% IF ( library.opac_info ) %]
+                                    <hr />
+                                    [% PROCESS library_description %]
+                                [% END %]
+                            </div>
+                            <div class="span4">
+                                [% IF ( libraries.count > 1 ) %]
+                                    <nav class="libraries">
+                                        <ul class="fa-ul">
+                                            [% FOREACH library IN libraries %]
+                                                [% IF ( branchcode == library.branchcode ) %]
+                                                    <li class="current">
+                                                        <a href="/cgi-bin/koha/opac-library.pl?branchcode=[% library.branchcode | url %]">
+                                                            <i class="fa fa-li fa-map-pin" aria-hidden="true"></i> [% library.branchname | html %]
+                                                        </a>
+                                                    </li>
+                                                [% ELSE %]
+                                                    <li>
+                                                        <a href="/cgi-bin/koha/opac-library.pl?branchcode=[% library.branchcode | url %]">
+                                                            <i class="fa fa-li" aria-hidden="true"></i> [% library.branchname | html %]
+                                                        </a>
+                                                    </li>
+                                                [% END %]
+                                            [% END %]
+                                        </ul>
+                                    </nav>
+                                [% END %]
+                            </div>
+                        </div>
+                    </div> <!-- /#library_info -->
+
+                [% ELSE %]
+                    <h2>Libraries</h2>
+
+                    [% FOREACH library IN libraries %]
+                        <h3 property="name">
+                            [% IF ( libraries.count > 1 ) %]
+                                <a href="/cgi-bin/koha/opac-library.pl?branchcode=[% library.branchcode | url %]">[% library.branchname | html %]</a>
+                            [% ELSE %]
+                                [% library.branchname | html %]
+                            [% END %]
+                        </h3>
+                        [% PROCESS library_info %]
+                        <hr>
+                        [% IF ( libraries.count == 1 ) %]
+                            [% PROCESS library_description %]
+                        [% END %]
+                    [% END %]
+
+                [% END %]
+
+        </div> <!-- /.row-fluid -->
+    </div> <!-- /.container-fluid -->
+</div> <!-- / .main -->
+[% INCLUDE 'opac-bottom.inc' %]
+[% BLOCK jsinclude %][% END %]
diff --git a/opac/opac-library.pl b/opac/opac-library.pl
new file mode 100755 (executable)
index 0000000..5216861
--- /dev/null
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+
+# Copyright 2020 Athens County Public Libraries
+#
+# 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 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+
+use Modern::Perl;
+
+use CGI qw ( -utf8 );
+use C4::Auth;
+use C4::Output;
+use Koha::Libraries;
+
+my $query = CGI->new();
+
+my $branchcode   = $query->param('branchcode');
+
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-library.tt",
+        query           => $query,
+        type            => "opac",
+        authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
+    }
+);
+
+if( $branchcode ){
+    my $library = Koha::Libraries->find( $branchcode );
+    $template->param( library => $library );
+}
+
+my $libraries = Koha::Libraries->search( {}, { order_by => ['branchname'] }, );
+$template->param(
+    libraries => $libraries,
+    branchcode => $branchcode,
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;