Advertisement
ABDev

News page - Templated version - Updated spitfire pat's code

Jan 31st, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.73 KB | None | 0 0
  1. <?php
  2.  
  3. // ignore
  4. define('IN_PHPBB', true);
  5. $phpbb_root_path = defined('PHPBB_ROOT_PATH') ? PHPBB_ROOT_PATH : './';
  6. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  7. include $phpbb_root_path . 'common.' . $phpEx;
  8.  
  9. // session
  10. $user->session_begin();
  11. $auth->acl($user->data);
  12. $user->setup();
  13.  
  14. // initial var setup
  15. $forum_id = request_var('f', 0);
  16.  
  17. $sql_where = $db->sql_in_set('forum_id', array_keys($auth->acl_getf('f_read', true)));
  18. if ( $forum_id )
  19. {
  20.     $sql_where = 'forum_id = ' . (int) $forum_id;
  21. }
  22.  
  23. $sql = 'SELECT topic_id, forum_id, icon_id, topic_time, topic_title, topic_views, topic_replies, topic_poster, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_time
  24.     FROM ' . TOPICS_TABLE . '
  25.     WHERE ' . $sql_where . '
  26.         AND topic_status <> ' . ITEM_MOVED . '
  27.     ORDER BY topic_time DESC';
  28. $result = $db->sql_query_limit($sql, 10);
  29.  
  30. // grab icons
  31. $icons = $cache->obtain_icons();
  32.  
  33. while ( $row = $db->sql_fetchrow($result) )
  34. {
  35.     $topic_id = (int) $row['topic_id'];
  36.     $topic_forum_id = $row['forum_id'] ? (int) $row['forum_id'] : $forum_id;
  37.  
  38.     // generate all the uris ...
  39.     $view_topic_url_params = 'f=' . $topic_forum_id . '&amp;t=' . $topic_id;
  40.  
  41.     $template->assign_block_vars('topicrow', array(
  42.         'TOPIC_AUTHOR' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
  43.         'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
  44.         'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
  45.         'LAST_POST_AUTHOR' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
  46.  
  47.         'REPLIES' => (int) $row['topic_replies'],
  48.         'VIEWS' => (int) $row['topic_views'],
  49.         'TOPIC_TITLE' => censor_text($row['topic_title']),
  50.  
  51.         'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&amp;p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],
  52.         'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params),
  53.     ));
  54.  
  55.     if ( !empty($icons[$row['icon_id']]) )
  56.     {
  57.         $template->alter_block_array('topicrow', array(
  58.             'TOPIC_ICON_IMG' => $icons[$row['icon_id']]['img'],
  59.             'TOPIC_ICON_IMG_WIDTH' => $icons[$row['icon_id']]['width'],
  60.             'TOPIC_ICON_IMG_HEIGHT' => $icons[$row['icon_id']]['height'],
  61.         ), true, 'change');
  62.     }
  63. }
  64. $db->sql_freeresult($result);
  65.  
  66. $template->assign_vars(array(
  67.     'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
  68.  
  69.     'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/",
  70. ));
  71.  
  72. $template->set_filenames(array('body' => 'news_body.html'));
  73. $template->display('body');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement