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

(-)a/C4/XSLT.pm (-21 / +23 lines)
Lines 269-299 sub XSLTParse4Display { Link Here
269
    my $partsxml = '';
269
    my $partsxml = '';
270
    # possibly insert component records into Detail views
270
    # possibly insert component records into Detail views
271
    if ($xslsyspref =~ m/Details/) {
271
    if ($xslsyspref =~ m/Details/) {
272
        my $biblio = Koha::Biblios->find( $biblionumber );
273
        my $components = $biblio->get_marc_components(300);
274
        $variables->{show_analytics_link} = ( scalar @{$components} == 0 ) ? 0 : 1;
275
272
        my $showcomp = C4::Context->preference('ShowComponentRecords');
276
        my $showcomp = C4::Context->preference('ShowComponentRecords');
273
        if ( $showcomp eq 'both' ||
277
        if ( $showcomp eq 'both' ||
274
             ($showcomp eq 'staff' && $xslsyspref !~ m/OPAC/ ) ||
278
             ($showcomp eq 'staff' && $xslsyspref !~ m/OPAC/ ) ||
275
             ($showcomp eq 'opac' && $xslsyspref =~ m/OPAC/  ) ) {
279
             ($showcomp eq 'opac' && $xslsyspref =~ m/OPAC/  ) ) {
276
            my $biblio = Koha::Biblios->find( $biblionumber );
280
             
277
            my $max_results = 300;
281
             $variables->{show_analytics_link} = 0;
278
282
279
            if ( $biblio->get_marc_components($max_results) ) {
283
             my $search_query = Koha::Util::Search::get_component_part_query($biblionumber);
280
                my $search_query = Koha::Util::Search::get_component_part_query($biblionumber);
284
             $variables->{ComponentPartQuery} = $search_query;
281
                $variables->{ComponentPartQuery} = $search_query;
285
282
286
             my @componentPartRecordXML = ('<componentPartRecords>');
283
                my @componentPartRecordXML = ('<componentPartRecords>');
287
             for my $cb ( @{ $biblio->get_marc_components($max_results) } ) {
284
                for my $cb ( @{ $biblio->get_marc_components($max_results) } ) {
288
                 if( ref $cb eq 'MARC::Record'){
285
                    if( ref $cb eq 'MARC::Record'){
289
                     $cb = $cb->as_xml_record();
286
                        $cb = $cb->as_xml_record();
290
                 } else {
287
                    } else {
291
                     $cb = decode('utf8', $cb);
288
                        $cb = decode('utf8', $cb);
292
                 }
289
                    }
293
                 # Remove the xml header
290
                    # Remove the xml header
294
                 $cb =~ s/^<\?xml.*?\?>//;
291
                    $cb =~ s/^<\?xml.*?\?>//;
295
                 push @componentPartRecordXML,$cb;
292
                    push @componentPartRecordXML,$cb;
296
             }
293
                }
297
             push @componentPartRecordXML, '</componentPartRecords>';
294
                push @componentPartRecordXML, '</componentPartRecords>';
298
             $partsxml = join "\n", @componentPartRecordXML;
295
                $partsxml = join "\n", @componentPartRecordXML;
296
            }
297
        }
299
        }
298
    }
300
    }
299
301
(-)a/Koha/Util/Search.pm (-14 / +28 lines)
Lines 36-57 Returns a query which can be used to search for all component parts of MARC21 bi Link Here
36
sub get_component_part_query {
36
sub get_component_part_query {
37
    my ($biblionumber) = @_;
37
    my ($biblionumber) = @_;
38
38
39
    my $marc = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber });
39
    my $marc = C4::Biblio::GetMarcBiblio( { biblionumber => $biblionumber } );
40
    my $pf001 = $marc->field('001') || undef;
40
41
41
    my $searchstr;
42
    if (defined($pf001)) {
42
    if ( C4::Context->preference('UseControlNumber') ) {
43
        my $pf003 = $marc->field('003') || undef;
43
        my $pf001 = $marc->field('001') || undef;
44
        my $searchstr;
44
45
45
        if ( defined($pf001) ) {
46
        if (!defined($pf003)) {
46
            my $pf003 = $marc->field('003') || undef;
47
            # search for 773$w='Host001'
47
48
            $searchstr = "rcn=\"".$pf001->data()."\"";
48
            if ( !defined($pf003) ) {
49
        } else {
49
                # search for 773$w='Host001'
50
            # search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001')
50
                $searchstr = "rcn=\"" . $pf001->data() . "\"";
51
            $searchstr = "(rcn=\"".$pf001->data()."\" AND cni=\"".$pf003->data()."\")";
51
            }
52
            $searchstr .= " OR rcn=\"".$pf003->data()." ".$pf001->data()."\"";
52
            else {
53
                $searchstr  = "(";
54
                # search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001')
55
                $searchstr .= "(rcn=\"" . $pf001->data() . "\" AND cni=\"" . $pf003->data() . "\")";
56
                $searchstr .= " OR rcn=\"" . $pf003->data() . " " . $pf001->data() . "\"";
57
                $searchstr .= ")";
58
            }
59
            
60
            # limit to monograph and serial component part records
61
            $serachstr .= " AND (bib-level:a OR bib-level:b)";
53
        }
62
        }
54
    }
63
    }
64
    else {
65
        my $cleaned_title = $marc->title;
66
        $cleaned_title =~ tr|/||;
67
        $searchstr = "Host-item:($cleaned_title)";
68
    }
55
}
69
}
56
70
57
1;
71
1;
(-)a/catalogue/detail.pl (-19 lines)
Lines 129-158 my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef; Link Here
129
129
130
if ( $xslfile ) {
130
if ( $xslfile ) {
131
131
132
    my $searcher = Koha::SearchEngine::Search->new(
133
        { index => $Koha::SearchEngine::BIBLIOS_INDEX }
134
    );
135
    my $cleaned_title = $biblio->title;
136
    $cleaned_title =~ tr|/||;
137
    my $query =
138
      ( C4::Context->preference('UseControlNumber') and $record->field('001') )
139
      ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)'
140
      : "Host-item:($cleaned_title)";
141
    my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 );
