]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Posting.pm
64b05373f4263c20560deedbeeae2908207daa80
1 package Template
::Posting
;
3 ################################################################################
5 # File: shared/Template/Posting.pm #
7 # Authors: Andre Malo <nd@o3media.de>, 2001-06-16 #
9 # Description: show HTML formatted posting #
11 ################################################################################
20 use Encode
::Plain
; $Encode::Plain
::utf8
= 1;
35 use Template
::_thread
;
39 ################################################################################
43 $VERSION = do { my @r =(q
$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x
$#r, @r };
45 ################################################################################
49 use base
qw(Exporter);
55 ### print_posting_as_HTML () ###################################################
57 # print HTML formatted Posting to STDOUT
59 # Params: $threadpath - /path/to/thread_files
60 # $tempfile - template file
61 # $param - Hash-Reference (see doc for details)
65 sub print_posting_as_HTML
($$$) {
66 my ($threadpath, $tempfile, $param) = @_;
68 my $template = new Template
$tempfile;
69 my $assign = $param -> {assign
};
71 my $view = get_view_params
({
72 adminDefault
=> $param -> {adminDefault
}
75 my ($xmlfile, $locked, $xml) = ($threadpath.'t'.$param -> {thread
}.'.xml', 0);
77 unless (($locked = lock_file
($xmlfile)) and ($xml = parse_xml_file
($xmlfile))) {
78 violent_unlock_file
($xmlfile);
79 print ${$template -> scrap
(
80 $assign -> {errorDoc
},
81 { $assign -> {errorText
} => $template -> insert
(
82 $assign -> {(defined $locked)
90 violent_unlock_file
($xmlfile) unless (unlock_file
($xmlfile));
92 my ($mnode, $tnode) = get_message_node
($xml, 't'.$param -> {thread
}, 'm'.$param -> {posting
});
94 unless ($mnode and not $mnode->getAttribute('invisible')) {
95 print ${$template -> scrap
(
96 $assign -> {errorDoc
},
97 { $assign -> {errorText
} => $template -> insert
($assign -> {'notAvailable'}) }
101 my $pnode = $mnode -> getParentNode
;
102 my $header = get_message_header
($mnode);
103 my $msg = parse_single_thread
($tnode, $param -> {showDeleted
}, $view -> {sortedMsg
});
104 my $pheader = ($pnode -> getNodeName
eq 'Message')?get_message_header
($pnode):{};
106 my $formdata = $param -> {form
} -> {data
};
107 my $formact = $param -> {form
} -> {action
};
109 my $body = get_message_body
($xml, 'm'.$param -> {posting
});
111 my $text = message_field
(
113 { quoteChars
=> plain
($view -> {quoteChars
}),
114 quoting
=> $view -> {quoting
},
115 startCite
=> ${$template -> scrap
($assign -> {startCite
})},
116 endCite
=> ${$template -> scrap
($assign -> {endCite
})}
120 my $area = answer_field
(
123 quoteChars
=> plain
($view -> {quoteChars
}),
124 messages
=> $param -> {messages
}
130 $pars -> {$formdata -> {$_} -> {assign
} -> {name
}} = plain
($formdata -> {$_} -> {name
})
144 my $cgi = $param -> {cgi
};
147 thread
=> $param -> {thread
},
148 template
=> $param -> {tree
},
149 start
=> $param -> {posting
},
156 $assign->{parentTitle
} => plain
(defined $pheader->{subject
} ?
$pheader->{subject
} : ''),
157 $assign->{parentCat
} => plain
(defined $pheader->{category
} ?
$pheader->{category
} : ''),
158 $assign->{parentName
} => plain
(defined $pheader->{name
} ?
$pheader->{name
} : ''),
159 $assign->{parentTime
} => plain
(hr_time
($pheader->{time})),
160 $assign->{parentLink
} => query_string
(
161 { $cgi -> {thread
} => $param -> {thread
},
162 $cgi -> {posting
} => ($pnode -> getAttribute
('id') =~ /(\d+)/)[0]
166 print ${$template -> scrap
(
168 { $assign->{name
} => plain
(defined $header->{name
} ?
$header->{name
} : ''),
169 $assign->{email
} => plain
(defined $header->{email
} ?
$header->{email
} : ''),
170 $assign->{home
} => plain
(defined $header->{home
} ?
$header->{home
} : ''),
171 $assign->{image
} => plain
(defined $header->{image
} ?
$header->{image
} : ''),
172 $assign->{time} => plain
(hr_time
($header->{time})),
173 $assign->{message
} => $text,
174 $assign->{messageTitle
} => plain
(defined $header->{subject
} ?
$header->{subject
} : ''),
175 $assign->{messageCat
} => plain
(defined $header->{category
} ?
$header->{category
} : ''),
176 $param->{tree
}->{main
} => html_thread
($msg, $template, $tpar),
177 $formact->{post
}->{assign
} => $formact->{post
}->{url
},
178 $formact->{vote
}->{assign
} => $formact->{vote
}->{url
},
179 $formdata->{posterBody
}->{assign
}->{value
} => $area,
180 $formdata->{uniqueID
} ->{assign
}->{value
} => plain
(unique_id
),
181 $formdata->{followUp
} ->{assign
}->{value
} => plain
($param -> {thread
}.';'.$param -> {posting
}),
182 $formdata->{quoteChar
} ->{assign
}->{value
} => "ÿ".plain
(defined $view -> {quoteChars
} ?
$view -> {quoteChars
} : ''),
183 $formdata->{userID
} ->{assign
}->{value
} => '',
184 $assign->{firsttime
} => $param->{firsttime
} ?
$param->{firsttime
} : '',
185 $assign->{voted
} => $param->{voted
} ?
$param->{voted
} : ''
195 if ($param->{firsttime
}) {
196 my $cache = new Posting
::Cache
($param->{cachepath
});
198 { thread
=> $param -> {thread
},
199 posting
=> $param -> {posting
}
209 ### message_as_HTML () #########################################################
211 # create HTML String for the Messagetext
213 # Params: $xml - XML::DOM::Document object
214 # $template - Template object
215 # $param - Hash reference
216 # (assign, posting, quoteChars, quoting)
218 # Return: HTML String
220 sub message_as_HTML
($$$) {
221 my ($xml, $template, $param) = @_;
223 my $assign = $param -> {assign
};
224 my $body = get_message_body
($xml, $param -> {posting
});
226 my $text = message_field
(
228 { quoteChars
=> plain
($param -> {quoteChars
}),
229 quoting
=> $param -> {quoting
},
230 startCite
=> ${$template -> scrap
($assign -> {startCite
})},
231 endCite
=> ${$template -> scrap
($assign -> {endCite
})}
239 # keep 'require' happy
244 ### end of Template::Posting ###################################################
patrick-canterino.de