You are here

function better_comments_entity_prepare_view in Better Comments 7.2

Same name and namespace in other branches
  1. 7 better_comments.module \better_comments_entity_prepare_view()

Prepares entity view.

File

./better_comments.module, line 592
Better Comments provides option to configure the comment system.

Code

function better_comments_entity_prepare_view($entities, $entity_type, $langcode) {
  if ($entity_type == 'comment') {
    $i = 0;
    $opened = 0;
    foreach ($entities as $id => $entity) {
      $depth = isset($entity->thread) ? count(explode('.', $entity->thread)) - 1 : 0;
      $entity->wrappers_to_close = 0;
      if ($depth > $opened) {
        $opened++;
      }
      else {
        $entity->wrappers_to_close = $depth == $opened ? 1 : $opened - $depth + 1;
        while ($depth < $opened) {
          $opened--;
        }
      }
      $i++;
    }
    $entities[$id]->final_wrappers_to_close = $opened;
  }
}