Report#35,82,84:Mouseover in compact view (news), archive news system, pagnition for news / announcements - as well as a switch to choose if the newest or the first post (link in compact view) should be shown, configurable in ACP
This commit is contained in:
@@ -19,9 +19,74 @@ if (!defined('IN_PORTAL'))
|
||||
}
|
||||
|
||||
$announcement = request_var('announcement', -1);
|
||||
|
||||
$start = request_var('ap', 0);
|
||||
$start = ($start < 0) ? 0 : $start;
|
||||
|
||||
// Pagnition
|
||||
if ( $portal_config['portal_announcements_archive'] )
|
||||
{
|
||||
$permissions = $portal_config['portal_announcements_permissions'];
|
||||
$forum_from = $portal_config['portal_global_announcements_forum'];
|
||||
|
||||
$forum_from = ( strpos($forum_from, ',') !== FALSE ) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
|
||||
|
||||
$str_where = '';
|
||||
|
||||
if( $permissions == TRUE )
|
||||
{
|
||||
$disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
|
||||
} else {
|
||||
$disallow_access = array();
|
||||
}
|
||||
|
||||
$global_f = 0;
|
||||
|
||||
if( sizeof($forum_from) )
|
||||
{
|
||||
$disallow_access = array_diff($forum_from, $disallow_access);
|
||||
if( !sizeof($disallow_access) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
foreach( $disallow_access as $acc_id)
|
||||
{
|
||||
$acc_id = (int) $acc_id;
|
||||
$str_where .= "forum_id = $acc_id OR ";
|
||||
if( $type == 'announcements' && $global_f < 1 && $acc_id > 0 )
|
||||
{
|
||||
$global_f = $acc_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach( $disallow_access as $acc_id )
|
||||
{
|
||||
$acc_id = (int) $acc_id;
|
||||
$str_where .= "forum_id <> $acc_id AND ";
|
||||
}
|
||||
}
|
||||
|
||||
$str_where = ( strlen($str_where) > 0 ) ? 'AND (forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : '';
|
||||
|
||||
$sql = 'SELECT COUNT(topic_id) AS num_topics
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE ((topic_type = ' . POST_GLOBAL . ')
|
||||
OR topic_type = ' . POST_ANNOUNCE . ')
|
||||
AND topic_approved = 1
|
||||
AND topic_moved_id = 0
|
||||
' . $str_where;
|
||||
$result = $db->sql_query($sql);
|
||||
$total_announcements = (int) $db->sql_fetchfield('num_topics');
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
|
||||
if($announcement < 0)
|
||||
{
|
||||
$fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_forum'], $portal_config['portal_announcements_permissions'], $portal_config['portal_number_of_announcements'], $portal_config['portal_announcements_length'], $portal_config['portal_announcements_day'], 'announcements');
|
||||
$fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_forum'], $portal_config['portal_announcements_permissions'], $portal_config['portal_number_of_announcements'], $portal_config['portal_announcements_length'], $portal_config['portal_announcements_day'], 'announcements', $start);
|
||||
|
||||
if (count($fetch_news) == 0)
|
||||
{
|
||||
@@ -57,6 +122,13 @@ if($announcement < 0)
|
||||
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||
|
||||
$real_forum_id = ( $forum_id == 0 ) ? $fetch_news['global_id']: $forum_id;
|
||||
|
||||
$read_full_url = (isset($_GET['ap'])) ? 'ap='. $start . '&announcement=' . $i . '#a' . $i : 'announcement=' . $i . '#a' . $i;
|
||||
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
|
||||
if ( $portal_config['portal_announcements_archive'] )
|
||||
{
|
||||
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $portal_config['portal_number_of_announcements'], $start, 'announcements');
|
||||
}
|
||||
|
||||
$template->assign_block_vars('announcements_row', array(
|
||||
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
@@ -69,25 +141,35 @@ if($announcement < 0)
|
||||
'TEXT' => $fetch_news[$i]['post_text'],
|
||||
'REPLIES' => $fetch_news[$i]['topic_replies'],
|
||||
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
|
||||
'A_ID' => $i,
|
||||
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
|
||||
'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 'p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
|
||||
'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id),
|
||||
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id),
|
||||
'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", 'announcement=' . $i),
|
||||
'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url),
|
||||
'L_READ_FULL' => $read_full,
|
||||
'OPEN' => $open_bracket,
|
||||
'CLOSE' => $close_bracket,
|
||||
'S_NOT_LAST' => ($i < count($fetch_news) - 1) ? true : false,
|
||||
'S_POLL' => $fetch_news[$i]['poll'],
|
||||
// 'MINI_POST_IMG' => $user->img('icon_post_target', 'POST'),
|
||||
'S_UNREAD_INFO' => $unread_topic,
|
||||
'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
|
||||
));
|
||||
|
||||
if ($portal_config['portal_number_of_announcements'] <> 0 && $portal_config['portal_announcements_archive'])
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'AP_PAGINATION' => $pagination,
|
||||
'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
|
||||
'AP_PAGE_NUMBER' => on_page($total_announcements, $portal_config['portal_number_of_announcements'], $start))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_forum'], $portal_config['portal_announcements_permissions'], $portal_config['portal_number_of_announcements'], 0, $portal_config['portal_announcements_day'], 'announcements');
|
||||
$fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_forum'], $portal_config['portal_announcements_permissions'], $portal_config['portal_number_of_announcements'], 0, $portal_config['portal_announcements_day'], 'announcements', $start);
|
||||
|
||||
$i = $announcement;
|
||||
$forum_id = $fetch_news[$i]['forum_id'];
|
||||
@@ -98,33 +180,51 @@ else
|
||||
$close_bracket = ' ]';
|
||||
$read_full = $user->lang['BACK'];
|
||||
|
||||
$read_full_url = (isset($_GET['ap'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "ap=$start#a$i") : append_sid("{$phpbb_root_path}portal.$phpEx#a$i");
|
||||
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
|
||||
if ( $portal_config['portal_announcements_archive'] )
|
||||
{
|
||||
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $portal_config['portal_number_of_announcements'], $start, 'announcements');
|
||||
}
|
||||
|
||||
$template->assign_block_vars('announcements_row', array(
|
||||
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
'FORUM_NAME' => ( $forum_id ) ? $fetch_news[$i]['forum_name'] : '',
|
||||
'TITLE' => $fetch_news[$i]['topic_title'],
|
||||
'POSTER' => $fetch_news[$i]['username'],
|
||||
'POSTER_FULL' => $fetch_news[$i]['username_full'],
|
||||
'TIME' => $fetch_news[$i]['topic_time'],
|
||||
'TEXT' => $fetch_news[$i]['post_text'],
|
||||
'REPLIES' => $fetch_news[$i]['topic_replies'],
|
||||
'TITLE' => $fetch_news[$i]['topic_title'],
|
||||
'POSTER' => $fetch_news[$i]['username'],
|
||||
'POSTER_FULL' => $fetch_news[$i]['username_full'],
|
||||
'TIME' => $fetch_news[$i]['topic_time'],
|
||||
'TEXT' => $fetch_news[$i]['post_text'],
|
||||
'REPLIES' => $fetch_news[$i]['topic_replies'],
|
||||
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
|
||||
'A_ID' => $i,
|
||||
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
|
||||
'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($forum_id) ? 'f=' . $forum_id . '&' : '') . 'p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
|
||||
'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id),
|
||||
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&' . (($forum_id) ? 'f=' . $forum_id . '&' : '') . 't=' . $topic_id),
|
||||
'S_POLL' => $fetch_news[$i]['poll'],
|
||||
'S_POLL' => $fetch_news[$i]['poll'],
|
||||
'S_UNREAD_INFO' => $unread_topic,
|
||||
'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx"),
|
||||
'L_READ_FULL' => $read_full,
|
||||
'OPEN' => $open_bracket,
|
||||
'U_READ_FULL' => $read_full_url,
|
||||
'L_READ_FULL' => $read_full,
|
||||
'OPEN' => $open_bracket,
|
||||
'CLOSE' => $close_bracket,
|
||||
|
||||
'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
|
||||
));
|
||||
|
||||
if ($portal_config['portal_number_of_announcements'] <> 0 && $portal_config['portal_announcements_archive'])
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'AP_PAGINATION' => $pagination,
|
||||
'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
|
||||
'AP_PAGE_NUMBER' => on_page($total_announcements, $portal_config['portal_number_of_announcements'], $start))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
|
||||
'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_NEWEST_POST'),
|
||||
'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'),
|
||||
'S_DISPLAY_ANNOUNCEMENTS' => true,
|
||||
));
|
||||
|
||||
|
||||
@@ -26,14 +26,74 @@ if (!defined('IN_PORTAL'))
|
||||
$template->assign_vars(array(
|
||||
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
|
||||
'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_NEWEST_POST'),
|
||||
'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'),
|
||||
'S_DISPLAY_NEWS' => true,
|
||||
));
|
||||
|
||||
#if (!isset($HTTP_GET_VARS['article']))
|
||||
$news = request_var('news', -1);
|
||||
|
||||
$user->add_lang('viewforum');
|
||||
$start = request_var('np', 0);
|
||||
$start = ($start < 0) ? 0 : $start;
|
||||
|
||||
// Pagnition
|
||||
if ( $portal_config['portal_news_archive'] )
|
||||
{
|
||||
$permissions = $portal_config['portal_news_permissions'];
|
||||
$forum_from = $portal_config['portal_news_forum'];
|
||||
|
||||
$forum_from = ( strpos($forum_from, ',') !== FALSE ) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
|
||||
|
||||
$str_where = '';
|
||||
|
||||
if( $permissions == TRUE )
|
||||
{
|
||||
$disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
|
||||
} else {
|
||||
$disallow_access = array();
|
||||
}
|
||||
|
||||
if( sizeof($forum_from) )
|
||||
{
|
||||
$disallow_access = array_diff($forum_from, $disallow_access);
|
||||
if( !sizeof($disallow_access) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
foreach( $disallow_access as $acc_id)
|
||||
{
|
||||
$acc_id = (int) $acc_id;
|
||||
$str_where .= "forum_id = $acc_id OR ";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach( $disallow_access as $acc_id )
|
||||
{
|
||||
$acc_id = (int) $acc_id;
|
||||
$str_where .= "forum_id <> $acc_id AND ";
|
||||
}
|
||||
}
|
||||
|
||||
$str_where = ( strlen($str_where) > 0 ) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
|
||||
|
||||
$topic_type = ($portal_config['portal_show_all_news']) ? '( topic_type <> ' . POST_ANNOUNCE . ' ) AND ( topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL;
|
||||
|
||||
$sql = 'SELECT COUNT(topic_id) AS num_topics
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $topic_type . '
|
||||
AND topic_approved = 1
|
||||
AND topic_moved_id = 0
|
||||
' . $str_where;
|
||||
$result = $db->sql_query($sql);
|
||||
$total_news = (int) $db->sql_fetchfield('num_topics');
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if($news < 0)
|
||||
{
|
||||
$fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_config['portal_news_permissions'], $portal_config['portal_number_of_news'], $portal_config['portal_news_length'], 0, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news');
|
||||
$fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_config['portal_news_permissions'], $portal_config['portal_number_of_news'], $portal_config['portal_news_length'], 0, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news', $start);
|
||||
|
||||
if (count($fetch_news) == 0)
|
||||
{
|
||||
@@ -64,67 +124,103 @@ if($news < 0)
|
||||
$topic_id = $fetch_news[$i]['topic_id'];
|
||||
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
|
||||
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||
|
||||
|
||||
$read_full_url = (isset($_GET['np'])) ? 'np='. $start . '&news=' . $i . '#n' . $i : 'news=' . $i . '#n' . $i;
|
||||
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
|
||||
if ( $portal_config['portal_news_archive'] )
|
||||
{
|
||||
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $portal_config['portal_number_of_news'], $start, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news');
|
||||
}
|
||||
|
||||
$template->assign_block_vars('news_row', array(
|
||||
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
'FORUM_NAME' => ( $forum_id ) ? $fetch_news[$i]['forum_name'] : '',
|
||||
'TITLE' => $fetch_news[$i]['topic_title'],
|
||||
'POSTER' => $fetch_news[$i]['username'],
|
||||
'POSTER_FULL' => $fetch_news[$i]['username_full'],
|
||||
'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '',
|
||||
'TIME' => $fetch_news[$i]['topic_time'],
|
||||
'TEXT' => $fetch_news[$i]['post_text'],
|
||||
'REPLIES' => $fetch_news[$i]['topic_replies'],
|
||||
'TITLE' => $fetch_news[$i]['topic_title'],
|
||||
'POSTER' => $fetch_news[$i]['username'],
|
||||
'POSTER_FULL' => $fetch_news[$i]['username_full'],
|
||||
'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '',
|
||||
'TIME' => $fetch_news[$i]['topic_time'],
|
||||
'TEXT' => $fetch_news[$i]['post_text'],
|
||||
'REPLIES' => $fetch_news[$i]['topic_replies'],
|
||||
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
|
||||
'N_ID' => $i,
|
||||
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
|
||||
'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
|
||||
'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", 'news=' . $i),
|
||||
'L_READ_FULL' => $read_full,
|
||||
'OPEN' => $open_bracket,
|
||||
'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url),
|
||||
'L_READ_FULL' => $read_full,
|
||||
'OPEN' => $open_bracket,
|
||||
'CLOSE' => $close_bracket,
|
||||
'S_NOT_LAST' => ($i < count($fetch_news) - 1) ? true : false,
|
||||
'S_POLL' => $fetch_news[$i]['poll'],
|
||||
'S_NOT_LAST' => ($i < count($fetch_news) - 1) ? true : false,
|
||||
'S_POLL' => $fetch_news[$i]['poll'],
|
||||
'S_UNREAD_INFO' => $unread_topic,
|
||||
'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
|
||||
));
|
||||
|
||||
if ($portal_config['portal_number_of_news'] <> 0 && $portal_config['portal_news_archive'])
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'NP_PAGINATION' => $pagination,
|
||||
'TOTAL_NEWS' => ($total_news == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $total_news),
|
||||
'NP_PAGE_NUMBER' => on_page($total_news, $portal_config['portal_number_of_news'], $start))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_config['portal_news_permissions'], $portal_config['portal_number_of_news'], 0, 0, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news');
|
||||
$fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_config['portal_news_permissions'], $portal_config['portal_number_of_news'], 0, 0, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news', $start);
|
||||
|
||||
$i = $news;
|
||||
$forum_id = $fetch_news[$i]['forum_id'];
|
||||
$topic_id = $fetch_news[$i]['topic_id'];
|
||||
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
|
||||
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||
$open_bracket = '[ ';
|
||||
$close_bracket = ' ]';
|
||||
$read_full = $user->lang['BACK'];
|
||||
$forum_id = $fetch_news[$i]['forum_id'];
|
||||
$topic_id = $fetch_news[$i]['topic_id'];
|
||||
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
|
||||
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||
$open_bracket = '[ ';
|
||||
$close_bracket = ' ]';
|
||||
$read_full = $user->lang['BACK'];
|
||||
|
||||
$read_full_url = (isset($_GET['np'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "np=$start#n$i") : append_sid("{$phpbb_root_path}portal.$phpEx#n$i");
|
||||
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
|
||||
if ( $portal_config['portal_news_archive'] )
|
||||
{
|
||||
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $portal_config['portal_number_of_news'], $start, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news');
|
||||
}
|
||||
|
||||
$template->assign_block_vars('news_row', array(
|
||||
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
'FORUM_NAME' => ( $forum_id ) ? $fetch_news[$i]['forum_name'] : '',
|
||||
'TITLE' => $fetch_news[$i]['topic_title'],
|
||||
'POSTER' => $fetch_news[$i]['username'],
|
||||
'POSTER_FULL' => $fetch_news[$i]['username_full'],
|
||||
'TIME' => $fetch_news[$i]['topic_time'],
|
||||
'TEXT' => $fetch_news[$i]['post_text'],
|
||||
'REPLIES' => $fetch_news[$i]['topic_replies'],
|
||||
'TITLE' => $fetch_news[$i]['topic_title'],
|
||||
'POSTER' => $fetch_news[$i]['username'],
|
||||
'POSTER_FULL' => $fetch_news[$i]['username_full'],
|
||||
'TIME' => $fetch_news[$i]['topic_time'],
|
||||
'TEXT' => $fetch_news[$i]['post_text'],
|
||||
'REPLIES' => $fetch_news[$i]['topic_replies'],
|
||||
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
|
||||
'N_ID' => $i,
|
||||
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
|
||||
'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
|
||||
'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'S_POLL' => $fetch_news[$i]['poll'],
|
||||
'S_POLL' => $fetch_news[$i]['poll'],
|
||||
'S_UNREAD_INFO' => $unread_topic,
|
||||
'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx"),
|
||||
'U_READ_FULL' => $read_full_url,
|
||||
'L_READ_FULL' => $read_full,
|
||||
'OPEN' => $open_bracket,
|
||||
'CLOSE' => $close_bracket,
|
||||
'OPEN' => $open_bracket,
|
||||
'CLOSE' => $close_bracket,
|
||||
'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
|
||||
));
|
||||
|
||||
if ($portal_config['portal_number_of_news'] <> 0 && $portal_config['portal_news_archive'])
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'NP_PAGINATION' => $pagination,
|
||||
'TOTAL_NEWS' => ($total_news == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $total_news),
|
||||
'NP_PAGE_NUMBER' => on_page($total_news, $portal_config['portal_number_of_news'], $start))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -71,7 +71,7 @@ function set_portal_config($config_name, $config_value)
|
||||
include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
|
||||
|
||||
// fetch post for news & announce
|
||||
function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_length, $time, $type)
|
||||
function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_length, $time, $type, $start = 0)
|
||||
{
|
||||
global $db, $phpbb_root_path, $auth, $user, $bbcode_bitfield, $bbcode;
|
||||
|
||||
@@ -118,6 +118,8 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
|
||||
$str_where .= "t.forum_id <> $acc_id AND ";
|
||||
}
|
||||
}
|
||||
|
||||
$portal_config = obtain_portal_config();
|
||||
|
||||
switch( $type )
|
||||
{
|
||||
@@ -135,7 +137,16 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
|
||||
$topic_type = 't.topic_type = ' . POST_NORMAL;
|
||||
$str_where = ( strlen($str_where) > 0 ) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
|
||||
$user_link = 't.topic_last_poster_id = u.user_id';
|
||||
$post_link = 't.topic_last_post_id = p.post_id';
|
||||
|
||||
if ( $portal_config['portal_news_show_last'] )
|
||||
{
|
||||
$post_link = 't.topic_last_post_id = p.post_id';
|
||||
}
|
||||
else
|
||||
{
|
||||
$post_link = 't.topic_first_post_id = p.post_id';
|
||||
}
|
||||
|
||||
$topic_order = 't.topic_last_post_time DESC';
|
||||
|
||||
break;
|
||||
@@ -144,7 +155,16 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
|
||||
$topic_type = '( t.topic_type <> ' . POST_ANNOUNCE . ' ) AND ( t.topic_type <> ' . POST_GLOBAL . ')';
|
||||
$str_where = ( strlen($str_where) > 0 ) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
|
||||
$user_link = 't.topic_last_poster_id = u.user_id';
|
||||
$post_link = 't.topic_last_post_id = p.post_id';
|
||||
|
||||
if ( $portal_config['portal_news_show_last'] )
|
||||
{
|
||||
$post_link = 't.topic_last_post_id = p.post_id';
|
||||
}
|
||||
else
|
||||
{
|
||||
$post_link = 't.topic_first_post_id = p.post_id';
|
||||
}
|
||||
|
||||
$topic_order = 't.topic_last_post_time DESC';
|
||||
|
||||
break;
|
||||
@@ -223,14 +243,13 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
|
||||
ORDER BY
|
||||
' . $topic_order;
|
||||
|
||||
if( $number_of_posts == '' OR $number_of_posts == 0)
|
||||
{
|
||||
if ($number_of_posts <> 0)
|
||||
{
|
||||
$sql .= '
|
||||
LIMIT
|
||||
'.$start.',' . $number_of_posts;
|
||||
}
|
||||
$result = $db->sql_query($sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $db->sql_query_limit($sql, $number_of_posts);
|
||||
}
|
||||
|
||||
// Instantiate BBCode if need be
|
||||
if ($bbcode_bitfield !== '')
|
||||
@@ -283,7 +302,7 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
|
||||
$posts[$i] = array_merge($posts[$i], array(
|
||||
'post_text' => ap_validate($message),
|
||||
'topic_id' => $row['topic_id'],
|
||||
'topic_last_post_id' => $row['topic_last_post_id'],
|
||||
'topic_last_post_id' => $row['post_id'],
|
||||
'forum_id' => $row['forum_id'],
|
||||
'topic_replies' => $row['topic_replies'],
|
||||
'topic_time' => $user->format_date($row['post_time']),
|
||||
@@ -432,4 +451,99 @@ function ap_validate($str) {
|
||||
return str_replace('</li><br/>', '</li>', $s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pagination routine, generates page number sequence
|
||||
* tpl_prefix is for using different pagination blocks at one page
|
||||
*/
|
||||
function generate_portal_pagination($base_url, $num_items, $per_page, $start_item, $type, $add_prevnext_text = false, $tpl_prefix = '')
|
||||
{
|
||||
global $template, $user;
|
||||
|
||||
switch( $type )
|
||||
{
|
||||
case "announcements":
|
||||
$pagination_type = 'ap';
|
||||
break;
|
||||
case "news":
|
||||
case "news_all":
|
||||
$pagination_type = 'np';
|
||||
break;
|
||||
}
|
||||
|
||||
// Make sure $per_page is a valid value
|
||||
$per_page = ($per_page <= 0) ? 1 : $per_page;
|
||||
|
||||
$seperator = '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
|
||||
$total_pages = ceil($num_items / $per_page);
|
||||
|
||||
if ($total_pages == 1 || !$num_items)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$on_page = floor($start_item / $per_page) + 1;
|
||||
$url_delim = (strpos($base_url, '?') === false) ? '?' : '&';
|
||||
|
||||
$page_string = ($on_page == 1) ? '<strong>1</strong>' : '<a href="' . $base_url . '">1</a>';
|
||||
|
||||
if ($total_pages > 5)
|
||||
{
|
||||
$start_cnt = min(max(1, $on_page - 4), $total_pages - 5);
|
||||
$end_cnt = max(min($total_pages, $on_page + 4), 6);
|
||||
|
||||
$page_string .= ($start_cnt > 1) ? ' ... ' : $seperator;
|
||||
|
||||
for ($i = $start_cnt + 1; $i < $end_cnt; $i++)
|
||||
{
|
||||
$page_string .= ($i == $on_page) ? '<strong>' . $i . '</strong>' : '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($i - 1) * $per_page) . '">' . $i . '</a>';
|
||||
if ($i < $end_cnt - 1)
|
||||
{
|
||||
$page_string .= $seperator;
|
||||
}
|
||||
}
|
||||
|
||||
$page_string .= ($end_cnt < $total_pages) ? ' ... ' : $seperator;
|
||||
}
|
||||
else
|
||||
{
|
||||
$page_string .= $seperator;
|
||||
|
||||
for ($i = 2; $i < $total_pages; $i++)
|
||||
{
|
||||
$page_string .= ($i == $on_page) ? '<strong>' . $i . '</strong>' : '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($i - 1) * $per_page) . '">' . $i . '</a>';
|
||||
if ($i < $total_pages)
|
||||
{
|
||||
$page_string .= $seperator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page_string .= ($on_page == $total_pages) ? '<strong>' . $total_pages . '</strong>' : '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($total_pages - 1) * $per_page) . '">' . $total_pages . '</a>';
|
||||
|
||||
if ($add_prevnext_text)
|
||||
{
|
||||
if ($on_page != 1)
|
||||
{
|
||||
$page_string = '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($on_page - 2) * $per_page) . '">' . $user->lang['PREVIOUS'] . '</a> ' . $page_string;
|
||||
}
|
||||
|
||||
if ($on_page != $total_pages)
|
||||
{
|
||||
$page_string .= ' <a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . ($on_page * $per_page) . '">' . $user->lang['NEXT'] . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
$tpl_prefix . 'BASE_URL' => $base_url,
|
||||
'A_' . $tpl_prefix . 'BASE_URL' => addslashes($base_url),
|
||||
$tpl_prefix . 'PER_PAGE' => $per_page,
|
||||
|
||||
$tpl_prefix . 'PREVIOUS_PAGE' => ($on_page == 1) ? '' : $base_url . "{$url_delim}" . $pagination_type . '=' . (($on_page - 2) * $per_page),
|
||||
$tpl_prefix . 'NEXT_PAGE' => ($on_page == $total_pages) ? '' : $base_url . "{$url_delim}" . $pagination_type . '=' . ($on_page * $per_page),
|
||||
$tpl_prefix . 'TOTAL_PAGES' => $total_pages,
|
||||
));
|
||||
|
||||
return $page_string;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user