| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Kwiki::Pane; |
|
2
|
1
|
|
|
1
|
|
2818
|
use Kwiki::Plugin -Base; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub order { () } |
|
6
|
|
|
|
|
|
|
sub pane_unit { $self->class_id } |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub register { |
|
9
|
|
|
|
|
|
|
my $registry = shift; |
|
10
|
|
|
|
|
|
|
$registry->add(preload => $self->class_id); |
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub html { |
|
14
|
|
|
|
|
|
|
return $self->{html} if defined $self->{html}; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @all = $self->pages->current->all; |
|
17
|
|
|
|
|
|
|
my $pane_info = $self->pane_info; |
|
18
|
|
|
|
|
|
|
my $params_method = $self->class_id . '_params'; |
|
19
|
|
|
|
|
|
|
my @units = grep { |
|
20
|
|
|
|
|
|
|
defined $_ and do { |
|
21
|
|
|
|
|
|
|
my $button = $_; |
|
22
|
|
|
|
|
|
|
$button =~ s///gs; |
|
23
|
|
|
|
|
|
|
$button =~ /\S/; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
} map { |
|
26
|
|
|
|
|
|
|
$self->show($_) |
|
27
|
|
|
|
|
|
|
? $self->template->process( |
|
28
|
|
|
|
|
|
|
$_->{template}, |
|
29
|
|
|
|
|
|
|
@all, |
|
30
|
|
|
|
|
|
|
$_->{params_class} |
|
31
|
|
|
|
|
|
|
? do { |
|
32
|
|
|
|
|
|
|
my $class_id = $_->{params_class}; |
|
33
|
|
|
|
|
|
|
$self->hub->$class_id->$params_method |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
: () |
|
36
|
|
|
|
|
|
|
) |
|
37
|
|
|
|
|
|
|
: undef |
|
38
|
|
|
|
|
|
|
} map { |
|
39
|
|
|
|
|
|
|
$pane_info->{$_}; |
|
40
|
|
|
|
|
|
|
} $self->ordered_unit_ids; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$self->{html} = $self->template->process($self->pane_template, |
|
43
|
|
|
|
|
|
|
units => \ @units, |
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub pane_info { |
|
48
|
|
|
|
|
|
|
my $units = $self->hub->registry->lookup->{$self->pane_unit} |
|
49
|
|
|
|
|
|
|
or return {}; |
|
50
|
|
|
|
|
|
|
my $info; |
|
51
|
|
|
|
|
|
|
for my $unit_id (keys %$units) { |
|
52
|
|
|
|
|
|
|
my $array = $units->{$unit_id}; |
|
53
|
|
|
|
|
|
|
$info->{$unit_id} = {@{$array}[1..$#{$array}]}; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
return $info; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub ordered_unit_ids { |
|
59
|
|
|
|
|
|
|
my $lookup = $self->hub->registry->lookup; |
|
60
|
|
|
|
|
|
|
my @unit_ids = map { |
|
61
|
|
|
|
|
|
|
@{$lookup->{add_order}{$_->{id}}{$self->pane_unit} || []}; |
|
62
|
|
|
|
|
|
|
} @{$lookup->plugins}; |
|
63
|
|
|
|
|
|
|
my @ordered_unit_ids; |
|
64
|
|
|
|
|
|
|
for my $unit_id ($self->order) { |
|
65
|
|
|
|
|
|
|
for (my $i = 0; $i < @unit_ids; $i++) { |
|
66
|
|
|
|
|
|
|
if ($unit_id eq $unit_ids[$i]) { |
|
67
|
|
|
|
|
|
|
push @ordered_unit_ids, splice @unit_ids, $i, 1; |
|
68
|
|
|
|
|
|
|
last; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
(@ordered_unit_ids, @unit_ids); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub show { |
|
76
|
|
|
|
|
|
|
my $unit = shift; |
|
77
|
|
|
|
|
|
|
my $action = $self->hub->action; |
|
78
|
|
|
|
|
|
|
my $show = $unit->{show_for}; |
|
79
|
|
|
|
|
|
|
if (defined $show) { |
|
80
|
|
|
|
|
|
|
for (ref($show) ? (@$show) : ($show)) { |
|
81
|
|
|
|
|
|
|
return 1 if $_ eq $action; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
return 0; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
my $omit = $unit->{omit_for}; |
|
86
|
|
|
|
|
|
|
if (defined $omit) { |
|
87
|
|
|
|
|
|
|
for (ref($omit) ? (@$omit) : ($omit)) { |
|
88
|
|
|
|
|
|
|
return 0 if $_ eq $action; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
return 1; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
my $pref = $unit->{show_if_preference}; |
|
93
|
|
|
|
|
|
|
if (defined $pref) { |
|
94
|
|
|
|
|
|
|
return $self->preferences->$pref->value; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
return 1; |
|
98
|
|
|
|
|
|
|
} |