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

(-)a/C4/Search.pm (-6 / +16 lines)
Lines 1648-1657 sub searchResults { Link Here
1648
    my ($bibliotag,$bibliosubf)=GetMarcFromKohaField( 'biblio.biblionumber' );
1648
    my ($bibliotag,$bibliosubf)=GetMarcFromKohaField( 'biblio.biblionumber' );
1649
1649
1650
    # set stuff for XSLT processing here once, not later again for every record we retrieved
1650
    # set stuff for XSLT processing here once, not later again for every record we retrieved
1651
    my $xslsyspref = $is_opac ? 'OPACXSLTResultsDisplay' : 'XSLTResultsDisplay';
1652
    my $xslfile = C4::Context->preference( $xslsyspref ) || "default";
1653
    my $lang   = C4::Languages::getlanguage();
1654
    my $sysxml = C4::XSLT::get_xslt_sysprefs();
1655
1651
1656
    my $userenv = C4::Context->userenv;
1652
    my $userenv = C4::Context->userenv;
1657
    my $logged_in_user
1653
    my $logged_in_user
Lines 1948-1961 sub searchResults { Link Here
1948
1944
1949
        # XSLT processing of some stuff
1945
        # XSLT processing of some stuff
1950
        # we fetched the sysprefs already before the loop through all retrieved record!
1946
        # we fetched the sysprefs already before the loop through all retrieved record!
1951
        if (!$scan && $xslfile) {
1947
        if (!$scan) {
1952
            $record_processor->options({
1948
            $record_processor->options({
1953
                frameworkcode => $fw,
1949
                frameworkcode => $fw,
1954
                interface     => $search_context->{'interface'}
1950
                interface     => $search_context->{'interface'}
1955
            });
1951
            });
1956
1952
1957
            $record_processor->process($marcrecord);
1953
            $record_processor->process($marcrecord);
1958
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang, $xslt_variables);
1954
1955
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display(
1956
                {
1957
                    biblionumber => $oldbiblio->{biblionumber},
1958
                    record       => $marcrecord,
1959
                    xsl_syspref  => (
1960
                        $is_opac
1961
                        ? 'OPACXSLTResultsDisplay'
1962
                        : 'XSLTResultsDisplay'
1963
                    ),
1964
                    fix_amps       => 1,
1965
                    hidden_items   => \@hiddenitems,
1966
                    xslt_variables => $xslt_variables
1967
                }
1968
            );
1959
        }
1969
        }
1960
1970
1961
        # if biblio level itypes are used and itemtype is notforloan, it can't be reserved either
1971
        # if biblio level itypes are used and itemtype is notforloan, it can't be reserved either
(-)a/C4/XSLT.pm (-8 / +25 lines)
Lines 189-205 sub get_xslt_sysprefs { Link Here
189
    return $sysxml;
189
    return $sysxml;
190
}
190
}
191
191
192
sub XSLTParse4Display {
192
sub get_xsl_filename {
193
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $variables, $items_rs ) = @_;
193
    my ( $xslsyspref ) = @_;
194
195
    my $lang   = C4::Languages::getlanguage();
194
196
195
    $sysxml ||= C4::Context->preference($xslsyspref);
197
    my $xslfilename = C4::Context->preference($xslsyspref) || "default";
196
    $xslfilename ||= C4::Context->preference($xslsyspref);
197
    $lang ||= C4::Languages::getlanguage();
198
198
199
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
199
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
200
        my $htdocs;
200
201
        my $theme;
201
        my ( $htdocs, $theme, $xslfile );
202
        my $xslfile;
202
203
        if ($xslsyspref eq "XSLTDetailsDisplay") {
203
        if ($xslsyspref eq "XSLTDetailsDisplay") {
204
            $htdocs  = C4::Context->config('intrahtdocs');
204
            $htdocs  = C4::Context->config('intrahtdocs');
205
            $theme   = C4::Context->preference("template");
205
            $theme   = C4::Context->preference("template");
Lines 240-245 sub XSLTParse4Display { Link Here
240
        $xslfilename =~ s/\{langcode\}/$lang/;
240
        $xslfilename =~ s/\{langcode\}/$lang/;
241
    }
241
    }
242
242
243
    return $xslfilename;
244
}
245
246
sub XSLTParse4Display {
247
    my ( $params ) = @_;
248
249
    my $biblionumber = $params->{biblionumber};
250
    my $orig_record  = $params->{record};
251
    my $xslsyspref   = $params->{xsl_syspref};
252
    my $fixamps      = $params->{fix_amps};
253
    my $hidden_items = $params->{hidden_items} || [];
254
    my $variables    = $params->{xslt_variables};
255
    my $items_rs     = $params->{items_rs};
256
257
    my $xslfilename = get_xsl_filename( $xslsyspref);
258
243
    # grab the XML, run it through our stylesheet, push it out to the browser
259
    # grab the XML, run it through our stylesheet, push it out to the browser
244
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
260
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
245
    my $itemsxml;
261
    my $itemsxml;
Lines 272-277 sub XSLTParse4Display { Link Here
272
    }
288
    }
273
    $varxml .= "</variables>\n";
289
    $varxml .= "</variables>\n";
274
290
291
    my $sysxml = get_xslt_sysprefs();
275
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml$varxml\<\/record\>/;
292
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml$varxml\<\/record\>/;
276
    if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs
293
    if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs
277
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
294
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
(-)a/catalogue/detail.pl (-8 / +9 lines)
Lines 119-127 my $marcflavour = C4::Context->preference("marcflavour"); Link Here
119
119
120
{
120
{
121
    # XSLT processing of some stuff
121
    # XSLT processing of some stuff
122
    my $xslfile = C4::Context->preference('XSLTDetailsDisplay') || "default";
123
    my $lang   = C4::Languages::getlanguage();
124
    my $sysxml = C4::XSLT::get_xslt_sysprefs();
125
122
126
    my $searcher = Koha::SearchEngine::Search->new(
123
    my $searcher = Koha::SearchEngine::Search->new(
127
        { index => $Koha::SearchEngine::BIBLIOS_INDEX }
124
        { index => $Koha::SearchEngine::BIBLIOS_INDEX }
Lines 143-153 my $marcflavour = C4::Context->preference("marcflavour"); Link Here
143
140
144
    $template->param(
141
    $template->param(
145
        XSLTDetailsDisplay => '1',
142
        XSLTDetailsDisplay => '1',
146
        XSLTBloc           => XSLTParse4Display(
143
        XSLTBloc => XSLTParse4Display(
147
            $biblionumber, $record, "XSLTDetailsDisplay", 1,
144
            {
148
            undef,         $sysxml, $xslfile,             $lang,
145
                biblionumber   => $biblionumber,
149
            $variables
146
                record         => $record,
150
        )
147
                xsl_syspref    => "XSLTDetailsDisplay",
148
                fix_amps       => 1,
149
                xslt_variables => $variables
150
            }
151
        ),
151
    );
152
    );
152
}
153
}
153
154
(-)a/opac/opac-detail.pl (-10 / +10 lines)
Lines 174-185 my $marcflavour = C4::Context->preference("marcflavour"); Link Here
174
my $ean = GetNormalizedEAN( $record, $marcflavour );
174
my $ean = GetNormalizedEAN( $record, $marcflavour );
175
175
176
{
176
{
177
178
    # XSLT processing of some stuff
179
    my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay') || "default";
180
    my $lang   = C4::Languages::getlanguage();
181
    my $sysxml = C4::XSLT::get_xslt_sysprefs();
182
183
    my $searcher = Koha::SearchEngine::Search->new(
177
    my $searcher = Koha::SearchEngine::Search->new(
184
        { index => $Koha::SearchEngine::BIBLIOS_INDEX }
178
        { index => $Koha::SearchEngine::BIBLIOS_INDEX }
185
    );
179
    );
Lines 192-204 my $ean = GetNormalizedEAN( $record, $marcflavour ); Link Here
192
    my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 );
186
    my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 );
193
187
194
    warn "Warning from simple_search_compat: $err"
188
    warn "Warning from simple_search_compat: $err"
195
        if $err;
189
       if $err;
196
190
197
    my $variables = {
191
    my $variables = {
198
        anonymous_session   => ($borrowernumber) ? 0 : 1,
192
        anonymous_session   => ($borrowernumber) ? 0 : 1,
199
        show_analytics_link => $count > 0 ? 1 : 0
193
        show_analytics_link => $count > 0 ? 1 : 0
200
    };
194
    };
201
195
196
    my $lang   = C4::Languages::getlanguage();
202
    my @plugin_responses = Koha::Plugins->call(
197
    my @plugin_responses = Koha::Plugins->call(
203
        'opac_detail_xslt_variables',
198
        'opac_detail_xslt_variables',
204
        {
199
        {
Lines 214-222 my $ean = GetNormalizedEAN( $record, $marcflavour ); Link Here
214
209
215
    $template->param(
210
    $template->param(
216
        XSLTBloc => XSLTParse4Display(
211
        XSLTBloc => XSLTParse4Display(
217
            $biblionumber, $record, "OPACXSLTDetailsDisplay", 1, undef,
212
            {
218
            $sysxml, $xslfile, $lang, $variables
213
                biblionumber   => $biblionumber,
219
        )
214
                record         => $record,
215
                xsl_syspref    => 'OPACXSLTDetailsDisplay',
216
                fix_amps       => 1,
217
                xslt_variables => $variables
218
            }
219
        ),
220
    );
220
    );
221
}
221
}
222
222
(-)a/opac/opac-shelves.pl (-10 / +9 lines)
Lines 294-304 if ( $op eq 'view' ) { Link Here
294
                $categorycode = $patron ? $patron->categorycode : undef;
294
                $categorycode = $patron ? $patron->categorycode : undef;
295
            }
295
            }
296
296
297
            # Lists display falls back to search results configuration
298
            my $xslfile = C4::Context->preference('OPACXSLTListsDisplay') || "default";
299
            my $lang   = C4::Languages::getlanguage();
300
            my $sysxml = C4::XSLT::get_xslt_sysprefs();
301
302
            my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
297
            my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
303
298
304
            my $art_req_itypes;
299
            my $art_req_itypes;
Lines 365-377 if ( $op eq 'view' ) { Link Here
365
                    anonymous_session => ($loggedinuser) ? 0 : 1
360
                    anonymous_session => ($loggedinuser) ? 0 : 1
366
                };
361
                };
367
                $this_item->{XSLTBloc} = XSLTParse4Display(
362
                $this_item->{XSLTBloc} = XSLTParse4Display(
368
                    $biblionumber,          $record,
363
                    {
369
                    "OPACXSLTListsDisplay", 1,
364
                        biblionumber   => $biblionumber,
370
                    undef,                 $sysxml,
365
                        record         => $record,
371
                    $xslfile,              $lang,
366
                        xsl_syspref    => "OPACXSLTListsDisplay",
372
                    $variables,            $items->reset
367
                        fix_amps       => 1,
368
                        xslt_variables => $variables,
369
                        items_rs       => $items->reset,
370
                    }
373
                );
371
                );
374
372
373
375
                if ( grep {$_ eq $biblionumber} @cart_list) {
374
                if ( grep {$_ eq $biblionumber} @cart_list) {
376
                    $this_item->{incart} = 1;
375
                    $this_item->{incart} = 1;
377
                }
376
                }
(-)a/opac/opac-tags.pl (-9 / +8 lines)
Lines 280-298 if ($loggedinuser) { Link Here
280
        # BZ17530: 'Intelligent' guess if result can be article requested
280
        # BZ17530: 'Intelligent' guess if result can be article requested
281
        $tag->{artreqpossible} = ( $art_req_itypes->{ $tag->{itemtype} // q{} } || $art_req_itypes->{ '*' } ) ? 1 : q{};
281
        $tag->{artreqpossible} = ( $art_req_itypes->{ $tag->{itemtype} // q{} } || $art_req_itypes->{ '*' } ) ? 1 : q{};
282
282
283
        my $xslfile = C4::Context->preference('OPACXSLTResultsDisplay') || "default";
284
        my $lang   = C4::Languages::getlanguage();
285
        my $sysxml = C4::XSLT::get_xslt_sysprefs();
286
287
        my $variables = {
283
        my $variables = {
288
            anonymous_session => ($loggedinuser) ? 0 : 1
284
            anonymous_session => ($loggedinuser) ? 0 : 1
289
        };
285
        };
290
        $tag->{XSLTBloc} = XSLTParse4Display(
286
        $tag->{XSLTBloc} = XSLTParse4Display(
291
            $tag->{biblionumber},     $record,
287
            {
292
            "OPACXSLTResultsDisplay", 1,
288
                biblionumber   => $tag->{biblionumber},
293
            $hidden_items,            $sysxml,
289
                record         => $record,
294
            $xslfile,                 $lang,
290
                xsl_filename   => 'OPACXSLTResultsDisplay',
295
            $variables
291
                fix_amps       => 1,
292
                hidden_items   => $hidden_items,
293
                xslt_variables => $variables
294
            }
296
        );
295
        );
297
296
298
        my $date = $tag->{date_created} || '';
297
        my $date = $tag->{date_created} || '';
(-)a/virtualshelves/shelves.pl (-7 / +8 lines)
Lines 253-270 if ( $op eq 'view' ) { Link Here
253
                }
253
                }
254
            );
254
            );
255
255
256
            my $xslfile = C4::Context->preference('XSLTListsDisplay');
257
            my $lang   = C4::Languages::getlanguage();
258
            my $sysxml = C4::XSLT::get_xslt_sysprefs();
259
260
            my @items;
256
            my @items;
261
            while ( my $content = $contents->next ) {
257
            while ( my $content = $contents->next ) {
262
                my $this_item;
258
                my $this_item;
263
                my $biblionumber = $content->biblionumber;
259
                my $biblionumber = $content->biblionumber;
264
                my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
260
                my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
265
261
266
                $this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "XSLTListsDisplay",
262
                $this_item->{XSLTBloc} = XSLTParse4Display(
267
                                                            1, undef, $sysxml, $xslfile, $lang);
263
                    {
264
                        biblionumber => $biblionumber,
265
                        record       => $record,
266
                        xsl_filename => "XSLTListsDisplay",
267
                        fix_amps     => 1,
268
                    }
269
                );
268
270
269
                my $marcflavour = C4::Context->preference("marcflavour");
271
                my $marcflavour = C4::Context->preference("marcflavour");
270
                my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
272
                my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
271
- 

Return to bug 12561