diff options
Diffstat (limited to 'forum')
-rw-r--r-- | forum/utils/forums.php | 25 | ||||
-rw-r--r-- | forum/utils/threads.php | 28 |
2 files changed, 41 insertions, 12 deletions
diff --git a/forum/utils/forums.php b/forum/utils/forums.php index 1827e3c..06196a6 100644 --- a/forum/utils/forums.php +++ b/forum/utils/forums.php @@ -1,4 +1,4 @@ -<?php +<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ include_once($UTIL_DIR . "/convert.php"); include_once($UTIL_DIR . "/threads.php"); @@ -8,18 +8,31 @@ class Forum { public $fid; public $name; private $newStuff; + private $numPosts; + private $latestPost; - public function setNewStuff($newStuff) + public function setNewStuff($newStuff, $threads) { + $this->numPosts = sizeof($threads->threads); + $this->latestPost = ""; + $t = $threads->getLatestThread(); + if($t) { + $this->latestPost = $t->name; + } + $this->newStuff = $newStuff; } public function show() { + $newcls = ""; + if($this->newStuff) $newcls = " forum_new"; + echo " <div class=\"forum\">\n"; - if($this->newStuff) echo " <div class=\"new\"></div>\n"; - else echo " <div class=\"nonew\"></div>\n"; - echo " <a href=\"?fid=" . $this->fid . "\">" . $this->name . "</a>\n"; + echo " <span class=\"forum_icon".$newcls."\"></span>\n"; + echo " <a class=\"forum_title\" href=\"?fid=" . $this->fid . "\">" . $this->name . "</a>\n"; + echo " <span class=\"forum_latestpost\">".$this->latestPost."</span>\n"; + echo " <span class=\"forum_numberofthreads\">".sprintf("%d", $this->numPosts)." threads</span>\n"; echo " </div>\n"; } @@ -92,7 +105,7 @@ class Forums { $this->add($forum); $threads = new Threads($FORUMS_DIR . "/" . $f->getAttribute('fid')); - $forum->setNewStuff($threads->newStuff()); + $forum->setNewStuff($threads->newStuff(), $threads); } } diff --git a/forum/utils/threads.php b/forum/utils/threads.php index 0c4ef32..11c54ee 100644 --- a/forum/utils/threads.php +++ b/forum/utils/threads.php @@ -1,4 +1,4 @@ -<?php +<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ include_once($UTIL_DIR . "/convert.php"); @@ -20,14 +20,16 @@ class Thread { public function show() { global $fid, $current_user; + $jumptonew = ""; - echo " <div class=\"thread\">\n"; + $newcls = ""; if($this->lastseen[$current_user->uid] < $this->lastpost) { - echo " <div class=\"new\"></div>"; + $newcls = " thread_new"; $jumptonew = "#firstunread"; - } else { - echo " <div class=\"nonew\"></div>\n"; - } + } + + echo " <div class=\"thread\">\n"; + echo " <span class=\"thread_icon".$newcls."\"></span>"; echo " <a href=\"?fid=" . $fid . "&tid=" . $this->tid . $jumptonew."\">" . $this->name . "</a>\n"; echo " </div>\n"; } @@ -117,6 +119,20 @@ class Threads { return $thread; } + public function getLatestThread() + { + $tid = -1; + $last = -1; + foreach($this->threads as $thread) { + if($thread->lastpost > $last) { + $last = $thread->lastpost; + $tid = $thread->tid; + } + } + if($tid != -1) return $this->getThread($tid); + return NULL; + } + public function show() { foreach($this->threads as $thread) { |