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

(-)a/C4/Biblio.pm (-7 / +19 lines)
Lines 674-708 sub _check_valid_auth_link { Link Here
674
674
675
=head2 GetRecordValue
675
=head2 GetRecordValue
676
676
677
  my $values = GetRecordValue($field, $record, $frameworkcode);
677
  my $values = GetRecordValue($field, $record, $frameworkcode, $as_string);
678
678
679
Get MARC fields from a keyword defined in fieldmapping table.
679
Get MARC fields from a keyword defined in fieldmapping table.
680
680
681
=cut
681
=cut
682
682
683
sub GetRecordValue {
683
sub GetRecordValue {
684
    my ( $field, $record, $frameworkcode ) = @_;
684
    my ( $field, $record, $frameworkcode, $as_string ) = @_;
685
    my $dbh = C4::Context->dbh;
685
    my $dbh = C4::Context->dbh;
686
686
687
    my $sth = $dbh->prepare('SELECT fieldcode, subfieldcode FROM fieldmapping WHERE frameworkcode = ? AND field = ?');
687
    my $sth = $dbh->prepare('SELECT fieldcode, subfieldcode FROM fieldmapping WHERE frameworkcode = ? AND field = ?');
688
    $sth->execute( $frameworkcode, $field );
688
    $sth->execute( $frameworkcode, $field );
689
689
690
    my @result = ();
690
    my @result = ();
691
    my $result_string = '';
691
692
692
    while ( my $row = $sth->fetchrow_hashref ) {
693
    while ( my $row = $sth->fetchrow_hashref ) {
693
        foreach my $field ( $record->field( $row->{fieldcode} ) ) {
694
        foreach my $field ( $record->field( $row->{fieldcode} ) ) {
694
            if ( ( $row->{subfieldcode} ne "" && $field->subfield( $row->{subfieldcode} ) ) ) {
695
            if ( ( $row->{subfieldcode} ne "" && $field->subfield( $row->{subfieldcode} ) ) ) {
695
                foreach my $subfield ( $field->subfield( $row->{subfieldcode} ) ) {
696
                foreach my $subfield ( $field->subfield( $row->{subfieldcode} ) ) {
696
                    push @result, { 'subfield' => $subfield };
697
                    if ($as_string) {
698
                        $result_string .= $subfield . ' ';
699
                    } else {
700
                        push @result, { 'subfield' => $subfield };
701
                    }
697
                }
702
                }
698
703
699
            } elsif ( $row->{subfieldcode} eq "" ) {
704
            } elsif ( $row->{subfieldcode} eq "" ) {
700
                push @result, { 'subfield' => $field->as_string() };
705
                if ($as_string) {
706
                    $result_string = $field->as_string();
707
                } else {
708
                    push @result, { 'subfield' => $field->as_string() };
709
                }
701
            }
710
            }
702
        }
711
        }
703
    }
712
    }
704
713
    if ($as_string) {
705
    return \@result;
714
        $result_string =~ s/\s+$//;;
715
        return $result_string;
716
    } else {
717
        return \@result;
718
    }
706
}
719
}
707
720
708
=head2 SetFieldMapping
721
=head2 SetFieldMapping
709
- 

Return to bug 9703