@@ -, +, @@ --- Koha/Messages.pm | 141 ++++++++++++++++++++ Koha/Template/Plugin/Messages.pm | 12 ++ .../intranet-tmpl/prog/en/css/staff-global.css | 29 ++++ .../intranet-tmpl/prog/en/includes/messages.inc | 19 +++ .../intranet-tmpl/prog/img/messages-error.png | Bin 0 -> 709 bytes .../intranet-tmpl/prog/img/messages-error.svg | 139 +++++++++++++++++++ koha-tmpl/intranet-tmpl/prog/img/messages-ok.png | Bin 0 -> 687 bytes koha-tmpl/intranet-tmpl/prog/img/messages-ok.svg | 127 ++++++++++++++++++ .../intranet-tmpl/prog/img/messages-warning.png | Bin 0 -> 508 bytes .../intranet-tmpl/prog/img/messages-warning.svg | 98 ++++++++++++++ koha-tmpl/opac-tmpl/bootstrap/css/opac.css | 30 +++++ .../opac-tmpl/bootstrap/en/includes/messages.inc | 19 +++ .../opac-tmpl/bootstrap/images/messages-error.png | Bin 0 -> 709 bytes .../opac-tmpl/bootstrap/images/messages-error.svg | 139 +++++++++++++++++++ .../opac-tmpl/bootstrap/images/messages-ok.png | Bin 0 -> 687 bytes .../opac-tmpl/bootstrap/images/messages-ok.svg | 127 ++++++++++++++++++ .../bootstrap/images/messages-warning.png | Bin 0 -> 508 bytes .../bootstrap/images/messages-warning.svg | 98 ++++++++++++++ koha-tmpl/opac-tmpl/prog/en/css/opac.css | 29 ++++ koha-tmpl/opac-tmpl/prog/en/includes/messages.inc | 19 +++ koha-tmpl/opac-tmpl/prog/images/messages-error.png | Bin 0 -> 709 bytes koha-tmpl/opac-tmpl/prog/images/messages-error.svg | 139 +++++++++++++++++++ koha-tmpl/opac-tmpl/prog/images/messages-ok.png | Bin 0 -> 687 bytes koha-tmpl/opac-tmpl/prog/images/messages-ok.svg | 127 ++++++++++++++++++ .../opac-tmpl/prog/images/messages-warning.png | Bin 0 -> 508 bytes .../opac-tmpl/prog/images/messages-warning.svg | 98 ++++++++++++++ 26 files changed, 1390 insertions(+) create mode 100644 Koha/Messages.pm create mode 100644 Koha/Template/Plugin/Messages.pm create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/messages.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/img/messages-error.png create mode 100644 koha-tmpl/intranet-tmpl/prog/img/messages-error.svg create mode 100644 koha-tmpl/intranet-tmpl/prog/img/messages-ok.png create mode 100644 koha-tmpl/intranet-tmpl/prog/img/messages-ok.svg create mode 100644 koha-tmpl/intranet-tmpl/prog/img/messages-warning.png create mode 100644 koha-tmpl/intranet-tmpl/prog/img/messages-warning.svg create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/messages.inc create mode 100644 koha-tmpl/opac-tmpl/bootstrap/images/messages-error.png create mode 100644 koha-tmpl/opac-tmpl/bootstrap/images/messages-error.svg create mode 100644 koha-tmpl/opac-tmpl/bootstrap/images/messages-ok.png create mode 100644 koha-tmpl/opac-tmpl/bootstrap/images/messages-ok.svg create mode 100644 koha-tmpl/opac-tmpl/bootstrap/images/messages-warning.png create mode 100644 koha-tmpl/opac-tmpl/bootstrap/images/messages-warning.svg create mode 100644 koha-tmpl/opac-tmpl/prog/en/includes/messages.inc create mode 100644 koha-tmpl/opac-tmpl/prog/images/messages-error.png create mode 100644 koha-tmpl/opac-tmpl/prog/images/messages-error.svg create mode 100644 koha-tmpl/opac-tmpl/prog/images/messages-ok.png create mode 100644 koha-tmpl/opac-tmpl/prog/images/messages-ok.svg create mode 100644 koha-tmpl/opac-tmpl/prog/images/messages-warning.png create mode 100644 koha-tmpl/opac-tmpl/prog/images/messages-warning.svg --- a/Koha/Messages.pm +++ a/Koha/Messages.pm @@ -0,0 +1,141 @@ +package Koha::Messages; + +# Copyright 2014 BibLibre +# +# 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 . + +use Modern::Perl; + +use CGI; +use C4::Auth qw( get_session ); + +use base qw( Exporter ); +our @EXPORT = qw( messages_set messages_get ); + +=head1 NAME + +Koha::Messages - Messages in user's session + +=head1 SYNOPSIS + + use Koha::Messages; + + messages_set("Operation succeeded"); + messages_set("Something odd happened", "warning"); + messages_set("Operation failed", "error"); + + my $messages = messages_get(); + +=head1 DESCRIPTION + +This module provides a uniform way to send messages to user interface. + +=head1 FUNCTIONS + +=cut + +sub session { + my $cgi = new CGI; + my $cgisessid = $cgi->cookie('CGISESSID') || ''; + return get_session($cgisessid); +} + +=head2 messages_set + + messages_set($message); + messages_set($message, $type); + +This function store a message into user session with a given type. + +=head3 Parameters + +=over 2 + +=item * $message: The message string to store + +=item * $type: The type of message. Can be one of 'ok', 'warning', or 'error'. +If not given, defaults to 'ok'. + +=back + +=cut + +sub messages_set { + my ($message, $type) = @_; + + return unless $message; + + $type //= 'ok'; + + my $session = session; + my $messages = $session->param('messages') // {}; + $messages->{$type} //= []; + + push @{ $messages->{$type} }, $message; + + $session->param('messages', $messages); + + # Save session + $session->flush; +} + +=head2 messages_get + + $messages = messages_get(); + +This function retrieves all messages in a hashref and remove them from user +session. + +=head3 Return value + +A hashref where keys are the type of messages and values are arrayrefs of +messages. + +Example: + + $messages = { + 'ok' => [ + "Everything is ok", + "Operation succeeded" + ], + 'warning' => [ + "Something odd happended" + ], + }; + +=cut + +sub messages_get { + my $session = session; + + my $messages = $session->param('messages') // {}; + + # Empty messages + $session->param('messages', {}); + + # Save session + $session->flush; + + return $messages; +} + +=head1 SEE ALSO + +Koha::Template::Plugin::Messages + +=cut + +1; --- a/Koha/Template/Plugin/Messages.pm +++ a/Koha/Template/Plugin/Messages.pm @@ -0,0 +1,12 @@ +package Koha::Template::Plugin::Messages; + +use Modern::Perl; + +use base qw( Template::Plugin ); +use Koha::Messages; + +sub Get { + return messages_get(); +} + +1; --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -2712,3 +2712,32 @@ span.browse-button { font-size:0.8em; padding:0.5em; } + +/* Messages */ +div.messages { + background-color: white; + background-position: 5px 5px; + background-repeat: no-repeat; + border: 1px solid #b9d8d9; + border-radius: 4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + color: black; + margin: 10px 0; + padding: 5px 5px 5px 25px; +} + +div.messages.ok { + background-color: #f4f8f9; + background-image: url('../../img/messages-ok.png'); +} + +div.messages.warning { + background-color: #ffff99; + background-image: url('../../img/messages-warning.png'); +} + +div.messages.error { + background-color: #ff7777; + background-image: url('../../img/messages-error.png'); +} --- a/koha-tmpl/intranet-tmpl/prog/en/includes/messages.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/messages.inc @@ -0,0 +1,19 @@ +[% USE Messages %] +[% contents = Messages.Get() %] + +[% FOREACH type IN contents.keys %] + [% messages = contents.$type %] + [% IF messages.size > 0 %] +
+ [% IF messages.size > 1 %] + + [% ELSE %] + [% messages.0 %] + [% END %] +
+ [% END %] +[% END %] --- a/koha-tmpl/intranet-tmpl/prog/img/messages-error.svg +++ a/koha-tmpl/intranet-tmpl/prog/img/messages-error.svg @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + --- a/koha-tmpl/intranet-tmpl/prog/img/messages-ok.svg +++ a/koha-tmpl/intranet-tmpl/prog/img/messages-ok.svg @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + --- a/koha-tmpl/intranet-tmpl/prog/img/messages-warning.svg +++ a/koha-tmpl/intranet-tmpl/prog/img/messages-warning.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + ! + --- a/koha-tmpl/opac-tmpl/bootstrap/css/opac.css +++ a/koha-tmpl/opac-tmpl/bootstrap/css/opac.css @@ -2278,6 +2278,36 @@ a.reviewlink:visited { -moz-box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.2); box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.2); } + +/* Messages */ +div.messages { + background-color: white; + background-position: 5px 5px; + background-repeat: no-repeat; + border: 1px solid #b9d8d9; + border-radius: 4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + color: black; + margin: 10px 20px; + padding: 5px 5px 5px 25px; +} + +div.messages.ok { + background-color: #f4f8f9; + background-image: url('../images/messages-ok.png'); +} + +div.messages.warning { + background-color: #ffff99; + background-image: url('../images/messages-warning.png'); +} + +div.messages.error { + background-color: #ff7777; + background-image: url('../images/messages-error.png'); +} + @media only screen and (min-width: 0px) and (max-width: 304px) { /* Screens bewteen 0 and 304 pixels wide */ #oh:after { --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/messages.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/messages.inc @@ -0,0 +1,19 @@ +[% USE Messages %] +[% contents = Messages.Get() %] + +[% FOREACH type IN contents.keys %] + [% messages = contents.$type %] + [% IF messages.size > 0 %] +
+ [% IF messages.size > 1 %] + + [% ELSE %] + [% messages.0 %] + [% END %] +
+ [% END %] +[% END %] --- a/koha-tmpl/opac-tmpl/bootstrap/images/messages-error.svg +++ a/koha-tmpl/opac-tmpl/bootstrap/images/messages-error.svg @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + --- a/koha-tmpl/opac-tmpl/bootstrap/images/messages-ok.svg +++ a/koha-tmpl/opac-tmpl/bootstrap/images/messages-ok.svg @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + --- a/koha-tmpl/opac-tmpl/bootstrap/images/messages-warning.svg +++ a/koha-tmpl/opac-tmpl/bootstrap/images/messages-warning.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + ! + --- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css +++ a/koha-tmpl/opac-tmpl/prog/en/css/opac.css @@ -3074,3 +3074,32 @@ padding: 0.1em 0; width: 35%; font-size: 111%; } + +/* Messages */ +div.messages { + background-color: white; + background-position: 5px 5px; + background-repeat: no-repeat; + border: 1px solid #b9d8d9; + border-radius: 4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + color: black; + margin: 10px 20px; + padding: 5px 5px 5px 25px; +} + +div.messages.ok { + background-color: #f4f8f9; + background-image: url('../../images/messages-ok.png'); +} + +div.messages.warning { + background-color: #ffff99; + background-image: url('../../images/messages-warning.png'); +} + +div.messages.error { + background-color: #ff7777; + background-image: url('../../images/messages-error.png'); +} --- a/koha-tmpl/opac-tmpl/prog/en/includes/messages.inc +++ a/koha-tmpl/opac-tmpl/prog/en/includes/messages.inc @@ -0,0 +1,19 @@ +[% USE Messages %] +[% contents = Messages.Get() %] + +[% FOREACH type IN contents.keys %] + [% messages = contents.$type %] + [% IF messages.size > 0 %] +
+ [% IF messages.size > 1 %] + + [% ELSE %] + [% messages.0 %] + [% END %] +
+ [% END %] +[% END %] --- a/koha-tmpl/opac-tmpl/prog/images/messages-error.svg +++ a/koha-tmpl/opac-tmpl/prog/images/messages-error.svg @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + --- a/koha-tmpl/opac-tmpl/prog/images/messages-ok.svg +++ a/koha-tmpl/opac-tmpl/prog/images/messages-ok.svg @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + --- a/koha-tmpl/opac-tmpl/prog/images/messages-warning.svg +++ a/koha-tmpl/opac-tmpl/prog/images/messages-warning.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + ! + --