/
DataSets.pm
143 lines (102 loc) · 3.08 KB
/
DataSets.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
=head1 NAME
EPrints::Plugin::Screen::DataSets
=cut
package EPrints::Plugin::Screen::DataSets;
use EPrints::Plugin::Screen;
@ISA = qw( EPrints::Plugin::Screen );
sub new
{
my( $class, %params ) = @_;
my $self = $class->SUPER::new(%params);
$self->{appears} = [
{
place => "key_tools",
position => 150,
}
];
$self->{actions} = [qw/ /];
return $self;
}
sub can_be_viewed
{
my( $self ) = @_;
return $self->allow( "datasets" );
}
sub render
{
my( $self ) = @_;
my $repo = $self->{session};
my $xml = $repo->xml;
my $user = $repo->current_user;
my $imagesurl = $repo->config( "rel_path" )."/style/images";
my @datasets = $self->datasets;
my $html = $xml->create_document_fragment;
if( $repo->get_lang->has_phrase( $self->html_phrase_id( "intro" ), $repo ) )
{
my $intro_div_outer = $xml->create_element( "div", class => "ep_toolbox" );
my $intro_div = $xml->create_element( "div", class => "ep_toolbox_content" );
$intro_div->appendChild( $self->html_phrase( "intro" ) );
$intro_div_outer->appendChild( $intro_div );
$html->appendChild( $intro_div_outer );
}
my $table = $xml->create_element( "table", id => "ep_datasets_table" );
$html->appendChild( $table );
foreach my $dataset (@datasets)
{
my $link = $xml->create_element( "a", href => $self->listing( $dataset ) );
$link->appendChild( $dataset->render_name( $repo ) );
$table->appendChild( $repo->render_row(
$link,
$repo->html_phrase( "datasethelp_".$dataset->id ) ) );
}
return $html;
}
sub datasets
{
my( $self ) = @_;
return @{$self->{processor}->{datasets}}
if defined $self->{processor}->{datasets};
my @datasets;
foreach my $datasetid ($self->{session}->get_dataset_ids)
{
my $dataset = $self->{session}->dataset( $datasetid );
push @datasets, $dataset
if
$self->allow( $dataset->id . "/view" ) ||
$self->allow( $dataset->id . "/view:owner" ) ||
$self->allow( $dataset->id . "/view:editor" );
}
@datasets = sort { $a->base_id cmp $b->base_id || $a->id cmp $b->id } @datasets;
$self->{processor}->{datasets} = \@datasets;
return @datasets;
}
sub listing
{
my( $self, $dataset ) = @_;
my $url = URI->new( $self->{session}->current_url() );
$url->query_form(
screen => "Listing",
dataset => $dataset->base_id
);
return $url;
}
1;
=head1 COPYRIGHT
=for COPYRIGHT BEGIN
Copyright 2022 University of Southampton.
EPrints 3.4 is supplied by EPrints Services.
http://www.eprints.org/eprints-3.4/
=for COPYRIGHT END
=for LICENSE BEGIN
This file is part of EPrints 3.4 L<http://www.eprints.org/>.
EPrints 3.4 and this file are released under the terms of the
GNU Lesser General Public License version 3 as published by
the Free Software Foundation unless otherwise stated.
EPrints 3.4 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with EPrints 3.4.
If not, see L<http://www.gnu.org/licenses/>.
=for LICENSE END