]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Posting.pm
1 package Template
::Posting
;
3 ################################################################################
5 # File: shared/Template/Posting.pm #
7 # Authors: Andre Malo <nd@o3media.de>, 2001-04-01 #
9 # Description: show HTML formatted posting #
11 ################################################################################
16 use Encode
::Plain
; $Encode::Plain
::utf8
= 1;
30 use Template
::_thread
;
34 ################################################################################
38 use base
qw(Exporter);
39 @Template::Posting
::EXPORT
= qw(
44 ### sub print_posting_as_HTML ($$$) ############################################
46 # print HTML formatted Posting to STDOUT
48 # Params: $threadpath - /path/to/thread_files
49 # $tempfile - template file
50 # $param - Hash-Reference (see doc for details)
54 sub print_posting_as_HTML
($$$) {
55 my ($threadpath, $tempfile, $param) = @_;
57 my $template = new Template
$tempfile;
58 my $assign = $param -> {assign
};
60 my $view = get_view_params
({
61 adminDefault
=> $param -> {adminDefault
}
64 my ($xmlfile, $locked, $xml) = ($threadpath.'t'.$param -> {thread
}.'.xml', 0);
66 unless (($locked = lock_file
($xmlfile)) and ($xml = parse_xml_file
($xmlfile))) {
67 violent_unlock_file
($xmlfile);
68 print ${$template -> scrap
(
69 $assign -> {errorDoc
},
70 { $assign -> {errorText
} => $template -> insert
(
71 $assign -> {(defined $locked)
79 violent_unlock_file
($xmlfile) unless (unlock_file
($xmlfile));
81 my ($mnode, $tnode) = get_message_node
($xml, 't'.$param -> {thread
}, 'm'.$param -> {posting
});
83 unless ($mnode and not $mnode->getAttribute('invisible')) {
84 print ${$template -> scrap
(
85 $assign -> {errorDoc
},
86 { $assign -> {errorText
} => $template -> insert
($assign -> {'notAvailable'}) }
90 my $pnode = $mnode -> getParentNode
;
91 my $header = get_message_header
($mnode);
92 my $msg = parse_single_thread
($tnode, $param -> {showDeleted
}, $view -> {sortedMsg
});
93 my $pheader = ($pnode -> getNodeName
eq 'Message')?get_message_header
($pnode):{};
95 my $formdata = $param -> {form
} -> {data
};
96 my $formact = $param -> {form
} -> {action
};
98 my $body = get_message_body
($xml, 'm'.$param -> {posting
});
100 my $text = message_field
(
102 { quoteChars
=> plain
($view -> {quoteChars
}),
103 quoting
=> $view -> {quoting
},
104 startCite
=> ${$template -> scrap
($assign -> {startCite
})},
105 endCite
=> ${$template -> scrap
($assign -> {endCite
})}
109 my $area = answer_field
(
112 quoteChars
=> plain
($view -> {quoteChars
}),
113 messages
=> $param -> {messages
}
119 $pars -> {$formdata -> {$_} -> {assign
} -> {name
}} = plain
($formdata -> {$_} -> {name
})
133 my $cgi = $param -> {cgi
};
136 thread
=> $param -> {thread
},
137 template
=> $param -> {tree
},
138 start
=> $param -> {posting
},
145 $assign->{parentTitle
} => plain
(defined $pheader->{subject
} ?
$pheader->{subject
} : ''),
146 $assign->{parentCat
} => plain
(defined $pheader->{category
} ?
$pheader->{category
} : ''),
147 $assign->{parentName
} => plain
(defined $pheader->{name
} ?
$pheader->{name
} : ''),
148 $assign->{parentTime
} => plain
(hr_time
($pheader->{time})),
149 $assign->{parentLink
} => query_string
(
150 { $cgi -> {thread
} => $param -> {thread
},
151 $cgi -> {posting
} => ($pnode -> getAttribute
('id') =~ /(\d+)/)[0]
155 print ${$template -> scrap
(
157 { $assign->{name
} => plain
(defined $header->{name
} ?
$header->{name
} : ''),
158 $assign->{email
} => plain
(defined $header->{email
} ?
$header->{email
} : ''),
159 $assign->{home
} => plain
(defined $header->{home
} ?
$header->{home
} : ''),
160 $assign->{image
} => plain
(defined $header->{image
} ?
$header->{image
} : ''),
161 $assign->{time} => plain
(hr_time
($header->{time})),
162 $assign->{message
} => $text,
163 $assign->{messageTitle
} => plain
(defined $header->{subject
} ?
$header->{subject
} : ''),
164 $assign->{messageCat
} => plain
(defined $header->{category
} ?
$header->{category
} : ''),
165 $param->{tree
}->{main
} => html_thread
($msg, $template, $tpar),
166 $formact->{post
}->{assign
} => $formact->{post
}->{url
},
167 $formact->{vote
}->{assign
} => $formact->{vote
}->{url
},
168 $formdata->{posterBody
}->{assign
}->{value
} => $area,
169 $formdata->{uniqueID
} ->{assign
}->{value
} => plain
(unique_id
),
170 $formdata->{followUp
} ->{assign
}->{value
} => plain
($param -> {thread
}.';'.$param -> {posting
}),
171 $formdata->{quoteChar
} ->{assign
}->{value
} => "ÿ".plain
(defined $view -> {quoteChars
} ?
$view -> {quoteChars
} : ''),
172 $formdata->{userID
} ->{assign
}->{value
} => ''
183 ### sub message_as_HTML ($$$) ##################################################
185 # create HTML String for the Messagetext
187 # Params: $xml - XML::DOM::Document object
188 # $template - Template object
189 # $param - Hash reference
190 # (assign, posting, quoteChars, quoting)
192 # Return: HTML String
194 sub message_as_HTML
($$$) {
195 my ($xml, $template, $param) = @_;
197 my $assign = $param -> {assign
};
198 my $body = get_message_body
($xml, $param -> {posting
});
200 my $text = message_field
(
202 { quoteChars
=> plain
($param -> {quoteChars
}),
203 quoting
=> $param -> {quoting
},
204 startCite
=> ${$template -> scrap
($assign -> {startCite
})},
205 endCite
=> ${$template -> scrap
($assign -> {endCite
})}
218 ### end of Template::Posting ###################################################
patrick-canterino.de