~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/lib/Foswiki/Form/Textarea.pm

  • Committer: James Michael DuPont
  • Date: 2009-07-18 19:58:49 UTC
  • Revision ID: jamesmikedupont@gmail.com-20090718195849-vgbmaht2ys791uo2
added foswiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See bottom of file for license and copyright details
 
2
package Foswiki::Form::Textarea;
 
3
use base 'Foswiki::Form::FieldDefinition';
 
4
 
 
5
use strict;
 
6
 
 
7
sub new {
 
8
    my $class = shift;
 
9
    my $this  = $class->SUPER::new(@_);
 
10
    if ( $this->{size} =~ /^\s*(\d+)x(\d+)\s*$/ ) {
 
11
        $this->{cols} = $1;
 
12
        $this->{rows} = $2;
 
13
    }
 
14
    else {
 
15
        $this->{cols} = 50;
 
16
        $this->{rows} = 4;
 
17
    }
 
18
    return $this;
 
19
}
 
20
 
 
21
=begin TML
 
22
 
 
23
---++ ObjectMethod finish()
 
24
Break circular references.
 
25
 
 
26
=cut
 
27
 
 
28
# Note to developers; please undef *all* fields in the object explicitly,
 
29
# whether they are references or not. That way this method is "golden
 
30
# documentation" of the live fields in the object.
 
31
sub finish {
 
32
    my $this = shift;
 
33
    $this->SUPER::finish();
 
34
    undef $this->{cols};
 
35
    undef $this->{rows};
 
36
}
 
37
 
 
38
sub renderForEdit {
 
39
    my ( $this, $web, $topic, $value ) = @_;
 
40
 
 
41
    return (
 
42
        '',
 
43
        CGI::textarea(
 
44
            -class => $this->cssClasses(
 
45
                'foswikiTextarea'
 
46
            ),
 
47
            -cols    => $this->{cols},
 
48
            -rows    => $this->{rows},
 
49
            -name    => $this->{name},
 
50
            -default => "\n" . $value
 
51
        )
 
52
    );
 
53
}
 
54
 
 
55
1;
 
56
__DATA__
 
57
 
 
58
Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/
 
59
 
 
60
# Copyright (C) 2008-2009 Foswiki Contributors. All Rights Reserved.
 
61
# Foswiki Contributors are listed in the AUTHORS file in the root
 
62
# of this distribution. NOTE: Please extend that file, not this notice.
 
63
#
 
64
# Additional copyrights apply to some or all of the code in this
 
65
# file as follows:
 
66
#
 
67
# Copyright (C) 2001-2007 TWiki Contributors. All Rights Reserved.
 
68
# TWiki Contributors are listed in the AUTHORS file in the root
 
69
# of this distribution. NOTE: Please extend that file, not this notice.
 
70
#
 
71
This program is free software; you can redistribute it and/or
 
72
modify it under the terms of the GNU General Public License
 
73
as published by the Free Software Foundation; either version 2
 
74
of the License, or (at your option) any later version. For
 
75
more details read LICENSE in the root of this distribution.
 
76
 
 
77
This program is distributed in the hope that it will be useful,
 
78
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
79
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
80
 
 
81
As per the GPL, removal of this notice is prohibited.
 
82