871B; Perl | 2019-09-06 00:49:03+02 | Statements 24 | SLOC 31
1
package Ged2site::Display::locations;
2
3
# Display the locations page
4
5
use Ged2site::Display;
6
7 2
our @ISA = ('Ged2site::Display');
8
9
sub html {
10
	my $self = shift;
11
	my %args = (ref($_[0]) eq 'HASH') ? %{$_[0]} : @_;
12
13
	my $info = $self->{_info};
14
	my $allowed = {
15
		'page' => 'locations',
16
		'year' => qr/^\d{4}$/,
17
		'lang' => qr/^[A-Z][A-Z]/i,
18
		'lint_content' => qr/^\d$/,
19
	};
20
	my %params = %{$info->params({ allow => $allowed })};
21
22
	delete $params{'page'};
23
	delete $params{'lint_content'};
24
	delete $params{'lang'};
25
26
	my $db = $args{'locations'};
27
	my @locations = $db->locations();
28
29
	if(scalar(keys %params) == 0) {
30
		# Display list of locations
31
		return $self->SUPER::html({ locations => \@locations, updated => $db->updated() });
32
	}
33
34
	return $self->SUPER::html({
35
		head => $db->head(year => $params{'year'}),
36
		locations => \@locations,
37
		updated => $db->updated()
38
	});
39
}
40
41
1;