]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/shared/Template/Posting.pm
3fafa4a081a5edb76beef0f4b095fc371e4fd169
1 package Template
::Posting
;
3 ################################################################################
5 # File: shared/Template/Posting.pm #
7 # Authors: André Malo <nd@o3media.de> #
9 # Description: show HTML formatted posting #
11 ################################################################################
19 use Encode
::Plain
; $Encode::Plain
::utf8
= 1;
34 use Template
::_thread
;
38 ################################################################################
46 sub VERSION
{(q
$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
48 ################################################################################
52 use base
qw(Exporter);
58 ### print_posting_as_HTML () ###################################################
60 # print HTML formatted Posting to STDOUT
62 # Params: $threadpath - /path/to/thread_files
63 # $tempfile - template file
64 # $param - Hash-Reference (see doc for details)
68 sub print_posting_as_HTML
($$$) {
69 my ($threadpath, $tempfile, $param) = @_;
71 my $template = new Template
$tempfile;
72 my $assign = $param -> {assign
};
74 my $view = get_view_params
({
75 adminDefault
=> $param -> {adminDefault
}
78 my $fh = new Lock
($threadpath.'t'.$param -> {thread
}.'.xml');
80 unless ($fh -> lock (LH_SHARED
)) {
81 print ${$template -> scrap
(
82 $assign -> {errorDoc
},
83 { $assign -> {errorText
} => $template -> insert
(
94 unless (-f
$fh -> filename
) {
96 print ${$template -> scrap
($assign -> {errorDoc
}, {$assign -> {errorText
} => $template -> insert
($assign->{notAvailable
})})};
99 my $xml = parse_xml_file
($fh -> filename
); #...
103 print ${$template -> scrap
($assign -> {errorDoc
}, {$assign -> {errorText
} => $template -> insert
($assign->{corrupt
})})};
106 my ($mnode, $tnode) = get_message_node
($xml, 't'.$param -> {thread
}, 'm'.$param -> {posting
});
108 unless ($mnode and not $mnode->getAttribute('invisible')) {
109 print ${$template -> scrap
(
110 $assign -> {errorDoc
},
111 { $assign -> {errorText
} => $template -> insert
($assign -> {'notAvailable'}) }
115 my $pnode = $mnode -> getParentNode
;
116 my $header = get_message_header
($mnode);
117 my $msg = parse_single_thread
($tnode, $param -> {showDeleted
}, $view -> {sortedMsg
});
118 my $pheader = ($pnode -> getNodeName
eq 'Message')?get_message_header
($pnode):{};
120 my $formdata = $param -> {form
} -> {data
};
121 my $formact = $param -> {form
} -> {action
};
123 my $body = get_message_body
($xml, 'm'.$param -> {posting
});
125 my $text = message_field
(
127 { quoteChars
=> plain
($view -> {quoteChars
}),
128 quoting
=> $view -> {quoting
},
129 startCite
=> ${$template -> scrap
($assign -> {startCite
})},
130 endCite
=> ${$template -> scrap
($assign -> {endCite
})}
134 my $area = answer_field
(
137 quoteChars
=> plain
($view -> {quoteChars
}),
138 messages
=> $param -> {messages
}
144 $pars -> {$formdata -> {$_} -> {assign
} -> {name
}} = plain
($formdata -> {$_} -> {name
})
158 my $cgi = $param -> {cgi
};
161 thread
=> $param -> {thread
},
162 template
=> $param -> {tree
},
163 start
=> $param -> {posting
},
170 $assign->{parentTitle
} => plain
(defined $pheader->{subject
} ?
$pheader->{subject
} : ''),
171 $assign->{parentCat
} => plain
(defined $pheader->{category
} ?
$pheader->{category
} : ''),
172 $assign->{parentName
} => plain
(defined $pheader->{name
} ?
$pheader->{name
} : ''),
173 $assign->{parentTime
} => plain
(hr_time
($pheader->{time})),
174 $assign->{parentLink
} => query_string
(
175 { $cgi -> {thread
} => $param -> {thread
},
176 $cgi -> {posting
} => ($pnode -> getAttribute
('id') =~ /(\d+)/)[0]
180 print ${$template -> scrap
(
182 { $assign->{name
} => plain
(defined $header->{name
} ?
$header->{name
} : ''),
183 $assign->{email
} => plain
(defined $header->{email
} ?
$header->{email
} : ''),
184 $assign->{home
} => plain
(defined $header->{home
} ?
$header->{home
} : ''),
185 $assign->{image
} => plain
(defined $header->{image
} ?
$header->{image
} : ''),
186 $assign->{time} => plain
(hr_time
($header->{time})),
187 $assign->{message
} => $text,
188 $assign->{messageTitle
} => plain
(defined $header->{subject
} ?
$header->{subject
} : ''),
189 $assign->{messageCat
} => plain
(defined $header->{category
} ?
$header->{category
} : ''),
190 $param->{tree
}->{main
} => html_thread
($msg, $template, $tpar),
191 $formact->{post
}->{assign
} => $formact->{post
}->{url
},
192 $formact->{vote
}->{assign
} => $formact->{vote
}->{url
},
193 $formdata->{posterBody
}->{assign
}->{value
} => $area,
194 $formdata->{uniqueID
} ->{assign
}->{value
} => plain
(unique_id
),
195 $formdata->{followUp
} ->{assign
}->{value
} => plain
($param -> {thread
}.';'.$param -> {posting
}),
196 $formdata->{quoteChar
} ->{assign
}->{value
} => "ÿ".plain
(defined $view -> {quoteChars
} ?
$view -> {quoteChars
} : ''),
197 $formdata->{userID
} ->{assign
}->{value
} => '',
198 $assign->{firsttime
} => $param->{firsttime
} ?
$param->{firsttime
} : '',
199 $assign->{voted
} => $param->{voted
} ?
$param->{voted
} : ''
209 if ($param->{firsttime
}) {
210 my $cache = new Posting
::Cache
($param->{cachepath
});
212 { thread
=> $param -> {thread
},
213 posting
=> $param -> {posting
}
225 ### message_as_HTML () #########################################################
227 # create HTML String for the Messagetext
229 # Params: $xml - XML::DOM::Document object
230 # $template - Template object
231 # $param - Hash reference
232 # (assign, posting, quoteChars, quoting)
234 # Return: HTML String
236 sub message_as_HTML
($$$) {
237 my ($xml, $template, $param) = @_;
239 my $assign = $param -> {assign
};
240 my $body = get_message_body
($xml, $param -> {posting
});
242 my $text = message_field
(
244 { quoteChars
=> plain
($param -> {quoteChars
}),
245 quoting
=> $param -> {quoting
},
246 startCite
=> ${$template -> scrap
($assign -> {startCite
})},
247 endCite
=> ${$template -> scrap
($assign -> {endCite
})}
255 # keep 'require' happy
260 ### end of Template::Posting ###################################################
patrick-canterino.de