forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDynamicHTML.pm
76 lines (66 loc) · 1.16 KB
/
DynamicHTML.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
package WebminUI::DynamicHTML;
use WebminCore;
=head2 new WebminUI::DynamicHTML(&function, &args, [before])
When the page is being rendered, executes the given function and prints any
text that it returns.
=cut
sub new
{
my ($self, $func, $args, $before) = @_;
$self = { 'func' => $func,
'args' => $args,
'before' => $before };
bless($self);
return $self;
}
=head2 set_before(text)
Sets the text describing what we are waiting for
=cut
sub set_before
{
my ($self, $before) = @_;
$self->{'before'} = $before;
}
sub get_before
{
my ($self) = @_;
return $self->{'before'};
}
sub html
{
my ($self) = @_;
my $rv;
if ($self->get_before()) {
$rv .= $self->get_before()."<p>\n";
}
return $rv;
}
=head2 start()
Called by the page to begin the dynamic output.
=cut
sub start
{
my ($self) = @_;
&{$self->{'func'}}($self, @$args);
}
sub get_wait
{
my ($self) = @_;
return 1;
}
=head2 needs_unbuffered()
Must return 1 if the page needs to be in un-buffered and no-table mode
=cut
sub needs_unbuffered
{
return 1;
}
=head2 set_page(WebminUI::Page)
Called when this dynamic HTML element is added to a page
=cut
sub set_page
{
my ($self, $page) = @_;
$self->{'page'} = $page;
}
1;