Bugzilla – Attachment 99362 Details for
Bug 22880
Convert opacheader system preference to news block
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22880: Convert opacheader system preference to news block
Bug-22880-Convert-opacheader-system-preference-to-.patch (text/plain), 7.90 KB, created by
Marcel de Rooy
on 2020-02-21 09:57:03 UTC
(
hide
)
Description:
Bug 22880: Convert opacheader system preference to news block
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2020-02-21 09:57:03 UTC
Size:
7.90 KB
patch
obsolete
>From 906d0c347bbee95e5cebcd4277d954076166d3d3 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 9 May 2019 13:52:30 +0000 >Subject: [PATCH] Bug 22880: Convert opacheader system preference to news block >Content-Type: text/plain; charset=utf-8 > >This patch builds on Bug 22318 to move the opacheader system preference >into the Koha news system, making it possible to have language- and >library-specific content. > >It extends the original patch by adding an option to the template plugin >specifying whether the content title should be shown (probably should be >a flag in opac_news). It also adds a wrapper div with the content >location as the ID (e.g. 'opacheader'). This will make it slightly more >backwards-compatible with CSS customizations. > >To test you should have some content in the opacheader system >preference. Apply the patch and run the database update process. > > - Go to the OPAC and confirm that the content which was previously in > the opacheader system preference now displays correctly where it was > before. > - In the staff client, go to Tools -> News and verify that the content > from opacheader is now stored in a news item with the location > 'opacheader_en.' > - Go to Administration -> System preferences and confirm that the > opacheader preference has been removed. > >Signed-off-by: Hayley Mapley <hayleymapley@catalyst.net.nz> > >Signed-off-by: Hayley Mapley <hayleymapley@catalyst.net.nz> > >Signed-off-by: Lisette Scheer <lisettes@latahlibrary.org> >--- > Koha/Template/Plugin/KohaNews.pm | 7 ++++++- > .../bug_22880-move-opacheader-to-news.perl | 18 ++++++++++++++++++ > .../prog/en/modules/admin/preferences/opac.pref | 6 ------ > .../intranet-tmpl/prog/en/modules/tools/koha-news.tt | 2 +- > .../opac-tmpl/bootstrap/en/includes/html_helpers.inc | 20 +++++++++++--------- > .../opac-tmpl/bootstrap/en/includes/masthead.inc | 12 +++--------- > 6 files changed, 39 insertions(+), 26 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_22880-move-opacheader-to-news.perl > >diff --git a/Koha/Template/Plugin/KohaNews.pm b/Koha/Template/Plugin/KohaNews.pm >index 49299f6e3d..bd56f63e2d 100644 >--- a/Koha/Template/Plugin/KohaNews.pm >+++ b/Koha/Template/Plugin/KohaNews.pm >@@ -32,6 +32,7 @@ sub get { > my ( $self, $params ) = @_; > > my $display_location = $params->{location}; >+ my $blocktitle = $params->{blocktitle}; > my $lang = $params->{lang}; > my $library = $params->{library} || ""; > my $news_lang; >@@ -44,7 +45,11 @@ sub get { > > my $content = &GetNewsToDisplay( $news_lang, $library ); > >- return $content; >+ return { >+ content => $content, >+ location => $display_location, >+ blocktitle => $blocktitle >+ }; > } > > 1; >diff --git a/installer/data/mysql/atomicupdate/bug_22880-move-opacheader-to-news.perl b/installer/data/mysql/atomicupdate/bug_22880-move-opacheader-to-news.perl >new file mode 100644 >index 0000000000..73bd289275 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_22880-move-opacheader-to-news.perl >@@ -0,0 +1,18 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ my $opaclang = C4::Context->preference("opaclanguages"); >+ my @langs; >+ push @langs, split ( '\,', $opaclang ); >+ # Get any existing value from the opacheader system preference >+ my ($opacheader) = $dbh->selectrow_array( q| >+ SELECT value FROM systempreferences WHERE variable='opacheader'; >+ |); >+ if( $opacheader ){ >+ # If there is a value in the opacheader preference, insert it into opac_news >+ $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, 'opacheader_$langs[0]', '', '$opacheader')"); >+ } >+ # Remove the opacheader system preference >+ $dbh->do("DELETE FROM systempreferences WHERE variable='opacheader'"); >+ SetVersion ($DBversion); >+ print "Upgrade to $DBversion done (Bug 22880: Move contents of opacheader preference to Koha news system)\n"; >+} >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 7c77af5b30..9c9b2b7f00 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 >@@ -251,12 +251,6 @@ OPAC: > syntax: text/html > class: code > - >- - "Include the following HTML in the header of all pages in the OPAC:" >- - pref: opacheader >- type: textarea >- syntax: text/html >- class: code >- - > - "Include the following HTML in the footer of all pages in the OPAC:" > - pref: opaccredits > type: textarea >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt >index 6621e0c878..e73e613194 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt >@@ -327,7 +327,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> > [% END %] > [% FOREACH lang_lis IN lang_list %] > <optgroup label="[% lang_lis.language | html %]"> >- [% FOREACH location IN [ '', 'OpacNavRight' ] %] >+ [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader' ] %] > [% IF ( location == '' ) %] > [% SET location_lang = lang_lis.language %] > [% location = BLOCK %]OPAC news[% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc >index 8cb9d2f674..d872c73f4d 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc >@@ -9,14 +9,16 @@ > [% END %] > > [% BLOCK koha_news_block %] >- [% IF ( news.size > 0 ) %] >- [% FOREACH n IN news %] >- <div class="[% n.lang | html %]_item"> >- [% IF ( n.title ) %] >- <h4 class="[% n.lang | html %]_header">[% n.title | html %]</h4> >- [% END %] >- <div class="[% n.lang | html %]_body">[% n.content | $raw %]</div> >- </div> >- [% END %] >+ [% IF ( news.content.size > 0 ) %] >+ <div id="[% news.location | html %]"> >+ [% FOREACH n IN news.content %] >+ <div class="[% n.lang | html %]_item"> >+ [% IF ( n.title && news.blocktitle ) %] >+ <h4 class="[% n.lang | html %]_header">[% n.title | html %]</h4> >+ [% END %] >+ <div class="[% n.lang | html %]_body">[% n.content | $raw %]</div> >+ </div> >+ [% END %] >+ </div> > [% END %] > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >index 82a1ae6440..f9192e67f4 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >@@ -2,6 +2,7 @@ > [% USE Koha %] > [% USE Branches %] > [% USE Categories %] >+[% USE KohaNews %] > [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %] > <div id="wrap"> > <div id="header-region" class="noprint"> >@@ -143,15 +144,8 @@ > </div> <!-- /navbar-inner --> > </div> <!-- /navbar --> > >- [% IF ( opacheader ) %] >- <div class="container-fluid"> >- <div class="row-fluid"> >- <div id="opacheader"> >- [% opacheader | $raw %] >- </div> >- </div> >- </div> >- [% END %] >+ [% PROCESS koha_news_block news => KohaNews.get( location => "opacheader", lang => news_lang, library => branchcode, blocktitle => 0 ) %] >+ > </div> <!-- / header-region --> > > <div class="container-fluid"> >-- >2.11.0
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 22880
:
89517
|
90495
|
92207
|
92208
|
92592
|
92593
|
92594
|
92600
|
92601
|
92602
|
96209
|
96210
|
96219
|
98773
|
98775
|
98985
|
98986
|
98987
|
98988
|
98989
|
99362
|
99363
|
99364
|
99365
|
99366
|
99367
|
99490
|
99491
|
99492
|
99493
|
99494
|
99495
|
99496
|
99497
|
99498