| 1 | <?php |
|---|
| 2 | /*********************************************************************** |
|---|
| 3 | |
|---|
| 4 | PunBB extension |
|---|
| 5 | Portal |
|---|
| 6 | Daris <daris91@gmail.com> |
|---|
| 7 | |
|---|
| 8 | ************************************************************************/ |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | // Make sure no one attempts to run this script "directly" |
|---|
| 12 | if (!defined('FORUM')) |
|---|
| 13 | exit; |
|---|
| 14 | |
|---|
| 15 | $count = 5; // active topics count |
|---|
| 16 | $cur_panel['class'] = 'forum'; |
|---|
| 17 | |
|---|
| 18 | // Load the viewforum.php language file |
|---|
| 19 | require_once FORUM_ROOT.'lang/'.$forum_user['language'].'/forum.php'; |
|---|
| 20 | require_once FORUM_ROOT.'lang/'.$forum_user['language'].'/search.php'; |
|---|
| 21 | |
|---|
| 22 | // Fetch list of topics |
|---|
| 23 | $query = array( |
|---|
| 24 | 'SELECT' => 't.id, t.poster, t.subject, t.posted, t.first_post_id, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.forum_id', |
|---|
| 25 | 'FROM' => 'topics AS t', |
|---|
| 26 | 'JOINS' => array( |
|---|
| 27 | array( |
|---|
| 28 | 'LEFT JOIN' => 'forums as f', |
|---|
| 29 | 'ON' => 't.forum_id=f.id' |
|---|
| 30 | ), |
|---|
| 31 | array( |
|---|
| 32 | 'LEFT JOIN' => 'forum_perms AS fp', |
|---|
| 33 | 'ON' => '(fp.forum_id=t.forum_id AND fp.group_id='.$forum_user['g_id'].')' |
|---|
| 34 | ) |
|---|
| 35 | ), |
|---|
| 36 | 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL', |
|---|
| 37 | 'ORDER BY' => 't.last_post DESC', |
|---|
| 38 | 'LIMIT' => '0, '.$count |
|---|
| 39 | ); |
|---|
| 40 | |
|---|
| 41 | // With "has posted" indication |
|---|
| 42 | if (!$forum_user['is_guest'] && $forum_config['o_show_dot'] == '1') |
|---|
| 43 | { |
|---|
| 44 | $subquery = array( |
|---|
| 45 | 'SELECT' => 'COUNT(p.id)', |
|---|
| 46 | 'FROM' => 'posts AS p', |
|---|
| 47 | 'WHERE' => 'p.poster_id='.$forum_user['id'].' AND p.topic_id=t.id' |
|---|
| 48 | ); |
|---|
| 49 | |
|---|
| 50 | ($hook = get_hook('xn_portal_by_daris_at_qr_get_has_posted')) ? eval($hook) : null; |
|---|
| 51 | $query['SELECT'] .= ', ('.$forum_db->query_build($subquery, true).') AS has_posted'; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | ($hook = get_hook('xn_portal_by_daris_at_qr_get_topics')) ? eval($hook) : null; |
|---|
| 55 | $result_at = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 56 | |
|---|
| 57 | // Get topic/forum tracking data |
|---|
| 58 | if (!$forum_user['is_guest']) |
|---|
| 59 | $tracked_topics = get_tracked_topics(); |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | ($hook = get_hook('xn_portal_by_daris_at_pre_header_load')) ? eval($hook) : null; |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | $forum_page['item_header'] = array(); |
|---|
| 66 | $forum_page['item_header']['subject']['title'] = '<strong class="subject-title">'.$lang_forum['Topics'].'</strong>'; |
|---|
| 67 | $forum_page['item_header']['info']['replies'] = '<strong class="info-replies">'.$lang_forum['replies'].'</strong>'; |
|---|
| 68 | |
|---|
| 69 | if ($forum_config['o_topic_views'] == '1') |
|---|
| 70 | $forum_page['item_header']['info']['views'] = '<strong class="info-views">'.$lang_forum['views'].'</strong>'; |
|---|
| 71 | |
|---|
| 72 | $forum_page['item_header']['info']['lastpost'] = '<strong class="info-lastpost">'.$lang_forum['last post'].'</strong>'; |
|---|
| 73 | |
|---|
| 74 | ($hook = get_hook('xn_portal_by_daris_at_main_output_start')) ? eval($hook) : null; |
|---|
| 75 | |
|---|
| 76 | // If there are topics in this forum |
|---|
| 77 | if ($forum_db->num_rows($result_at)) |
|---|
| 78 | { |
|---|
| 79 | |
|---|
| 80 | ?> |
|---|
| 81 | <div class="main-subhead"> |
|---|
| 82 | <p class="item-summary<?php echo ($forum_config['o_topic_views'] == '1') ? ' forum-views' : ' forum-noview' ?>"><span><?php printf($lang_forum['Forum subtitle'], implode(' ', $forum_page['item_header']['subject']), implode(', ', $forum_page['item_header']['info'])) ?></span></p> |
|---|
| 83 | </div> |
|---|
| 84 | <div id="forum" class="main-content main-forum<?php echo ($forum_config['o_topic_views'] == '1') ? ' forum-views' : ' forum-noview' ?>"> |
|---|
| 85 | <?php |
|---|
| 86 | |
|---|
| 87 | ($hook = get_hook('xn_portal_by_daris_at_pre_topic_loop_start')) ? eval($hook) : null; |
|---|
| 88 | |
|---|
| 89 | $forum_page['item_count'] = 0; |
|---|
| 90 | |
|---|
| 91 | while ($cur_topic = $forum_db->fetch_assoc($result_at)) |
|---|
| 92 | { |
|---|
| 93 | ($hook = get_hook('xn_portal_by_daris_at_topic_loop_start')) ? eval($hook) : null; |
|---|
| 94 | |
|---|
| 95 | ++$forum_page['item_count']; |
|---|
| 96 | |
|---|
| 97 | // Start from scratch |
|---|
| 98 | $forum_page['item_subject'] = $forum_page['item_body'] = $forum_page['item_status'] = $forum_page['item_nav'] = $forum_page['item_title'] = $forum_page['item_title_status'] = array(); |
|---|
| 99 | $forum_page['item_indicator'] = ''; |
|---|
| 100 | |
|---|
| 101 | if ($forum_config['o_censoring'] == '1') |
|---|
| 102 | $cur_topic['subject'] = censor_words($cur_topic['subject']); |
|---|
| 103 | |
|---|
| 104 | if ($cur_topic['moved_to'] != null) |
|---|
| 105 | { |
|---|
| 106 | $forum_page['item_status']['moved'] = 'moved'; |
|---|
| 107 | $forum_page['item_title']['link'] = '<span class="item-status"><em class="moved">'.sprintf($lang_forum['Item status'], $lang_forum['Moved']).'</em></span> <a href="'.forum_link($forum_url['topic'], array($cur_topic['moved_to'], sef_friendly($cur_topic['subject']))).'">'.forum_htmlencode($cur_topic['subject']).'</a>'; |
|---|
| 108 | |
|---|
| 109 | // Combine everything to produce the Topic heading |
|---|
| 110 | $forum_page['item_body']['subject']['title'] = '<h3 class="hn"><span class="item-num">'.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).'</span>'.$forum_page['item_title']['link'].'</h3>'; |
|---|
| 111 | |
|---|
| 112 | ($hook = get_hook('xn_portal_by_daris_at_topic_loop_moved_topic_pre_item_subject_merge')) ? eval($hook) : null; |
|---|
| 113 | |
|---|
| 114 | if ($forum_config['o_topic_views'] == '1') |
|---|
| 115 | $forum_page['item_body']['info']['views'] = '<li class="info-views"><span class="label">'.$lang_forum['No views info'].'</span></li>'; |
|---|
| 116 | |
|---|
| 117 | $forum_page['item_body']['info']['replies'] = '<li class="info-replies"><span class="label">'.$lang_forum['No replies info'].'</span></li>'; |
|---|
| 118 | $forum_page['item_body']['info']['lastpost'] = '<li class="info-lastpost"><span class="label">'.$lang_forum['No lastpost info'].'</span></li>'; |
|---|
| 119 | } |
|---|
| 120 | else |
|---|
| 121 | { |
|---|
| 122 | // Assemble the Topic heading |
|---|
| 123 | |
|---|
| 124 | // Should we display the dot or not? :) |
|---|
| 125 | if (!$forum_user['is_guest'] && $forum_config['o_show_dot'] == '1' && $cur_topic['has_posted'] > 0) |
|---|
| 126 | { |
|---|
| 127 | $forum_page['item_title']['posted'] = '<span class="posted-mark">'.$lang_forum['You posted indicator'].'</span>'; |
|---|
| 128 | $forum_page['item_status']['posted'] = 'posted'; |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | if ($cur_topic['sticky'] == '1') |
|---|
| 132 | { |
|---|
| 133 | $forum_page['item_title_status']['sticky'] = '<em class="sticky">'.$lang_forum['Sticky'].'</em>'; |
|---|
| 134 | $forum_page['item_status']['sticky'] = 'sticky'; |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | if ($cur_topic['closed'] == '1') |
|---|
| 138 | { |
|---|
| 139 | $forum_page['item_title_status']['closed'] = '<em class="closed">'.$lang_forum['Closed'].'</em>'; |
|---|
| 140 | $forum_page['item_status']['closed'] = 'closed'; |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | ($hook = get_hook('xn_portal_by_daris_at_topic_loop_normal_topic_pre_item_title_status_merge')) ? eval($hook) : null; |
|---|
| 144 | |
|---|
| 145 | if (!empty($forum_page['item_title_status'])) |
|---|
| 146 | $forum_page['item_title']['status'] = '<span class="item-status">'.sprintf($lang_forum['Item status'], implode(', ', $forum_page['item_title_status'])).'</span>'; |
|---|
| 147 | |
|---|
| 148 | $forum_page['item_title']['link'] = '<a href="'.forum_link($forum_url['topic'], array($cur_topic['id'], sef_friendly($cur_topic['subject']))).'">'.forum_htmlencode($cur_topic['subject']).'</a>'; |
|---|
| 149 | |
|---|
| 150 | ($hook = get_hook('xn_portal_by_daris_at_topic_loop_normal_topic_pre_item_title_merge')) ? eval($hook) : null; |
|---|
| 151 | |
|---|
| 152 | $forum_page['item_body']['subject']['title'] = '<h3 class="hn"><span class="item-num">'.$forum_page['item_count'].'</span> '.implode(' ', $forum_page['item_title']).'</h3>'; |
|---|
| 153 | |
|---|
| 154 | // Assemble the Topic subject |
|---|
| 155 | |
|---|
| 156 | if (empty($forum_page['item_status'])) |
|---|
| 157 | $forum_page['item_status']['normal'] = 'normal'; |
|---|
| 158 | |
|---|
| 159 | $forum_page['item_pages'] = ceil(($cur_topic['num_replies'] + 1) / $forum_user['disp_posts']); |
|---|
| 160 | |
|---|
| 161 | if ($forum_page['item_pages'] > 1) |
|---|
| 162 | $forum_page['item_nav']['pages'] = '<span>'.$lang_forum['Pages'].' </span>'.paginate($forum_page['item_pages'], -1, $forum_url['topic'], $lang_common['Page separator'], array($cur_topic['id'], sef_friendly($cur_topic['subject']))); |
|---|
| 163 | |
|---|
| 164 | // Does this topic contain posts we haven't read? If so, tag it accordingly. |
|---|
| 165 | if (!$forum_user['is_guest'] && $cur_topic['last_post'] > $forum_user['last_visit'] && (!isset($tracked_topics['topics'][$cur_topic['id']]) || $tracked_topics['topics'][$cur_topic['id']] < $cur_topic['last_post'])) |
|---|
| 166 | { |
|---|
| 167 | $forum_page['item_nav']['new'] = '<em class="item-newposts"><a href="'.forum_link($forum_url['topic_new_posts'], array($cur_topic['id'], sef_friendly($cur_topic['subject']))).'">'.$lang_forum['New posts'].'</a></em>'; |
|---|
| 168 | $forum_page['item_status']['new'] = 'new'; |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | ($hook = get_hook('xn_portal_by_daris_at_topic_loop_normal_topic_pre_item_nav_merge')) ? eval($hook) : null; |
|---|
| 172 | |
|---|
| 173 | if (!empty($forum_page['item_nav'])) |
|---|
| 174 | $forum_page['item_subject']['nav'] = '<span class="item-nav">'.sprintf($lang_forum['Topic navigation'], implode('  ', $forum_page['item_nav'])).'</span>'; |
|---|
| 175 | |
|---|
| 176 | ($hook = get_hook('xn_portal_by_daris_at_topic_loop_normal_topic_pre_item_subject_merge')) ? eval($hook) : null; |
|---|
| 177 | |
|---|
| 178 | $forum_page['item_body']['info']['replies'] = '<li class="info-replies"><strong>'.forum_number_format($cur_topic['num_replies']).'</strong> <span class="label">'.(($cur_topic['num_replies'] == 1) ? $lang_forum['reply'] : $lang_forum['replies']).'</span></li>'; |
|---|
| 179 | |
|---|
| 180 | if ($forum_config['o_topic_views'] == '1') |
|---|
| 181 | $forum_page['item_body']['info']['views'] = '<li class="info-views"><strong>'.forum_number_format($cur_topic['num_views']).'</strong> <span class="label">'.(($cur_topic['num_views'] == 1) ? $lang_forum['view'] : $lang_forum['views']).'</span></li>'; |
|---|
| 182 | |
|---|
| 183 | $forum_page['item_body']['info']['lastpost'] = '<li class="info-lastpost"><span class="label">'.$lang_forum['Last post'].'</span> <strong><a href="'.forum_link($forum_url['post'], $cur_topic['last_post_id']).'">'.format_time($cur_topic['last_post']).'</a></strong> <cite>'.sprintf($lang_forum['by poster'], forum_htmlencode($cur_topic['last_poster'])).'</cite></li>'; |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | $forum_page['item_subject']['starter'] = '<span class="item-starter">'.sprintf($lang_forum['Topic starter'], '<cite>'.forum_htmlencode($cur_topic['poster']).'</cite>').'</span>'; |
|---|
| 187 | $forum_page['item_body']['subject']['desc'] = implode(' ', $forum_page['item_subject']); |
|---|
| 188 | |
|---|
| 189 | ($hook = get_hook('xn_portal_by_daris_at_row_pre_item_status_merge')) ? eval($hook) : null; |
|---|
| 190 | |
|---|
| 191 | $forum_page['item_style'] = (($forum_page['item_count'] % 2 != 0) ? ' odd' : ' even').(($forum_page['item_count'] == 1) ? ' main-first-item' : '').((!empty($forum_page['item_status'])) ? ' '.implode(' ', $forum_page['item_status']) : ''); |
|---|
| 192 | |
|---|
| 193 | ($hook = get_hook('xn_portal_by_daris_at_row_pre_display')) ? eval($hook) : null; |
|---|
| 194 | |
|---|
| 195 | ?> |
|---|
| 196 | <div id="topic<?php echo $cur_topic['id'] ?>" class="main-item<?php echo $forum_page['item_style'] ?>"> |
|---|
| 197 | <span class="icon <?php echo implode(' ', $forum_page['item_status']) ?>"><!-- --></span> |
|---|
| 198 | <div class="item-subject"> |
|---|
| 199 | <?php echo implode("\n\t\t\t\t", $forum_page['item_body']['subject'])."\n" ?> |
|---|
| 200 | </div> |
|---|
| 201 | <ul class="item-info"> |
|---|
| 202 | <?php echo implode("\n\t\t\t\t", $forum_page['item_body']['info'])."\n" ?> |
|---|
| 203 | </ul> |
|---|
| 204 | </div> |
|---|
| 205 | <?php |
|---|
| 206 | |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | ?> |
|---|
| 210 | </div> |
|---|
| 211 | <?php |
|---|
| 212 | |
|---|
| 213 | } |
|---|
| 214 | // Else there are no topics in this forum |
|---|
| 215 | else |
|---|
| 216 | { |
|---|
| 217 | $forum_page['item_body']['subject']['title'] = '<h3 class="hn">'.$lang_forum['No topics'].'</h3>'; |
|---|
| 218 | $forum_page['item_body']['subject']['desc'] = '<p>'.$lang_forum['First topic nag'].'</p>'; |
|---|
| 219 | |
|---|
| 220 | ($hook = get_hook('xn_portal_by_daris_at_no_results_row_pre_display')) ? eval($hook) : null; |
|---|
| 221 | |
|---|
| 222 | ?> |
|---|
| 223 | <div id="forum" class="main-content main-forum"> |
|---|
| 224 | <div class="main-item empty main-first-item"> |
|---|
| 225 | <span class="icon empty"><!-- --></span> |
|---|
| 226 | <div class="item-subject"> |
|---|
| 227 | <?php echo implode("\n\t\t\t\t", $forum_page['item_body']['subject'])."\n" ?> |
|---|
| 228 | </div> |
|---|
| 229 | </div> |
|---|
| 230 | </div> |
|---|
| 231 | <?php |
|---|
| 232 | |
|---|
| 233 | } |
|---|
| 234 | ?> |
|---|
| 235 | <div class="main-options gen-content"> |
|---|
| 236 | <p class="options"> |
|---|
| 237 | <span class="item1"><a href="<?php echo forum_link($forum_url['search_recent']) ?>"><?php echo $lang_search['Recently active topics'] ?></a></span> |
|---|
| 238 | <span><a href="<?php echo forum_link($forum_url['search_unanswered']) ?>"><?php echo $lang_search['Unanswered topics'] ?></a></span> |
|---|
| 239 | <?php if (!$forum_user['is_guest']): ?> |
|---|
| 240 | <span><a href="<?php echo forum_link($forum_url['search_subscriptions'], array($forum_user['id'])) ?>"><?php echo $lang_search['Subscriptions'] ?></a></span> |
|---|
| 241 | <?php endif; ?> |
|---|
| 242 | </p> |
|---|
| 243 | </div> |
|---|