Revision a12274fd
Von Thomas Heck vor mehr als 11 Jahren hinzugefügt
SL/DB/CustomVariableConfig.pm | ||
---|---|---|
25 | 25 |
return @errors; |
26 | 26 |
} |
27 | 27 |
|
28 |
use constant OPTION_DEFAULTS => |
|
29 |
{ |
|
30 |
MAXLENGTH => 75, |
|
31 |
WIDTH => 30, |
|
32 |
HEIGHT => 5, |
|
33 |
}; |
|
34 |
|
|
35 |
sub processed_options { |
|
36 |
my ($self) = @_; |
|
37 |
|
|
38 |
if( exists($self->{processed_options_cache}) ) { |
|
39 |
return $self->{processed_options_cache}; |
|
40 |
} |
|
41 |
|
|
42 |
my $ops = $self->options; |
|
43 |
my $ret; |
|
44 |
|
|
45 |
if ( $self->type eq 'select' ) { |
|
46 |
my @op_array = split('##', $ops); |
|
47 |
$ret = \@op_array; |
|
48 |
} |
|
49 |
else { |
|
50 |
$ret = {%{$self->OPTION_DEFAULTS}}; |
|
51 |
while ( $ops =~ /\s*([^=\s]+)\s*=\s*([^\s]*)(?:\s*|$)/g ) { |
|
52 |
$ret->{$1} = $2; |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
56 |
$self->{processed_options_cache} = $ret; |
|
57 |
|
|
58 |
return $ret; |
|
59 |
} |
|
60 |
|
|
61 |
sub processed_flags { |
|
62 |
my ($self) = @_; |
|
63 |
|
|
64 |
if( exists($self->{processed_flags_cache}) ) { |
|
65 |
return $self->{processed_flags_cache}; |
|
66 |
} |
|
67 |
|
|
68 |
my $flags = $self->flags; |
|
69 |
my $ret; |
|
70 |
|
|
71 |
foreach my $flag (split m/:/, $flags) { |
|
72 |
if ( $flag =~ m/(.*?)=(.*)/ ) { |
|
73 |
$ret->{$1} = $2; |
|
74 |
} else { |
|
75 |
$ret->{$flag} = 1; |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
$self->{processed_flags_cache} = $ret; |
|
80 |
|
|
81 |
return $ret; |
|
82 |
} |
|
83 |
|
|
84 |
sub has_flag { |
|
85 |
my ($self, $flag) = @_; |
|
86 |
|
|
87 |
return $self->processed_flags()->{$flag}; |
|
88 |
} |
|
89 |
|
|
28 | 90 |
1; |
Auch abrufbar als: Unified diff
CVar-Accessor für Optionen und Flags