From f021432755309594e599fedf794dd6c50de074dc Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 5 Jun 2025 20:17:00 +0000 Subject: [PATCH] Bug 39860: Move display control from system preference to additional contents --- C4/XSLT.pm | 35 ++++++++++++++++--- .../en/modules/tools/additional-contents.tt | 32 +++++++++++++++++ .../prog/en/modules/tools/tools-home.tt | 3 ++ 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index a961583c15b..9fc8d3c9d88 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -33,7 +33,9 @@ use Koha::XSLT::Base; use Koha::Libraries; use Koha::Recalls; use Koha::TemplateUtils qw( process_tt ); +use Koha::AdditionalContents; use C4::Scrubber; +use C4::Languages; my $engine; #XSLT Handler object @@ -241,13 +243,38 @@ sub XSLTParse4Display { } } my $extracontent = ''; + my $location; + my $branch = C4::Context->userenv->{branch} || ''; + my $lang = C4::Languages::getlanguage; + + if ( $xslsyspref eq "XSLTDetailsDisplay" ) { + $location = 'StaffDetailPage'; + } elsif ( $xslsyspref eq "XSLTResultsDisplay" ) { + $location = 'StaffResultsPage'; + } elsif ( $xslsyspref eq "OPACXSLTDetailsDisplay" ) { + $location = 'OPACDetailPage'; + } elsif ( $xslsyspref eq "OPACXSLTResultsDisplay" ) { + $location = 'OPACResultsPage'; + } + + my @record_display_customizations = Koha::AdditionalContents->search_for_display( + { + category => 'record_display', + location => $location, + lang => $lang, + library_id => $branch, + } + )->as_list; - # Check if we should add extra content based on system preference - if ( C4::Context->preference('ExtraContentForXSLTDisplay') ) { + if (@record_display_customizations) { + foreach my $customization (@record_display_customizations) { + $extracontent .= $customization->content; + } + } + if ($extracontent) { my $scrubber = C4::Scrubber->new('staff'); - my $extracontentvalue = C4::Context->preference('ExtraContentForXSLTDisplay'); - my $extracontentproccessed = process_tt( $extracontentvalue, { record => $record } ); + my $extracontentproccessed = process_tt( $extracontent, { record => $record } ); $extracontent = $scrubber->scrub($extracontentproccessed); } 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 330b5522acb..811a587baa8 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 @@ -12,6 +12,8 @@ [% t("Modify news item") | html %] [% ELSIF category == 'pages' %] [% t("Modify page") | html %] + [% ELSIF category == 'record_display' %] + [% t("Modify record display customization") | html %] [% ELSE %] [% t("Modify HTML customization") | html %] [% END %] @@ -20,6 +22,8 @@ [% t("New news item") | html %] [% ELSIF category == 'pages' %] [% t("New page") | html %] + [% ELSIF category == 'record_display' %] + [% t("New record display customization") | html %] [% ELSE %] [% t("New HTML customization") | html %] [% END %] @@ -30,6 +34,8 @@ [% t("News") | html %] [% ELSIF category == 'pages' %] [% t("Pages") | html %] + [% ELSIF category == 'record_display' %] + [% t("Record display customizations") | html %] [% ELSE %] [% t("HTML customizations") | html %] [% END %] @@ -97,6 +103,8 @@ News [% ELSIF category == 'pages' %] Pages + [% ELSIF category == 'record_display' %] + Record display customizations [% ELSE %] HTML customizations [% END %] @@ -356,6 +364,8 @@ [% t("News") | html %] [% ELSIF category == 'pages' %] [% t("Pages") | html %] + [% ELSIF category == 'record_display' %] + [% t("Record display customizations") | html %] [% ELSE %] [% t("HTML customizations") | html %] [% END %] @@ -365,6 +375,7 @@ News HTML customizations Pages + Record display customizations [% IF ( CAN_user_parameters_manage_sysprefs ) %] OPACUserJS OPACUserCSS @@ -531,6 +542,27 @@ [% END %] [% END %] + [% ELSIF category == 'record_display' %] + [% SET staff_available_options = ['StaffResultsPage' , 'StaffDetailPage'] %] + + [% FOREACH l IN staff_available_options.sort %] + [% IF l == location %] + + [% ELSE %] + + [% END %] + [% END %] + + [% SET opac_available_options = ['OPACResultsPage' , 'OPACResultsPage'] %] + + [% FOREACH l IN opac_available_options.sort %] + [% IF l == location %] + + [% ELSE %] + + [% END %] + [% END %] + [% ELSE %] [% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'OpacMaintenanceNotice', 'OPACResultsSidebar', 'OpacSuppressionMessage', 'SCOMainUserBlock', 'SelfCheckInMainUserBlock', 'SelfCheckHelpMessage', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup', 'PatronSelfRegistrationAdditionalInstructions', 'ILLModuleCopyrightClearance' ] %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt index 3aa18b39636..6b359282497 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -140,6 +140,9 @@
Pages
Write custom pages
+ +
Record display customizations
+
Write record display customizations
[% END %] [% IF ( CAN_user_tools_schedule_tasks ) %] -- 2.39.5