From 008411240d192871d40bc2075911ff794ecb25a0 Mon Sep 17 00:00:00 2001 From: deva Date: Sat, 13 Mar 2010 13:43:39 +0000 Subject: Some layout changes on forum/threads. --- forum/utils/forums.php | 25 +++++++++++++++++++------ 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 @@ -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 "
\n"; - if($this->newStuff) echo "
\n"; - else echo "
\n"; - echo " fid . "\">" . $this->name . "\n"; + echo " \n"; + echo " fid . "\">" . $this->name . "\n"; + echo " ".$this->latestPost."\n"; + echo " ".sprintf("%d", $this->numPosts)." threads\n"; echo "
\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 @@ -\n"; + $newcls = ""; if($this->lastseen[$current_user->uid] < $this->lastpost) { - echo "
"; + $newcls = " thread_new"; $jumptonew = "#firstunread"; - } else { - echo "
\n"; - } + } + + echo "
\n"; + echo " "; echo " " . $this->name . "\n"; echo "
\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) { -- cgit v1.2.3