diff --git a/installer/data/mysql/atomicupdate/bug_23796-move-OpacCustomSearch-to-news.perl b/installer/data/mysql/atomicupdate/bug_23796-move-OpacCustomSearch-to-news.perl new file mode 100644 index 0000000000..0ae9e6e759 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_23796-move-OpacCustomSearch-to-news.perl @@ -0,0 +1,30 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + # get list of installed translations + require C4::Languages; + my @langs; + my $tlangs = C4::Languages::getTranslatedLanguages(); + + foreach my $language ( @$tlangs ) { + foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) { + push @langs, $sublanguage->{'rfc4646_subtag'}; + } + } + + # Get any existing value from the OpacCustomSearch system preference + my ($OpacCustomSearch) = $dbh->selectrow_array( q| + SELECT value FROM systempreferences WHERE variable='OpacCustomSearch'; + |); + if( $OpacCustomSearch ){ + foreach my $lang ( @langs ) { + print "Inserting OpacCustomSearch contents into $lang news item...\n"; + # If there is a value in the OpacCustomSearch preference, insert it into opac_news + $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, '', ?)", undef, "OpacCustomSearch_$lang", $OpacCustomSearch); + } + } + # Remove the OpacCustomSearch system preference + $dbh->do("DELETE FROM systempreferences WHERE variable='OpacCustomSearch'"); + SetVersion ($DBversion); + print "Upgrade to $DBversion done (Bug 23796: Convert OpacCustomSearch system preference to news block)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index d1d47fd2fb..1fe25d38ea 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -376,7 +376,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OpacAdditionalStylesheet','','','Define an auxiliary stylesheet for OPAC use, to override specified settings from the primary opac.css stylesheet. Enter the filename (if the file is in the server\'s css directory) or a complete URL beginning with http (if the file lives on a remote server).','free'), ('OpacCoce','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the OPAC', 'YesNo'), ('OPACCustomCoverImages','0',NULL,'If enabled, the custom cover images will be displayed at the OPAC. CustomCoverImagesURL must be defined.','YesNo'), -('OpacCustomSearch','','70|10','Replace the search box on the OPAC with the provided HTML','Textarea'), ('OPACdefaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'), ('OPACdefaultSortOrder','dsc','asc|dsc|za|az','Specify the default sort order','Choice'), ('OPACdidyoumean','',NULL,'Did you mean? configuration for the OPAC. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free'), 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 318d9d556c..71d328e2b9 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 @@ -351,12 +351,6 @@ OPAC: type: textarea syntax: text/html class: code - - - - "Replace the search box at the top of OPAC pages with the following HTML:" - - pref: OpacCustomSearch - type: textarea - syntax: text/html - class: code - - "Display language selector on " - pref: OpacLangSelectorMode 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 12e835ddeb..f321e6b348 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 @@ -332,7 +332,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %] [% END %] [% FOREACH lang_lis IN lang_list %] - [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader', 'OpacMainUserBlock', 'opaccredits' ] %] + [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits' ] %] [% IF ( location == '' ) %] [% SET location_lang = lang_lis.language %] [% location = BLOCK %]OPAC news[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index 0f7cbc6155..c1784458e3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -6,6 +6,7 @@ [% PROCESS 'html_helpers.inc' %] [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %] [% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %] +[% SET OpacCustomSearch = KohaNews.get( location => "OpacCustomSearch", lang => lang, library => branchcode, blocktitle => 0 ) %]
@@ -169,7 +170,9 @@ [% ELSE %]
[% END %] - [% IF Koha.Preference('OpacCustomSearch') == '' %] + [% IF ( OpacCustomSearch ) %] + [% PROCESS koha_news_block news => OpacCustomSearch %] + [% ELSE %]
[% END # / UNLESS advsearch %]