@@ -, +, @@ this for now. be warned that there are no reports in the group with code SIG and given a link for creating a new report. Follow the link and create a new report with report group code SIG. En example SQL command for the report could be: SELECT * FROM biblio WHERE timestamp > DATE_SUB(NOW(), INTERVAL 7 DAY) warning message, and your newly created report should appear in the list of reports. appear in the list of streams. created. system preference OPACDigitalSigns and reload the page. display. that you attached to your stream. attached should be presented using this cover. If no local cover is available and the book has a ISBN with a cover in openlibrary.org, the cover image from openlibrary.org should be shown. If all of the above fails, a cover matching the theme of the page should be seen, showing the book title and author. can see the books availability. You should also see the two next books and the two previous books in the stream (unless you're at the beginning or end of the stream) left/right should bring you to next/previous book. Clicking on the next/previous books (right/left of the active one) should bring you to the detailed view of the clicked book. specified in step 6. should result in the page automatically switching to the next book in the stream. --- Koha/Signs.pm | 330 ++++++++++++ .../prog/en/modules/admin/preferences/opac.pref | 21 +- .../intranet-tmpl/prog/en/modules/tools/signs.tt | 479 +++++++++++++++++ .../prog/en/modules/tools/tools-home.tt | 5 + koha-tmpl/opac-tmpl/bootstrap/css/signs.css | 102 ++++ .../opac-tmpl/bootstrap/en/modules/opac-signs.tt | 565 +++++++++++++++++++++ opac/opac-signs.pl | 49 ++ tools/signs.pl | 258 ++++++++++ 8 files changed, 1808 insertions(+), 1 deletion(-) create mode 100644 Koha/Signs.pm create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/signs.tt create mode 100644 koha-tmpl/opac-tmpl/bootstrap/css/signs.css create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-signs.tt create mode 100755 opac/opac-signs.pl create mode 100755 tools/signs.pl --- a/Koha/Signs.pm +++ a/Koha/Signs.pm @@ -0,0 +1,330 @@ +package Koha::Signs; + +use C4::Context; +use C4::Biblio; +use C4::Koha; +use C4::Items; +use Modern::Perl; + +use base qw( Exporter ); + +# set the version for version checking +our @EXPORT = qw( + + AddSignStream + ModSignStream + GetSignStream + GetSignStreams + DelSignStream + + GetSignStreamRecords + + AddSign + ModSign + GetSign + GetSigns + DelSign + + AttachSignStreamToSign + DetachSignStreamFromSign + GetSignStreamsAttachedToSign + GetSignStreamsAttachedToSignWithRecords + + ModSignStreamParams + GetSignStreamParams +); + +my $dbh = C4::Context->dbh; + +# Streams + +# Returns id of new sign_stream +sub AddSignStream { + + my ( $name, $report ) = @_; + + my $sth=$dbh->prepare("INSERT INTO sign_streams SET name = ?, saved_sql_id = ?"); + $sth->execute( $name, $report ); + return $dbh->last_insert_id( undef, undef, 'sign_streams', 'sign_stream_id' ); + +} + +sub ModSignStream { + + my ( $name, $report, $sign_stream_id ) = @_; + + my $sth = $dbh->prepare("UPDATE sign_streams SET name = ?, saved_sql_id = ? WHERE sign_stream_id = ?"); + return $sth->execute( $name, $report, $sign_stream_id ); + +} + +sub GetSignStream { + + my ( $sign_id ) = @_; + + return unless $sign_id; + + my $query = "SELECT s.*, sq.report_name, sq.savedsql + FROM sign_streams AS s, saved_sql AS sq + WHERE s.saved_sql_id = sq.id + AND s.sign_stream_id = ?"; + my $sth = $dbh->prepare($query); + $sth->execute($sign_id); + return $sth->fetchrow_hashref(); + +} + +sub GetSignStreams { + + my $query = "SELECT s.*, sq.report_name, sq.savedsql + FROM sign_streams AS s, saved_sql AS sq + WHERE s.saved_sql_id = sq.id + ORDER BY s.name"; + my $sth = $dbh->prepare($query); + $sth->execute(); + return $sth->fetchall_arrayref({}); + +} + +sub DelSignStream { + + my ( $sign_stream_id ) = @_; + + return unless $sign_stream_id; + + my $sth = $dbh->prepare('DELETE FROM sign_streams WHERE sign_stream_id = ?'); + return $sth->execute($sign_stream_id); + +} + +sub GetSignStreamRecords { + my ( $stream, $sign_to_stream_id) = @_; + my $sql = $stream->{'savedsql'}; + + if ( defined $sign_to_stream_id ) { + my $params = GetSignStreamParams( $sign_to_stream_id ); + $sql = ReplaceParamsInSQL( $sql, $params ); + return undef if ( $sql =~ m/< ); + } + + return {result => RunSQL( $sql ), sql => $sql }; +} + +# Signs + +# Returns id of new sign +sub AddSign { + + my ( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter ) = @_; + + my $sth=$dbh->prepare("INSERT INTO signs SET name = ?, webapp = ?, swatch = ?, transition = ?, idleafter = ?, pagedelay = ?, reloadafter = ?"); + $sth->execute( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter ); + return $dbh->last_insert_id( undef, undef, 'signs', 'sign_id' ); + +} + +sub ModSign { + + my ( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter, $sign_id ) = @_; + + my $sth = $dbh->prepare("UPDATE signs SET name = ?, webapp = ?, swatch = ?, transition = ?, idleafter = ?, pagedelay = ?, reloadafter = ? WHERE sign_id = ?"); + return $sth->execute( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter, $sign_id ); + +} + +sub GetSign { + + my ( $sign_id ) = @_; + + return unless $sign_id; + + my $query = "SELECT * + FROM signs + WHERE sign_id = ?"; + my $sth = $dbh->prepare($query); + $sth->execute($sign_id); + return $sth->fetchrow_hashref(); + +} + +sub GetSigns { + + my $query = "SELECT * + FROM signs + ORDER BY name"; + my $sth = $dbh->prepare($query); + $sth->execute(); + return $sth->fetchall_arrayref({}); + +} + +sub DelSign { + + my ( $sign_id ) = @_; + + return unless $sign_id; + + my $sth = $dbh->prepare('DELETE FROM signs WHERE sign_id = ?'); + return $sth->execute($sign_id); + +} + +# Streams attached to signs + +# Returns the ID of the connection between sign and stream +sub AttachSignStreamToSign { + + my ( $sign_stream_id, $sign_id ) = @_; + + return unless $sign_stream_id || $sign_id; + + my $sth = $dbh->prepare( 'INSERT INTO signs_to_streams SET sign_stream_id = ?, sign_id = ?' ); + $sth->execute( $sign_stream_id, $sign_id ); + return $dbh->last_insert_id( undef, undef, 'signs_to_streams', 'sign_to_stream_id' ); + +} + +sub ModSignStreamParams { + + my ( $sign_to_stream_id, $params ) = @_; + return unless $sign_to_stream_id; + my $sth = $dbh->prepare( 'UPDATE signs_to_streams SET params = ? WHERE sign_to_stream_id = ?' ); + return $sth->execute( $params, $sign_to_stream_id ); + +} + +# Returns the string of params for a given stream-attached-to-sign +sub GetSignStreamParams { + + my ( $sign_to_stream_id ) = @_; + + return unless $sign_to_stream_id; + + my $query = 'SELECT params FROM signs_to_streams WHERE sign_to_stream_id = ?'; + my $sth = $dbh->prepare( $query ); + $sth->execute( $sign_to_stream_id ); + return $sth->fetchrow_array(); + +} + +sub ReplaceParamsInSQL { + + my ( $sql, $params ) = @_; + + return unless $sql || $params; + return $sql unless $sql =~ m/<; + + foreach my $param ( split /&/, $params ) { + my ( $key, $value ) = split /=/, $param; + # FIXME Handle spaces + $sql =~ s/<<$key>>/$value/g; + } + return $sql; + +} + +sub GetSignStreamsAttachedToSign { + + my ( $sign_id ) = @_; + + return unless $sign_id; + + my $query = 'SELECT s.*, sts.sign_to_stream_id, sts.params, sq.report_name, sq.savedsql + FROM sign_streams AS s, signs_to_streams AS sts, saved_sql AS sq + WHERE s.sign_stream_id = sts.sign_stream_id + AND s.saved_sql_id = sq.id + AND sts.sign_id = ? + ORDER BY s.name'; + my $sth = $dbh->prepare( $query ); + $sth->execute( $sign_id ); + return $sth->fetchall_arrayref({}); + +} + +sub GetSignStreamsAttachedToSignWithRecords { + + my ( $sign_id, $include_marc ) = @_; + + return unless $sign_id; + + my $streams = GetSignStreamsAttachedToSign( $sign_id ); + my @changedstreams; + my %record_cache = (); + + # Add records to the streams + foreach my $stream ( @{$streams} ) { + + my $records = RunSQL( ReplaceParamsInSQL( $stream->{'savedsql'}, $stream->{'params'} ) ); + + if ( $include_marc ) { + + my @processed_records; + foreach my $rec ( @{$records} ) { + unless(defined $record_cache{$rec->{'biblionumber'}}) { + my $marc = GetMarcBiblio( $rec->{'biblionumber'} ); + if ( ! $marc ) { + next; + } + + my $isbn = GetNormalizedISBN( undef, $marc, C4::Context->preference("marcflavor") ) || ''; + $rec->{'isbn'} = $isbn; + + my $dat = GetBiblioData($rec->{'biblionumber'}); + my @items = GetItemsInfo($rec->{'biblionumber'}); + foreach my $item ( @items ) { + my $shelflocations = GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac'); + if ( defined $item->{'location'} ) { + $item->{'location_description'} = $shelflocations->{ $item->{'location'} }; + } + } + $rec->{'items'} = \@items; + foreach ( keys %{$dat} ) { + $rec->{"$_"} = defined $dat->{$_} ? $dat->{$_} : ''; + } + + $rec->{'marc'} = $marc; + + $record_cache{$rec->{'biblionumber'}} = $rec; + } + push @processed_records, $record_cache{$rec->{'biblionumber'}}; + } + $stream->{'records'} = \@processed_records; + + } else { + + $stream->{'records'} = $records; + + } + + push @changedstreams, $stream; + + } + + return \@changedstreams; + +} + +sub DetachSignStreamFromSign { + + my ( $sign_to_stream_id ) = @_; + + return unless $sign_to_stream_id; + + my $sth = $dbh->prepare( 'DELETE FROM signs_to_streams WHERE sign_to_stream_id = ?' ); + return $sth->execute( $sign_to_stream_id ); + +} + +sub RunSQL { + + my ( $query ) = @_; + + return unless $query; + + my $sth = $dbh->prepare($query); + $sth->execute(); + return $sth->fetchall_arrayref({}); + +} + +1; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -703,7 +703,6 @@ OPAC: yes: Use no: "Don't use" - "the item collection code when finding items for the shelf browser." - Self Registration: - - pref: PatronSelfRegistration @@ -765,6 +764,26 @@ OPAC: no: "Do not display and prefill" - "password and login form after a patron has self registered." + Digital Signs: + - + - pref: OPACDigitalSigns + default: 0 + choices: + yes: Enable + no: Disable + - "digital signs in the OPAC. Please note: Digital signs are not linked to from the OPAC by default, so you will have to load the relevant URL by hand on displays where you want to use them." + - + - "Include the following CSS in all digital signs:" + - pref: OPACDigitalSignsCSS + type: textarea + class: code + - (If you use this option to create custom swatches (e.g. with the ThemeRoller for jQuery Mobile) you might have to adjust the list of letters identifying available themes (swatches) in the OPACDigitalSignsSwatches preference.) + - + - Make it possible to choose one of the themes (swatches) + - pref: OPACDigitalSignsSwatches + class: long + - when creating a new sign. By default the themes a-e are provided, but you can override these by creating your own themes and entering them into the OPACDigitalSignsCSS system preference. If you do add your own custom themes there you will want to adjust the letters in this system preference to match the themes you created. + Advanced Search Options: - - Show search options --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/signs.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/signs.tt @@ -0,0 +1,479 @@ +[% USE Koha %] +[% INCLUDE 'doc-head-open.inc' %] +
+ Digital signs are not enabled. Please enable + OPACDigitalSigns + for OPAC digital signs to work. +
+No reports with group code "SIG" were found. Please create + a new report with group code "SIG" and try again.
+Name | Parameters | Edit parameters | Detach |
---|---|---|---|
[% s.name %] | +[% s.params %] | +[% IF s.savedsql.match('<<') %]Edit parameters[% ELSE %]No parameters[% END %] | +Detach | +
There are no streams attached to this sign, yet.
+ [% END %] + +Based on report: [% stream.report_name %] | Edit this report
+ + + +[% stream.savedsql | html %]+ +
[% newsql | html %]+ [% IF ( has_params ) %] +
Sorry, your SQL still contains placeholders. You need to add more parameters.
+ [% ELSE %] +No streams attached.
+ [% END%] + +[% ELSIF op == 'view_stream' %] + +Based on report: [% stream.report_name %] | Edit this report
+[% stream.savedsql | html %]+
Sorry, the report this stream is based on has parameters and displaying it only makes sense after it has been attached to a sign and parameters have been added.
+ [% ELSE %] + [% INCLUDE display_records %] + [% END %] + +[% ELSE %] + +Name | +Web-app | +Theme (swatch) | +Transition | +Idle after | +Page delay | +Reload after | +Edit | +Edit streams | +Delete | +View sign | +
---|---|---|---|---|---|---|---|---|---|---|
[% s.name %] | +[% IF ( s.webapp ) %]Yes[% ELSE %]No[% END %] | +[% s.swatch %] | +[% s.transition %] | +[% s.idleafter %] | +[% s.pagedelay %] | +[% s.reloadafter %] | +Edit | +Edit streams | +Delete | +[% IF ( OPACBaseURL ) %]View sign[% END %] | +
Please note: Links to view signs in the OPAC will only be displayed if you fill in the OPACBaseURL system preference.
[% END %] + [% ELSE %] +No signs defined!
+ [% END %] + + [% IF streams %] +Name | +Report | +Edit | +Delete | +
---|---|---|---|
[% s.name %] | +[% s.report_name %] | +Edit | +Delete | +
No streams defined!
+ [% END %] + +[% END %] + + + +biblionumber | +title | +
---|---|
[% r.biblionumber %] | [% r.title %] |
No records found.
+ [% END %] +[% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -99,6 +99,11 @@Digital signs are not enabled!
+[%- ELSE -%] + [%# Display a sign, all its streams and all records %] + [%- IF ( sign ) -%] + [%- IF ( streams.0 ) -%] + [%# Iterate through the streams, creating one front page for each %] + [%- FOREACH s IN streams -%] +No streams attached to this sign.
+ [% END # IF ( streams.0 ) %] + [% END # IF ( sign ) %] + + [%# Display a list of all signs, as a default. Links use data-ajax="false" so signs will replace the first page, not be AJAXed in. %] + [%# This page is not meant to be viewed by non-librarians, so it can not be themed. %] + [% IF ( signs ) %] +