Skip to content

Commit

Permalink
Add eprintid on to default eprint report export, fix bug with fields …
Browse files Browse the repository at this point in the history
…from itemref fields not being included in export options, and adjust CSV export to use phrases for headers rather than field IDS.
  • Loading branch information
wfyson committed Dec 11, 2018
1 parent 658f966 commit 997b467
Show file tree
Hide file tree
Showing 6 changed files with 548 additions and 455 deletions.
8 changes: 5 additions & 3 deletions cfg/cfg.d/z_reports.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# EPrints Services - Generic Reporting System
#
# Version: 0.1
# Version: 3.0
#


Expand Down Expand Up @@ -39,6 +39,7 @@
#export field options
$c->{eprint_report}->{exportfields} = {
eprint_report_core => [ qw(
eprintid
title
creators_name
abstract
Expand All @@ -51,11 +52,12 @@
ispublished
refereed
publication
document_format
documents.format
datestamp
)],
};
$c->{eprint_report}->{exportfield_defaults} = [ qw(
eprintid
title
creators_name
abstract
Expand All @@ -68,7 +70,7 @@
ispublished
refereed
publication
document_format
documents.format
datestamp
)];

Expand Down
69 changes: 63 additions & 6 deletions lib/plugins/EPrints/Plugin/Export/Grid2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,50 @@ sub header_row

if ($field->isa("EPrints::MetaField::Multipart"))
{
my $name = $field->name;
push @names, map {
$name . '.' . $_->{sub_name}
} @{$field->property("fields_cache")};
my $parent_name = $field->render_name;
if( $field->isa( "EPrints::MetaField::Name" )) #need to deal with legacy phrase id's
{
foreach my $bit ( $field->get_input_bits() )
{
$bit = "given_names" if( $bit eq "given" );
$bit = "family_names" if( $bit eq "family" );
my $custom_phrase = $field->name . "_" . $bit;
if( $ds->repository->get_lang->has_phrase( $custom_phrase ) ) #allow a custom phrase to be used
{
push @names, $ds->repository->html_phrase( $custom_phrase );
}
else
{
push @names, $parent_name . ": " . $ds->repository->html_phrase( "lib/metafield:".$bit );
}
}
}
else
{
my $name = $field->name;
push @names, map {
$name . '.' . $_->{sub_name}
} @{$field->property("fields_cache")};
}
}
elsif( $field->isa("EPrints::MetaField::Compound" ) )
{
foreach my $sub_field (@{$field->property("fields_cache")})
{
my $custom_phrase = $field->name . "_" . $sub_field->name;
if( $ds->repository->get_lang->has_phrase( $custom_phrase ) ) #allow a custom phrase to be used
{
push @names, $ds->repository->html_phrase( $custom_phrase );
}
else
{
push @names, $field->render_name . ": " . $sub_field->render_name;
}
}
}
else
{
push @names, $field->name;
push @names, $field->render_name;
}
}
}
Expand Down Expand Up @@ -237,7 +273,28 @@ sub value_to_rows
}
elsif ($field->isa("EPrints::MetaField::Multipart"))
{
push @rows, [map { $value->{$_->{sub_name}} } @{$field->property("fields_cache")}];
if( $field->isa( "EPrints::MetaField::Name" )) #need to deal with legacy phrase id's
{
my @bit_values;
foreach my $bit ( $field->get_input_bits() )
{
push @bit_values, $value->{$bit};
}
push @rows, \@bit_values;
}
else
{
push @rows, [map { $value->{$_->{sub_name}} } @{$field->property("fields_cache")}];
}
}
elsif ($field->isa("EPrints::MetaField::Compound"))
{
my @sub_values;
foreach my $key (keys %{$value})
{
push @sub_values, $value->{$key};
}
push @rows, \@sub_values;
}
else
{
Expand Down
9 changes: 5 additions & 4 deletions lib/plugins/EPrints/Plugin/Export/Report/HTML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,14 @@ sub output_dataobj
}
else #render normal value like a normal field
{
my $ds_id = $dataobj->get_dataset_id;
my $ds = $repo->dataset( $ds_id );
my $ds = $dataobj->dataset;
if( $ds->has_field( $f ) )
{
my $field = EPrints::Utils::field_from_config_string( $ds, $f );

$table->appendChild( $repo->render_row(
$repo->html_phrase( $ds_id."_fieldname_".$f ),
$dataobj->render_value( $f )
$field->render_name,
$dataobj->render_value( $f )
) );
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/EPrints/Plugin/Screen/Report.pm
Original file line number Diff line number Diff line change
Expand Up @@ -816,12 +816,12 @@ sub render_export_bar
my $count = 0; #count how many fields we add
foreach my $fieldname( @{$repo->config( $self->{export_conf}, "exportfields" )->{$key}} )
{
if( defined $repo->config( $self->{export_conf}, "customer_export" ) && exists ${$repo->config( $self->{export_conf}, "custom_export" )}{$fieldname} ) #no field in dataset, but we have a custom export function instead
if( defined $repo->config( $self->{export_conf}, "custom_export" ) && exists ${$repo->config( $self->{export_conf}, "custom_export" )}{$fieldname} ) #we have a custom export function instead
{
$count++;
$self->_export_field_checkbox( $repo, $fieldname, $ul, $repo->html_phrase( "exportfieldoptions:$fieldname" ) );
}
elsif( $report_ds->has_field( $fieldname ) )
elsif( defined EPrints::Utils::field_from_config_string( $report_ds, $fieldname ) )
{
my $field = EPrints::Utils::field_from_config_string( $report_ds, $fieldname );
$count++;
Expand Down
Loading

0 comments on commit 997b467

Please sign in to comment.