public function getForumStatistics($pagesize = null, $page = null) { $statistic = array(); $threads = array(); $conditionalStatement = "forum_id = {$this->id} AND is_active = 1 AND status+0 < 16"; $conditionalStatement_sticky = "forum_id = {$this->id} AND is_active = 1 AND status+0 >= 16"; $orderby = " created_at"; $sort = "DESC"; $stickies = PaForumThread::listPaForumThread($conditionalStatement_sticky, $orderby, $sort); $threads = PaForumThread::listPaForumThread($conditionalStatement, $orderby, $sort); $threads = array_merge($stickies, $threads); $statistics['nb_threads'] = count($threads); $nb_posts = 0; $last_post = null; $last_post_date = 0; $statistics['last_thread'] = !empty($threads[0]) ? $threads[0] : null; foreach ($threads as &$thread) { $thread->statistics = $thread->getThreadStatistics(); $statistics['threads'][] = $thread; $nb_posts += $thread->statistics['posts']; if (is_object($thread->statistics['last_post'])) { $__obj = $thread->statistics['last_post']; $__obj->thread = $thread; $__post_date = strtotime($__obj->get_created_at()); if ($__post_date > $last_post_date) { $last_post = $__obj; $last_post_date = $__post_date; } } } if (!is_null($page)) { $this->pagination = new MemoryPagging(@$statistics['threads'], $pagesize, $page); $statistics['threads'] = $this->pagination->getPageItems(); } $statistics['nb_posts'] = $nb_posts; $statistics['last_post'] = $last_post; return $statistics; }