| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Kwiki::HomePagePreference; |
|
2
|
1
|
|
|
1
|
|
23882
|
use Kwiki::Plugin -Base; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
const class_id => 'home_page_preference'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub register { |
|
8
|
|
|
|
|
|
|
my $register = shift; |
|
9
|
|
|
|
|
|
|
$register->add(preference => $self->home_page_preference); |
|
10
|
|
|
|
|
|
|
$register->add(hook => 'hub:process', |
|
11
|
|
|
|
|
|
|
pre => 'process_hook', |
|
12
|
|
|
|
|
|
|
); |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub process_hook { |
|
16
|
|
|
|
|
|
|
require CGI; |
|
17
|
|
|
|
|
|
|
my $hook = pop; |
|
18
|
|
|
|
|
|
|
$self = $self->hub->home_page_preference; |
|
19
|
|
|
|
|
|
|
if (not length $ENV{QUERY_STRING} and CGI->request_method eq 'GET') { |
|
20
|
|
|
|
|
|
|
my $redirect = $self->preferences->home_page_preference->value; |
|
21
|
|
|
|
|
|
|
if (length $redirect) { |
|
22
|
|
|
|
|
|
|
$hook->cancel; |
|
23
|
|
|
|
|
|
|
return $self->redirect($redirect); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub home_page_preference { |
|
29
|
|
|
|
|
|
|
my $p = $self->new_preference('home_page_preference'); |
|
30
|
|
|
|
|
|
|
$p->query('Choose a custom home page?'); |
|
31
|
|
|
|
|
|
|
$p->type('input'); |
|
32
|
|
|
|
|
|
|
$p->size(15); |
|
33
|
|
|
|
|
|
|
$p->edit('check_home_page'); |
|
34
|
|
|
|
|
|
|
$p->default(''); |
|
35
|
|
|
|
|
|
|
return $p; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub check_home_page { |
|
39
|
|
|
|
|
|
|
my $preference = shift; |
|
40
|
|
|
|
|
|
|
my $value = $preference->new_value; |
|
41
|
|
|
|
|
|
|
$self->utf8_decode($value); |
|
42
|
|
|
|
|
|
|
return unless length $value; |
|
43
|
|
|
|
|
|
|
return $preference->error('Value must not contain spaces') |
|
44
|
|
|
|
|
|
|
if $value =~ /\s/; |
|
45
|
|
|
|
|
|
|
$self->users->current(undef); |
|
46
|
|
|
|
|
|
|
return 1; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__DATA__ |