More work on viewtopic, still needs SQL tweeking (normal ranks arn't working)

git-svn-id: file:///svn/phpbb/trunk@82 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
James Atkinson 2001-03-05 01:40:39 +00:00
parent 476718aa43
commit 231c945e35
5 changed files with 165 additions and 31 deletions

View file

@ -105,6 +105,8 @@ $image_quote = "$url_images/quote.gif";
$image_edit = "$url_images/edit.gif";
$image_profile = "$url_images/profile.gif";
$image_email = "$url_images/email.gif";
$image_pmsg = "$url_images/pm.gif";
$image_delpost = "$url_images/edit.gif";
$image_ip = "$url_images/ip_logged.gif";

View file

@ -1,6 +1,6 @@
<tr>
<td>
<table border="0" align="center" width="100%" bgcolor="#000000" cellpadding="0" cellspacing="1">
<table border="0" align="center" width="100%" bgcolor="#000000" cellpadding="0" cellspacing="1">
<tr>
<td>
<table border="0" width="100%" cellpadding="3" cellspacing="1">
@ -14,15 +14,30 @@
<!-- BEGIN topicrow -->
<tr bgcolor="#DDDDDD" class="tablebody">
<td width="5%" align="center" valign="middle">{FOLDER}</td>
<td><a href="viewtopic.{PHPEX}?forum_id={FORUM_ID}&topic_id={TOPIC_ID}&{REPLIES}">{TOPIC_TITLE}</a></td>
<td width="5%" align="center" valign="middle">{REPLIES}</td>
<td><a href="viewtopic.{PHPEX}?forum_id={FORUM_ID}&topic_id={TOPIC_ID}&{REPLIES}">{TOPIC_TITLE}</a></td>
<td width="5%" align="center" valign="middle">{REPLIES}</td>
<td width="5%" align="center" valign="middle">{VIEWS}</td>
<td width="15%" align="center" valign="middle">{LAST_POST}</td>
</tr>
</tr>
<!-- END topicrow -->
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" align="center" width="100%" bgcolor="#000000" cellpadding="0" cellspacing="1">
<tr>
<td>
<table border="0" width="100%" cellpadding="3" cellspacing="1">
<tr bgcolor="#CCCCCC" class="tablebody">
<td align="right">{PAGINATION}</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>

View file

@ -1,6 +1,23 @@
<tr>
<td>
<table border="0" align="center" width="100%" bgcolor="#000000" cellpadding="0" cellspacing="1">
<table border="0" align="center" width="100%" bgcolor="#000000" cellpadding="0" cellspacing="1">
<tr>
<td>
<table border="0" width="100%" cellpadding="3" cellspacing="1">
<tr><td wdith="90%" class="tablebody" bgcolor="#CCCCCC">This topic is {PAGES} long. {PAGINATION}</td>
<td width="5%" class="tableheader" align="center"><a href="viewtopic.{PHPEX}?forum_id={FORUM_ID}&topic_id={TOPIC_ID}&view=older"><img src="images/prev.gif" alt="View previous topic" border="0"></a></td>
<td width="5%" class="tableheader" align="center"><a href="viewtopic.{PHPEX}?forum_id={FORUM_ID}&topic_id={TOPIC_ID}&view=newer"><img src="images/next.gif" alt="View next topic" border="0"></a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" align="center" width="100%" bgcolor="#000000" cellpadding="0" cellspacing="1">
<tr>
<td>
<table border="0" width="100%" cellpadding="3" cellspacing="1">
@ -13,6 +30,7 @@
<td width="15%" align="left" valign="top">
<font style="{font-size: 10pt; font-weight: bold;}">{POSTER_NAME}</font><br>
{POSTER_RANK}<br>
{RANK_IMAGE}<br>
<br>
<font style="{font-size: 8pt;}">
{L_JOINED}: {POSTER_JOINED}<br>{L_POSTS}: {POSTER_POSTS}<br>{POSTER_FROM}</font>
@ -20,7 +38,7 @@
<td>
<img src="images/posticon.gif"><font style="{font-size: 8pt;}">{L_POSTED}: {POST_DATE}</font><hr>
{MESSAGE}<hr>
{PROFILE_IMG} {EMAIL_IMG} {WWW_IMG} {ICQ_STATUS_IMG} {ICQ_ADD_IMG} {AIM_IMG} {YIM_IMG} {MSN_IMG} | {EDIT_IMG} {QUOTE_IMG} {PMSG_IMG} | {IP_IMG} {DELPOST_IMG}
{PROFILE_IMG}&nbsp;{EMAIL_IMG}&nbsp;{WWW_IMG}&nbsp;{ICQ_STATUS_IMG}&nbsp;{ICQ_ADD_IMG}&nbsp;{AIM_IMG}&nbsp;{YIM_IMG}&nbsp;{MSN_IMG}&nbsp;<img src="images/div.gif">&nbsp;{EDIT_IMG}&nbsp;{QUOTE_IMG}&nbsp;{PMSG_IMG}&nbsp;<img src="images/div.gif">&nbsp;{IP_IMG}&nbsp;{DELPOST_IMG}
</td>
</tr>
<!-- END postrow -->
@ -30,3 +48,19 @@
</table>
</td>
</tr>
<tr>
<td>
<table border="0" align="center" width="100%" bgcolor="#000000" cellpadding="0" cellspacing="1">
<tr>
<td>
<table border="0" width="100%" cellpadding="3" cellspacing="1">
<tr><td wdith="90%" class="tablebody" bgcolor="#CCCCCC">This topic is {PAGES} long. {PAGINATION}</td>
<td width="5%" class="tableheader" align="center"><a href="viewtopic.{PHPEX}?forum_id={FORUM_ID}&topic_id={TOPIC_ID}&view=older"><img src="images/prev.gif" alt="View previous topic" border="0"></a></td>
<td width="5%" class="tableheader" align="center"><a href="viewtopic.{PHPEX}?forum_id={FORUM_ID}&topic_id={TOPIC_ID}&view=newer"><img src="images/next.gif" alt="View next topic" border="0"></a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>

View file

@ -27,7 +27,7 @@ include('common.'.$phpEx);
// If not give them a nice error page.
if(isset($forum_id))
{
$sql = "SELECT f.forum_type, f.forum_name, u.username, u.user_id
$sql = "SELECT f.forum_type, f.forum_name, f.forum_topics, u.username, u.user_id
FROM ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u
WHERE f.forum_id = '$forum_id'
AND fm.forum_id = '$forum_id'
@ -61,6 +61,7 @@ if(!$forum_row)
}
$forum_name = stripslashes($forum_row[0]["forum_name"]);
$topics_count = $forum_row[0]["forum_topics"];
for($x = 0; $x < $db->sql_numrows($result); $x++)
{
if($x > 0)
@ -78,7 +79,7 @@ if(!isset($start))
$start = 0;
}
$sql = "SELECT t.*, u.username, p.post_time
$sql = "SELECT t.*, u.username, u.user_id, p.post_time
FROM " . TOPICS_TABLE ." t
LEFT JOIN ". USERS_TABLE. " u ON t.topic_poster = u.user_id
LEFT JOIN ".POSTS_TABLE." p ON p.post_id = t.topic_last_post_id
@ -93,26 +94,55 @@ $total_topics = $db->sql_numrows();
if($total_topics)
{
$topic_rowset = $db->sql_fetchrowset($t_result);
for($x = 0; $x < $total_topics; $x++)
{
$topic_title = stripslashes($topic_rowset[$x]["topic_title"]);
$topic_id = $topic_rowset[$x]["topic_id"];
$replies = $topic_rowset[$x]["topic_replies"];
$views = $topic_rowset[$x]["topic_views"];
$last_post_time = date($date_format, $topic_rowset[$x]["post_time"]);
$last_post_user = $topic_rowset[$x]["username"];
$folder_img = "<img src=\"images/folder.gif\">";
$template->set_var(array("FORUM_ID" => $forum_id,
"TOPIC_ID" => $topic_id,
"FOLDER" => $folder_img,
"REPLIES" => $replies,
"TOPIC_TITLE" => $topic_title,
"VIEWS" => $views,
"LAST_POST" => $last_post_time . "<br>" . $last_post_user));
$template->parse("topics", "topicrow", true);
}
$template->pparse("output", array("topics", "body"));
$topic_rowset = $db->sql_fetchrowset($t_result);
for($x = 0; $x < $total_topics; $x++)
{
$topic_title = stripslashes($topic_rowset[$x]["topic_title"]);
$topic_id = $topic_rowset[$x]["topic_id"];
$replies = $topic_rowset[$x]["topic_replies"];
$views = $topic_rowset[$x]["topic_views"];
$last_post_time = date($date_format, $topic_rowset[$x]["post_time"]);
$last_post_user = $topic_rowset[$x]["username"];
$folder_img = "<img src=\"images/folder.gif\">";
$template->set_var(array("FORUM_ID" => $forum_id,
"TOPIC_ID" => $topic_id,
"FOLDER" => $folder_img,
"REPLIES" => $replies,
"TOPIC_TITLE" => $topic_title,
"VIEWS" => $views,
"LAST_POST" => $last_post_time . "<br><a href=\"profile.$phpEx?mode=viewprofile?user_id=".$topic_rowset[$x]["user_id"]."\">" . $last_post_user ."</a>"));
$template->parse("topics", "topicrow", true);
}
$count = 1;
$next = $start + $topics_per_page;
if($topics_count > $topics_per_page)
{
if($next < $topics_count)
{
$pagination = "<a href=\"viewforum.$phpEx?forum_id=$forum_id&start=$next\">$l_nextpage</a> | ";
}
for($x = 0; $x < $topics_count; $x++)
{
if(!($x % $topics_per_page))
{
if($x == $start)
{
$pagination .= "$count";
}
else
{
$pagination .= " <a href=\"viewforum.$phpEx?forum_id=$forum_id&start=$x\">$count</a> ";
}
$count++;
if(!($count % 20))
{
$pagination .= "<br>";
}
}
}
}
$template->set_var(array("PAGINATION" => $pagination));
$template->pparse("output", array("topics", "body"));
}
else
{

View file

@ -64,7 +64,7 @@ if(!isset($start))
{
$start = 0;
}
$sql = "SELECT t.topic_title, t.topic_status, f.forum_name
$sql = "SELECT t.topic_title, t.topic_status, t.topic_replies, f.forum_name
FROM ".TOPICS_TABLE." t, ".FORUMS_TABLE." f
WHERE t.topic_id = '$topic_id' AND f.forum_id = t.forum_id";
@ -78,6 +78,8 @@ if(!$topic_info = $db->sql_fetchrowset($result))
}
$forum_name = stripslashes($topic_info[0]["forum_name"]);
$topic_title = stripslashes($topic_info[0]["topic_title"]);
$total_replies = $topic_info[0]["topic_replies"] + 1;
$pagetype = "viewtopic";
$page_title = "View Topic - $topic_title";
include('page_header.'.$phpEx);
@ -86,7 +88,7 @@ $sql = "SELECT u.*, r.rank_title, r.rank_image,
p.post_time, p.post_id, pt.post_text
FROM ".POSTS_TABLE." p
LEFT JOIN ".USERS_TABLE." u ON p.poster_id = u.user_id
LEFT JOIN ".RANKS_TABLE." r ON (u.user_rank = r.rank_id OR (u.user_posts > r.rank_min AND u.user_posts < r.rank_max))
LEFT JOIN ".RANKS_TABLE." r ON (u.user_rank = r.rank_id) AND NOT (u.user_posts > r.rank_min AND u.user_posts < r.rank_max)
LEFT JOIN ".POSTS_TEXT_TABLE." pt ON p.post_id = pt.post_id
WHERE p.topic_id = '$topic_id'
ORDER BY p.post_time ASC LIMIT $start, $posts_per_page";
@ -135,7 +137,7 @@ for($x = 0; $x < $total_posts; $x++)
$edit_img = "<a href=\"posting.$phpEx?mode=editpost&post_id=".$postrow[$x]["post_id"]."&topic_id=$topic_id&forum_id=$forum_id\"><img src=\"$image_edit\" alt=\"$l_editdelete\" border=\"0\"></a>";
$quote_img = "<a href=\"posting.$phpEx?mode=reply&quote=true&post_id=".$postrow[$x]["post_id"]."&topic_id=$topic_id&forum_id=$forum_id\"><img src=\"$image_quote\" alt=\"$l_replyquote\" border=\"0\"></a>";
$pmsg_img = "<a href=\"priv_msgs.$phpEx?mode=send\"><img src=\"$image_pmsg\" alt=\"$l_sendpsmg\" border=\"0\"></a>";
$pmsg_img = "<a href=\"priv_msgs.$phpEx?mode=send\"><img src=\"$image_pmsg\" alt=\"$l_sendpmsg\" border=\"0\"></a>";
if($is_moderator)
{
$ip_img = "<a href=\"topicadmin.$phpEx?mode=viewip&user_id=".$poster_id."\"><img src=\"$image_ip\" alt=\"$l_viewip\" border=\"0\"></a>";
@ -190,6 +192,57 @@ for($x = 0; $x < $total_posts; $x++)
"DELPOST_IMG" => $delpost_img));
$template->parse("posts", "postrow", true);
}
if($total_replies > $posts_per_page)
{
$times = 0;
for($x = 0; $x < $total_replies; $x += $posts_per_page)
{
$times++;
}
$pages = $times . " pages";
$times = 1;
$pagination = "$l_gotopage (";
$last_page = $start - $posts_per_page;
if($start > 0)
{
$pagination .= "<a href=\"$PHP_SELF?topic_id=$topic_id&forum_id=$forum_id&start=$last_page\">$l_prevpage</a> ";
}
for($x = 0; $x < $total_replies; $x += $posts_per_page)
{
if($times != 1)
{
$pagination .= " | ";
}
if($start && ($start == $x))
{
$pagination .= $times;
}
else if($start == 0 && $x == 0)
{
$pagination .= "1";
}
else
{
$pagination .= "<a href=\"$PHP_SELF?topic_id=$topic_id&forum_id=$forum_id&start=$x\">$times</a>";
}
$times++;
}
if(($start + $posts_per_page) < $total_replies)
{
$next_page = $start + $posts_per_page;
$pagination .= " <a href=\"$PHP_SELF?topic_id=$topic_id&forum_id=$forum_id&start=$next_page\">$l_nextpage</a>";
}
$pagination .= " )";
}
else
{
$pages = "1 page";
}
$template->set_var(array("PAGES" => $pages,
"PAGINATION" => $pagination));
$template->pparse("output", array("posts", "body"));
include('page_tail.'.$phpEx);