Exemplo n.º 1
0
 private function getCommentList(comments $tree, $parent_id, $TEMPLATE)
 {
     $all_count = $tree->countComments($parent_id);
     $list = '';
     $num = 0;
     while ($comment = $tree->getComment($parent_id)) {
         $sub_comments = $tree->issetComments($parent_id) ? $this->getCommentList($tree, $comment->id(), $TEMPLATE) : '';
         $num++;
         page::assign('obj.num', $num);
         page::assign('class-first', $num == 1 ? 'first' : '');
         page::assign('class-last', $num == $all_count ? 'last' : '');
         page::assign('class-odd', $num % 2 == 0 ? 'odd' : '');
         page::assign('class-even', $num % 2 != 0 ? 'even' : '');
         page::assign('class-third', $num % 3 == 0 ? 'third' : '');
         page::assign('obj.id', $comment->id());
         page::assign('obj.parent_id', $comment->getParentId());
         page::assign('obj.user_id', $comment->getUserId());
         page::assign('obj.publ_date', $comment->getPublDate());
         page::assign('obj.username', $comment->getUserName());
         page::assign('obj.email', $comment->getEmail());
         page::assign('obj.text', $comment->getText());
         page::assign('obj.rate', $comment->getRate());
         if (isset($_SESSION['comments_rate'][$comment->id()])) {
             page::fParse('rate', $TEMPLATE['rate_change']);
         } else {
             page::fParse('rate', $TEMPLATE['rate']);
         }
         if (!empty($sub_comments)) {
             page::assign('list', $sub_comments);
             page::fParse('list', $TEMPLATE['frame_list']);
         } else {
             page::assign('list', '');
         }
         $list .= page::parse($TEMPLATE['list']);
     }
     return $list;
 }