1 |
3 |
ahitrov@rambler.ru |
require 'subs_local.pl'; |
2 |
|
|
|
3 |
|
|
sub abort404 { |
4 |
|
|
use vars qw($m); |
5 |
|
|
$m->clear_buffer(); |
6 |
|
|
$m->abort(404); |
7 |
|
|
}; |
8 |
|
|
|
9 |
|
|
sub abort403 { |
10 |
|
|
use vars qw($m); |
11 |
|
|
$m->clear_buffer(); |
12 |
|
|
$m->abort(403); |
13 |
|
|
}; |
14 |
|
|
|
15 |
|
|
sub abort503 { |
16 |
|
|
use vars qw($m); |
17 |
|
|
$m->clear_buffer(); |
18 |
|
|
$m->abort(503); |
19 |
|
|
}; |
20 |
|
|
|
21 |
|
|
|
22 |
|
|
sub spacer { |
23 |
|
|
my %opts = @_; |
24 |
|
|
my $w = $opts{w}; |
25 |
|
|
my $h = $opts{h}; |
26 |
|
|
|
27 |
|
|
if (!$w && !$h) { |
28 |
|
|
return '<spacer type="block" width="1" height="1" border="0">'; |
29 |
|
|
} else { |
30 |
|
|
return '<div style="'.($w ? 'width:'.$w.'px;' : '').($h ? 'height:'.$h.'px;' : '').'">'. |
31 |
|
|
'<spacer type="block" width="'.($w ? $w : 1).'" height="'.($h ? $h : 1).'" border="0"></div>'; |
32 |
|
|
} |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
|
36 |
|
|
sub tlontl { |
37 |
|
|
my %opts = @_; |
38 |
|
|
my $link = $opts{link}; |
39 |
|
|
my $param = $opts{param}; |
40 |
|
|
my $object = $opts{object}; |
41 |
|
|
|
42 |
|
|
if ($link eq '') { |
43 |
|
|
return $object; |
44 |
|
|
} elsif($ENV{REQUEST_URI} eq $link || $ENV{REQUEST_URI} eq $link.'index.html') { |
45 |
|
|
return $object; |
46 |
|
|
} else { |
47 |
|
|
return '<a href="'.$link.'"'.($param ? ' '.$param : '' ).'>'.$object.'</a>'; |
48 |
|
|
} |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
sub easy_get { |
52 |
|
|
my %opts=@_; |
53 |
|
|
&abort404() unless ($opts{$id}); |
54 |
|
|
&abort404() unless ($opts{$id}=~/^\d+$/); |
55 |
|
|
if ($opts{type} eq 'document') { |
56 |
|
|
my $doc=$keeper->get_document_by_id($opts{id},class=>$opts{class}); |
57 |
|
|
&abort404() unless ($doc); |
58 |
|
|
return $doc; |
59 |
|
|
} elsif ($opts{type} eq 'section') { |
60 |
|
|
my $doc=$keeper->get_section_by_id($opts{id},class=>$opts{class}); |
61 |
|
|
&abort404() unless ($doc); |
62 |
|
|
return $doc; |
63 |
|
|
} else { |
64 |
|
|
&abort404(); |
65 |
|
|
} |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
1; |