function comment_prepare_thread
comment_prepare_thread(&$comments)
Loop over comment thread, noting indentation level.
Parameters
array $comments: An array of comment objects, keyed by cid.
Return value
The $comments argument is altered by reference with indentation information.
File
- modules/comment/comment.module, line 869
- Enables users to comment on published content.
Code
function comment_prepare_thread(&$comments) { // A flag stating if we are still searching for first new comment on the thread. $first_new = TRUE; // A counter that helps track how indented we are. $divs = 0; foreach ($comments as $key => $comment) { if ($first_new && $comment->new != MARK_READ) { // Assign the anchor only for the first new comment. This avoids duplicate // id attributes on a page. $first_new = FALSE; $comment->first_new = TRUE; } // The $divs element instructs #prefix whether to add an indent div or // close existing divs (a negative value). $comment->depth = count(explode('.', $comment->thread)) - 1; if ($comment->depth > $divs) { $comment->divs = 1; $divs++; } else { $comment->divs = $comment->depth - $divs; while ($comment->depth < $divs) { $divs--; } } $comments[$key] = $comment; } // The final comment must close up some hanging divs $comments[$key]->divs_final = $divs; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!comment!comment.module/function/comment_prepare_thread/7.x