Solstice::View::FormInput::EmailList - A view of an html <textarea> element containing email addresses


Solstice documentation Contained in the Solstice distribution.

Index


Code Index:

NAME

Top

Solstice::View::FormInput::EmailList - A view of an html <textarea> element containing email addresses

SYNOPSIS

Top

  # See L<Solstice::View> for usage.

DESCRIPTION

Top

A view of a form input, showing email addresses

Export

None by default.

Methods

setInvalidEmails(\@list)
getInvalidEmails()
generateParams()

AUTHOR

Top

Educational Technology Development Group, <catalyst@u.washington.edu>

VERSION

Top

$Revision: 107 $

SEE ALSO

Top

UMail::View, perl.

COPYRIGHT

Top


Solstice documentation Contained in the Solstice distribution.
package Solstice::View::FormInput::EmailList;

# $Id: EmailList.pm 107 2005-09-01 23:14:11Z mcrawfor $

use strict;
use warnings;
use 5.006_000;

use base qw(Solstice::View::FormInput);

use Solstice::List;
use Solstice::StringLibrary qw(unrender);

use constant TRUE  => 1;
use constant FALSE => 0;

our $template = 'form_input/email_list.html';

sub new {
    my $class = shift;
    my $self = $class->SUPER::new(@_);

    $self->_setTemplatePath('templates');

    return $self;
}

sub setInvalidEmails {
    my $self = shift;
    $self->{'_invalid_emails'} = shift;
}

sub getInvalidEmails {
    my $self = shift;
    return $self->{'_invalid_emails'};
}

sub generateParams {
    my $self = shift;
    my $email_list = $self->getModel();

    my $name = $self->getName();
    
    $self->setParam('name', $name);

    if (my $error = $self->getError()) {
        my $error_hash = $error->getFormMessages();
        for my $key (keys %$error_hash){
            if ($key =~ /^err_$name$/) {
                $self->setParam('error', $error_hash->{$key});
                
                #TODO: maximum number of invalid emails displayed?
                for my $str (@{$self->getInvalidEmails()}) {
                    $self->addParam('invalid', { address => unrender($str) });
                }
                last;
            }
        }
    }
    
    my $iterator = $email_list->iterator();
    while (my $email = $iterator->next()) {
        $self->addParam('addresses', { address => unrender($email) });
    }
    
    return TRUE;
}


1;
__END__