1 package LJ
::Setting
::TextSetting
;
2 use base
'LJ::Setting';
7 # if override to something non-undef, current_value and save_text work
9 sub prop_name
{ undef }
13 if (my $propname = $class->prop_name) {
14 return $u->prop($propname);
20 my ($class, $args) = @_;
21 return LJ
::Setting
::get_arg
($class, $args, "txt");
24 # zero means no limit.
31 sub question
{ croak
; }
34 my ($class, $u, $errs, $post) = @_;
35 my $key = $class->pkgkey;
36 return "<label for=''>" . $class->question . "</label>" .
41 value
=> $errs ?
$class->get_arg($post, "txt") : $class->current_value($u),
42 size
=> $class->text_size,
43 maxlength
=> $class->max_chars || undef,
45 $class->errdiv($errs, "txt");
48 # each subclass can override if necessary
52 my ($class, $u, $args) = @_;
53 $class->error_check($u, $args);
55 my $txt = $args->{txt
} || "";
56 return 1 if $txt eq $class->current_value($u);
57 unless (LJ
::text_in
($txt)) {
58 $class->errors(txt
=> "Invalid UTF-8");
60 if ($class->max_bytes || $class->max_chars) {
61 my $trimmed = LJ
::text_trim
($txt, $class->max_bytes, $class->max_chars);
62 $class->errors(txt
=> "Too long") if $trimmed ne $txt;
64 return $class->save_text($u, $txt);
68 my ($class, $u, $txt) = @_;
69 if (my $propname = $class->prop_name) {
70 return $u->set_prop($propname, $txt);