Bug 23798: Convert OpacMaintenanceNotice system preference to additional contents

This patch moves the OpacMaintenanceNotice system preference into HTML
customizations, making it possible to have language-specific content.

The patch modifies the OPAC maintenance page template so that the
language selection menu can be shown correctly according to the
OpacLangSelectorMode preference.

To test you should have some content in the OpacMaintenanceNotice
system preference before applying the patch. Apply the patch and run the
database update process.

- In the staff client, go to Tools -> HTML customizations and verify
  that the content from OpacMaintenanceNotice is now stored there.
- The HTML customization entry form should offer OpacMaintenanceNotice
  as a choice under "Display location."
- Update and reinstall active translations (for instance fr-FR):
  - perl misc/translator/translate update fr-FR
  - perl misc/translator/translate install fr-FR
- Enable the translation if necessary under Administration -> System
  preferences -> language.
- Enable the "opaclanguagesdisplay" preference if necessary.
- Enable the "OpacMaintenance" system preference.
- Edit the OpacMaintenanceNotice HTML customization and add unique
  content to the "fr-FR" tab.

- Try to view any page in the OPAC. You should see the content you
  added to the OpacMaintenanceNotice HTML customization.
- Switch to your updated translation. The page should redisplay with
  your translated content.
- Go to Administration -> System preferences and search for
  "OpacMaintenanceNotice." The search should return no
  results.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Owen Leonard 2023-10-12 14:17:57 +00:00 committed by Tomas Cohen Arazi
parent 1869a0e18c
commit b7f0b58ee8
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
7 changed files with 77 additions and 17 deletions

View file

@ -0,0 +1,29 @@
use Modern::Perl;
return {
bug_number => "23798",
description => "Convert OpacMaintenanceNotice system preference to additional contents",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
# Get any existing value from the OpacMaintenanceNotice system preference
my ($opacmaintenancenotice) = $dbh->selectrow_array(
q|
SELECT value FROM systempreferences WHERE variable='OpacMaintenanceNotice';
|
);
if ($opacmaintenancenotice) {
# Insert any values found from system preference into additional_contents
$dbh->do(
"INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', 'OpacMaintenanceNotice', 'OpacMaintenanceNotice', NULL, 'OpacMaintenanceNotice default', ?, 'default', CAST(NOW() AS date) )",
undef, $opacmaintenancenotice
);
# Remove old system preference
$dbh->do("DELETE FROM systempreferences WHERE variable='OpacMaintenanceNotice'");
say $out "Bug 23798 update done";
}
}
}

View file

@ -487,7 +487,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('OpacLocationOnDetail','holding','holding|home|both|column','In the OPAC detail, display the shelving location on its own column or under a library columns.', 'Choice'), ('OpacLocationOnDetail','holding','holding|home|both|column','In the OPAC detail, display the shelving location on its own column or under a library columns.', 'Choice'),
('OPACMandatoryHoldDates', '', '|start|end|both', 'Define which hold dates are required on OPAC reserve form', 'Choice'), ('OPACMandatoryHoldDates', '', '|start|end|both', 'Define which hold dates are required on OPAC reserve form', 'Choice'),
('OpacMaintenance','0','','If ON, enables maintenance warning in OPAC','YesNo'), ('OpacMaintenance','0','','If ON, enables maintenance warning in OPAC','YesNo'),
('OpacMaintenanceNotice','','','A user-defined block of HTML to appear on screen when OpacMaintenace is enabled','Textarea'),
('OpacMaxItemsToDisplay','50','','Max items to display at the OPAC on a biblio detail','Integer'), ('OpacMaxItemsToDisplay','50','','Max items to display at the OPAC on a biblio detail','Integer'),
('OpacMetaDescription','','','This description will show in search engine results (160 characters).','Textarea'), ('OpacMetaDescription','','','This description will show in search engine results (160 characters).','Textarea'),
('OPACMySummaryHTML','','70|10','Enter the HTML that will appear in a column on the \'my summary\' and \'my checkout history\' tabs when a user is logged in to the OPAC. Enter {BIBLIONUMBER}, {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the HTML. Leave blank to disable.','Textarea'), ('OPACMySummaryHTML','','70|10','Enter the HTML that will appear in a column on the \'my summary\' and \'my checkout history\' tabs when a user is logged in to the OPAC. Enter {BIBLIONUMBER}, {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the HTML. Leave blank to disable.','Textarea'),

View file

@ -55,13 +55,7 @@ OPAC:
choices: choices:
1: Show 1: Show
0: "Don't show" 0: "Don't show"
- "a warning that the OPAC is under maintenance, instead of the OPAC itself. Note: this shows the same warning as when the database needs to be upgraded, but unconditionally." - "a warning that the OPAC is under maintenance, instead of the OPAC itself. Note: this shows the same warning as when the database needs to be upgraded, but unconditionally. A custom message can be shown on OPAC maintenance page by creating an <a href='/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations'>HTML customization</a> in the OpacMaintenanceNotice region."
-
- 'Show the following HTML when <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=OpacMaintenance">OpacMaintenance</a> is enabled:'
- pref: OpacMaintenanceNotice
type: textarea
syntax: text/html
class: code
- -
- "This description will show in search engine results (160 characters)." - "This description will show in search engine results (160 characters)."
- pref: OpacMetaDescription - pref: OpacMetaDescription

View file

@ -524,7 +524,7 @@
[% END %] [% END %]
[% END %] [% END %]
[% ELSE %] [% ELSE %]
[% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup' ] %] [% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'OpacMaintenanceNotice', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup' ] %]
<optgroup label="OPAC"> <optgroup label="OPAC">
[% FOREACH l IN opac_available_options.sort %] [% FOREACH l IN opac_available_options.sort %]
[% IF l == location %] [% IF l == location %]

View file

@ -55,8 +55,8 @@
</div> <!-- / #wrapper in masthead.inc --> </div> <!-- / #wrapper in masthead.inc -->
[% IF OpacLangSelectorMode == 'both' || OpacLangSelectorMode == 'footer' %] [% IF OpacLangSelectorMode == 'both' || OpacLangSelectorMode == 'footer' %]
[% IF ( opaclanguagesdisplay ) %] [% IF ( Koha.Preference('opaclanguagesdisplay') ) %]
[% IF ( languages_loop && opaclanguagesdisplay ) %] [% IF ( languages_loop ) %]
[% UNLESS ( one_language_enabled ) %] [% UNLESS ( one_language_enabled ) %]
<footer id="changelanguage" class="noprint"> <footer id="changelanguage" class="noprint">
<ul class="nav"> <ul class="nav">

View file

@ -3,10 +3,16 @@
[% USE AdditionalContents %] [% USE AdditionalContents %]
[% INCLUDE 'doc-head-open.inc' %] [% INCLUDE 'doc-head-open.inc' %]
[% SET OpacHeader = AdditionalContents.get( location => "opacheader", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacHeader = AdditionalContents.get( location => "opacheader", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
[% SET OpacMaintenanceNotice = AdditionalContents.get( location => "OpacMaintenanceNotice", lang => lang, library => branchcode || default_branch ) %]
[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
[% SET opaclanguagedisplay = Koha.Preference('opaclanguagedisplay') %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title> <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
[% INCLUDE 'doc-head-close.inc' %] [% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %] [% BLOCK cssinclude %]
<style> <style>
.navbar-expand {
justify-content: space-between;
}
#opac-maintenance-message { #opac-maintenance-message {
background:none repeat scroll 0 0 #FFFFFF; background:none repeat scroll 0 0 #FFFFFF;
border:1px solid #A2A2A2; border:1px solid #A2A2A2;
@ -19,10 +25,32 @@
top:auto; top:auto;
width:50%; width:50%;
} }
.langlabel {
display: inline;
}
</style> </style>
[% END %] [% END %]
</head> </head>
<body id="opac_maintenance" class="opac"> <body id="opac_maintenance" class="opac">
<div id="wrapper">
<div id="header-region" class="noprint">
<nav class="navbar navbar-expand">
<div id="logo">
<a class="navbar-brand" href="/cgi-bin/koha/opac-main.pl">
[% IF ( LibraryNameTitle ) %]
[% LibraryNameTitle | html %]
[% ELSE %]
Koha online
[% END %]
</a>
</div>
[% IF ( Koha.Preference( 'opaclanguagesdisplay' ) ) %]
[% INCLUDE 'masthead-langmenu.inc' %]
[% END %]
</nav>
</div>
[% IF ( OpacHeader ) %] [% IF ( OpacHeader ) %]
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
@ -32,12 +60,14 @@
</div> </div>
</div> </div>
[% END %] [% END %]
<div class="main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<div id="opac-maintenance-message" class="maincontent"> <div id="opac-maintenance-message" class="maincontent">
[% IF Koha.Preference( 'OpacMaintenanceNotice' ) %] [% IF ( OpacMaintenanceNotice ) %]
[% Koha.Preference( 'OpacMaintenanceNotice' ) | $raw %] [% PROCESS koha_news_block news => OpacMaintenanceNotice %]
[% ELSE %] [% ELSE %]
<h1>System maintenance</h1> <h1>System maintenance</h1>
<p> <p>
@ -53,6 +83,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
[% INCLUDE 'opac-bottom.inc' is_popup=1 %] [% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %][% END %] [% BLOCK jsinclude %][% END %]

View file

@ -18,14 +18,21 @@
use Modern::Perl; use Modern::Perl;
use CGI qw ( -utf8 ); use CGI qw ( -utf8 );
use C4::Auth; use C4::Auth qw( get_template_and_user );
use C4::Output qw( output_html_with_http_headers ); use C4::Output qw( output_html_with_http_headers );
use C4::Templates qw/gettemplate/;
use Koha; use Koha;
my $query = CGI->new; my $query = CGI->new;
my $template = C4::Templates::gettemplate( 'maintenance.tt', 'opac', $query );
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "maintenance.tt",
type => "opac",
query => $query,
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
}
);
my $koha_db_version = C4::Context->preference('Version'); my $koha_db_version = C4::Context->preference('Version');
my $kohaversion = Koha::version(); my $kohaversion = Koha::version();