lib/TWiki/Form/Textarea.pm
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
permissions -rw-r--r--
RELEASE 4.2.0 freetown
     1 # See bottom of file for license and copyright details
     2 package TWiki::Form::Textarea;
     3 use base 'TWiki::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     } else {
    14         $this->{cols} = 50;
    15         $this->{rows} = 4;
    16     }
    17     return $this;
    18 }
    19 
    20 =begin twiki
    21 
    22 ---++ ObjectMethod finish()
    23 Break circular references.
    24 
    25 =cut
    26 
    27 # Note to developers; please undef *all* fields in the object explicitly,
    28 # whether they are references or not. That way this method is "golden
    29 # documentation" of the live fields in the object.
    30 sub finish {
    31     my $this = shift;
    32     $this->SUPER::finish();
    33     undef $this->{cols};
    34     undef $this->{rows};
    35 }
    36 
    37 sub renderForEdit {
    38     my( $this, $web, $topic, $value ) = @_;
    39 
    40     return ( '',
    41              CGI::textarea(
    42                  -class => $this->cssClasses('twikiInputField',
    43                                              'twikiEditFormTextAreaField'),
    44                  -cols => $this->{cols},
    45                  -rows => $this->{rows},
    46                  -name => $this->{name},
    47                  -default => "\n".$value ));
    48 }
    49 
    50 1;
    51 __DATA__
    52 
    53 Module of TWiki Enterprise Collaboration Platform, http://TWiki.org/
    54 
    55 Copyright (C) 2001-2007 TWiki Contributors. All Rights Reserved.
    56 TWiki Contributors are listed in the AUTHORS file in the root of
    57 this distribution. NOTE: Please extend that file, not this notice.
    58 
    59 This program is free software; you can redistribute it and/or
    60 modify it under the terms of the GNU General Public License
    61 as published by the Free Software Foundation; either version 2
    62 of the License, or (at your option) any later version. For
    63 more details read LICENSE in the root of this distribution.
    64 
    65 This program is distributed in the hope that it will be useful,
    66 but WITHOUT ANY WARRANTY; without even the implied warranty of
    67 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    68 
    69 As per the GPL, removal of this notice is prohibited.
    70