From 95a9c7a6429ae197046e3f87ece87f832df4f6c0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 17 Nov 2013 00:07:26 +0100 Subject: [PATCH] [feature/module_services] Move news module to module services --- config/services.yml | 14 ++ migrations/v210_beta1.php | 2 +- .../portal_news.php => modules/news.php | 233 +++++++++++------- 3 files changed, 162 insertions(+), 87 deletions(-) rename portal/modules/portal_news.php => modules/news.php (54%) diff --git a/config/services.yml b/config/services.yml index 1908db7e..a5702f6a 100644 --- a/config/services.yml +++ b/config/services.yml @@ -191,6 +191,20 @@ services: tags: - { name: board3.module } + board3.module.news: + class: \board3\portal\modules\news + arguments: + - @auth + - @cache + - @config + - @dbal.conn + - @template + - %core.root_path% + - %core.php_ext% + - @user + tags: + - { name: board3.module } + board3.module.search: class: \board3\portal\modules\search arguments: diff --git a/migrations/v210_beta1.php b/migrations/v210_beta1.php index e63dc1a3..8a844a01 100644 --- a/migrations/v210_beta1.php +++ b/migrations/v210_beta1.php @@ -435,7 +435,7 @@ class v210_beta1 extends \phpbb\db\migration\migration 'module_status' => 1, ), array( - 'module_classname' => 'news', + 'module_classname' => '\board3\portal\modules\news', 'module_column' => 2, 'module_order' => 4, 'module_name' => 'LATEST_NEWS', diff --git a/portal/modules/portal_news.php b/modules/news.php similarity index 54% rename from portal/modules/portal_news.php rename to modules/news.php index d8cd194b..7ea1ccb0 100644 --- a/portal/modules/portal_news.php +++ b/modules/news.php @@ -1,24 +1,18 @@ auth = $auth; + $this->cache = $cache; + $this->config = $config; + $this->db = $db; + $this->template = $template; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $phpEx; + $this->user = $user; + } + + /** + * @inheritdoc + */ public function get_template_center($module_id) { - global $config, $template, $db, $user, $auth, $cache, $phpEx, $phpbb_root_path; - $news = request_var('news', -1); - $news = ($news > $config['board3_number_of_news_' . $module_id] -1) ? -1 : $news; - $user->add_lang('viewforum'); + $news = ($news > $this->config['board3_number_of_news_' . $module_id] -1) ? -1 : $news; + $this->user->add_lang('viewforum'); $start = request_var('np', 0); $start = ($start < 0) ? 0 : $start; // Fetch news from portal/includes/functions.php with check if "read full" is requested. - $portal_news_length = ($news < 0) ? $config['board3_news_length_' . $module_id] : 0; - $fetch_news = phpbb_fetch_posts($module_id, $config['board3_news_forum_' . $module_id], $config['board3_news_permissions_' . $module_id], $config['board3_number_of_news_' . $module_id], $portal_news_length, 0, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $start, $config['board3_news_exclude_' . $module_id]); + $portal_news_length = ($news < 0) ? $this->config['board3_news_length_' . $module_id] : 0; + $fetch_news = phpbb_fetch_posts($module_id, $this->config['board3_news_forum_' . $module_id], $this->config['board3_news_permissions_' . $module_id], $this->config['board3_number_of_news_' . $module_id], $portal_news_length, 0, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $start, $this->config['board3_news_exclude_' . $module_id]); // Any news present? If not terminate it here. if (sizeof($fetch_news) == 0) { - $template->assign_block_vars('news_row', array( + $this->template->assign_block_vars('news_row', array( 'S_NO_TOPICS' => true, 'S_NOT_LAST' => false, )); @@ -73,10 +116,10 @@ class portal_news_module extends \board3\portal\modules\module_base else { // Count number of posts for news archive, considering if permission check is dis- or enabled. - if ($config['board3_news_archive_' . $module_id]) + if ($this->config['board3_news_archive_' . $module_id]) { - $permissions = $config['board3_news_permissions_' . $module_id]; - $forum_from = $config['board3_news_forum_' . $module_id]; + $permissions = $this->config['board3_news_permissions_' . $module_id]; + $forum_from = $this->config['board3_news_forum_' . $module_id]; $forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array()); @@ -84,14 +127,14 @@ class portal_news_module extends \board3\portal\modules\module_base if($permissions == true) { - $disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true))); + $disallow_access = array_unique(array_keys($this->auth->acl_getf('!f_read', true))); } else { $disallow_access = array(); } - if($config['board3_news_exclude_' . $module_id] == true) + if($this->config['board3_news_exclude_' . $module_id] == true) { $disallow_access = array_merge($disallow_access, $forum_from); $forum_from = array(); @@ -122,7 +165,7 @@ class portal_news_module extends \board3\portal\modules\module_base $str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : ''; - $topic_type = ($config['board3_show_all_news_' . $module_id]) ? '(topic_type <> ' . POST_ANNOUNCE . ') AND (topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL; + $topic_type = ($this->config['board3_show_all_news_' . $module_id]) ? '(topic_type <> ' . POST_ANNOUNCE . ') AND (topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL; $sql = 'SELECT COUNT(topic_id) AS num_topics FROM ' . TOPICS_TABLE . ' @@ -130,9 +173,9 @@ class portal_news_module extends \board3\portal\modules\module_base AND topic_visibility = ' . ITEM_APPROVED . ' AND topic_moved_id = 0 ' . $str_where; - $result = $db->sql_query($sql); - $total_news = (int) $db->sql_fetchfield('num_topics'); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $total_news = (int) $this->db->sql_fetchfield('num_topics'); + $this->db->sql_freeresult($result); } $topic_tracking_info = get_portal_tracking_info($fetch_news); @@ -147,7 +190,7 @@ class portal_news_module extends \board3\portal\modules\module_base { $open_bracket = '[ '; $close_bracket = ' ]'; - $read_full = $user->lang['READ_FULL']; + $read_full = $this->user->lang['READ_FULL']; } else { @@ -161,13 +204,13 @@ class portal_news_module extends \board3\portal\modules\module_base $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 ($config['board3_news_archive_' . $module_id]) + $view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); + if ($this->config['board3_news_archive_' . $module_id]) { - $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $config['board3_number_of_news_' . $module_id], $start, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news'); + $pagination = generate_portal_pagination(append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal"), $total_news, $this->config['board3_number_of_news_' . $module_id], $start, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news'); } - $replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies']; + $replies = ($this->auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies']; $folder_img = $folder_alt = $topic_type = $folder = $folder_new = ''; switch ($fetch_news[$i]['topic_type']) { @@ -182,7 +225,7 @@ class portal_news_module extends \board3\portal\modules\module_base default: $folder = 'topic_read'; $folder_new = 'topic_unread'; - if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED) + if ($this->config['hot_threshold'] && $replies >= $this->config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED) { $folder .= '_hot'; $folder_new .= '_hot'; @@ -205,38 +248,38 @@ class portal_news_module extends \board3\portal\modules\module_base $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); // Grab icons - $icons = $cache->obtain_icons(); + $icons = $this->cache->obtain_icons(); - phpbb_generate_template_pagination($template, $view_topic_url, 'pagination', 'np', $fetch_news[$i]['topic_replies'], $config['board3_number_of_news_' . $module_id], $start); + phpbb_generate_template_pagination($this->template, $view_topic_url, 'pagination', 'np', $fetch_news[$i]['topic_replies'], $this->config['board3_number_of_news_' . $module_id], $start); - $template->assign_block_vars('news_row', array( - 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', + $this->template->assign_block_vars('news_row', array( + 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->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'], 'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'], - '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']) : '', + '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("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '', 'TIME' => $fetch_news[$i]['topic_time'], - 'LAST_POST_TIME' => $user->format_date($fetch_news[$i]['topic_last_post_time']), + 'LAST_POST_TIME' => $this->user->format_date($fetch_news[$i]['topic_last_post_time']), 'TEXT' => $fetch_news[$i]['post_text'], 'REPLIES' => $fetch_news[$i]['topic_replies'], 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], 'N_ID' => $i, - 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), + 'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt), 'TOPIC_IMG_STYLE' => $folder_img, - 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), - 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], + 'TOPIC_FOLDER_IMG_SRC' => $this->user->img($folder_img, $folder_alt, false, '', 'src'), + 'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt], 'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '', - 'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'), - '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'] . '&t=' . $fetch_news[$i]['topic_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_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&view=unread#unread'), - '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", $read_full_url), + 'FOLDER_IMG' => $this->user->img('topic_read', 'NO_NEW_POSTS'), + 'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']), + 'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), + 'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), + 'U_VIEW_UNREAD' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&view=unread#unread'), + 'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), + 'U_READ_FULL' => append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", $read_full_url), 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket, @@ -250,18 +293,18 @@ class portal_news_module extends \board3\portal\modules\module_base { foreach ($fetch_news[$i]['attachments'] as $attachment) { - $template->assign_block_vars('news_row.attachment', array( + $this->template->assign_block_vars('news_row.attachment', array( 'DISPLAY_ATTACHMENT' => $attachment) ); } } - if ($config['board3_number_of_news_' . $module_id] <> 0 && $config['board3_news_archive_' . $module_id]) + if ($this->config['board3_number_of_news_' . $module_id] <> 0 && $this->config['board3_news_archive_' . $module_id]) { - $template->assign_vars(array( + $this->template->assign_vars(array( 'NP_PAGINATION' => $pagination, - 'TOTAL_NEWS' => ($total_news == 1) ? sprintf($user->lang['VIEW_FORUM_TOPICS'][1], $total_news) : sprintf($user->lang['VIEW_FORUM_TOPICS'][2], $total_news), - 'NP_PAGE_NUMBER' => phpbb_on_page($template, $user, $view_topic_url, $total_news, $config['board3_number_of_news_' . $module_id], $start)) + 'TOTAL_NEWS' => ($total_news == 1) ? sprintf($this->user->lang['VIEW_FORUM_TOPICS'][1], $total_news) : sprintf($this->user->lang['VIEW_FORUM_TOPICS'][2], $total_news), + 'NP_PAGE_NUMBER' => phpbb_on_page($this->template, $this->user, $view_topic_url, $total_news, $this->config['board3_number_of_news_' . $module_id], $start)) ); } } @@ -275,17 +318,17 @@ class portal_news_module extends \board3\portal\modules\module_base $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 = $this->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 ($config['board3_news_archive_' . $module_id]) + $read_full_url = (isset($_GET['np'])) ? append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "np=$start#n$i") : append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal#n$i"); + $view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); + if ($this->config['board3_news_archive_' . $module_id]) { - $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $config['board3_number_of_news_' . $module_id], $start, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news'); + $pagination = generate_portal_pagination(append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal"), $total_news, $this->config['board3_number_of_news_' . $module_id], $start, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news'); } - $template->assign_block_vars('news_row', array( - 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', + $this->template->assign_block_vars('news_row', array( + 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '', 'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '', 'TITLE' => $fetch_news[$i]['topic_title'], 'POSTER' => $fetch_news[$i]['username'], @@ -295,36 +338,37 @@ class portal_news_module extends \board3\portal\modules\module_base '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", '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_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']), + 'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), + 'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), + 'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), 'S_POLL' => $fetch_news[$i]['poll'], 'S_UNREAD_INFO' => $unread_topic, '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), 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, )); + phpbb_generate_template_pagination($this->template, $view_topic_url, 'news_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true); + if(!empty($fetch_news[$i]['attachments'])) { foreach ($fetch_news[$i]['attachments'] as $attachment) { - $template->assign_block_vars('news_row.attachment', array( + $this->template->assign_block_vars('news_row.attachment', array( 'DISPLAY_ATTACHMENT' => $attachment) ); } } - if ($config['board3_number_of_news_' . $module_id] <> 0 && $config['board3_news_archive_' . $module_id]) + if ($this->config['board3_number_of_news_' . $module_id] <> 0 && $this->config['board3_news_archive_' . $module_id]) { - $template->assign_vars(array( + $this->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, $config['board3_number_of_news_' . $module_id], $start)) + 'TOTAL_NEWS' => ($total_news == 1) ? $this->user->lang['VIEW_FORUM_TOPIC'] : $this->user->lang('VIEW_FORUM_TOPICS', $total_news), + 'NP_PAGE_NUMBER' => phpbb_on_page($this->template, $this->user, '', $total_news, $this->config['board3_number_of_news_' . $module_id], $start)) ); } } @@ -336,17 +380,17 @@ class portal_news_module extends \board3\portal\modules\module_base $topic_icons = true; } - $template->assign_vars(array( - 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), - 'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), - 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), - 'S_NEWEST_OR_FIRST' => ($config['board3_news_show_last_' . $module_id]) ? $user->lang['JUMP_NEWEST'] : $user->lang['JUMP_FIRST'], - 'POSTED_BY_TEXT' => ($config['board3_news_show_last_' . $module_id]) ? $user->lang['LAST_POST'] : $user->lang['POSTED'], - 'S_DISPLAY_NEWS_RVS' => ($config['board3_show_news_replies_views_' . $module_id]) ? true : false, + $this->template->assign_vars(array( + 'NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), + 'READ_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'), + 'GOTO_PAGE_IMG' => $this->user->img('icon_post_target', 'GOTO_PAGE'), + 'S_NEWEST_OR_FIRST' => ($this->config['board3_news_show_last_' . $module_id]) ? $this->user->lang['JUMP_NEWEST'] : $this->user->lang['JUMP_FIRST'], + 'POSTED_BY_TEXT' => ($this->config['board3_news_show_last_' . $module_id]) ? $this->user->lang['LAST_POST'] : $this->user->lang['POSTED'], + 'S_DISPLAY_NEWS_RVS' => ($this->config['board3_show_news_replies_views_' . $module_id]) ? true : false, 'S_TOPIC_ICONS' => $topic_icons, )); - if($config['board3_news_style_' . $module_id]) + if($this->config['board3_news_style_' . $module_id]) { return 'news_compact_center.html'; } @@ -356,6 +400,9 @@ class portal_news_module extends \board3\portal\modules\module_base } } + /** + * @inheritdoc + */ public function get_template_acp($module_id) { return array( @@ -377,7 +424,7 @@ class portal_news_module extends \board3\portal\modules\module_base } /** - * API functions + * @inheritdoc */ public function install($module_id) { @@ -394,6 +441,9 @@ class portal_news_module extends \board3\portal\modules\module_base return true; } + /** + * @inheritdoc + */ public function uninstall($module_id, $db) { $del_config = array( @@ -413,17 +463,23 @@ class portal_news_module extends \board3\portal\modules\module_base return $db->sql_query($sql); } - // Create forum select box + /** + * Create forum select box + * + * @param mixed $value Value of input + * @param string $key Key name + * @param int $module_id Module ID + * + * @return null + */ public function select_forums($value, $key, $module_id) { - global $user, $config; - $forum_list = make_forum_select(false, false, true, true, true, false, true); $selected = array(); - if(isset($config[$key]) && strlen($config[$key]) > 0) + if(isset($this->config[$key]) && strlen($this->config[$key]) > 0) { - $selected = explode(',', $config[$key]); + $selected = explode(',', $this->config[$key]); } // Build forum options $s_forum_options = '