function views_plugin_row_comment_view::pre_render in Views (for Drupal 7) 6.3
Same name and namespace in other branches
- 6.2 modules/comment/views_plugin_row_comment_view.inc \views_plugin_row_comment_view::pre_render()
- 7.3 modules/comment/views_plugin_row_comment_view.inc \views_plugin_row_comment_view::pre_render()
Allow the style to do stuff before each row is rendered.
Parameters
$result: The full array of results from the query.
Overrides views_plugin_row::pre_render
File
- modules/
comment/ views_plugin_row_comment_view.inc, line 28 - Contains the node RSS row style plugin.
Class
- views_plugin_row_comment_view
- Plugin which performs a comment_view on the resulting object.
Code
function pre_render($result) {
$cids = array();
$this->comments = array();
foreach ($result as $row) {
$cids[] = $row->cid;
}
if (count($cids) > 1) {
$placeholder = " IN (" . implode(', ', array_fill(0, sizeof($cids), '%d')) . ")";
}
else {
$placeholder = " = %d";
}
$cresult = db_query("SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid {$placeholder}", $cids);
while ($comment = db_fetch_object($cresult)) {
$comment = drupal_unpack($comment);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
$comment->depth = count(explode('.', $comment->thread)) - 1;
$this->comments[$comment->cid] = $comment;
}
}