simplified message box creation

git-svn-id: http://yolanda.mister-muffin.de/svn@329 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2008-04-27 21:37:08 +00:00
parent f7419101c3
commit 84fcdbd516
5 changed files with 25 additions and 51 deletions

View file

@ -339,3 +339,16 @@ sub output_page
#$stylesheet->output_as_bytes($output); <= for future use with XML::LibXSLT (>= 1.62) #$stylesheet->output_as_bytes($output); <= for future use with XML::LibXSLT (>= 1.62)
} }
} }
sub message
{
my ($type, $text, $value) = @_;
my $message = XML::LibXML::Element->new( "message" );
$message->setAttribute("type", $type);
$message->setAttribute("text", $text);
if ($value)
{
$message->setAttribute("value", $value);
}
return $message;
}

View file

@ -15,27 +15,15 @@ $page->appendChild(XML::LibXML::Element->new( "frontpage" ));
if($query->param('information')) if($query->param('information'))
{ {
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("information", $query->param('information'), $query->param('value')));
$message->setAttribute("type", "information");
$message->setAttribute("text", $query->param('information'));
$message->setAttribute("value",$query->param('value'));
$page->appendChild($message);
} }
elsif($query->param('error')) elsif($query->param('error'))
{ {
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("error", $query->param('error'), $query->param('value')));
$message->setAttribute("type", "error");
$message->setAttribute("text", $query->param('error'));
$message->setAttribute("value",$query->param('value'));
$page->appendChild($message);
} }
elsif($query->param('warning')) elsif($query->param('warning'))
{ {
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("warning", $query->param('warning'), $query->param('value')));
$message->setAttribute("type", "warning");
$message->setAttribute("text", $query->param('warning'));
$message->setAttribute("value",$query->param('value'));
$page->appendChild($message);
} }
my $tagcloud = XML::LibXML::Element->new( "tagcloud" ); my $tagcloud = XML::LibXML::Element->new( "tagcloud" );

View file

@ -14,10 +14,7 @@ my $page = get_page_array(@userinfo);
#check if user is logged in #check if user is logged in
if($username) if($username)
{ {
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("error", "error_already_registered"));
$message->setAttribute("type", "error");
$message->setAttribute("text", "error_already_registered");
$page->appendChild($message);
$doc->setDocumentElement($page); $doc->setDocumentElement($page);
@ -38,10 +35,7 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re
{ {
$page->appendChild(XML::LibXML::Element->new( "registerform" )); $page->appendChild(XML::LibXML::Element->new( "registerform" ));
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("error", "error_username_already_registered"));
$message->setAttribute("type", "error");
$message->setAttribute("text", "error_username_already_registered");
$page->appendChild($message);
$doc->setDocumentElement($page); $doc->setDocumentElement($page);
@ -60,10 +54,7 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re
{ {
$page->appendChild(XML::LibXML::Element->new( "registerform" )); $page->appendChild(XML::LibXML::Element->new( "registerform" ));
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("error", "error_passwords_do_not_match"));
$message->setAttribute("type", "error");
$message->setAttribute("text", "error_passwords_do_not_match");
$page->appendChild($message);
$doc->setDocumentElement($page); $doc->setDocumentElement($page);
@ -74,10 +65,7 @@ elsif(not $query->param('user') and ($query->param('pass') or $query->param('pas
{ {
$page->appendChild(XML::LibXML::Element->new( "registerform" )); $page->appendChild(XML::LibXML::Element->new( "registerform" ));
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("error", "error_insert_username"));
$message->setAttribute("type", "error");
$message->setAttribute("text", "error_insert_username");
$page->appendChild($message);
$doc->setDocumentElement($page); $doc->setDocumentElement($page);
@ -87,10 +75,7 @@ elsif(not $query->param('pass') and ($query->param('user') or $query->param('pas
{ {
$page->appendChild(XML::LibXML::Element->new( "registerform" )); $page->appendChild(XML::LibXML::Element->new( "registerform" ));
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("error", "error_insert_password"));
$message->setAttribute("type", "error");
$message->setAttribute("text", "error_insert_password");
$page->appendChild($message);
$doc->setDocumentElement($page); $doc->setDocumentElement($page);
@ -100,10 +85,7 @@ elsif(not $query->param('pass_repeat') and ($query->param('user') or $query->par
{ {
$page->appendChild(XML::LibXML::Element->new( "registerform" )); $page->appendChild(XML::LibXML::Element->new( "registerform" ));
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("error", "error_repeat_password"));
$message->setAttribute("type", "error");
$message->setAttribute("text", "error_repeat_password");
$page->appendChild($message);
$doc->setDocumentElement($page); $doc->setDocumentElement($page);

View file

@ -21,10 +21,7 @@ if($userinfo->{'username'})
$page = get_page_array(@userinfo); $page = get_page_array(@userinfo);
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("information", "information_settings_changed"));
$message->setAttribute("type", "information");
$message->setAttribute("text", "information_settings_changed");
$page->appendChild($message);
} }
} }
@ -37,10 +34,7 @@ if($userinfo->{'username'})
} }
else else
{ {
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("error", "error_202c"));
$message->setAttribute("type", "error");
$message->setAttribute("text", "error_202c");
$page->appendChild($message);
} }
$doc->setDocumentElement($page); $doc->setDocumentElement($page);

View file

@ -93,10 +93,7 @@ if($query->url_param('id'))
else else
{ {
#output infobox #output infobox
my $message = XML::LibXML::Element->new( "message" ); $page->appendChild(message("information", "information_comment_created"));
$message->setAttribute("type", "information");
$message->setAttribute("text", "information_comment_created");
$page->appendChild($message);
#add to database #add to database
$dbh->do(qq{insert into comments (userid, videoid, text, timestamp) values (?, ?, ?, unix_timestamp())}, undef, $dbh->do(qq{insert into comments (userid, videoid, text, timestamp) values (?, ?, ?, unix_timestamp())}, undef,