&GetBiblioItemInfosOf
&GetBiblioItemByBiblioNumber
&GetBiblioFromItemNumber
+ &GetBiblioSummary
&GetRecordValue
&GetFieldMapping
=cut
sub GetISBDView {
- my $biblionumber = shift;
+ my ($biblionumber, $template) = @_;
my $record = GetMarcBiblio($biblionumber);
my $itemtype = &GetFrameworkCode($biblionumber);
my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbranch",$itemtype);
my $tagslib = &GetMarcStructure( 1, $itemtype );
my $ISBD = C4::Context->preference('ISBD');
+ if($template eq "opac"){
+ $ISBD = C4::Context->preference('OPACISBD');
+ }
+
my $bloc = $ISBD;
my $res;
my $blocres;
my $tagsubf = $tag . $subfvalue;
$calculated =~
s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
- $calculated =~s#/cgi-bin/koha/[^/]+/([^.]*.pl\?.*)$#opac-$1#g;
# field builded, store the result
if ( $calculated && !$hasputtextbefore )
else {
my @subf = $field->subfields;
for my $i ( 0 .. $#subf ) {
- my $valuecode = $subf[$i][1];
- my $subfieldcode = $subf[$i][0];
- my $subfieldvalue =
- GetAuthorisedValueDesc( $tag, $subf[$i][0],
- $subf[$i][1], '', $tagslib );
- my $tagsubf = $tag . $subfieldcode;
-
- $calculated =~ s/ # replace all {{}} codes by the value code.
- \{\{$tagsubf\}\} # catch the {{actualcode}}
- /
- $valuecode # replace by the value code
- /gx;
-
- $calculated =~
- s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
- $calculated =~s#/cgi-bin/koha/[^/]+/([^.]*.pl\?.*)$#opac-$1#g;
+ my $valuecode = $subf[$i][1];
+ my $subfieldcode = $subf[$i][0];
+ my $subfieldvalue =
+ GetAuthorisedValueDesc( $tag, $subf[$i][0],
+ $subf[$i][1], '', $tagslib );
+ my $tagsubf = $tag . $subfieldcode;
+
+ $calculated =~ s/\{\{$tagsubf\}\}/$valuecode/gx;
+ $calculated =~
+ s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g;
}
# field builded, store the result
$genre = ($mtx eq 'dc') ? "&rft.type=$genre" : "&rft.genre=$genre";
# Setting datas
- $aulast = $record->subfield('700','a');
- $aufirst = $record->subfield('700','b');
+ $aulast = $record->subfield('700','a') || '';
+ $aufirst = $record->subfield('700','b') || '';
$oauthors = "&rft.au=$aufirst $aulast";
# others authors
if($record->field('200')){
}
$title = ( $mtx eq 'dc' ) ? "&rft.title=".$record->subfield('200','a') :
"&rft.title=".$record->subfield('200','a')."&rft.btitle=".$record->subfield('200','a');
- $pubyear = $record->subfield('210','d');
- $publisher = $record->subfield('210','c');
- $isbn = $record->subfield('010','a');
- $issn = $record->subfield('011','a');
+ $pubyear = $record->subfield('210','d') || '';
+ $publisher = $record->subfield('210','c') || '';
+ $isbn = $record->subfield('010','a') || '';
+ $issn = $record->subfield('011','a') || '';
}else{
# MARC21 need some improve
my $fmts;
return $coins_value;
}
+=head2 GetBiblioSummary
+
+=over 4
+
+$summary = GetBiblioSummary($marcrecord);
+
+Return the summary of a record.
+
+=back
+
+=cut
+
+sub GetBiblioSummary {
+ my $recorddata =shift @_;
+
+ my $marcflavour = C4::Context->preference("marcflavour");
+ my $marc=MARC::Record::new_from_xml($recorddata,"utf-8",$marcflavour);
+
+ my $str;
+
+ if($marcflavour eq "MARC21"){
+ $str="<b>".$marc->subfield('245',"a")."</b>" if $marc->subfield('245','a');
+ $str.= " <i>".$marc->subfield('245',"b")."</i> " if $marc->subfield('245','b');
+
+ if ($marc->field('245')){
+ $str.=" / ";
+ foreach ($marc->field('100')->subfield("a")) {
+ $str.=$_." ; ";
+ }
+ $str=~s/ ; $/. /;
+ }
+
+ if ($marc->field('260')){
+ $str.=" - ";
+ $str.=$marc->subfield('260',"a")." " if $marc->subfield('260','a');
+ $str.=" : ".$marc->subfield('260',"b")." " if $marc->subfield('260','b');
+ $str.=", ".$marc->subfield('260',"c")." " if $marc->subfield('260','c');
+ }
+ if ($marc->field('300')){
+ $str.=" - ";
+ $str.=$marc->subfield('300','a') if ($marc->subfield(300,'a'));
+ $str.=" ; ".$marc->subfield('300','b') if $marc->subfield('300','b');
+ $str.=" ; ".$marc->subfield('300','c') if $marc->subfield('300','c');
+ $str.=" ; ".$marc->subfield('300','e') if $marc->subfield('300','e');
+ }
+ foreach ($marc->field('500')){
+ $str.= " - ";
+ foreach ($_->subfield("a")){
+ $str.=$_."; "
+ }
+ }
+ my $itemtypes=GetItemTypes();
+ $str.=" - <u>".$itemtypes->{$marc->subfield('942','c')}->{'description'}."</u> ";
+ $str.="<br />\n";
+
+ }else{
+ $str = "<b>".$marc->subfield('200','a')."</b>" if $marc->subfield('200','a');
+ $str.= " <i>".$marc->subfield('200','e')."</i> " if $marc->subfield('200','e');
+ if ($marc->field('200')){
+ $str.=" / ";
+ foreach ($marc->field('200')->subfield("f")) {
+ $str.=$_." ; ";
+ }
+ $str=~s/ ; $/. /;
+ }
+
+ if ($marc->subfield('200','g')){
+ $str.=" ; ";
+ foreach ($marc->field('200')->subfield("g")){
+ $str.=$_." ; ";
+ }
+ $str=~s/ ; $/. /;
+ }
+
+ if ($marc->field('461')){
+ $str.="- In :";
+ $str.= $marc->subfield('461','t') if $marc->subfield('461','t');
+ $str.=", ".$marc->subfield('461','d') if $marc->subfield('461','d');
+ $str.=", ".$marc->subfield('461','v') if $marc->subfield('461','v');
+ $str.=", ".$marc->subfield('461','h') if $marc->subfield('461','h');
+ $str.=" ; ".$marc->subfield('461','x') if $marc->subfield('461','x');
+ }
+
+ if ($marc->field('210')){
+ $str.=" - ";
+ $str.=$marc->subfield('210',"a")." " if $marc->subfield('210','a');
+ $str.=" : ".$marc->subfield('210',"c")." " if $marc->subfield('210','c');
+ $str.=", ".$marc->subfield('210',"d")." " if $marc->subfield('210','d');
+ }
+
+ if ($marc->field('215')){
+ $str.=" - ";
+ $str.=$marc->subfield('215','a') if ($marc->subfield(215,'a'));
+ $str.=" ; ".$marc->subfield('215','d') if $marc->subfield('215','d');
+ $str.=" ; ".$marc->subfield('215','c') if $marc->subfield('215','c');
+ $str.=" ; ".$marc->subfield('215','e') if $marc->subfield('215','e');
+ }
+ foreach ($marc->field('300')){
+ $str.=" - ";
+ foreach ($_->subfield("a")){
+ $str.=$_."; "
+ }
+ }
+
+ my $itemtypes=GetItemTypes;
+ if($itemtypes->{$marc->subfield('200','b')}){
+ $str.=" - <u>".$itemtypes->{$marc->subfield('200','b')}->{'description'}."</u> ";
+ }
+ $str.="<br />\n";
+ }
+ return $str;
+}
+
=head2 GetAuthorisedValueDesc
=over 4
# }
if ( ( @$tags[$i] ne $prevtag ) ) {
$j++ unless ( @$tags[$i] eq "" );
+ my $indicator1=eval{substr( @$indicator[$j], 0, 1 )};
+ my $indicator2=eval{substr( @$indicator[$j], 1, 1 )};
+ my $ind1 = _default_ind_to_space($indicator1);
+ my $ind2;
+ if ( @$indicator[$j] ) {
+ $ind2 = _default_ind_to_space($indicator2);
+ }
+ else {
+ warn "Indicator in @$tags[$i] is empty";
+ $ind2 = " ";
+ }
if ( !$first ) {
$xml .= "</datafield>\n";
if ( ( @$tags[$i] && @$tags[$i] > 10 )
&& ( @$values[$i] ne "" ) )
{
- my $ind1 = substr( @$indicator[$j], 0, 1 );
- my $ind2;
- if ( @$indicator[$j] ) {
- $ind2 = substr( @$indicator[$j], 1, 1 );
- }
- else {
- warn "Indicator in @$tags[$i] is empty";
- $ind2 = " ";
- }
$xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
$xml .= "<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
$first = 0;
$first = 1;
}
else {
- my $ind1 = default_ind_to_space( substr( @$indicator[$j], 0, 1 ) );
- my $ind2 = default_ind_to_space( substr( @$indicator[$j], 1, 1 ) );
$xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
$xml .= "<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
$first = 0;
}
}
else { # @$tags[$i] eq $prevtag
- if ( @$values[$i] eq "" ) {
+ my $indicator1=eval{substr( @$indicator[$j], 0, 1 )};
+ my $indicator2=eval{substr( @$indicator[$j], 1, 1 )};
+ my $ind1 = _default_ind_to_space($indicator1);
+ my $ind2;
+ if ( @$indicator[$j] ) {
+ $ind2 = _default_ind_to_space($indicator2);
+ }
+ else {
+ warn "Indicator in @$tags[$i] is empty";
+ $ind2 = " ";
+ }
+ if ( @$values[$i] eq "" ) {
}
else {
if ($first) {
- my $ind1 = default_ind_to_space( substr( @$indicator[$j], 0, 1 ) );
- my $ind2 = default_ind_to_space( substr( @$indicator[$j], 1, 1 ) );
$xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
$first = 0;
}
return $xml;
}
-=head2 default_ind_to_space
+=head2 _default_ind_to_space
Passed what should be an indicator returns a space
if its undefined or zero length
=cut
-sub default_ind_to_space {
+sub _default_ind_to_space {
my $s = shift;
- if (!defined $s || $s eq q{} ) {
+ if (!defined $s || $s eq q{}) {
return ' ';
}
return $s;
elsif ($param =~ /^tag_(\d*)_indicator1_/){ # new field start when having 'input name="..._indicator1_..."
my $tag = $1;
- my $ind1 = substr($cgi->param($param),0,1);
- my $ind2 = substr($cgi->param($params->[$i+1]),0,1);
+ my $ind1 = _default_ind_to_space(substr($cgi->param($param), 0, 1));
+ my $ind2 = _default_ind_to_space(substr($cgi->param($params->[$i+1]), 0, 1));
$newfield=0;
my $j=$i+2;
if ( $cgi->param($params->[$j+1]) ne '' ) { # creating only if there is a value (code => value)
$newfield = MARC::Field->new(
$tag,
- ''.$ind1,
- ''.$ind2,
+ $ind1,
+ $ind2,
$cgi->param($inner_param) => $cgi->param($params->[$j+1]),
);
}
my ( $bibnum, $itemnum, $defaultvalues ) = @_;
my $dbh = C4::Context->dbh;
+ my $today_iso = C4::Dates->today('iso');
my $frameworkcode = &GetFrameworkCode( $bibnum );
my ( $itemtagfield, $itemtagsubfield ) =
&GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
my $tagslib = &GetMarcStructure( 1, $frameworkcode );
my $itemrecord = C4::Items::GetMarcItem( $bibnum, $itemnum) if ($itemnum);
+ # FIXME : I'd rather have GetMarcBiblio called out of this.
+ # Since it gets the whole Biblio record for each item
+ my $marcrecord = GetMarcBiblio( $bibnum) if ($bibnum);
my @loop_data;
my $authorised_values_sth =
$dbh->prepare(
if ($itemrecord) {
( $x, $value ) = _find_value( $tag, $subfield, $itemrecord );
}
- if (!defined $value) {
- $value = q||;
- }
+ unless ($value) {
+ $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
+ $value ||= $defaultvalues->{$tagslib->{$tag}->{$subfield}->{'kohafield'}};
+ # get today date & replace YYYY, MM, DD if provided in the default value
+ my ( $year, $month, $day ) = split ',', $today_iso; # FIXME: iso dates don't have commas!
+ $value =~ s/YYYY/$year/g;
+ $value =~ s/MM/$month/g;
+ $value =~ s/DD/$day/g;
+ }
$value =~ s/"/"/g;
# search for itemcallnumber if applicable
substr( C4::Context->preference('itemcallnumber'), 0, 3 );
my $CNsubfield =
substr( C4::Context->preference('itemcallnumber'), 3, 1 );
- my $temp = $itemrecord->field($CNtag) if ($itemrecord);
+ my $temp = $marcrecord->field($CNtag) if ($marcrecord);
if ($temp) {
$value = $temp->subfield($CNsubfield);
}