aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/config/feed.yml56
-rw-r--r--phpBB/feed.php3
-rw-r--r--phpBB/includes/feed/base.php15
-rw-r--r--phpBB/includes/feed/factory.php69
-rw-r--r--phpBB/includes/feed/forum.php12
-rw-r--r--phpBB/includes/feed/forums.php2
-rw-r--r--phpBB/includes/feed/post_base.php2
-rw-r--r--phpBB/includes/feed/topic.php12
-rw-r--r--phpBB/includes/feed/topic_base.php2
9 files changed, 139 insertions, 34 deletions
diff --git a/phpBB/config/feed.yml b/phpBB/config/feed.yml
new file mode 100644
index 0000000000..218ce7a4e4
--- /dev/null
+++ b/phpBB/config/feed.yml
@@ -0,0 +1,56 @@
+services:
+ feed.helper:
+ class: phpbb_feed_helper
+ arguments:
+ - @config
+ - @user
+ - %core.root_path%
+
+ feed.factory:
+ class: phpbb_feed_factory
+ arguments:
+ - @service_container
+ - @config
+ - @dbal.conn
+
+ feed.forum:
+ class: phpbb_feed_forum
+ scope: prototype
+ arguments:
+ - @feed.helper
+
+ feed.forums:
+ class: phpbb_feed_forums
+ scope: prototype
+ arguments:
+ - @feed.helper
+
+ feed.news:
+ class: phpbb_feed_news
+ scope: prototype
+ arguments:
+ - @feed.helper
+
+ feed.overall:
+ class: phpbb_feed_overall
+ scope: prototype
+ arguments:
+ - @feed.helper
+
+ feed.topic:
+ class: phpbb_feed_topic
+ scope: prototype
+ arguments:
+ - @feed.helper
+
+ feed.topics:
+ class: phpbb_feed_topics
+ scope: prototype
+ arguments:
+ - @feed.helper
+
+ feed.topics_active:
+ class: phpbb_feed_topics_active
+ scope: prototype
+ arguments:
+ - @feed.helper
diff --git a/phpBB/feed.php b/phpBB/feed.php
index c1940a5eb6..38bb9de008 100644
--- a/phpBB/feed.php
+++ b/phpBB/feed.php
@@ -63,7 +63,8 @@ $phpbb_feed_helper = $phpbb_container->get('feed.helper');
$board_url = $phpbb_feed_helper->get_board_url();
// Get correct feed object
-$feed = phpbb_feed_factory::init($mode, $forum_id, $topic_id);
+$phpbb_feed_factory = $phpbb_container->get('feed.factory');
+$feed = $phpbb_feed_factory->get_feed($mode, $forum_id, $topic_id);
// No feed found
if ($feed === false)
diff --git a/phpBB/includes/feed/base.php b/phpBB/includes/feed/base.php
index 300ccf9b1e..2ffd20d31a 100644
--- a/phpBB/includes/feed/base.php
+++ b/phpBB/includes/feed/base.php
@@ -23,6 +23,12 @@ if (!defined('IN_PHPBB'))
abstract class phpbb_feed_base
{
/**
+ * Feed helper object
+ * @var phpbb_feed_helper
+ */
+ protected $helper;
+
+ /**
* SQL Query to be executed to get feed items
*/
var $sql = array();
@@ -49,8 +55,11 @@ abstract class phpbb_feed_base
/**
* Constructor
+ *
+ * @param phpbb_feed_helper $helper Feed helper
+ * @return null
*/
- function __construct()
+ function __construct(phpbb_feed_helper $helper)
{
global $config;
@@ -67,6 +76,8 @@ abstract class phpbb_feed_base
$this->num_items = 10;
}
}
+
+ $this->helper = $helper;
}
/**
@@ -225,6 +236,6 @@ abstract class phpbb_feed_base
return $user->lang['GUEST'];
}
- return '<a href="' . feed_append_sid('/memberlist.' . $phpEx, 'mode=viewprofile&amp;u=' . $author_id) . '">' . $row[$this->get('creator')] . '</a>';
+ return '<a href="' . $this->helper->append_sid('/memberlist.' . $phpEx, 'mode=viewprofile&amp;u=' . $author_id) . '">' . $row[$this->get('creator')] . '</a>';
}
}
diff --git a/phpBB/includes/feed/factory.php b/phpBB/includes/feed/factory.php
index 30a415cacb..346cf9d870 100644
--- a/phpBB/includes/feed/factory.php
+++ b/phpBB/includes/feed/factory.php
@@ -22,6 +22,33 @@ if (!defined('IN_PHPBB'))
class phpbb_feed_factory
{
/**
+ * Service container object
+ * @var object
+ */
+ protected $container;
+
+ /** @var phpbb_config */
+ protected $config;
+
+ /** @var phpbb_db_driver */
+ protected $driver;
+
+ /**
+ * Constructor
+ *
+ * @param objec $container Container object
+ * @param phpbb_config $config Config object
+ * @param phpbb_db_driver $db Database connection
+ * @return null
+ */
+ public function __construct($container, phpbb_config $config, phpbb_db_driver $db)
+ {
+ $this->container = $container;
+ $this->config = $config;
+ $this->db = $db;
+ }
+
+ /**
* Return correct object for specified mode
*
* @param string $mode The feeds mode.
@@ -30,71 +57,69 @@ class phpbb_feed_factory
*
* @return object Returns correct feeds object for specified mode.
*/
- function init($mode, $forum_id, $topic_id)
+ function get_feed($mode, $forum_id, $topic_id)
{
- global $config;
-
switch ($mode)
{
case 'forums':
- if (!$config['feed_overall_forums'])
+ if (!$this->config['feed_overall_forums'])
{
return false;
}
- return new phpbb_feed_forums();
+ return $this->container->get('feed.forums');
break;
case 'topics':
case 'topics_new':
- if (!$config['feed_topics_new'])
+ if (!$this->config['feed_topics_new'])
{
return false;
}
- return new phpbb_feed_topics();
+ return $this->container->get('feed.topics');
break;
case 'topics_active':
- if (!$config['feed_topics_active'])
+ if (!$this->config['feed_topics_active'])
{
return false;
}
- return new phpbb_feed_topics_active();
+ return $this->container->get('feed.topics_active');
break;
case 'news':
- global $db;
-
// Get at least one news forum
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
- WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0');
- $result = $db->sql_query_limit($sql, 1, 0, 600);
- $s_feed_news = (int) $db->sql_fetchfield('forum_id');
- $db->sql_freeresult($result);
+ WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0');
+ $result = $this->db->sql_query_limit($sql, 1, 0, 600);
+ $s_feed_news = (int) $this->db->sql_fetchfield('forum_id');
+ $this->db->sql_freeresult($result);
if (!$s_feed_news)
{
return false;
}
- return new phpbb_feed_news();
+ return $this->container->get('feed.news');
break;
default:
- if ($topic_id && $config['feed_topic'])
+ if ($topic_id && $this->config['feed_topic'])
{
- return new phpbb_feed_topic($topic_id);
+ return $this->container->get('feed.topic')
+ ->set_topic_id($topic_id);
}
- else if ($forum_id && $config['feed_forum'])
+ else if ($forum_id && $this->config['feed_forum'])
{
- return new phpbb_feed_forum($forum_id);
+ return $this->container->get('feed.forum')
+ ->set_forum_id($forum_id);
}
- else if ($config['feed_overall'])
+ else if ($this->config['feed_overall'])
{
- return new phpbb_feed_overall();
+ return $this->container->get('feed.overall');
}
return false;
diff --git a/phpBB/includes/feed/forum.php b/phpBB/includes/feed/forum.php
index d625751ec3..ec95cabe89 100644
--- a/phpBB/includes/feed/forum.php
+++ b/phpBB/includes/feed/forum.php
@@ -28,11 +28,17 @@ class phpbb_feed_forum extends phpbb_feed_post_base
var $forum_id = 0;
var $forum_data = array();
- function __construct($forum_id)
+ /**
+ * Set the Forum ID
+ *
+ * @param int $forum_id Forum ID
+ * @return phpbb_feed_forum
+ */
+ public function set_forum_id($topic_id)
{
- parent::__construct();
-
$this->forum_id = (int) $forum_id;
+
+ return $this;
}
function open()
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'])
{
diff --git a/phpBB/includes/feed/post_base.php b/phpBB/includes/feed/post_base.php
index 5af30f686b..b4ce467b9c 100644
--- a/phpBB/includes/feed/post_base.php
+++ b/phpBB/includes/feed/post_base.php
@@ -47,7 +47,7 @@ abstract class phpbb_feed_post_base extends phpbb_feed_base
{
global $phpEx, $config, $user;
- $item_row['link'] = feed_append_sid('/viewtopic.' . $phpEx, "t={$row['topic_id']}&amp;p={$row['post_id']}#p{$row['post_id']}");
+ $item_row['link'] = $this->helper->append_sid('/viewtopic.' . $phpEx, "t={$row['topic_id']}&amp;p={$row['post_id']}#p{$row['post_id']}");
if ($config['feed_item_statistics'])
{
diff --git a/phpBB/includes/feed/topic.php b/phpBB/includes/feed/topic.php
index eb77eddb5c..e4805e5539 100644
--- a/phpBB/includes/feed/topic.php
+++ b/phpBB/includes/feed/topic.php
@@ -28,11 +28,17 @@ class phpbb_feed_topic extends phpbb_feed_post_base
var $forum_id = 0;
var $topic_data = array();
- function __construct($topic_id)
+ /**
+ * Set the Topic ID
+ *
+ * @param int $topic_id Topic ID
+ * @return phpbb_feed_topic
+ */
+ public function set_topic_id($topic_id)
{
- parent::__construct();
-
$this->topic_id = (int) $topic_id;
+
+ return $this;
}
function open()
diff --git a/phpBB/includes/feed/topic_base.php b/phpBB/includes/feed/topic_base.php
index 353b9cac15..959ed5c469 100644
--- a/phpBB/includes/feed/topic_base.php
+++ b/phpBB/includes/feed/topic_base.php
@@ -47,7 +47,7 @@ abstract class phpbb_feed_topic_base extends phpbb_feed_base
{
global $phpEx, $config, $user;
- $item_row['link'] = feed_append_sid('/viewtopic.' . $phpEx, 't=' . $row['topic_id'] . '&amp;p=' . $row['post_id'] . '#p' . $row['post_id']);
+ $item_row['link'] = $this->helper->append_sid('/viewtopic.' . $phpEx, 't=' . $row['topic_id'] . '&amp;p=' . $row['post_id'] . '#p' . $row['post_id']);
if ($config['feed_item_statistics'])
{