View | Details | Raw Unified | Return to bug 28373
Collapse All | Expand All

(-)a/C4/Search.pm (+1 lines)
Lines 1773-1778 sub searchResults { Link Here
1773
1773
1774
        # Pull out the items fields
1774
        # Pull out the items fields
1775
        my @fields = $marcrecord->field($itemtag);
1775
        my @fields = $marcrecord->field($itemtag);
1776
        $marcrecord->delete_fields( @fields ) unless C4::Context->preference('PassItemMarcToXSLT');
1776
        my $marcflavor = C4::Context->preference("marcflavour");
1777
        my $marcflavor = C4::Context->preference("marcflavour");
1777
1778
1778
        # adding linked items that belong to host records
1779
        # adding linked items that belong to host records
(-)a/installer/data/mysql/atomicupdate/bug28373_add_PassItemMarcToXSLT_preference.perl (+15 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do( q{
4
        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
5
        ('PassItemMarcToXSLT','0',NULL,'If enabled, item fields in the MARC record will be made avaiable to XSLT sheets. Otherwise they will be removed.','YesNo');
6
    });
7
    foreach my $pref ('XSLTDetailsDisplay','XSLTListsDisplay','XSLTResultsDisplay','OPACXSLTDetailsDisplay','OPACXSLTListsDisplay','OPACXSLTResultsDisplay'){
8
        if( C4::Context->preference($pref) ne 'default' ){
9
            print "NOTE: You have defined a custom stylesheet. If your custom stylesheets are utilizing item fields you must enable the system preference 'PassItemMarcToXSLT'\n";
10
            last;
11
        }
12
    }
13
14
    NewVersion( $DBversion, 28373, "Add PassItemMarcToXSLT system preference");
15
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 507-512 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
507
('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'),
507
('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'),
508
('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'),
508
('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'),
509
('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'),
509
('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'),
510
('PassItemMarcToXSLT','0',NULL,'If enabled, item fields in the MARC record will be made avaiable to XSLT sheets. Otherwise they will be removed.','YesNo'),
510
('PatronAnonymizeDelay','',NULL,'Delay for anonymizing patrons', 'Integer'),
511
('PatronAnonymizeDelay','',NULL,'Delay for anonymizing patrons', 'Integer'),
511
('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'),
512
('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'),
512
('PatronDuplicateMatchingAddFields','surname|firstname|dateofbirth', NULL,'A list of fields separated by "|" to deduplicate patrons when created','Free'),
513
('PatronDuplicateMatchingAddFields','surname|firstname|dateofbirth', NULL,'A list of fields separated by "|" to deduplicate patrons when created','Free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-3 / +3 lines)
Lines 101-117 OPAC: Link Here
101
            - 'Display lists in the OPAC using XSLT stylesheet at: '
101
            - 'Display lists in the OPAC using XSLT stylesheet at: '
102
            - pref: OPACXSLTListsDisplay
102
            - pref: OPACXSLTListsDisplay
103
              class: file
103
              class: file
104
            - '<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.'
104
            - '<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.'
105
        -
105
        -
106
            - 'Display OPAC results using XSLT stylesheet at: '
106
            - 'Display OPAC results using XSLT stylesheet at: '
107
            - pref: OPACXSLTResultsDisplay
107
            - pref: OPACXSLTResultsDisplay
108
              class: file
108
              class: file
109
            - '<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.'
109
            - '<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.'
110
        -
110
        -
111
            - 'Display OPAC details using XSLT stylesheet at: '
111
            - 'Display OPAC details using XSLT stylesheet at: '
112
            - pref: OPACXSLTDetailsDisplay
112
            - pref: OPACXSLTDetailsDisplay
113
              class: file
113
              class: file
114
            - '<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.'
114
            - '<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.'
115
        -
115
        -
116
            - "Show itemtype icons in the OPAC: "
116
            - "Show itemtype icons in the OPAC: "
117
            - pref: OpacNoItemTypeImages
117
            - pref: OpacNoItemTypeImages
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (+7 lines)
Lines 273-278 Searching: Link Here
273
                  1: "Display"
273
                  1: "Display"
274
                  0: "Don't display"
274
                  0: "Don't display"
275
            - ' 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.'
275
            - ' 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.'
276
        -
277
            - pref: PassItemMarcToXSLT
278
              type: boolean
279
              choices:
280
                  1: Do
281
                  0: "Don't"
282
            - "make item MARC tags available to XSLT stylesheets. Default is \"Don't\", items are displayed using other methods."
276
    Did you mean/spell checking:
283
    Did you mean/spell checking:
277
        -
284
        -
278
            - "Swedish service for spellchecking.<br/>"
285
            - "Swedish service for spellchecking.<br/>"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref (-3 / +3 lines)
Lines 71-87 Staff interface: Link Here
71
            - 'Display lists in the staff interface using XSLT stylesheet at: '
71
            - 'Display lists in the staff interface using XSLT stylesheet at: '
72
            - pref: XSLTListsDisplay
72
            - pref: XSLTListsDisplay
73
              class: file
73
              class: file
74
            - '<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'
74
            - '<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.'
75
        -
75
        -
76
            - 'Display results in the staff interface using XSLT stylesheet at: '
76
            - 'Display results in the staff interface using XSLT stylesheet at: '
77
            - pref: XSLTResultsDisplay
77
            - pref: XSLTResultsDisplay
78
              class: file
78
              class: file
79
            - '<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'
79
            - '<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.'
80
        -
80
        -
81
            - 'Display details in the staff interface using XSLT stylesheet at: '
81
            - 'Display details in the staff interface using XSLT stylesheet at: '
82
            - pref: XSLTDetailsDisplay
82
            - pref: XSLTDetailsDisplay
83
              class: file
83
              class: file
84
            - '<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'
84
            - '<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.'
85
        -
85
        -
86
            - pref: DisplayIconsXSLT
86
            - pref: DisplayIconsXSLT
87
              choices:
87
              choices:
(-)a/t/Search.t (-2 / +37 lines)
Lines 17-30 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use C4::Biblio;
20
use Test::More;
21
use Test::More;
22
use Test::MockModule;
23
use Test::Warn;
21
use t::lib::Mocks;
24
use t::lib::Mocks;
25
use t::lib::TestBuilder;
22
26
23
use Module::Load::Conditional qw/check_install/;
27
use Module::Load::Conditional qw/check_install/;
24
28
25
BEGIN {
29
BEGIN {
26
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
30
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
27
        plan tests => 3;
31
        plan tests => 4;
28
    } else {
32
    } else {
29
        plan skip_all => "Need Test::DBIx::Class"
33
        plan skip_all => "Need Test::DBIx::Class"
30
    }
34
    }
Lines 169-172 subtest "_build_initial_query tests" => sub { Link Here
169
173
170
};
174
};
171
175
176
subtest "searchResults PassItemMarcToXSLT test" => sub {
172
177
173
- 
178
    plan tests => 2;
179
180
    t::lib::Mocks::mock_preference('OPACXSLTResultsDisplay','default');
181
    t::lib::Mocks::mock_preference('marcflavour','MARC21');
182
    my $mock_xslt = Test::MockModule->new("C4::Search");
183
    $mock_xslt->mock( XSLTParse4Display => sub {
184
        my $params = shift;
185
        my $record = $params->{record};
186
        warn $record->field('952') ? "Item here" : "No item";
187
        return;
188
    });
189
190
    my $builder = t::lib::TestBuilder->new;
191
192
    my $item = $builder->build_sample_item();
193
    my $record = $item->biblio->metadata->record;
194
    C4::Biblio::EmbedItemsInMarcBiblio({ marc_record => $record, biblionumber => $item->biblionumber });
195
196
    t::lib::Mocks::mock_preference('PassItemMarcToXSLT','1');
197
198
    warnings_like { C4::Search::searchResults({ interface => "opac" },"test",1,1,0,0,[ $record->as_xml_record ] ,undef) }
199
        [qr/Item here/],
200
        "Item field returned from default XSLT if pref set";
201
202
    t::lib::Mocks::mock_preference('PassItemMarcToXSLT','0');
203
204
    warnings_like { C4::Search::searchResults({ interface => "opac" },"test",1,1,0,0,[ $record->as_xml_record ] ,undef) }
205
        [qr/No item/],
206
        "Item field returned from default XSLT if pref set";
207
208
}

Return to bug 28373