Bugzilla – Attachment 157584 Details for
Bug 23798
Convert OpacMaintenanceNotice system preference to additional contents
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23798: Convert OpacMaintenanceNotice system preference to additional contents
Bug-23798-Convert-OpacMaintenanceNotice-system-pre.patch (text/plain), 12.68 KB, created by
David Nind
on 2023-10-21 01:03:03 UTC
(
hide
)
Description:
Bug 23798: Convert OpacMaintenanceNotice system preference to additional contents
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-10-21 01:03:03 UTC
Size:
12.68 KB
patch
obsolete
>From 6412ea83515ca103a78818c42d419a82a00a8195 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 12 Oct 2023 14:17:57 +0000 >Subject: [PATCH] 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> >--- > ...aintenanceNotice-to-additional-contents.pl | 31 ++++++++++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 - > .../en/modules/admin/preferences/opac.pref | 8 +--- > .../en/modules/tools/additional-contents.tt | 2 +- > .../bootstrap/en/includes/opac-bottom.inc | 4 +- > .../bootstrap/en/modules/maintenance.tt | 37 +++++++++++++++++-- > opac/maintenance.pl | 13 +++++-- > 7 files changed, 79 insertions(+), 17 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug-23798-move-OpacMaintenanceNotice-to-additional-contents.pl > >diff --git a/installer/data/mysql/atomicupdate/bug-23798-move-OpacMaintenanceNotice-to-additional-contents.pl b/installer/data/mysql/atomicupdate/bug-23798-move-OpacMaintenanceNotice-to-additional-contents.pl >new file mode 100755 >index 0000000000..70b1add1d5 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug-23798-move-OpacMaintenanceNotice-to-additional-contents.pl >@@ -0,0 +1,31 @@ >+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 >+ foreach my $lang ('default') { >+ $dbh->do( >+ "INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', 'OpacMaintenanceNotice', 'OpacMaintenanceNotice', NULL, ?, ?, ?, CAST(NOW() AS date) )", >+ undef, "OpacMaintenanceNotice $lang", $opacmaintenancenotice, $lang >+ ); >+ } >+ >+ # Remove old system preference >+ $dbh->do("DELETE FROM systempreferences WHERE variable='OpacMaintenanceNotice'"); >+ say $out "Bug 23798 update done"; >+ } >+ } >+ } >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 8a7aec0d27..359bbbaffc 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -481,7 +481,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'), > ('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'), >-('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'), > ('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'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 39815ecf72..461f5273fe 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -55,13 +55,7 @@ OPAC: > choices: > 1: 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." >- - >- - '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 >+ - "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." > - > - "This description will show in search engine results (160 characters)." > - pref: OpacMetaDescription >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt >index f76683941a..3e900bd74a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt >@@ -523,7 +523,7 @@ > [% END %] > [% END %] > [% ELSE %] >- [% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', ] %] >+ [% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'OpacMaintenanceNotice' ] %] > <optgroup label="OPAC"> > [% FOREACH l IN opac_available_options.sort %] > [% IF l == location %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index c7ff522e02..943c862eab 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -55,8 +55,8 @@ > </div> <!-- / #wrapper in masthead.inc --> > > [% IF OpacLangSelectorMode == 'both' || OpacLangSelectorMode == 'footer' %] >- [% IF ( opaclanguagesdisplay ) %] >- [% IF ( languages_loop && opaclanguagesdisplay ) %] >+ [% IF ( Koha.Preference('opaclanguagesdisplay') ) %] >+ [% IF ( languages_loop ) %] > [% UNLESS ( one_language_enabled ) %] > <footer id="changelanguage" class="noprint"> > <ul class="nav"> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt >index cec3b0951e..a61bebc7cd 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt >@@ -3,10 +3,16 @@ > [% USE AdditionalContents %] > [% INCLUDE 'doc-head-open.inc' %] > [% 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> > [% INCLUDE 'doc-head-close.inc' %] > [% BLOCK cssinclude %] > <style> >+ .navbar-expand { >+ justify-content: space-between; >+ } > #opac-maintenance-message { > background:none repeat scroll 0 0 #FFFFFF; > border:1px solid #A2A2A2; >@@ -19,10 +25,32 @@ > top:auto; > width:50%; > } >+ .langlabel { >+ display: inline; >+ } > </style> > [% END %] > </head> > <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 ) %] > <div class="container-fluid"> > <div class="row"> >@@ -32,12 +60,14 @@ > </div> > </div> > [% END %] >+ >+<div class="main"> > <div class="container-fluid"> > <div class="row"> > <div class="col"> > <div id="opac-maintenance-message" class="maincontent"> >- [% IF Koha.Preference( 'OpacMaintenanceNotice' ) %] >- [% Koha.Preference( 'OpacMaintenanceNotice' ) | $raw %] >+ [% IF ( OpacMaintenanceNotice ) %] >+ [% PROCESS koha_news_block news => OpacMaintenanceNotice %] > [% ELSE %] > <h1>System maintenance</h1> > <p> >@@ -53,6 +83,7 @@ > </div> > </div> > </div> >+</div> > >-[% INCLUDE 'opac-bottom.inc' is_popup=1 %] >+[% INCLUDE 'opac-bottom.inc' %] > [% BLOCK jsinclude %][% END %] >diff --git a/opac/maintenance.pl b/opac/maintenance.pl >index c7924921c3..11b02bd2c9 100755 >--- a/opac/maintenance.pl >+++ b/opac/maintenance.pl >@@ -18,14 +18,21 @@ > use Modern::Perl; > > 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::Templates qw/gettemplate/; > > use Koha; > > 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 $kohaversion = Koha::version(); >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23798
:
157205
|
157472
|
157584
|
157822
|
157905
|
157906
|
158308
|
158309
|
158667
|
158669