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

(-)a/C4/Biblio.pm (-4 / +34 lines)
Lines 674-687 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 = ?');
Lines 701-708 sub GetRecordValue { Link Here
701
            }
701
            }
702
        }
702
        }
703
    }
703
    }
704
    
705
    if ($as_string) {
706
        my $string = _array_of_hashes_to_string(\@result, ' ');
707
        return $string;
708
    } else {
709
        return \@result;
710
    }
711
}
704
712
705
    return \@result;
713
=head2 _array_of_hashes_to_string
714
715
  my $string = _array_of_hashes_to_string($array, $glue);
716
  
717
  Transform an array ref of hash refs into a string
718
719
=cut
720
721
sub _array_of_hashes_to_string {
722
    my ( $array, $glue ) = @_;
723
    my $string = '';
724
    
725
    if ($array) {
726
        for my $element (@$array) {
727
            if ($element) {
728
                foreach my $key ( keys %$element ) {
729
                    $string .= $element->{$key} . $glue;
730
                }
731
            }
732
        }
733
    }    
734
    
735
    $string =~ s/\s+$//;
736
    return $string;
706
}
737
}
707
738
708
=head2 SetFieldMapping
739
=head2 SetFieldMapping
709
- 

Return to bug 9703