Thread Board-rewrite: allgemeine Ideen
(44 answers)
Opened by jan10001 at 2003-08-25 00:08
und schöner geht es vielleicht auch so
Code (perl): (dl
)
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 #! /usr/bin/perl use warnings; use strict; my %Actions = ( boardconf => { subs => [ \&handler_boardconf, ], }, otherconf => { subs => [ \&handler_otherconf, ], }, ); sub handler_boardconf { my ($r) = @_; my $action = lc($r->param('action')); handler_handler($r, $action, \%BoardConf::Actions, 'start'); } sub handler_otherconf { my ($r) = @_; my $action = lc($r->param('other')); handler_handler($r, $action, \%OtherConf::Actions, 'begin'); } sub handler_handler { my ($r, $action, $ref, $def) = @_; unless(exists $ref->{$action}->{subs}) { $action = $def; } foreach my $sub (@{$ref->{$action}->{subs}}) { unless ($sub->($cgi)) { # error in sub last; # errorhandling } else { # ok } } } sub handler { my $r = Apache::Request->new(shift); $r->send_http_header('text/html'); my $section = lc($r->param('section')); handler_handler($r, $section, \%Actions, 'boardconf'); } <!--EDIT|esskar|1061869240--> |