2004-06-09 21:42:23 +00:00
|
|
|
<?php
|
2004-05-24 03:40:38 +00:00
|
|
|
// Number of forum topics per page.
|
|
|
|
$threads_per_page = 50;
|
|
|
|
|
|
|
|
// print links to other pages in this forum
|
|
|
|
// If there are more than the threshold number of threads on the page,
|
|
|
|
// show only the first $thread_per_page and display links to the rest
|
|
|
|
//
|
|
|
|
//
|
|
|
|
function show_page_nav($forum) {
|
|
|
|
global $threads_per_page;
|
|
|
|
|
|
|
|
if ($forum->threads > $threads_per_page) {
|
2005-01-13 21:17:41 +00:00
|
|
|
$totalPages = ceil($forum->threads / $threads_per_page);
|
2005-05-12 14:07:22 +00:00
|
|
|
if (isset($_GET['start'])) {
|
|
|
|
$curPage = floor($_GET['start'] / $threads_per_page);
|
|
|
|
} else {
|
|
|
|
$curPage = 0;
|
|
|
|
}
|
2005-01-14 21:21:04 +00:00
|
|
|
if ($totalPages == 2) {
|
2005-01-13 21:17:41 +00:00
|
|
|
$pages = array(0, 1);
|
|
|
|
} else {
|
|
|
|
$pages = array(0, 1, 2);
|
|
|
|
}
|
2004-05-24 03:40:38 +00:00
|
|
|
for ($i = -1 ; $i <= 1 ; $i++) {
|
|
|
|
if ($curPage + $i > 0 && $curPage + $i < $totalPages - 1) {
|
|
|
|
array_push($pages, $curPage + $i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for ($i = -3 ; $i <= -1 ; $i++) {
|
|
|
|
if ($totalPages + $i > 0) {
|
|
|
|
array_push($pages, $totalPages + $i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$pages = array_unique($pages);
|
|
|
|
natsort($pages);
|
|
|
|
$pages = array_values($pages);
|
|
|
|
|
|
|
|
$gotoStr = '<p style="text-align:right">Go to page ';
|
|
|
|
|
|
|
|
if ($curPage == 0) {
|
2005-01-13 21:17:41 +00:00
|
|
|
$gotoStr .= '1 ';
|
2004-05-24 03:40:38 +00:00
|
|
|
} else {
|
2004-05-30 21:47:11 +00:00
|
|
|
$gotoStr .= '<a href="forum_forum.php?id='.$_GET['id'];
|
2004-05-24 03:40:38 +00:00
|
|
|
$gotoStr .= '&start='.(($curPage-1)*$threads_per_page);
|
2005-05-11 09:37:44 +00:00
|
|
|
if (isset($_GET["sort"])) $gotoStr .= '&sort='.$_GET["sort"];
|
2004-05-30 21:47:11 +00:00
|
|
|
$gotoStr .= '">Previous</a> <a href="forum_forum.php?id='.$_GET['id'].'&start=0">1</a>';
|
2004-05-24 03:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for ($i = 1 ; $i < count($pages)-1 ; $i++) {
|
|
|
|
if ($curPage == $pages[$i]) {
|
|
|
|
$gotoStr .= ($i > 0 && $pages[$i-1] == $pages[$i] - 1)?', ':' ... ';
|
2005-01-13 21:17:41 +00:00
|
|
|
$gotoStr .= $pages[$i]+1;
|
2004-05-24 03:40:38 +00:00
|
|
|
} else {
|
|
|
|
$gotoStr .= ($i > 0 && $pages[$i-1] == $pages[$i] - 1)?', ':' ... ';
|
2004-05-30 21:47:11 +00:00
|
|
|
$gotoStr .= '<a href="forum_forum.php?id='.$_GET['id'];
|
2004-05-24 03:40:38 +00:00
|
|
|
$gotoStr .= '&start='.($pages[$i]*$threads_per_page);
|
2005-05-11 09:37:44 +00:00
|
|
|
if (isset($_GET["sort"])) $gotoStr .= '&sort='.$_GET["sort"];
|
2004-05-24 03:40:38 +00:00
|
|
|
$gotoStr .= '">'.($pages[$i]+1).'</a>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($curPage == $totalPages-1) {
|
2005-01-13 21:17:41 +00:00
|
|
|
$gotoStr .= $totalPages;
|
2004-05-24 03:40:38 +00:00
|
|
|
} else {
|
2004-05-30 21:47:11 +00:00
|
|
|
$gotoStr .= ', <a href="forum_forum.php?id='.$_GET['id'];
|
2004-05-24 03:40:38 +00:00
|
|
|
$gotoStr .= '&start='.(($totalPages-1)*$threads_per_page);
|
2005-05-11 09:37:44 +00:00
|
|
|
if (isset($_GET["sort"])) $gotoStr .= '&sort='.$_GET["sort"];
|
2004-05-24 03:40:38 +00:00
|
|
|
$gotoStr .= '">'.$totalPages.'</a> ';
|
2004-05-30 21:47:11 +00:00
|
|
|
$gotoStr .= '<a href="forum_forum.php?id='.$_GET['id'];
|
2004-05-24 03:40:38 +00:00
|
|
|
$gotoStr .= '&start='.(($curPage+1)*$threads_per_page);
|
2005-05-11 09:37:44 +00:00
|
|
|
if (isset($_GET["sort"])) $gotoStr .= '&sort='.$_GET["sort"];
|
2004-05-24 03:40:38 +00:00
|
|
|
$gotoStr .= '">Next</a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$gotoStr .= '</p>';
|
|
|
|
|
|
|
|
echo $gotoStr;
|
|
|
|
}
|
|
|
|
return $gotoStr;
|
|
|
|
}
|
|
|
|
|
2004-09-04 23:37:49 +00:00
|
|
|
function show_forum($category, $forum, $start, $sort_style, $logged_in_user) {
|
2004-05-24 03:40:38 +00:00
|
|
|
global $threads_per_page;
|
|
|
|
$gotoStr = show_page_nav($forum);
|
|
|
|
if ($category->is_helpdesk) {
|
|
|
|
start_forum_table(array("Question", "Answers"));
|
|
|
|
} else {
|
2005-05-13 19:13:30 +00:00
|
|
|
start_forum_table(array("", "Threads", "Posts", "Author", "Views", "<nobr>Last post</nobr>"));
|
2004-05-24 03:40:38 +00:00
|
|
|
}
|
2005-04-30 10:20:49 +00:00
|
|
|
$sticky_first = !$logged_in_user->ignore_sticky_posts;
|
|
|
|
$threads = getThreads($forum->id, $start, $threads_per_page, $sort_style, 0, $sticky_first);
|
2004-05-24 03:40:38 +00:00
|
|
|
$n = 0;
|
|
|
|
|
|
|
|
while ($thread = mysql_fetch_object($threads)) {
|
|
|
|
$user = lookup_user_id($thread->owner);
|
2005-01-09 21:52:22 +00:00
|
|
|
$logged_in_user=getThreadLastVisited($logged_in_user,$thread);
|
|
|
|
$unread = ($thread->timestamp>$logged_in_user->thread_last_visited);
|
2004-12-18 19:27:37 +00:00
|
|
|
|
2004-05-24 03:40:38 +00:00
|
|
|
echo "
|
2005-01-07 18:29:20 +00:00
|
|
|
<tr class=row$n style=\"text-align:center\">";
|
2005-01-09 21:52:22 +00:00
|
|
|
|
2005-01-12 12:54:34 +00:00
|
|
|
if (!$category->is_helpdesk) { //Show thread icons if in forum:
|
2005-01-09 21:52:22 +00:00
|
|
|
echo "<td width=\"1%\" align=\"right\"><nobr>";
|
2005-01-12 12:54:34 +00:00
|
|
|
$first_post = getFirstPost($thread->id);
|
|
|
|
if ($first_post->score*$first_post->votes>$logged_in_user->high_rating_threshold) {
|
|
|
|
echo "<img src=\"".EMPHASIZE_IMAGE."\" alt=\"Emphasized thread\">";
|
|
|
|
}
|
|
|
|
if ($first_post->score*$first_post->votes<$logged_in_user->low_rating_threshold) {
|
|
|
|
echo "<img src=\"".FILTER_IMAGE."\" alt=\"Filtered thread\">";
|
2005-01-09 21:52:22 +00:00
|
|
|
}
|
2005-04-20 21:11:20 +00:00
|
|
|
if ($unread && !$thread->sticky) {
|
2005-01-09 21:52:22 +00:00
|
|
|
echo "<img src=\"".NEW_IMAGE."\" alt=\"Unread post(s)\">";
|
|
|
|
}
|
2005-04-20 21:11:20 +00:00
|
|
|
elseif($unread) {
|
|
|
|
echo "<img src=\"".NEW_IMAGE_STICKY."\" alt=\"Unread post(s)\">";
|
|
|
|
}
|
|
|
|
elseif($thread->sticky) {
|
|
|
|
echo "<img src=\"".STICKY_IMAGE."\" alt=\"Sticky\">";
|
|
|
|
}
|
2005-01-09 21:52:22 +00:00
|
|
|
echo "</nobr></td>";
|
|
|
|
}
|
2005-05-17 08:53:29 +00:00
|
|
|
|
|
|
|
$titlelength = 48;
|
2005-05-13 19:13:30 +00:00
|
|
|
$title = cleanup_title($thread->title);
|
|
|
|
if (strlen($title) > $titlelength) {
|
|
|
|
$title = substr($title,0,$titlelength)."...";
|
|
|
|
}
|
2005-05-17 08:53:29 +00:00
|
|
|
echo "<td style=\"font-size:10pt; text-align:left\"><a href=\"forum_thread.php?id=", $thread->id, "\"><b>", $title, "</b></a><br>";
|
2004-05-24 03:40:38 +00:00
|
|
|
$n = ($n+1)%2;
|
|
|
|
|
|
|
|
if ($category->is_helpdesk) {
|
2004-10-10 03:04:29 +00:00
|
|
|
$first_post = getFirstPost($thread->id);
|
2005-01-09 21:52:22 +00:00
|
|
|
$excerpt = sub_sentence($first_post->content, ' ', EXCERPT_LENGTH, true);
|
2004-05-24 03:40:38 +00:00
|
|
|
echo strip_tags(stripslashes($excerpt));
|
|
|
|
$na = $thread->sufferers + 1;
|
|
|
|
$x = time_diff_str($first_post->timestamp, time());
|
|
|
|
echo "<br><font size=-2>Asked $x; asked $na times";
|
|
|
|
}
|
|
|
|
|
2005-05-17 08:53:29 +00:00
|
|
|
echo "</td>";
|
2004-05-24 03:40:38 +00:00
|
|
|
$x = time_diff_str($thread->timestamp, time());
|
2004-09-04 23:37:49 +00:00
|
|
|
|
2004-05-24 03:40:38 +00:00
|
|
|
if ($category->is_helpdesk) {
|
|
|
|
if ($thread->replies == 0) $x = "---";
|
2005-05-17 08:53:29 +00:00
|
|
|
echo "<td align=left>
|
2004-05-24 03:40:38 +00:00
|
|
|
Total: $thread->replies
|
|
|
|
<br>Last: $x
|
2005-05-17 08:53:29 +00:00
|
|
|
</td>
|
2004-05-24 03:40:38 +00:00
|
|
|
";
|
|
|
|
} else {
|
|
|
|
echo "
|
2005-05-17 08:53:29 +00:00
|
|
|
<td>", $thread->replies+1, "</td>
|
|
|
|
<td align=left><div class=\"authorcol\">", user_links($user), "</div></td>
|
|
|
|
<td>", $thread->views, "</td>
|
|
|
|
<td style=\"text-align:right\">", $x, "</td>
|
2004-05-24 03:40:38 +00:00
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
end_forum_table();
|
|
|
|
|
|
|
|
if ($forum->threads > $n) {
|
|
|
|
echo $gotoStr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|