]>
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;
31 use Template
::_thread
;
35 ################################################################################
39 use base
qw(Exporter);
40 @Template::Posting
::EXPORT
= qw(
45 ### sub print_posting_as_HTML ($$$) ############################################
47 # print HTML formatted Posting to STDOUT
49 # Params: $threadpath - /path/to/thread_files
50 # $tempfile - template file
51 # $param - Hash-Reference (see doc for details)
55 sub print_posting_as_HTML
($$$) {
56 my ($threadpath, $tempfile, $param) = @_;
58 my $template = new Template
$tempfile;
59 my $assign = $param -> {assign
};
61 my $view = get_view_params
({
62 adminDefault
=> $param -> {adminDefault
}
65 my ($xmlfile, $locked, $xml) = ($threadpath.'t'.$param -> {thread
}.'.xml', 0);
67 unless (($locked = lock_file
($xmlfile)) and ($xml = parse_xml_file
($xmlfile))) {
68 violent_unlock_file
($xmlfile);
69 print ${$template -> scrap
(
70 $assign -> {errorDoc
},
71 { $assign -> {errorText
} => $template -> insert
(
72 $assign -> {(defined $locked)
80 violent_unlock_file
($xmlfile) unless (unlock_file
($xmlfile));
82 my ($mnode, $tnode) = get_message_node
($xml, 't'.$param -> {thread
}, 'm'.$param -> {posting
});
84 unless ($mnode and not $mnode->getAttribute('invisible')) {
85 print ${$template -> scrap
(
86 $assign -> {errorDoc
},
87 { $assign -> {errorText
} => $template -> insert
($assign -> {'notAvailable'}) }
91 my $pnode = $mnode -> getParentNode
;
92 my $header = get_message_header
($mnode);
93 my $msg = parse_single_thread
($tnode, $param -> {showDeleted
}, $view -> {sortedMsg
});
94 my $pheader = ($pnode -> getNodeName
eq 'Message')?get_message_header
($pnode):{};
96 my $formdata = $param -> {form
} -> {data
};
97 my $formact = $param -> {form
} -> {action
};
99 my $body = get_message_body
($xml, 'm'.$param -> {posting
});
101 my $text = message_field
(
103 { quoteChars
=> plain
($view -> {quoteChars
}),
104 quoting
=> $view -> {quoting
},
105 startCite
=> ${$template -> scrap
($assign -> {startCite
})},
106 endCite
=> ${$template -> scrap
($assign -> {endCite
})}
110 my $area = answer_field
(
113 quoteChars
=> plain
($view -> {quoteChars
}),
114 messages
=> $param -> {messages
}
120 $pars -> {$formdata -> {$_} -> {assign
} -> {name
}} = plain
($formdata -> {$_} -> {name
})
134 my $cgi = $param -> {cgi
};
137 thread
=> $param -> {thread
},
138 template
=> $param -> {tree
},
139 start
=> $param -> {posting
},
146 $assign->{parentTitle
} => plain
(defined $pheader->{subject
} ?
$pheader->{subject
} : ''),
147 $assign->{parentCat
} => plain
(defined $pheader->{category
} ?
$pheader->{category
} : ''),
148 $assign->{parentName
} => plain
(defined $pheader->{name
} ?
$pheader->{name
} : ''),
149 $assign->{parentTime
} => plain
(hr_time
($pheader->{time})),
150 $assign->{parentLink
} => query_string
(
151 { $cgi -> {thread
} => $param -> {thread
},
152 $cgi -> {posting
} => ($pnode -> getAttribute
('id') =~ /(\d+)/)[0]
156 print ${$template -> scrap
(
158 { $assign->{name
} => plain
(defined $header->{name
} ?
$header->{name
} : ''),
159 $assign->{email
} => plain
(defined $header->{email
} ?
$header->{email
} : ''),
160 $assign->{home
} => plain
(defined $header->{home
} ?
$header->{home
} : ''),
161 $assign->{image
} => plain
(defined $header->{image
} ?
$header->{image
} : ''),
162 $assign->{time} => plain
(hr_time
($header->{time})),
163 $assign->{message
} => $text,
164 $assign->{messageTitle
} => plain
(defined $header->{subject
} ?
$header->{subject
} : ''),
165 $assign->{messageCat
} => plain
(defined $header->{category
} ?
$header->{category
} : ''),
166 $param->{tree
}->{main
} => html_thread
($msg, $template, $tpar),
167 $formact->{post
}->{assign
} => $formact->{post
}->{url
},
168 $formact->{vote
}->{assign
} => $formact->{vote
}->{url
},
169 $formdata->{posterBody
}->{assign
}->{value
} => $area,
170 $formdata->{uniqueID
} ->{assign
}->{value
} => plain
(unique_id
),
171 $formdata->{followUp
} ->{assign
}->{value
} => plain
($param -> {thread
}.';'.$param -> {posting
}),
172 $formdata->{quoteChar
} ->{assign
}->{value
} => "ÿ".plain
(defined $view -> {quoteChars
} ?
$view -> {quoteChars
} : ''),
173 $formdata->{userID
} ->{assign
}->{value
} => '',
174 $assign->{firsttime
} => $param->{firsttime
} ?
$param->{firsttime
} : '',
175 $assign->{voted
} => $param->{voted
} ?
$param->{voted
} : ''
185 if ($param->{firsttime
}) {
186 my $cache = new Posting
::Cache
($param->{cachefile
});
188 { thread
=> $param -> {thread
},
189 posting
=> $param -> {posting
}
199 ### sub message_as_HTML ($$$) ##################################################
201 # create HTML String for the Messagetext
203 # Params: $xml - XML::DOM::Document object
204 # $template - Template object
205 # $param - Hash reference
206 # (assign, posting, quoteChars, quoting)
208 # Return: HTML String
210 sub message_as_HTML
($$$) {
211 my ($xml, $template, $param) = @_;
213 my $assign = $param -> {assign
};
214 my $body = get_message_body
($xml, $param -> {posting
});
216 my $text = message_field
(
218 { quoteChars
=> plain
($param -> {quoteChars
}),
219 quoting
=> $param -> {quoting
},
220 startCite
=> ${$template -> scrap
($assign -> {startCite
})},
221 endCite
=> ${$template -> scrap
($assign -> {endCite
})}
234 ### end of Template::Posting ###################################################
patrick-canterino.de