Question about part of Comment.module The following is part of the comment.module file (line 950):

// Add indentation div or close open divs as needed.
if ($is_threaded) {
  $prefix .= $comment-&gt;divs &lt;= 0 ? str_repeat('&lt;/div&gt;', abs($comment-&gt;divs)) : "\n"     . '&lt;div class="indented"&gt;';
}


Can someone explain that what is it doing?
For reference, this is in the comment_view() function.

It is equivalent to this, which makes it a little easier to understand:

if ($is_threaded) {
  if ($comment-&gt;divs &lt;= 0) {
    $prefix .= str_repeat('&lt;/div&gt;', abs($comment-&gt;divs));
  }
  else {
    $prefix .= "\n" . '&lt;div class="indented"&gt;';
  }
}


$is_threaded is a boolean value for whether or not threading has been enabledfor comments in the settings for this content type.

$comment->divs is set in comment_prepare_thread() and is a count of the indentation divs required to have this comment in the right place in terms of the comment's depth. So this value will either be 1 if a new indentation div needs to be added to make sure the comment is at the correct depth, or a negative number, which is how many indentation divs need to be closed to have the comment at the correct depth.

So if comment threading is enabled, then if $comment-&gt;divs is less than or equal to zero then close zero or more indentation divs by appending str_repeat('&lt;/div&gt;', abs($comment-&gt;divs)) to the markup otherwise, if $comment-&gt;divs is 1 then open a new indentation div by adding '&lt;div class="indented"&gt;' to the markup.

For example if you had these comments:

Comment 1
-Comment 2
--Comment 3
---Comment 4
--Comment 5
---Comment 6
----Comment 7
-----Comment 8
-----Comment 9
Comment 10
Comment 11
-Comment 12
Comment 13
Comment 14


Then for each comment, $comment->divs would be:


Comment 1: 0
Comment 2: 1
Comment 3: 1
Comment 4: 1
Comment 5: -1
Comment 6: 1
Comment 7: 1
Comment 8: 1
Comment 9: 0
Comment 10: -5
Comment 11: 0
Comment 12: 1
Comment 13: -1
Comment 14: 0