]>
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-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]
167 print ${$template -> scrap
(
169 { $assign->{name
} => plain
(defined $header->{name
} ?
$header->{name
} : ''),
170 $assign->{email
} => plain
(defined $header->{email
} ?
$header->{email
} : ''),
171 $assign->{home
} => plain
(defined $header->{home
} ?
$header->{home
} : ''),
172 $assign->{image
} => plain
(defined $header->{image
} ?
$header->{image
} : ''),
173 $assign->{time} => plain
(hr_time
($header->{time})),
174 $assign->{message
} => $text,
175 $assign->{messageTitle
} => plain
(defined $header->{subject
} ?
$header->{subject
} : ''),
176 $assign->{messageCat
} => plain
(defined $header->{category
} ?
$header->{category
} : ''),
177 $param->{tree
}->{main
} => html_thread
($msg, $template, $tpar),
178 $formact->{post
}->{assign
} => $formact->{post
}->{url
},
179 $formact->{vote
}->{assign
} => $formact->{vote
}->{url
},
180 $formdata->{posterBody
}->{assign
}->{value
} => $area,
181 $formdata->{uniqueID
} ->{assign
}->{value
} => plain
(unique_id
),
182 $formdata->{followUp
} ->{assign
}->{value
} => plain
($param -> {thread
}.';'.$param -> {posting
}),
183 $formdata->{quoteChar
} ->{assign
}->{value
} => "ÿ".plain
(defined $view -> {quoteChars
} ?
$view -> {quoteChars
} : ''),
184 $formdata->{userID
} ->{assign
}->{value
} => '',
185 $assign->{firsttime
} => $param->{firsttime
} ?
$param->{firsttime
} : '',
186 $assign->{voted
} => $param->{voted
} ?
$param->{voted
} : ''
196 if ($param->{firsttime
}) {
197 my $cache = new Posting
::Cache
($param->{cachepath
});
199 { thread
=> $param -> {thread
},
200 posting
=> $param -> {posting
}
210 ### message_as_HTML () #########################################################
212 # create HTML String for the Messagetext
214 # Params: $xml - XML::DOM::Document object
215 # $template - Template object
216 # $param - Hash reference
217 # (assign, posting, quoteChars, quoting)
219 # Return: HTML String
221 sub message_as_HTML
($$$) {
222 my ($xml, $template, $param) = @_;
224 my $assign = $param -> {assign
};
225 my $body = get_message_body
($xml, $param -> {posting
});
227 my $text = message_field
(
229 { quoteChars
=> plain
($param -> {quoteChars
}),
230 quoting
=> $param -> {quoting
},
231 startCite
=> ${$template -> scrap
($assign -> {startCite
})},
232 endCite
=> ${$template -> scrap
($assign -> {endCite
})}
240 # keep 'require' happy
245 ### end of Template::Posting ###################################################
patrick-canterino.de