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

(-)a/C4/Search.pm (-6 / +16 lines)
Lines 1655-1664 sub searchResults { Link Here
1655
    my ($bibliotag,$bibliosubf)=GetMarcFromKohaField( 'biblio.biblionumber' );
1655
    my ($bibliotag,$bibliosubf)=GetMarcFromKohaField( 'biblio.biblionumber' );
1656
1656
1657
    # set stuff for XSLT processing here once, not later again for every record we retrieved
1657
    # set stuff for XSLT processing here once, not later again for every record we retrieved
1658
    my $xslsyspref = $is_opac ? 'OPACXSLTResultsDisplay' : 'XSLTResultsDisplay';
1659
    my $xslfile = C4::Context->preference( $xslsyspref ) || "default";
1660
    my $lang   = C4::Languages::getlanguage();
1661
    my $sysxml = C4::XSLT::get_xslt_sysprefs();
1662
1658
1663
    my $userenv = C4::Context->userenv;
1659
    my $userenv = C4::Context->userenv;
1664
    my $logged_in_user
1660
    my $logged_in_user
Lines 1955-1968 sub searchResults { Link Here
1955
1951
1956
        # XSLT processing of some stuff
1952
        # XSLT processing of some stuff
1957
        # we fetched the sysprefs already before the loop through all retrieved record!
1953
        # we fetched the sysprefs already before the loop through all retrieved record!
1958
        if (!$scan && $xslfile) {
1954
        if (!$scan) {
1959
            $record_processor->options({
1955
            $record_processor->options({
1960
                frameworkcode => $fw,
1956
                frameworkcode => $fw,
1961
                interface     => $search_context->{'interface'}
1957
                interface     => $search_context->{'interface'}
1962
            });
1958
            });
1963
1959
1964
            $record_processor->process($marcrecord);
1960
            $record_processor->process($marcrecord);
1965
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang, $xslt_variables);
1961
1962
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display(
1963
                {
1964
                    biblionumber => $oldbiblio->{biblionumber},
1965
                    record       => $marcrecord,
1966
                    xsl_syspref  => (
1967
                        $is_opac
1968
                        ? 'OPACXSLTResultsDisplay'
1969
                        : 'XSLTResultsDisplay'
1970
                    ),
1971
                    fix_amps       => 1,
1972
                    hidden_items   => \@hiddenitems,
1973
                    xslt_variables => $xslt_variables
1974
                }
1975
            );
1966
        }
1976
        }
1967
1977
1968
        # if biblio level itypes are used and itemtype is notforloan, it can't be reserved either
1978
        # if biblio level itypes are used and itemtype is notforloan, it can't be reserved either
(-)a/C4/XSLT.pm (-8 / +25 lines)
Lines 188-204 sub get_xslt_sysprefs { Link Here
188
    return $sysxml;
188
    return $sysxml;
189
}
189
}
190
190
191
sub XSLTParse4Display {
191
sub get_xsl_filename {
192
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $variables, $items_rs ) = @_;
192
    my ( $xslsyspref ) = @_;
193
194
    my $lang   = C4::Languages::getlanguage();
193
195
194
    $sysxml ||= C4::Context->preference($xslsyspref);
196
    my $xslfilename = C4::Context->preference($xslsyspref) || "default";
195
    $xslfilename ||= C4::Context->preference($xslsyspref);
196
    $lang ||= C4::Languages::getlanguage();
197
197
198
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
198
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
199
        my $htdocs;
199
200
        my $theme;
200
        my ( $htdocs, $theme, $xslfile );
201
        my $xslfile;
201
202
        if ($xslsyspref eq "XSLTDetailsDisplay") {
202
        if ($xslsyspref eq "XSLTDetailsDisplay") {
203
            $htdocs  = C4::Context->config('intrahtdocs');
203
            $htdocs  = C4::Context->config('intrahtdocs');
204
            $theme   = C4::Context->preference("template");
204
            $theme   = C4::Context->preference("template");
Lines 239-244 sub XSLTParse4Display { Link Here
239
        $xslfilename =~ s/\{langcode\}/$lang/;
239
        $xslfilename =~ s/\{langcode\}/$lang/;
240
    }
240
    }
241
241
242
    return $xslfilename;
243
}
244
245
sub XSLTParse4Display {
246
    my ( $params ) = @_;
247
248
    my $biblionumber = $params->{biblionumber};
249
    my $orig_record  = $params->{record};
250
    my $xslsyspref   = $params->{xsl_syspref};
251
    my $fixamps      = $params->{fix_amps};
252
    my $hidden_items = $params->{hidden_items} || [];
253
    my $variables    = $params->{xslt_variables};
254
    my $items_rs     = $params->{items_rs};
255
256
    my $xslfilename = get_xsl_filename( $xslsyspref);
257
242
    # grab the XML, run it through our stylesheet, push it out to the browser
258
    # grab the XML, run it through our stylesheet, push it out to the browser
243
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
259
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
244
    my $itemsxml;
260
    my $itemsxml;
Lines 271-276 sub XSLTParse4Display { Link Here
271
    }
287
    }
272
    $varxml .= "</variables>\n";
288
    $varxml .= "</variables>\n";
273
289
290
    my $sysxml = get_xslt_sysprefs();
274
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml$varxml\<\/record\>/;
291
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml$varxml\<\/record\>/;
275
    if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs
292
    if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs
276
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
293
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
(-)a/catalogue/detail.pl (-8 / +9 lines)
Lines 124-132 my $marcflavour = C4::Context->preference("marcflavour"); Link Here
124
124
125
{
125
{
126
    # XSLT processing of some stuff
126
    # XSLT processing of some stuff
127
    my $xslfile = C4::Context->preference('XSLTDetailsDisplay') || "default";
128
    my $lang   = C4::Languages::getlanguage();
129
    my $sysxml = C4::XSLT::get_xslt_sysprefs();
130
127
131
    my $searcher = Koha::SearchEngine::Search->new(
128
    my $searcher = Koha::SearchEngine::Search->new(
132
        { index => $Koha::SearchEngine::BIBLIOS_INDEX }
129
        { index => $Koha::SearchEngine::BIBLIOS_INDEX }
Lines 148-158 my $marcflavour = C4::Context->preference("marcflavour"); Link Here
148
145
149
    $template->param(
146
    $template->param(
150
        XSLTDetailsDisplay => '1',
147
        XSLTDetailsDisplay => '1',
151
        XSLTBloc           => XSLTParse4Display(
148
        XSLTBloc => XSLTParse4Display(
152
            $biblionumber, $record, "XSLTDetailsDisplay", 1,
149
            {
153
            undef,         $sysxml, $xslfile,             $lang,
150
                biblionumber   => $biblionumber,
154
            $variables
151
                record         => $record,
155
        )
152
                xsl_syspref    => "XSLTDetailsDisplay",
153
                fix_amps       => 1,
154
                xslt_variables => $variables
155
            }
156
        ),
156
    );
157
    );
157
}
158
}
158
159
(-)a/opac/opac-detail.pl (-10 / +10 lines)
Lines 194-205 my $marcflavour = C4::Context->preference("marcflavour"); Link Here
194
my $ean = GetNormalizedEAN( $record, $marcflavour );
194
my $ean = GetNormalizedEAN( $record, $marcflavour );
195
195
196
{
196
{
197
198
    # XSLT processing of some stuff
199
    my $xslfile = C4::Context->preference('OPACXSLTDetailsDisplay') || "default";
200
    my $lang   = C4::Languages::getlanguage();
201
    my $sysxml = C4::XSLT::get_xslt_sysprefs();
202
203
    my $searcher = Koha::SearchEngine::Search->new(
197
    my $searcher = Koha::SearchEngine::Search->new(
204
        { index => $Koha::SearchEngine::BIBLIOS_INDEX }
198
        { index => $Koha::SearchEngine::BIBLIOS_INDEX }
205
    );
199
    );
Lines 212-224 my $ean = GetNormalizedEAN( $record, $marcflavour ); Link Here
212
    my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 );
206
    my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 );
213
207
214
    warn "Warning from simple_search_compat: $err"
208
    warn "Warning from simple_search_compat: $err"
215
        if $err;
209
       if $err;
216
210
217
    my $variables = {
211
    my $variables = {
218
        anonymous_session   => ($borrowernumber) ? 0 : 1,
212
        anonymous_session   => ($borrowernumber) ? 0 : 1,
219
        show_analytics_link => $count > 0 ? 1 : 0
213
        show_analytics_link => $count > 0 ? 1 : 0
220
    };
214
    };
221
215
216
    my $lang   = C4::Languages::getlanguage();
222
    my @plugin_responses = Koha::Plugins->call(
217
    my @plugin_responses = Koha::Plugins->call(
223
        'opac_detail_xslt_variables',
218
        'opac_detail_xslt_variables',
224
        {
219
        {
Lines 234-242 my $ean = GetNormalizedEAN( $record, $marcflavour ); Link Here
234
229
235
    $template->param(
230
    $template->param(
236
        XSLTBloc => XSLTParse4Display(
231
        XSLTBloc => XSLTParse4Display(
237
            $biblionumber, $record, "OPACXSLTDetailsDisplay", 1, undef,
232
            {
238
            $sysxml, $xslfile, $lang, $variables
233
                biblionumber   => $biblionumber,
239
        )
234
                record         => $record,
235
                xsl_syspref    => 'OPACXSLTDetailsDisplay',
236
                fix_amps       => 1,
237
                xslt_variables => $variables
238
            }
239
        ),
240
    );
240
    );
241
}
241
}
242
242
(-)a/opac/opac-shelves.pl (-10 / +9 lines)
Lines 299-309 if ( $op eq 'view' ) { Link Here
299
                $categorycode = $patron ? $patron->categorycode : undef;
299
                $categorycode = $patron ? $patron->categorycode : undef;
300
            }
300
            }
301
301
302
            # Lists display falls back to search results configuration
303
            my $xslfile = C4::Context->preference('OPACXSLTListsDisplay') || "default";
304
            my $lang   = C4::Languages::getlanguage();
305
            my $sysxml = C4::XSLT::get_xslt_sysprefs();
306
307
            my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
302
            my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
308
303
309
            my $art_req_itypes;
304
            my $art_req_itypes;
Lines 370-382 if ( $op eq 'view' ) { Link Here
370
                    anonymous_session => ($loggedinuser) ? 0 : 1
365
                    anonymous_session => ($loggedinuser) ? 0 : 1
371
                };
366
                };
372
                $this_item->{XSLTBloc} = XSLTParse4Display(
367
                $this_item->{XSLTBloc} = XSLTParse4Display(
373
                    $biblionumber,          $record,
368
                    {
374
                    "OPACXSLTListsDisplay", 1,
369
                        biblionumber   => $biblionumber,
375
                    undef,                 $sysxml,
370
                        record         => $record,
376
                    $xslfile,              $lang,
371
                        xsl_syspref    => "OPACXSLTListsDisplay",
377
                    $variables,            $items->reset
372
                        fix_amps       => 1,
373
                        xslt_variables => $variables,
374
                        items_rs       => $items->reset,
375
                    }
378
                );
376
                );
379
377
378
380
                if ( grep {$_ eq $biblionumber} @cart_list) {
379
                if ( grep {$_ eq $biblionumber} @cart_list) {
381
                    $this_item->{incart} = 1;
380
                    $this_item->{incart} = 1;
382
                }
381
                }
(-)a/opac/opac-tags.pl (-9 / +8 lines)
Lines 285-303 if ($loggedinuser) { Link Here
285
        # BZ17530: 'Intelligent' guess if result can be article requested
285
        # BZ17530: 'Intelligent' guess if result can be article requested
286
        $tag->{artreqpossible} = ( $art_req_itypes->{ $tag->{itemtype} // q{} } || $art_req_itypes->{ '*' } ) ? 1 : q{};
286
        $tag->{artreqpossible} = ( $art_req_itypes->{ $tag->{itemtype} // q{} } || $art_req_itypes->{ '*' } ) ? 1 : q{};
287
287
288
        my $xslfile = C4::Context->preference('OPACXSLTResultsDisplay') || "default";
289
        my $lang   = C4::Languages::getlanguage();
290
        my $sysxml = C4::XSLT::get_xslt_sysprefs();
291
292
        my $variables = {
288
        my $variables = {
293
            anonymous_session => ($loggedinuser) ? 0 : 1
289
            anonymous_session => ($loggedinuser) ? 0 : 1
294
        };
290
        };
295
        $tag->{XSLTBloc} = XSLTParse4Display(
291
        $tag->{XSLTBloc} = XSLTParse4Display(
296
            $tag->{biblionumber},     $record,
292
            {
297
            "OPACXSLTResultsDisplay", 1,
293
                biblionumber   => $tag->{biblionumber},
298
            $hidden_items,            $sysxml,
294
                record         => $record,
299
            $xslfile,                 $lang,
295
                xsl_filename   => 'OPACXSLTResultsDisplay',
300
            $variables
296
                fix_amps       => 1,
297
                hidden_items   => $hidden_items,
298
                xslt_variables => $variables
299
            }
301
        );
300
        );
302
301
303
        my $date = $tag->{date_created} || '';
302
        my $date = $tag->{date_created} || '';
(-)a/virtualshelves/shelves.pl (-7 / +8 lines)
Lines 258-275 if ( $op eq 'view' ) { Link Here
258
                }
258
                }
259
            );
259
            );
260
260
261
            my $xslfile = C4::Context->preference('XSLTListsDisplay');
262
            my $lang   = C4::Languages::getlanguage();
263
            my $sysxml = C4::XSLT::get_xslt_sysprefs();
264
265
            my @items;
261
            my @items;
266
            while ( my $content = $contents->next ) {
262
            while ( my $content = $contents->next ) {
267
                my $this_item;
263
                my $this_item;
268
                my $biblionumber = $content->biblionumber;
264
                my $biblionumber = $content->biblionumber;
269
                my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
265
                my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
270
266
271
                $this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "XSLTListsDisplay",
267
                $this_item->{XSLTBloc} = XSLTParse4Display(
272
                                                            1, undef, $sysxml, $xslfile, $lang);
268
                    {
269
                        biblionumber => $biblionumber,
270
                        record       => $record,
271
                        xsl_filename => "XSLTListsDisplay",
272
                        fix_amps     => 1,
273
                    }
274
                );
273
275
274
                my $marcflavour = C4::Context->preference("marcflavour");
276
                my $marcflavour = C4::Context->preference("marcflavour");
275
                my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
277
                my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
276
- 

Return to bug 12561