Bug 28373: [21.05.x] Add PassItemMarcToXSLT system preference
Default stylesheets do not reference item fields for XSLT display, however, we spend time translating the values in the item fields. This patch adds a system preference, PassItemMarcToXSLT. and unless enabled we remove item fields before processing To test: 1 - Perform some search on the staff client and opac 2 - Use the console (F12) to view the time spent on the network tab 3 - Note performance 4 - Apply patch, updatedatabase, restart_all 5 - Repeat searches 6 - Note that display has not changed 7 - Note performance, results should display slightly faster Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Bug 28373: Unit test Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Bug 28373: (QA follow-up) Fix typo in system preference description Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Bug 28373: (follow-up) QA fixes Use fully qualified subroutine name Don't return explicit undef Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Bug 28373: (QA follow-up) Add . to end of system preference description Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Bug 28373: Add note to XSLT prefs about the new pref Bug 28373: Add warning if custom stylesheets are defined This patch adds a check of the current XSLT prefs and warns to check the new pref if any are not set to default Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
417cbafa8c
commit
315a0fd149
|
|
@ -1773,6 +1773,7 @@ sub searchResults {
|
|||
|
||||
# Pull out the items fields
|
||||
my @fields = $marcrecord->field($itemtag);
|
||||
$marcrecord->delete_fields( @fields ) unless C4::Context->preference('PassItemMarcToXSLT');
|
||||
my $marcflavor = C4::Context->preference("marcflavour");
|
||||
|
||||
# adding linked items that belong to host records
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
$DBversion = 'XXX';
|
||||
if( CheckVersion( $DBversion ) ) {
|
||||
$dbh->do( q{
|
||||
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
|
||||
('PassItemMarcToXSLT','0',NULL,'If enabled, item fields in the MARC record will be made avaiable to XSLT sheets. Otherwise they will be removed.','YesNo');
|
||||
});
|
||||
foreach my $pref ('XSLTDetailsDisplay','XSLTListsDisplay','XSLTResultsDisplay','OPACXSLTDetailsDisplay','OPACXSLTListsDisplay','OPACXSLTResultsDisplay'){
|
||||
if( C4::Context->preference($pref) ne 'default' ){
|
||||
print "NOTE: You have defined a custom stylesheet. If your custom stylesheets are utilizing item fields you must enable the system preference 'PassItemMarcToXSLT'\n";
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
NewVersion( $DBversion, 28373, "Add PassItemMarcToXSLT system preference");
|
||||
}
|
||||
|
|
@ -507,6 +507,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
|
|||
('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'),
|
||||
('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'),
|
||||
('OverduesBlockRenewing','allow','allow|blockitem|block','If any of patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','Choice'),
|
||||
('PassItemMarcToXSLT','0',NULL,'If enabled, item fields in the MARC record will be made avaiable to XSLT sheets. Otherwise they will be removed.','YesNo'),
|
||||
('PatronAnonymizeDelay','',NULL,'Delay for anonymizing patrons', 'Integer'),
|
||||
('PatronAutoComplete','1','Try|Don\'t try','to guess the patron being entered while typing a patron search for circulation or patron search. Only returns the first 10 results at a time.','YesNo'),
|
||||
('PatronDuplicateMatchingAddFields','surname|firstname|dateofbirth', NULL,'A list of fields separated by "|" to deduplicate patrons when created','Free'),
|
||||
|
|
|
|||
|
|
@ -101,17 +101,17 @@ OPAC:
|
|||
- 'Display lists in the OPAC using XSLT stylesheet at: '
|
||||
- pref: OPACXSLTListsDisplay
|
||||
class: file
|
||||
- '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="OPACXSLTListsDisplay" data-value="">leave empty</a> for "no xslt"</li><li>enter "<a href="#" class="set_syspref" data-syspref="OPACXSLTListsDisplay" data-value="default">default</a>" for the default one</li><li> put a path to define a xslt file</li><li>put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language.'
|
||||
- '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="OPACXSLTListsDisplay" data-value="">leave empty</a> for "no xslt"</li><li>Enter "<a href="#" class="set_syspref" data-syspref="OPACXSLTListsDisplay" data-value="default">default</a>" for the default stylesheet</li><li>Put a path to define an xslt file</li><li>Put a URL for an external specific stylesheet.</li><li>NOTE: The system preference <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PassItemMarcToXSLT">PassItemMarcToXSLT</a> must be enabled if your custom stylesheet utilizes data in the item fields</li></ul>If you have multiple stylesheets for different langues the placeholder {langcode} will be replaced with current interface language.'
|
||||
-
|
||||
- 'Display OPAC results using XSLT stylesheet at: '
|
||||
- pref: OPACXSLTResultsDisplay
|
||||
class: file
|
||||
- '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="OPACXSLTResultsDisplay" data-value="">leave empty</a> for "no xslt"</li><li>enter "<a href="#" class="set_syspref" data-syspref="OPACXSLTResultsDisplay" data-value="default">default</a>" for the default one</li><li> put a path to define a xslt file</li><li>put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language.'
|
||||
- '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="OPACXSLTResultsDisplay" data-value="">leave empty</a> for "no xslt"</li><li>Enter "<a href="#" class="set_syspref" data-syspref="OPACXSLTResultsDisplay" data-value="default">default</a>" for the default stylesheet</li><li>Put a path to define an xslt file</li><li>Put a URL for an external specific stylesheet.</li><li>NOTE: The system preference <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PassItemMarcToXSLT">PassItemMarcToXSLT</a> must be enabled if your custom stylesheet utilizes data in the item fields</li></ul>If you have multiple stylesheets for different langues the placeholder {langcode} will be replaced with current interface language.'
|
||||
-
|
||||
- 'Display OPAC details using XSLT stylesheet at: '
|
||||
- pref: OPACXSLTDetailsDisplay
|
||||
class: file
|
||||
- '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="OPACXSLTDetailsDisplay" data-value="">leave empty</a> for "no xslt"</li><li>enter "<a href="#" class="set_syspref" data-syspref="OPACXSLTDetailsDisplay" data-value="default">default</a>" for the default one</li><li>put a path to define a xslt file</li><li>put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language.'
|
||||
- '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="OPACXSLTDetailsDisplay" data-value="">leave empty</a> for "no xslt"</li><li>Enter "<a href="#" class="set_syspref" data-syspref="OPACXSLTDetailsDisplay" data-value="default">default</a>" for the default stylesheet</li><li>Put a path to define an xslt file</li><li>Put a URL for an external specific stylesheet.</li><li>NOTE: The system preference <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PassItemMarcToXSLT">PassItemMarcToXSLT</a> must be enabled if your custom stylesheet utilizes data in the item fields</li></ul>If you have multiple stylesheets for different langues the placeholder {langcode} will be replaced with current interface language.'
|
||||
-
|
||||
- "Show itemtype icons in the OPAC: "
|
||||
- pref: OpacNoItemTypeImages
|
||||
|
|
|
|||
|
|
@ -273,6 +273,13 @@ Searching:
|
|||
1: "Display"
|
||||
0: "Don't display"
|
||||
- ' Koha record level itemtype info on detail and result pages in the OPAC and staff interface. This info also displays if the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=item-level_itypes">item-level_itypes</a> system preference is set to bibliographic record.'
|
||||
-
|
||||
- pref: PassItemMarcToXSLT
|
||||
type: boolean
|
||||
choices:
|
||||
1: Do
|
||||
0: "Don't"
|
||||
- "make item MARC tags available to XSLT stylesheets. Default is \"Don't\", items are displayed using other methods."
|
||||
Did you mean/spell checking:
|
||||
-
|
||||
- "Swedish service for spellchecking.<br/>"
|
||||
|
|
|
|||
|
|
@ -71,17 +71,17 @@ Staff interface:
|
|||
- 'Display lists in the staff interface using XSLT stylesheet at: '
|
||||
- pref: XSLTListsDisplay
|
||||
class: file
|
||||
- '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="XSLTListsDisplay" data-value="">Leave empty</a> for "no xslt"</li><li>enter "<a href="#" class="set_syspref" data-syspref="XSLTListsDisplay" data-value="default">default</a>" for the default one</li><li> put a path to define a xslt file</li><li>put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language'
|
||||
- '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="XSLTListsDisplay" data-value="">Leave empty</a> for "no xslt"</li><li>Enter "<a href="#" class="set_syspref" data-syspref="XSLTListsDisplay" data-value="default">default</a>" for the default stylesheet</li><li>Put a path to define an xslt file</li><li>Put a URL for an external specific stylesheet.</li><li>NOTE: The system preference <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PassItemMarcToXSLT">PassItemMarcToXSLT</a> must be enabled if your custom stylesheet utilizes data in the item fields</li></ul>If you have multiple stylesheets for different langues the placeholder {langcode} will be replaced with current interface language.'
|
||||
-
|
||||
- 'Display results in the staff interface using XSLT stylesheet at: '
|
||||
- pref: XSLTResultsDisplay
|
||||
class: file
|
||||
- '<br />Options:<ul><li>Enter "<a href="#" class="set_syspref" data-syspref="XSLTResultsDisplay" data-value="default">default</a>" for the default one</li><li>Put a path to define a xslt file</li><li>Put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language'
|
||||
- '<br />Options:<ul><li>Enter "<a href="#" class="set_syspref" data-syspref="XSLTResultsDisplay" data-value="default">default</a>" for the default stylesheet</li><li>Put a path to define an xslt file</li><li>Put a URL for an external specific stylesheet.</li><li>NOTE: The system preference <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PassItemMarcToXSLT">PassItemMarcToXSLT</a> must be enabled if your custom stylesheet utilizes data in the item fields</li></ul>If you have multiple stylesheets for different langues the placeholder {langcode} will be replaced with current interface language.'
|
||||
-
|
||||
- 'Display details in the staff interface using XSLT stylesheet at: '
|
||||
- pref: XSLTDetailsDisplay
|
||||
class: file
|
||||
- '<br />Options:<ul><li>Enter "<a href="#" class="set_syspref" data-syspref="XSLTDetailsDisplay" data-value="default">default</a>" for the default one</li><li>Put a path to define a xslt file</li><li>Put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language'
|
||||
- '<br />Options:<ul><li>Enter "<a href="#" class="set_syspref" data-syspref="XSLTDetailsDisplay" data-value="default">default</a>" for the default stylesheet</li><li>Put a path to define an xslt file</li><li>Put a URL for an external specific stylesheet.</li><li>NOTE: The system preference <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PassItemMarcToXSLT">PassItemMarcToXSLT</a> must be enabled if your custom stylesheet utilizes data in the item fields</li></ul>If you have multiple stylesheets for different langues the placeholder {langcode} will be replaced with current interface language.'
|
||||
-
|
||||
- pref: DisplayIconsXSLT
|
||||
choices:
|
||||
|
|
|
|||
38
t/Search.t
38
t/Search.t
|
|
@ -17,14 +17,18 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use C4::Biblio;
|
||||
use Test::More;
|
||||
use Test::MockModule;
|
||||
use Test::Warn;
|
||||
use t::lib::Mocks;
|
||||
use t::lib::TestBuilder;
|
||||
|
||||
use Module::Load::Conditional qw/check_install/;
|
||||
|
||||
BEGIN {
|
||||
if ( check_install( module => 'Test::DBIx::Class' ) ) {
|
||||
plan tests => 3;
|
||||
plan tests => 4;
|
||||
} else {
|
||||
plan skip_all => "Need Test::DBIx::Class"
|
||||
}
|
||||
|
|
@ -169,4 +173,36 @@ subtest "_build_initial_query tests" => sub {
|
|||
|
||||
};
|
||||
|
||||
subtest "searchResults PassItemMarcToXSLT test" => sub {
|
||||
|
||||
plan tests => 2;
|
||||
|
||||
t::lib::Mocks::mock_preference('OPACXSLTResultsDisplay','default');
|
||||
t::lib::Mocks::mock_preference('marcflavour','MARC21');
|
||||
my $mock_xslt = Test::MockModule->new("C4::Search");
|
||||
$mock_xslt->mock( XSLTParse4Display => sub {
|
||||
my $params = shift;
|
||||
my $record = $params->{record};
|
||||
warn $record->field('952') ? "Item here" : "No item";
|
||||
return;
|
||||
});
|
||||
|
||||
my $builder = t::lib::TestBuilder->new;
|
||||
|
||||
my $item = $builder->build_sample_item();
|
||||
my $record = $item->biblio->metadata->record;
|
||||
C4::Biblio::EmbedItemsInMarcBiblio({ marc_record => $record, biblionumber => $item->biblionumber });
|
||||
|
||||
t::lib::Mocks::mock_preference('PassItemMarcToXSLT','1');
|
||||
|
||||
warnings_like { C4::Search::searchResults({ interface => "opac" },"test",1,1,0,0,[ $record->as_xml_record ] ,undef) }
|
||||
[qr/Item here/],
|
||||
"Item field returned from default XSLT if pref set";
|
||||
|
||||
t::lib::Mocks::mock_preference('PassItemMarcToXSLT','0');
|
||||
|
||||
warnings_like { C4::Search::searchResults({ interface => "opac" },"test",1,1,0,0,[ $record->as_xml_record ] ,undef) }
|
||||
[qr/No item/],
|
||||
"Item field returned from default XSLT if pref set";
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue