- return (0, $thread, $mid);
- }
-}
-
-# ====================================================
-# Private Funktionen
-# ====================================================
-
-sub create_message ($$) {
- my ($xml,$par) = @_;
-
- my $message = $xml -> createElement ('Message');
- $message -> setAttribute ('id', $par -> {msg});
- $message -> setAttribute ('ip', $par -> {ip});
-
- # Header erzeugen
- my $header = $xml -> createElement ('Header');
-
- # alles inside of 'Header'
- my $author = $xml -> createElement ('Author');
- my $name = $xml -> createElement ('Name');
- $name -> addText ($par -> {name});
- $author -> appendChild ($name);
-
- my $email = $xml -> createElement ('Email');
- $email -> addText ($par -> {email});
- $author -> appendChild ($email);
-
- if (length ($par -> {home})) {
- my $home = $xml -> createElement ('HomepageUrl');
- $home -> addText ($par -> {home});
- $author -> appendChild ($home);}
-
- if (length ($par -> {image})) {
- my $image = $xml -> createElement ('ImageUrl');
- $image -> addText ($par -> {image});
- $author -> appendChild ($image);}
-
- my $category = $xml -> createElement ('Category');
- $category -> addText ($par -> {category});
-
- my $subject = $xml -> createElement ('Subject');
- $subject -> addText ($par -> {subject});
-
- my $date = $xml -> createElement ('Date');
- $date -> setAttribute ('longSec', $par -> {time});
-
- $header -> appendChild ($author);
- $header -> appendChild ($category);
- $header -> appendChild ($subject);
- $header -> appendChild ($date);
- $message -> appendChild ($header);
-
- $message;
-}
-
-sub create_new_thread ($) {
- my $par = shift;
-
- # neues Dokument
- my $xml = new XML::DOM::Document;
-
- # XML-declaration
- my $decl = new XML::DOM::XMLDecl;
- $decl -> setVersion ('1.0');
- $decl -> setEncoding ('UTF-8');
- $xml -> setXMLDecl ($decl);
-
- # Doctype
- my $dtd = $xml -> createDocumentType ('Forum', $par -> {dtd}, undef, undef);
- $xml -> setDoctype ($dtd);
+ my $pars = {
+ msg => $mid,
+ ip => $param -> {ip},
+ name => defined $param -> {author} ? $param -> {author} :'',
+ email => defined $param -> {email} ? $param -> {email} :'',
+ home => defined $param -> {homepage} ? $param -> {homepage} :'',
+ image => defined $param -> {image} ? $param -> {image} :'',
+ category => defined $param -> {category} ? $param -> {category} :'',
+ subject => defined $param -> {subject} ? $param -> {subject} :'',
+ time => $param -> {time},
+ };
+
+ my $message = create_message ($xml, $pars);
+
+ $mnode -> appendChild ($message);
+
+ my $mcontent = $xml -> createElement ('MessageContent');
+ $mcontent -> setAttribute ('mid' => $mid);
+ $mcontent -> appendChild (
+ $xml -> createCDATASection (
+ ${encoded_body(
+ \($param -> {body}),
+ { quoteChars => $param -> {quoteChars},
+ messages => $param -> {messages},
+ base_uri => $param -> {base_uri}
+ }
+ )}
+ )
+ );