From 231c945e35ea8550bf2e1acbe79e125b9e69db61 Mon Sep 17 00:00:00 2001 From: James Atkinson Date: Mon, 5 Mar 2001 01:40:39 +0000 Subject: [PATCH] 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 --- phpBB/config.php | 2 + phpBB/templates/Default/viewforum_body.tpl | 23 +++++-- phpBB/templates/Default/viewtopic_body.tpl | 38 ++++++++++- phpBB/viewforum.php | 74 +++++++++++++++------- phpBB/viewtopic.php | 59 ++++++++++++++++- 5 files changed, 165 insertions(+), 31 deletions(-) diff --git a/phpBB/config.php b/phpBB/config.php index b6cefb27d3..43dab2004c 100644 --- a/phpBB/config.php +++ b/phpBB/config.php @@ -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"; diff --git a/phpBB/templates/Default/viewforum_body.tpl b/phpBB/templates/Default/viewforum_body.tpl index 7c00fc65d5..d09e73daa0 100644 --- a/phpBB/templates/Default/viewforum_body.tpl +++ b/phpBB/templates/Default/viewforum_body.tpl @@ -1,6 +1,6 @@ - +
@@ -14,15 +14,30 @@ - - + + - +
{FOLDER}{TOPIC_TITLE}{REPLIES}{TOPIC_TITLE}{REPLIES} {VIEWS} {LAST_POST}
+ + + + + + + + +
+ + + + +
{PAGINATION}
+
diff --git a/phpBB/templates/Default/viewtopic_body.tpl b/phpBB/templates/Default/viewtopic_body.tpl index e1bd52e275..5735a21cff 100644 --- a/phpBB/templates/Default/viewtopic_body.tpl +++ b/phpBB/templates/Default/viewtopic_body.tpl @@ -1,6 +1,23 @@ - +
+ + + +
+ + + + + +
This topic is {PAGES} long. {PAGINATION}View previous topicView next topic
+
+ + + + + + + + + diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 094e5ee61f..07e801fe32 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -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 = ""; - $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 . "
" . $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 = ""; + $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 . "
" . $last_post_user ."")); + $template->parse("topics", "topicrow", true); + } + $count = 1; + $next = $start + $topics_per_page; + if($topics_count > $topics_per_page) + { + if($next < $topics_count) + { + $pagination = "$l_nextpage | "; + } + for($x = 0; $x < $topics_count; $x++) + { + if(!($x % $topics_per_page)) + { + if($x == $start) + { + $pagination .= "$count"; + } + else + { + $pagination .= " $count "; + } + $count++; + if(!($count % 20)) + { + $pagination .= "
"; + } + } + } + } + $template->set_var(array("PAGINATION" => $pagination)); + $template->pparse("output", array("topics", "body")); } else { diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index fba5d0352a..ebedb1b5c3 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -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 = "\"$l_editdelete\""; $quote_img = "\"$l_replyquote\""; - $pmsg_img = "\"$l_sendpsmg\""; + $pmsg_img = "\"$l_sendpmsg\""; if($is_moderator) { $ip_img = "\"$l_viewip\""; @@ -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 .= "$l_prevpage "; + } + 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 .= "$times"; + } + $times++; + } + if(($start + $posts_per_page) < $total_replies) + { + $next_page = $start + $posts_per_page; + $pagination .= " $l_nextpage"; + } + $pagination .= " )"; +} +else +{ + $pages = "1 page"; +} +$template->set_var(array("PAGES" => $pages, + "PAGINATION" => $pagination)); $template->pparse("output", array("posts", "body")); include('page_tail.'.$phpEx);
@@ -13,6 +30,7 @@ @@ -30,3 +48,19 @@
{POSTER_NAME}
{POSTER_RANK}
+ {RANK_IMAGE}

{L_JOINED}: {POSTER_JOINED}
{L_POSTS}: {POSTER_POSTS}
{POSTER_FROM}
@@ -20,7 +38,7 @@
{L_POSTED}: {POST_DATE}
{MESSAGE}
- {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} {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}
+ + + + +
+ + + + + +
This topic is {PAGES} long. {PAGINATION}View previous topicView next topic
+
+