From caf7c45fb4c63eb138078a8d6c2da270d2dba935 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Jun 2013 17:05:41 +0200 Subject: [ticket/11481] Move forums feed to own file PHPBB3-11481 --- phpBB/includes/feed/forums.php | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 phpBB/includes/feed/forums.php (limited to 'phpBB/includes/feed/forums.php') diff --git a/phpBB/includes/feed/forums.php b/phpBB/includes/feed/forums.php new file mode 100644 index 0000000000..f1c3e3531f --- /dev/null +++ b/phpBB/includes/feed/forums.php @@ -0,0 +1,78 @@ +set('title', 'forum_name'); + $this->set('text', 'forum_desc'); + $this->set('bitfield', 'forum_desc_bitfield'); + $this->set('bbcode_uid','forum_desc_uid'); + $this->set('updated', 'forum_last_post_time'); + $this->set('options', 'forum_desc_options'); + } + + function get_sql() + { + global $auth, $db; + + $in_fid_ary = array_diff($this->get_readable_forums(), $this->get_excluded_forums()); + if (empty($in_fid_ary)) + { + return false; + } + + // Build SQL Query + $this->sql = array( + 'SELECT' => 'f.forum_id, f.left_id, f.forum_name, f.forum_last_post_time, + f.forum_desc, f.forum_desc_bitfield, f.forum_desc_uid, f.forum_desc_options, + f.forum_topics, f.forum_posts', + 'FROM' => array(FORUMS_TABLE => 'f'), + 'WHERE' => 'f.forum_type = ' . FORUM_POST . ' + AND ' . $db->sql_in_set('f.forum_id', $in_fid_ary), + 'ORDER_BY' => 'f.left_id ASC', + ); + + return true; + } + + function adjust_item(&$item_row, &$row) + { + global $phpEx, $config; + + $item_row['link'] = feed_append_sid('/viewforum.' . $phpEx, 'f=' . $row['forum_id']); + + if ($config['feed_item_statistics']) + { + global $user; + + $item_row['statistics'] = $user->lang('TOTAL_TOPICS', (int) $row['forum_topics']) + . ' ' . $this->separator_stats . ' ' . $user->lang('TOTAL_POSTS_COUNT', (int) $row['forum_posts']); + } + } +} -- cgit v1.2.1 From 3efe0eb24687a0e36e316b60887eff3ed45ae9b4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Jun 2013 20:04:23 +0200 Subject: [ticket/11481] Use container for all classes and inject dependencies PHPBB3-11481 --- phpBB/includes/feed/forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/feed/forums.php') diff --git a/phpBB/includes/feed/forums.php b/phpBB/includes/feed/forums.php index f1c3e3531f..5f56d28d2c 100644 --- a/phpBB/includes/feed/forums.php +++ b/phpBB/includes/feed/forums.php @@ -65,7 +65,7 @@ class phpbb_feed_forums extends phpbb_feed_base { global $phpEx, $config; - $item_row['link'] = feed_append_sid('/viewforum.' . $phpEx, 'f=' . $row['forum_id']); + $item_row['link'] = $this->helper->append_sid('/viewforum.' . $phpEx, 'f=' . $row['forum_id']); if ($config['feed_item_statistics']) { -- cgit v1.2.1 From 63334514555acea665186f20046a49a5ed41c334 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Jun 2013 20:32:47 +0200 Subject: [ticket/11481] Remove globals and use dependency injection instead PHPBB3-11481 --- phpBB/includes/feed/forums.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'phpBB/includes/feed/forums.php') diff --git a/phpBB/includes/feed/forums.php b/phpBB/includes/feed/forums.php index 5f56d28d2c..130da1c56a 100644 --- a/phpBB/includes/feed/forums.php +++ b/phpBB/includes/feed/forums.php @@ -39,8 +39,6 @@ class phpbb_feed_forums extends phpbb_feed_base function get_sql() { - global $auth, $db; - $in_fid_ary = array_diff($this->get_readable_forums(), $this->get_excluded_forums()); if (empty($in_fid_ary)) { @@ -54,7 +52,7 @@ class phpbb_feed_forums extends phpbb_feed_base f.forum_topics, f.forum_posts', 'FROM' => array(FORUMS_TABLE => 'f'), 'WHERE' => 'f.forum_type = ' . FORUM_POST . ' - AND ' . $db->sql_in_set('f.forum_id', $in_fid_ary), + AND ' . $this->db->sql_in_set('f.forum_id', $in_fid_ary), 'ORDER_BY' => 'f.left_id ASC', ); @@ -63,16 +61,12 @@ class phpbb_feed_forums extends phpbb_feed_base function adjust_item(&$item_row, &$row) { - global $phpEx, $config; - - $item_row['link'] = $this->helper->append_sid('/viewforum.' . $phpEx, 'f=' . $row['forum_id']); + $item_row['link'] = $this->helper->append_sid('/viewforum.' . $this->phpEx, 'f=' . $row['forum_id']); - if ($config['feed_item_statistics']) + if ($this->config['feed_item_statistics']) { - global $user; - - $item_row['statistics'] = $user->lang('TOTAL_TOPICS', (int) $row['forum_topics']) - . ' ' . $this->separator_stats . ' ' . $user->lang('TOTAL_POSTS_COUNT', (int) $row['forum_posts']); + $item_row['statistics'] = $this->user->lang('TOTAL_TOPICS', (int) $row['forum_topics']) + . ' ' . $this->separator_stats . ' ' . $this->user->lang('TOTAL_POSTS_COUNT', (int) $row['forum_posts']); } } } -- cgit v1.2.1 From e36deed24f62f4fca0a3e82b2d58d97499ff7764 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Jun 2013 20:35:38 +0200 Subject: [ticket/11481] Move prepended slash from calls into function PHPBB3-11481 --- phpBB/includes/feed/forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/feed/forums.php') diff --git a/phpBB/includes/feed/forums.php b/phpBB/includes/feed/forums.php index 130da1c56a..72f786aa6a 100644 --- a/phpBB/includes/feed/forums.php +++ b/phpBB/includes/feed/forums.php @@ -61,7 +61,7 @@ class phpbb_feed_forums extends phpbb_feed_base function adjust_item(&$item_row, &$row) { - $item_row['link'] = $this->helper->append_sid('/viewforum.' . $this->phpEx, 'f=' . $row['forum_id']); + $item_row['link'] = $this->helper->append_sid('viewforum.' . $this->phpEx, 'f=' . $row['forum_id']); if ($this->config['feed_item_statistics']) { -- cgit v1.2.1