Esempio n. 1
0
 public function Show($list = false)
 {
     global $user;
     if ($this->parent_obj === false) {
         return '';
     }
     $sql_where = "`item_id`='" . $this->parent_obj->id() . "' AND `item_type`='" . $this->parent_obj->type() . "'";
     $line = getDB()->fetchRow("SELECT COUNT(*) FROM `{$this->db}` WHERE " . $sql_where, false, 'num');
     $comments_html = '';
     $arrows_html = '';
     $commentnum = (int) $line[0];
     if ($commentnum) {
         $comm_pnum = $this->per_page;
         $comm_order = $this->revers ? 'ASC' : 'DESC';
         $list_def = $this->revers ? ceil($commentnum / $comm_pnum) : 1;
         $list = $list <= 0 ? $list_def : (int) $list;
         $result = getDB()->ask("SELECT `id` FROM `{$this->db}` " . "WHERE " . $sql_where . " ORDER BY `time` " . $comm_order . " " . "LIMIT " . $comm_pnum * ($list - 1) . "," . $comm_pnum);
         while ($line = $result->fetch('num')) {
             $comments_item = new Comments_Item($line[0], $this->st_subdir);
             $comments_html .= $comments_item->Show($user);
             unset($comments_item);
         }
         $arrows_html = $this->arrowsGenerator($this->work_script, $list, $commentnum, $comm_pnum);
     }
     ob_start();
     include $this->GetView('comments_container.html');
     return ob_get_clean();
 }