142
143
    warn "Warning from simple_search_compat: $err"
144
        if $err;
145
146
    my $variables = {
147
        show_analytics_link => $count > 0 ? 1 : 0
148
    };
149
150
    $template->param(
132
    $template->param(
151
        XSLTDetailsDisplay => '1',
133
        XSLTDetailsDisplay => '1',
152
        XSLTBloc           => XSLTParse4Display(
134
        XSLTBloc           => XSLTParse4Display(
153
            $biblionumber, $record, "XSLTDetailsDisplay", 1,
135
            $biblionumber, $record, "XSLTDetailsDisplay", 1,
154
            undef,         $sysxml, $xslfile,             $lang,
136
            undef,         $sysxml, $xslfile,             $lang,
155
            $variables
156
        )
137
        )
157
    );
138
    );
158
}
139
}
(-)a/opac/opac-detail.pl (-16 lines)
Lines 200-222 my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef; Link Here
200
200
201
if ( $xslfile ) {
201
if ( $xslfile ) {
202
202
203
    my $searcher = Koha::SearchEngine::Search->new(
204
        { index => $Koha::SearchEngine::BIBLIOS_INDEX }
205
    );
206
    my $cleaned_title = $biblio->title;
207
    $cleaned_title =~ tr|/||;
208
    my $query =
209
      ( C4::Context->preference('UseControlNumber') and $record->field('001') )
210
      ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)'
211
      : "Host-item:($cleaned_title)";
212
    my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 );
213
214
    warn "Warning from simple_search_compat: $err"
215
        if $err;
216
217
    my $variables = {
203
    my $variables = {
218
        anonymous_session   => ($borrowernumber) ? 0 : 1,
204
        anonymous_session   => ($borrowernumber) ? 0 : 1,
219
        show_analytics_link => $count > 0 ? 1 : 0
220
    };
205
    };
221
206
222
    my @plugin_responses = Koha::Plugins->call(
207
    my @plugin_responses = Koha::Plugins->call(
223
- 

Return to bug 11175