Koha/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recordedbooks-search.tt
Owen Leonard b1c70a3c7e Bug 22432: Star ratings plugin replacement missing from a couple pages
This patch modifies two templates to conform to the change to the start
ratings plugin: Overdrive search results and RecordedBooks search
results.

On the Overdrive page, the star ratings are now correctly displayed
using the new plugin. On the RecordedBooks page, star ratings code has
been removed because it is unused. RecordedBooks doesn't provide ratings
information in their API.

To test you need credentials for both Overdrive and RecordedBooks. Apply
the patch and enable both services.

 - In the OPAC, perform a search that will return results from Overdrive
   and RecordedBooks.
 - Open the search results for each of those services.
   - On the Overdrive search results page, star ratings should appear
     correctly (in read-only mode).
   - On the RecordedBooks page everything should look the same.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2019-03-23 08:52:03 +00:00

162 lines
6.3 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; RecordedBooks search for '[% q | html %]'</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %]
[% END %]
</head>
[% INCLUDE 'bodytag.inc' bodyid='recordedbooks-results-page' bodyclass='scrollto' %]
[% INCLUDE 'masthead.inc' %]
<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="#">RecordedBooks search for '[% q | html %]'</a></li>
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
[% IF ( OpacNav || OpacNavBottom ) %]
[% INCLUDE 'navigation.inc' %]
[% END %]
</div>
<div class="span10">
<div id="recordedbooks-results-content" class="maincontent searchresults">
<h1>RecordedBooks search for '[% q | html %]'</h1>
<div id="breadcrumbs">
<p></p>
</div>
<div id="top-pages">
<div class="pagination pagination-small">
</div>
</div>
<table id="recordedbooks-results-list" class="table table-striped">
<tbody>
</tbody>
</table>
<div id="bottom-pages">
<div class="pagination pagination-small">
</div>
</div>
</div> <!-- / #recordedbooks-results-content -->
</div> <!-- / .span10 -->
</div> <!-- / .row-fluid -->
</div> <!-- / .container-fluid -->
</div> <!-- / .main -->
[% INCLUDE 'recordedbooks-checkout.inc' %]
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
[% Asset.js("js/recordedbooks.js") | $raw %]
<script>
var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]";
var results_per_page = [% OPACnumSearchResults || 20 | html %];
function search( page ) {
$( '#recordedbooks-status' ).html( MSG_SEARCHING.format("RecordedBooks") + ' <img class="throbber" src="[% interface | html %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
KOHA.RecordedBooks.search( querystring, results_per_page, page, function( data ) {
if ( data.error ) {
$( '#recordedbooks-status' ).html( '<strong class="unavailable">' + MSG_ERROR_SEARCHING_COLLECTION.format("RecordedBooks") + ': ' + data.error + '</strong>' );
return;
}
if ( !data.total ) {
$( '#recordedbooks-status' ).html( '<strong>' + MSG_NO_RESULTS_FOUND_IN_COLLECTION.format("RecordedBooks") + '</strong>' );
return;
}
$( '#recordedbooks-results-list tbody' ).empty();
$( '#recordedbooks-status' ).html( '<strong>' + MSG_RESULTS_FOUND_IN_COLLECTION.format(data.total, "RecordedBooks") + '</strong>' );
for ( var i = 0; data.items[i]; i++ ) {
var prod = data.items[i];
var results = [];
results.push( '<tr>' );
results.push( '<td class="info"><span class="title">' );
if (prod.url) results.push( '<a href="', prod.url, '" target="recordedbooks">' );
results.push( prod.title );
if (prod.url) results.push( '</a>' );
results.push( '</span>' );
results.push( '<p>' + MSG_BY + ' ', prod.author, '</p>' );
if (prod.description) results.push( '<p>' + prod.description, '</p>' );
results.push( '<span class="results_summary mediatype"><span class="label">' + MSG_TYPE + ': </span>', prod.media, '</span>' );
results.push( '</td>' );
results.push( '<td>' );
if ( prod.images && prod.images.medium ) {
if (prod.url) results.push( '<a href="', prod.url, '" target="recordedbooks">' );
results.push( '<img class="thumbnail" src="', prod.images.medium, '" />' );
if (prod.url) results.push( '</a>' );
}
results.push( '</td>' );
results.push( '</tr>' );
var $tr = $( results.join( '' ));
$( '#recordedbooks-results-list tbody' ).append( $tr );
$tr.find( '.info' ).each(function() {
KOHA.RecordedBooks.add_actions(this, prod.isbn);
});
}
$( '#recordedbooks-results-list tr:odd' ).addClass( 'highlight' );
var pages = [];
var max_page = Math.floor( data.total / results_per_page );
if (data.total == page*results_per_page) max_page++;
if ( page != 1 ) {
pages.push( '<li><a class="od-nav" href="#" data-page="' + (page - 1) + '">&laquo; ' + MSG_PREVIOUS + '</a></li>' );
}
for ( var p = Math.max( 0, page - 9 ); p <= Math.min( max_page, p + 9 ); p++ ) {
if ( p == page ) {
pages.push( ' <li class="active"><a href="#">' + ( p + 1 ) + '</a></li>' );
} else {
pages.push( ' <li><a class="od-nav" href="#" data-page="' + p + '">' + p + '</a></li>' );
}
}
if ( page < max_page ) {
pages.push( ' <li><a class="od-nav" href="#" data-page="' + (page + 1) + '">' + MSG_NEXT + ' &raquo;</a></li>' );
}
if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul>' + pages.join( '' ) + '</ul>');
} );
}
$( document ).ready( function() {
$( '#breadcrumbs p' )
.append( ' ' )
.append( '<span id="recordedbooks-status"></span>' );
$( document ).on( 'click', 'a.od-nav', function() {
search( $( this ).data( 'page' ) );
return false;
});
[% IF ( loggedinusername ) %]
KOHA.RecordedBooks.with_account_details("#breadcrumbs", function() {
search( 1 );
});
[% ELSE %]
search( 1 );
[% END %]
} );
</script>
[% END %]