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

(-)a/C4/Breeding.pm (-6 / +39 lines)
Lines 27-33 use C4::Charset; Link Here
27
use MARC::File::USMARC;
27
use MARC::File::USMARC;
28
use C4::ImportBatch;
28
use C4::ImportBatch;
29
use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority
29
use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority
30
use C4::Languages;
30
use Koha::Database;
31
use Koha::Database;
32
use Koha::XSLT_Handler;
31
33
32
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
34
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
33
35
Lines 164-169 sub Z3950Search { Link Here
164
                    _translate_query( $server, $squery )));
166
                    _translate_query( $server, $squery )));
165
        $s++;
167
        $s++;
166
    }
168
    }
169
    my $xslh = Koha::XSLT_Handler->new;
167
170
168
    my $nremaining = $s;
171
    my $nremaining = $s;
169
    while ( $nremaining-- ) {
172
    while ( $nremaining-- ) {
Lines 185-201 sub Z3950Search { Link Here
185
            else {
188
            else {
186
                my $numresults = $oResult[$k]->size();
189
                my $numresults = $oResult[$k]->size();
187
                my $i;
190
                my $i;
188
                my $result = '';
191
                my $res;
189
                if ( $numresults > 0  and $numresults >= (($page-1)*20)) {
192
                if ( $numresults > 0  and $numresults >= (($page-1)*20)) {
190
                    $show_next = 1 if $numresults >= ($page*20);
193
                    $show_next = 1 if $numresults >= ($page*20);
191
                    $total_pages = int($numresults/20)+1 if $total_pages < ($numresults/20);
194
                    $total_pages = int($numresults/20)+1 if $total_pages < ($numresults/20);
192
                    for ($i = ($page-1)*20; $i < (($numresults < ($page*20)) ? $numresults : ($page*20)); $i++) {
195
                    for ($i = ($page-1)*20; $i < (($numresults < ($page*20)) ? $numresults : ($page*20)); $i++) {
193
                        if($oResult[$k]->record($i)) {
196
                        if ( $oResult[$k]->record($i) ) {
194
                            my $res=_handle_one_result($oResult[$k]->record($i), $servers[$k], ++$imported, $biblionumber); #ignores error in sequence numbering
197
                            undef $error;
198
                            ( $res, $error ) = _handle_one_result( $oResult[$k]->record($i), $servers[$k], ++$imported, $biblionumber, $xslh ); #ignores error in sequence numbering
195
                            push @breeding_loop, $res if $res;
199
                            push @breeding_loop, $res if $res;
200
                            push @errconn, { server => $servers[$k]->{servername}, error => $error, seq => $i+1 } if $error;
196
                        }
201
                        }
197
                        else {
202
                        else {
198
                            push(@breeding_loop,{'server'=>$servers[$k]->{servername},'title'=>join(': ',$oConnection[$k]->error_x()),'breedingid'=>-1,'biblionumber'=>-1});
203
                            push @errconn, { 'server' => $servers[$k]->{servername}, error => ( ( $oConnection[$k]->error_x() )[0] ), seq => $i+1 };
199
                        }
204
                        }
200
                    }
205
                    }
201
                }    #if $numresults
206
                }    #if $numresults
Lines 258-264 sub _build_query { Link Here
258
}
263
}
259
264
260
sub _handle_one_result {
265
sub _handle_one_result {
261
    my ($zoomrec, $servhref, $seq, $bib)= @_;
266
    my ( $zoomrec, $servhref, $seq, $bib, $xslh )= @_;
262
267
263
    my $raw= $zoomrec->raw();
268
    my $raw= $zoomrec->raw();
264
    my $marcrecord;
269
    my $marcrecord;
Lines 269-274 sub _handle_one_result { Link Here
269
        ($marcrecord) = MarcToUTF8Record($raw, C4::Context->preference('marcflavour'), $servhref->{encoding} // "iso-5426" ); #ignores charset return values
274
        ($marcrecord) = MarcToUTF8Record($raw, C4::Context->preference('marcflavour'), $servhref->{encoding} // "iso-5426" ); #ignores charset return values
270
    }
275
    }
271
    SetUTF8Flag($marcrecord);
276
    SetUTF8Flag($marcrecord);
277
    my $error;
278
    ( $marcrecord, $error ) = _do_xslt_proc($marcrecord, $servhref, $xslh);
272
279
273
    my $batch_id = GetZ3950BatchId($servhref->{servername});
280
    my $batch_id = GetZ3950BatchId($servhref->{servername});
274
    my $breedingid = AddBiblioToBatch($batch_id, $seq, $marcrecord, 'UTF-8', 0, 0);
281
    my $breedingid = AddBiblioToBatch($batch_id, $seq, $marcrecord, 'UTF-8', 0, 0);
Lines 279-290 sub _handle_one_result { Link Here
279
286
280
    #call to TransformMarcToKoha replaced by next call
287
    #call to TransformMarcToKoha replaced by next call
281
    #we only need six fields from the marc record
288
    #we only need six fields from the marc record
282
    return _add_rowdata(
289
    my $row;
290
    $row = _add_rowdata(
283
        {
291
        {
284
            biblionumber => $bib,
292
            biblionumber => $bib,
285
            server       => $servhref->{servername},
293
            server       => $servhref->{servername},
286
            breedingid   => $breedingid,
294
            breedingid   => $breedingid,
287
        }, $marcrecord) if $breedingid;
295
        }, $marcrecord) if $breedingid;
296
    return ( $row, $error );
297
}
298
299
sub _do_xslt_proc {
300
    my ( $marc, $server, $xslh ) = @_;
301
    return $marc if !$server->{add_xslt};
302
303
    my $htdocs = C4::Context->config('intrahtdocs');
304
    my $theme = C4::Context->preference("template"); #staff
305
    my $lang = C4::Languages::getlanguage() || 'en';
306
307
    my @files= split ',', $server->{add_xslt};
308
    my $xml = $marc->as_xml;
309
    foreach my $f ( @files ) {
310
        $f =~ s/^\s+//; $f =~ s/\s+$//; next if !$f;
311
        $f = C4::XSLT::_get_best_default_xslt_filename(
312
            $htdocs, $theme, $lang, $f ) unless $f =~ /^\//;
313
        $xml = $xslh->transform( $xml, $f );
314
        last if $xslh->err; #skip other files
315
    }
316
    if( !$xslh->err ) {
317
        return MARC::Record->new_from_xml($xml, 'UTF-8');
318
    } else {
319
        return ( $marc, 'xslt_err' ); #original record in case of errors
320
    }
288
}
321
}
289
322
290
sub _add_rowdata {
323
sub _add_rowdata {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt (-15 / +16 lines)
Lines 161-166 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
161
        [% IF ( stdid ) %]<em>Standard ID: </em><span class=term>[% stdid %]</span> [% END %]
161
        [% IF ( stdid ) %]<em>Standard ID: </em><span class=term>[% stdid %]</span> [% END %]
162
    </p>
162
    </p>
163
163
164
    [% IF ( errconn ) %]
165
            <div class="dialog alert">
166
                <ul>
167
                [% FOREACH errcon IN errconn %]
168
                    [% IF ( errcon.error == '10000' ) %]<li>Connection failed to [% errcon.server %]</li>
169
                    [% ELSIF ( errcon.error == '10007' ) %]<li>Connection timeout to [% errcon.server %]</li>
170
                    [% ELSIF ( errcon.error == 'xslt_err' ) %]<li>[% errcon.server %]: Warning: XSLT error on search result [% errcon.seq %]</li>
171
                    [% ELSE %]<li>[% errcon.server %] record [% errcon.seq %]: [% errcon.error %]</li>
172
                    [% END %]
173
                [% END %]
174
                </ul>
175
            </div>
176
    [% END %]
177
164
    [% IF ( breeding_loop ) %]
178
    [% IF ( breeding_loop ) %]
165
    <table id="resultst">
179
    <table id="resultst">
166
<thead>    <tr>
180
<thead>    <tr>
Lines 223-244 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
223
        <br />Go to page : <input id="goto_page" name="goto_page" value="[% current_page %]" size="4" /><input type="submit" name="changepage_goto" onclick="return validate_goto_page();" value="Go" />
237
        <br />Go to page : <input id="goto_page" name="goto_page" value="[% current_page %]" size="4" /><input type="submit" name="changepage_goto" onclick="return validate_goto_page();" value="Go" />
224
    </form>
238
    </form>
225
239
226
<p><form method="get" action="/cgi-bin/koha/cataloguing/z3950_search.pl"><input type="hidden" name="biblionumber" value="[% biblionumber %]"/><input type="hidden" name="frameworkcode" value="[% frameworkcode %]"/><input type="submit" value="Try Another Search"/></form></p>
227
    [% ELSE %]
240
    [% ELSE %]
228
        [% IF ( errconn ) %]
241
        <div class="dialog message">Nothing found.</div>
229
            <div class="dialog alert">
230
                <ul>
231
                [% FOREACH errcon IN errconn %]
232
                    [% IF ( errcon.error == '10000' ) %]<li>Connection failed to [% errcon.server %]</li>
233
                    [% ELSIF ( errcon.error == '10007' ) %]<li>Connection timeout to [% errcon.server %]</li>[% END %]
234
                [% END %]
235
                </ul>
236
            </div>
237
         [% END %]
238
    <div class="dialog message"><h3>Nothing found</h3>
239
    <p><form method="get" action="/cgi-bin/koha/cataloguing/z3950_search.pl"><input type="hidden" name="biblionumber" value="[% biblionumber %]"/><input type="hidden" name="frameworkcode" value="[% frameworkcode %]"/><input type="submit" value="Try Another Search"/></form></p>
240
    [% END %]
242
    [% END %]
241
243
<p><form method="get" action="/cgi-bin/koha/cataloguing/z3950_search.pl"><input type="hidden" name="biblionumber" value="[% biblionumber %]"/><input type="hidden" name="frameworkcode" value="[% frameworkcode %]"/><input type="submit" value="Try Another Search"/></form></p>
242
244
243
[% END %]
245
[% END %]
244
246
245
- 

Return to bug 6536