964B; Perl | 2018-11-27 17:29:09+01 | Statements 29 | SLOC 33
1
package Ged2site::Display::twins;
2 2
;
3
4
# Display the list of twins
5
6
use warnings;
7
use strict;
8
use Ged2site::Display;
9
10
our @ISA = ('Ged2site::Display');
11
12
sub html {
13
	my $self = shift;
14
	my %args = (ref($_[0]) eq 'HASH') ? %{$_[0]} : @_;
15
16
	my $info = $self->{_info};
17
	my $allowed = {
18
		'page' => 'twins',
19
		'lang' => qr/^[A-Z][A-Z]/i,
20
		'lint_content' => qr/^\d$/,
21
	};
22
	my %params = %{$info->params({ allow => $allowed })};
23
	return "" if(delete($params{'page'}) ne 'twins');
24
25
	my $people = $args{'people'};
26
	my @all_twins = $args{'twins'}->selectall_hash();
27
	my @twins;
28
	my %done;	# Avoid printing the twins twice
29
	foreach my $twin(@all_twins) {
30
		next if($done{$twin->{'twin'}});
31
32
		push @twins, {
33
			left => $people->fetchrow_hashref(entry => $twin->{'entry'}),
34
			right => $people->fetchrow_hashref(entry => $twin->{'twin'}),
35
		};
36
		$done{$twin->{'entry'}} = $twin->{'twin'};
37
	}
38
	return $self->SUPER::html({ twins => \@twins, updated => $people->updated() });
39
}
40
41
1;