2009-01-31 08:30:59 +01:00
|
|
|
## @file
|
|
|
|
# Prepare Lemonldap::NG::Manager response for new configurations
|
|
|
|
|
|
|
|
## @class
|
|
|
|
# Prepare Lemonldap::NG::Manager response for new configurations
|
2007-06-23 22:01:37 +02:00
|
|
|
package Lemonldap::NG::Manager::_Response;
|
|
|
|
|
|
|
|
our $VERSION = '0.1';
|
|
|
|
|
2009-01-31 08:30:59 +01:00
|
|
|
## @cmethod Lemonldap::NG::Manager::_Response new()
|
|
|
|
# Constructor
|
|
|
|
# @return Lemonldap::NG::Manager::_Response object
|
2007-06-23 22:01:37 +02:00
|
|
|
sub new {
|
|
|
|
my $class = shift;
|
|
|
|
return bless { errors => [], warnings => [] }, $class;
|
|
|
|
}
|
|
|
|
|
2009-01-31 08:30:59 +01:00
|
|
|
## @method void print(array p)
|
|
|
|
# Join all stings in @p into $self->{txt}
|
2007-06-23 22:01:37 +02:00
|
|
|
sub print {
|
|
|
|
my $self = shift;
|
|
|
|
$self->{txt} .= $_ foreach(@_);
|
|
|
|
}
|
|
|
|
|
2009-01-31 08:30:59 +01:00
|
|
|
## @method void message(string title,string txt)
|
|
|
|
# Build HTML part to display.
|
|
|
|
# @param $title title of the message
|
|
|
|
# @param $txt text of the message
|
2007-06-23 22:01:37 +02:00
|
|
|
sub message {
|
|
|
|
my $self = shift;
|
|
|
|
my ($title, $txt) = @_;
|
|
|
|
$self->{txt} = "<h3>$title</h3><p>$txt</p>" . $self->{txt};
|
|
|
|
}
|
|
|
|
|
2009-01-31 08:30:59 +01:00
|
|
|
## @method private void warning(array warnings)
|
|
|
|
# Store warnings in $self->{warnings}
|
|
|
|
# @param @warnings array of string
|
2007-06-23 22:01:37 +02:00
|
|
|
sub warning {
|
|
|
|
my $self = shift;
|
|
|
|
push @{$self->{warnings}}, @_;
|
|
|
|
}
|
|
|
|
|
2009-01-31 08:30:59 +01:00
|
|
|
## @method private void error(array errors)
|
|
|
|
# Store warnings in $self->{errors}
|
|
|
|
# @param @errors array of string
|
2007-06-23 22:01:37 +02:00
|
|
|
sub error {
|
|
|
|
my $self = shift;
|
|
|
|
return scalar @{$self->{errors}} unless(@_);
|
|
|
|
push @{$self->{errors}}, @_;
|
|
|
|
}
|
|
|
|
|
2009-01-31 08:30:59 +01:00
|
|
|
## @method protected void setConfiguration(hashref configuration)
|
|
|
|
# Store $configuration in $self->{configuration}
|
|
|
|
# @param $configuration Lemonldap::NG configuration
|
2007-06-23 22:01:37 +02:00
|
|
|
sub setConfiguration {
|
|
|
|
my $self = shift;
|
|
|
|
$self->{configuration} = shift;
|
|
|
|
}
|
|
|
|
|
2009-01-31 08:30:59 +01:00
|
|
|
## @method void send()
|
|
|
|
# Display upload response.
|
2007-06-23 22:01:37 +02:00
|
|
|
sub send {
|
|
|
|
my $self = shift;
|
|
|
|
my $buf;
|
|
|
|
$buf = "tree.setItemText('root','Configuration $self->{configuration}');"
|
|
|
|
if($self->{configuration});
|
|
|
|
if ( $self->error ) {
|
|
|
|
$self->{txt} .= "<h4>Errors</h4><ul>";
|
|
|
|
foreach ( @{$self->{errors}} ) {
|
|
|
|
s/</</g;
|
|
|
|
s/>/>/g;
|
|
|
|
$self->{txt} .= "<li>$_</li>"
|
|
|
|
}
|
|
|
|
$self->{txt} .= "</ul>";
|
|
|
|
}
|
|
|
|
if ( $self->warning ) {
|
|
|
|
$self->{txt} .= "<h4>Warnings</h4><ul>";
|
|
|
|
foreach ( @{$self->{warnings}} ) {
|
|
|
|
s/</</g;
|
|
|
|
s/>/>/g;
|
|
|
|
$self->{txt} .= "<li>$_</li>"
|
|
|
|
}
|
|
|
|
$self->{txt} .= "</ul>";
|
|
|
|
}
|
|
|
|
if($self->{txt}) {
|
|
|
|
$self->{txt} =~ s/'/\\'/g;
|
|
|
|
$self->{txt} =~ s/[\r\n]//g;
|
|
|
|
$buf .= "document.getElementById('help').innerHTML='$self->{txt}';";
|
|
|
|
}
|
|
|
|
print $buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
__END__
|