|
Lines 215-220
sub _should_hide_on_interface {
Link Here
|
| 215 |
return $hide; |
215 |
return $hide; |
| 216 |
} |
216 |
} |
| 217 |
|
217 |
|
|
|
218 |
|
| 219 |
=head2 ShouldHideMARC |
| 220 |
|
| 221 |
Return a hash reference of whether a field, built from |
| 222 |
kohafield and tag, is hidden (1) or not (0) for a given |
| 223 |
interface |
| 224 |
|
| 225 |
my $OpacHideMARC = |
| 226 |
GetOpacHideMARC( { |
| 227 |
frameworkcode => $frameworkcode, |
| 228 |
interface => 'opac', |
| 229 |
} ); |
| 230 |
|
| 231 |
if ($OpacHideMARC->{'stocknumber'}==1) { |
| 232 |
print "Hidden!\n"; |
| 233 |
} |
| 234 |
|
| 235 |
C<$OpacHideMARC> is a ref to a hash which contains a series |
| 236 |
of key value pairs indicating if that field (key) is |
| 237 |
hidden (value == 1) or not (value == 0). |
| 238 |
|
| 239 |
C<$frameworkcode> is the framework code. |
| 240 |
|
| 241 |
C<$interface> is the interface. It defaults to 'opac' if |
| 242 |
nothing is passed. Valid values include 'opac' or 'intranet'. |
| 243 |
|
| 244 |
=cut |
| 245 |
|
| 246 |
sub ShouldHideMARC { |
| 247 |
my ($self,$parms) = @_; |
| 248 |
my $frameworkcode = $parms->{frameworkcode} // ''; |
| 249 |
my $interface = $parms->{interface} // 'opac'; |
| 250 |
my $hide = _should_hide_on_interface(); |
| 251 |
|
| 252 |
my $dbh = C4::Context->dbh; |
| 253 |
my $sth = $dbh->prepare("SELECT kohafield AS field, tagfield AS tag, hidden FROM marc_subfield_structure WHERE kohafield>'' AND frameworkcode=? ORDER BY field, tagfield;"); |
| 254 |
$sth->execute($frameworkcode); |
| 255 |
|
| 256 |
my %shouldhidemarc; |
| 257 |
my $data = $sth->fetchall_hashref( [ qw(field tag) ] ); |
| 258 |
foreach my $fullfield (keys %{$data}) { |
| 259 |
my @tmpsplit = split(/\./,$fullfield); |
| 260 |
my $field = $tmpsplit[-1]; |
| 261 |
foreach my $tag (keys %{$data->{$fullfield}}) { |
| 262 |
my $shouldhide = $hide->{$interface}->{ $data->{$fullfield}->{$tag}->{'hidden'} }; |
| 263 |
if ($shouldhide) { |
| 264 |
$shouldhidemarc{ $field } = 1; |
| 265 |
} |
| 266 |
elsif ( !exists($shouldhidemarc{ $field }) ) { |
| 267 |
$shouldhidemarc{ $field } = 0; |
| 268 |
} |
| 269 |
} |
| 270 |
} |
| 271 |
return \%shouldhidemarc; |
| 272 |
} |
| 273 |
|
| 274 |
|
| 218 |
=head1 DIAGNOSTICS |
275 |
=head1 DIAGNOSTICS |
| 219 |
|
276 |
|
| 220 |
$ prove -v t/RecordProcessor.t |
277 |
$ prove -v t/RecordProcessor.t |
| 221 |
- |
|
|