| 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 | if (!defined('FORUM_PORTAL')) |
|---|
| 16 | define('FORUM_PORTAL', $ext_info['path'].'/'); |
|---|
| 17 | |
|---|
| 18 | ($hook = get_hook('xn_portal_by_daris_nw_start')) ? eval($hook) : null; |
|---|
| 19 | |
|---|
| 20 | if ($forum_user['g_read_board'] == '0') |
|---|
| 21 | message($lang_common['No view']); |
|---|
| 22 | |
|---|
| 23 | // Load the viewforum.php language file |
|---|
| 24 | require FORUM_ROOT.'lang/'.$forum_user['language'].'/forum.php'; |
|---|
| 25 | |
|---|
| 26 | if (file_exists(FORUM_PORTAL.'lang/'.$forum_user['language'].'/portal.php')) |
|---|
| 27 | require FORUM_PORTAL.'lang/'.$forum_user['language'].'/portal.php'; |
|---|
| 28 | else |
|---|
| 29 | require FORUM_PORTAL.'lang/English/portal.php'; |
|---|
| 30 | |
|---|
| 31 | define('FORUM_ALLOW_INDEX', 1); |
|---|
| 32 | define('FORUM_PAGE', 'news'); |
|---|
| 33 | require FORUM_ROOT.'header.php'; |
|---|
| 34 | |
|---|
| 35 | ob_start(); |
|---|
| 36 | |
|---|
| 37 | if ($forum_config['o_portal_news_count'] == 0) |
|---|
| 38 | require FORUM_ROOT.'footer.php'; |
|---|
| 39 | |
|---|
| 40 | // Fetch list of news |
|---|
| 41 | $query = array( |
|---|
| 42 | 'SELECT' => 't.id, t.subject, t.posted, t.first_post_id, t.num_views, t.num_replies, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted', |
|---|
| 43 | 'JOINS' => array( |
|---|
| 44 | array( |
|---|
| 45 | 'LEFT JOIN' => 'posts AS p', |
|---|
| 46 | 'ON' => 't.first_post_id=p.id' |
|---|
| 47 | ), |
|---|
| 48 | array( |
|---|
| 49 | 'LEFT JOIN' => 'forum_perms AS fp', |
|---|
| 50 | 'ON' => '(fp.forum_id=t.forum_id AND fp.group_id='.$forum_user['g_id'].')' |
|---|
| 51 | ) |
|---|
| 52 | ), |
|---|
| 53 | 'FROM' => 'topics AS t', |
|---|
| 54 | 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.forum_id IN ('.(isset($forum_config['o_portal_news_forums']) ? $forum_config['o_portal_news_forums'] : 0).')', |
|---|
| 55 | 'ORDER BY' => 'p.posted DESC', |
|---|
| 56 | ); |
|---|
| 57 | |
|---|
| 58 | if (isset($forum_config['o_portal_news_count'])) |
|---|
| 59 | $query['LIMIT'] = '0, '.intval($forum_config['o_portal_news_count']); |
|---|
| 60 | |
|---|
| 61 | ($hook = get_hook('xn_portal_by_daris_nw_qr_get_news')) ? eval($hook) : null; |
|---|
| 62 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 63 | |
|---|
| 64 | ($hook = get_hook('xn_portal_by_daris_nw_pre_header_load')) ? eval($hook) : null; |
|---|
| 65 | |
|---|
| 66 | require FORUM_ROOT.'include/parser.php'; |
|---|
| 67 | |
|---|
| 68 | // Setup main head/foot options |
|---|
| 69 | $forum_page['main_head_options'] = array( |
|---|
| 70 | '<a class="feed-option" href="'.forum_link($forum_url['news_atom'], $forum_config['o_portal_news_forums']).'"><span>'.$lang_common['ATOM Feed'].'</span></a>', |
|---|
| 71 | '<a class="feed-option" href="'.forum_link($forum_url['news_rss'], $forum_config['o_portal_news_forums']).'"><span>'.$lang_common['RSS Feed'].'</span></a>' |
|---|
| 72 | ); |
|---|
| 73 | |
|---|
| 74 | ($hook = get_hook('xn_portal_by_daris_nw_main_output_start')) ? eval($hook) : null; |
|---|
| 75 | |
|---|
| 76 | // If there are news in selected forums |
|---|
| 77 | if ($forum_db->num_rows($result)) |
|---|
| 78 | { |
|---|
| 79 | while ($cur_news = $forum_db->fetch_assoc($result)) |
|---|
| 80 | { |
|---|
| 81 | ($hook = get_hook('xn_portal_by_daris_nw_news_loop_start')) ? eval($hook) : null; |
|---|
| 82 | |
|---|
| 83 | $forum_page['info'] = $forum_page['info-right'] = array(); |
|---|
| 84 | |
|---|
| 85 | $cur_news['subject'] = forum_htmlencode($cur_news['subject']); |
|---|
| 86 | |
|---|
| 87 | if ($forum_config['o_censoring'] == '1') |
|---|
| 88 | $cur_news['subject'] = censor_words($cur_news['subject']); |
|---|
| 89 | |
|---|
| 90 | $forum_page['info'][] = $lang_portal['Posted'].': '.format_time($cur_news['posted']); |
|---|
| 91 | $forum_page['info'][] = $lang_portal['Author'].': '.forum_htmlencode($cur_news['poster']); |
|---|
| 92 | |
|---|
| 93 | $forum_page['post_message'] = $cur_news['message']; |
|---|
| 94 | |
|---|
| 95 | if (utf8_strlen($forum_page['post_message']) > $forum_config['o_portal_news_description_length'] && $forum_config['o_portal_news_description_length'] > 0) |
|---|
| 96 | { |
|---|
| 97 | $forum_page['post_message'] = utf8_substr($forum_page['post_message'], 0, $forum_config['o_portal_news_description_length']).'...'; |
|---|
| 98 | $forum_page['info'][] = '<a href="'.forum_link($forum_url['topic'], array($cur_news['id'], sef_friendly($cur_news['subject']))).'">'.$lang_portal['Read more'].'</a>'; |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | $forum_page['post_message'] = parse_message($forum_page['post_message'], $cur_news['hide_smilies']); |
|---|
| 102 | |
|---|
| 103 | // $forum_page['info'][] = $lang_portal['Views'].': '.$cur_news['num_views']; |
|---|
| 104 | $forum_page['info-right'][] = '<a href="'.forum_link($forum_url['topic'], array($cur_news['id'], sef_friendly($cur_news['subject']))).'">'.$lang_portal['Comments'].': '.$cur_news['num_replies'].'</a>'; |
|---|
| 105 | |
|---|
| 106 | ($hook = get_hook('xn_portal_by_daris_nw_row_pre_display')) ? eval($hook) : null; |
|---|
| 107 | |
|---|
| 108 | ?> |
|---|
| 109 | <div class="panel"> |
|---|
| 110 | |
|---|
| 111 | <div class="main-head"> |
|---|
| 112 | <!--<?php if (!empty($forum_page['main_head_options'])) : ?> <p class="main-options"><?php echo implode(' ', $forum_page['main_head_options']) ?></p><?php endif; ?>--> |
|---|
| 113 | <h2 class="hn"><span><a href="<?php echo forum_link($forum_url['topic'], array($cur_news['id'], sef_friendly($cur_news['subject']))) ?>"><?php echo $cur_news['subject'] ?></a></span></h2> |
|---|
| 114 | </div> |
|---|
| 115 | |
|---|
| 116 | <div class="main-content news panel-content"> |
|---|
| 117 | <div class="entry-content"> |
|---|
| 118 | <?php echo $forum_page['post_message'] ?> |
|---|
| 119 | <div class="news-info-right"><?php echo implode(' | ', $forum_page['info-right']) ?></div> |
|---|
| 120 | <div class="news-info"><?php echo implode(' | ', $forum_page['info']) ?></div> |
|---|
| 121 | </div> |
|---|
| 122 | </div> |
|---|
| 123 | |
|---|
| 124 | </div> |
|---|
| 125 | |
|---|
| 126 | <?php |
|---|
| 127 | $forum_page['main_head_options'] = array(); |
|---|
| 128 | } |
|---|
| 129 | } |
|---|
| 130 | // Else there are no news in selected forums |
|---|
| 131 | else |
|---|
| 132 | { |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | ?> |
|---|
| 136 | <div class="panel"> |
|---|
| 137 | |
|---|
| 138 | <div class="main-head"> |
|---|
| 139 | <h2 class="hn"><span><?php echo $lang_portal['News'] ?></span></h2> |
|---|
| 140 | </div> |
|---|
| 141 | |
|---|
| 142 | <div class="main-content news panel-content"> |
|---|
| 143 | <div class="entry-content"> |
|---|
| 144 | <?php echo $lang_portal['No news'] ?> |
|---|
| 145 | </div> |
|---|
| 146 | </div> |
|---|
| 147 | </div> |
|---|
| 148 | <?php |
|---|
| 149 | |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | //$forum_id = $id; |
|---|
| 153 | |
|---|
| 154 | ($hook = get_hook('xn_portal_by_daris_nw_end')) ? eval($hook) : null; |
|---|
| 155 | |
|---|
| 156 | $tpl_temp = trim(ob_get_contents()); |
|---|
| 157 | $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main); |
|---|
| 158 | ob_end_clean(); |
|---|
| 159 | // END SUBST - <!-- forum_main --> |
|---|
| 160 | |
|---|
| 161 | require FORUM_ROOT.'footer.php'; |
|---|