mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/13645] Proper OOP for feeds
PHPBB3-13645
This commit is contained in:
parent
8e5e954438
commit
5df9a45473
15 changed files with 506 additions and 320 deletions
|
@ -229,6 +229,7 @@ $lang = array_merge($lang, array(
|
||||||
'FACEBOOK' => 'Facebook',
|
'FACEBOOK' => 'Facebook',
|
||||||
'FAQ' => 'FAQ',
|
'FAQ' => 'FAQ',
|
||||||
'FAQ_EXPLAIN' => 'Frequently Asked Questions',
|
'FAQ_EXPLAIN' => 'Frequently Asked Questions',
|
||||||
|
'FEATURE_NOT_AVAILABLE' => 'The requested feature is not available on this board.',
|
||||||
'FILENAME' => 'Filename',
|
'FILENAME' => 'Filename',
|
||||||
'FILESIZE' => 'File size',
|
'FILESIZE' => 'File size',
|
||||||
'FILEDATE' => 'File date',
|
'FILEDATE' => 'File date',
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace phpbb\feed;
|
||||||
/**
|
/**
|
||||||
* Abstract class for feeds displaying attachments
|
* Abstract class for feeds displaying attachments
|
||||||
*/
|
*/
|
||||||
abstract class attachments_base extends \phpbb\feed\base
|
abstract class attachments_base extends base
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Attachments that may be displayed
|
* Attachments that may be displayed
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\feed;
|
namespace phpbb\feed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class with some generic functions and settings.
|
* Base class with some generic functions and settings.
|
||||||
*/
|
*/
|
||||||
abstract class base
|
abstract class base implements feed_interface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Feed helper object
|
* Feed helper object
|
||||||
|
@ -45,27 +45,27 @@ abstract class base
|
||||||
/**
|
/**
|
||||||
* SQL Query to be executed to get feed items
|
* SQL Query to be executed to get feed items
|
||||||
*/
|
*/
|
||||||
var $sql = array();
|
protected $sql = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys specified for retrieval of title, content, etc.
|
* Keys specified for retrieval of title, content, etc.
|
||||||
*/
|
*/
|
||||||
var $keys = array();
|
protected $keys = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of items to fetch. Usually overwritten by $config['feed_something']
|
* Number of items to fetch. Usually overwritten by $config['feed_something']
|
||||||
*/
|
*/
|
||||||
var $num_items = 15;
|
protected $num_items = 15;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Separator for title elements to separate items (for example forum / topic)
|
* Separator for title elements to separate items (for example forum / topic)
|
||||||
*/
|
*/
|
||||||
var $separator = "\xE2\x80\xA2"; // •
|
protected $separator = "\xE2\x80\xA2"; // •
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Separator for the statistics row (Posted by, post date, replies, etc.)
|
* Separator for the statistics row (Posted by, post date, replies, etc.)
|
||||||
*/
|
*/
|
||||||
var $separator_stats = "\xE2\x80\x94"; // —
|
protected $separator_stats = "\xE2\x80\x94"; // —
|
||||||
|
|
||||||
/** @var mixed Query result handle */
|
/** @var mixed Query result handle */
|
||||||
protected $result;
|
protected $result;
|
||||||
|
@ -82,7 +82,7 @@ abstract class base
|
||||||
* @param \phpbb\content_visibility $content_visibility Auth object
|
* @param \phpbb\content_visibility $content_visibility Auth object
|
||||||
* @param string $phpEx php file extension
|
* @param string $phpEx php file extension
|
||||||
*/
|
*/
|
||||||
function __construct(\phpbb\feed\helper $helper, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\content_visibility $content_visibility, $phpEx)
|
public function __construct(\phpbb\feed\helper $helper, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\content_visibility $content_visibility, $phpEx)
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->helper = $helper;
|
$this->helper = $helper;
|
||||||
|
@ -109,23 +109,23 @@ abstract class base
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set keys.
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
function set_keys()
|
public function set_keys()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open feed
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
function open()
|
public function open()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close feed
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
function close()
|
public function close()
|
||||||
{
|
{
|
||||||
if (!empty($this->result))
|
if (!empty($this->result))
|
||||||
{
|
{
|
||||||
|
@ -134,28 +134,47 @@ abstract class base
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set key
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param string $key Key
|
|
||||||
* @param mixed $value Value
|
|
||||||
*/
|
*/
|
||||||
function set($key, $value)
|
public function set($key, $value)
|
||||||
{
|
{
|
||||||
$this->keys[$key] = $value;
|
$this->keys[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get key
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param string $key Key
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
function get($key)
|
public function get($key)
|
||||||
{
|
{
|
||||||
return (isset($this->keys[$key])) ? $this->keys[$key] : null;
|
return (isset($this->keys[$key])) ? $this->keys[$key] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_readable_forums()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function get_item()
|
||||||
|
{
|
||||||
|
if (!isset($this->result))
|
||||||
|
{
|
||||||
|
if (!$this->get_sql())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query database
|
||||||
|
$sql = $this->db->sql_build_query('SELECT', $this->sql);
|
||||||
|
$this->result = $this->db->sql_query_limit($sql, $this->num_items);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->db->sql_fetchrow($this->result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ids of the forums readable by the current user.
|
||||||
|
*
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
protected function get_readable_forums()
|
||||||
{
|
{
|
||||||
static $forum_ids;
|
static $forum_ids;
|
||||||
|
|
||||||
|
@ -167,7 +186,12 @@ abstract class base
|
||||||
return $forum_ids;
|
return $forum_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_moderator_approve_forums()
|
/**
|
||||||
|
* Returns the ids of the forum for which the current user can approve the post in the moderation queue.
|
||||||
|
*
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
protected function get_moderator_approve_forums()
|
||||||
{
|
{
|
||||||
static $forum_ids;
|
static $forum_ids;
|
||||||
|
|
||||||
|
@ -179,7 +203,13 @@ abstract class base
|
||||||
return $forum_ids;
|
return $forum_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_moderator_approve_forum($forum_id)
|
/**
|
||||||
|
* Returns true if the current user can approve the post of the given forum
|
||||||
|
*
|
||||||
|
* @param int $forum_id Forum id to check
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function is_moderator_approve_forum($forum_id)
|
||||||
{
|
{
|
||||||
static $forum_ids;
|
static $forum_ids;
|
||||||
|
|
||||||
|
@ -191,7 +221,12 @@ abstract class base
|
||||||
return (isset($forum_ids[$forum_id])) ? true : false;
|
return (isset($forum_ids[$forum_id])) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_excluded_forums()
|
/**
|
||||||
|
* Returns the ids of the forum excluded from the feeds
|
||||||
|
*
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
protected function get_excluded_forums()
|
||||||
{
|
{
|
||||||
static $forum_ids;
|
static $forum_ids;
|
||||||
|
|
||||||
|
@ -218,36 +253,35 @@ abstract class base
|
||||||
return $forum_ids;
|
return $forum_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_excluded_forum($forum_id)
|
/**
|
||||||
|
* Returns true if the given id is in the excluded forums list.
|
||||||
|
*
|
||||||
|
* @param int $forum_id Id to check
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function is_excluded_forum($forum_id)
|
||||||
{
|
{
|
||||||
$forum_ids = $this->get_excluded_forums();
|
$forum_ids = $this->get_excluded_forums();
|
||||||
|
|
||||||
return isset($forum_ids[$forum_id]) ? true : false;
|
return isset($forum_ids[$forum_id]) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_passworded_forums()
|
/**
|
||||||
|
* Returns all password protected forum ids the current user is currently NOT authenticated for.
|
||||||
|
*
|
||||||
|
* @return array Array of forum ids
|
||||||
|
*/
|
||||||
|
protected function get_passworded_forums()
|
||||||
{
|
{
|
||||||
return $this->user->get_passworded_forums();
|
return $this->user->get_passworded_forums();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_item()
|
/**
|
||||||
{
|
* Returns the link to the user profile.
|
||||||
if (!isset($this->result))
|
*
|
||||||
{
|
* @return string
|
||||||
if (!$this->get_sql())
|
*/
|
||||||
{
|
protected function user_viewprofile($row)
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Query database
|
|
||||||
$sql = $this->db->sql_build_query('SELECT', $this->sql);
|
|
||||||
$this->result = $this->db->sql_query_limit($sql, $this->num_items);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->db->sql_fetchrow($this->result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function user_viewprofile($row)
|
|
||||||
{
|
{
|
||||||
$author_id = (int) $row[$this->get('author_id')];
|
$author_id = (int) $row[$this->get('author_id')];
|
||||||
|
|
||||||
|
@ -260,4 +294,11 @@ abstract class base
|
||||||
|
|
||||||
return '<a href="' . $this->helper->append_sid('memberlist.' . $this->phpEx, 'mode=viewprofile&u=' . $author_id) . '">' . $row[$this->get('creator')] . '</a>';
|
return '<a href="' . $this->helper->append_sid('memberlist.' . $this->phpEx, 'mode=viewprofile&u=' . $author_id) . '">' . $row[$this->get('creator')] . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the SQL query used to retrieve the posts of the feed.
|
||||||
|
*
|
||||||
|
* @return string SQL SELECT query
|
||||||
|
*/
|
||||||
|
protected abstract function get_sql();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ use phpbb\auth\auth;
|
||||||
use phpbb\config\config;
|
use phpbb\config\config;
|
||||||
use phpbb\db\driver\driver_interface;
|
use phpbb\db\driver\driver_interface;
|
||||||
use phpbb\exception\http_exception;
|
use phpbb\exception\http_exception;
|
||||||
use phpbb\feed\base;
|
use phpbb\feed\feed_interface;
|
||||||
use phpbb\feed\exception\feed_unavailable_exception;
|
use phpbb\feed\exception\feed_unavailable_exception;
|
||||||
use phpbb\feed\exception\unauthorized_exception;
|
use phpbb\feed\exception\unauthorized_exception;
|
||||||
use phpbb\feed\helper as feed_helper;
|
use phpbb\feed\helper as feed_helper;
|
||||||
|
@ -252,11 +252,11 @@ class feed
|
||||||
/**
|
/**
|
||||||
* Display a given feed
|
* Display a given feed
|
||||||
*
|
*
|
||||||
* @param base $feed
|
* @param feed_interface $feed
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
protected function send_feed(base $feed)
|
protected function send_feed(feed_interface $feed)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -275,13 +275,13 @@ class feed
|
||||||
/**
|
/**
|
||||||
* Really send the feed
|
* Really send the feed
|
||||||
*
|
*
|
||||||
* @param base $feed
|
* @param feed_interface $feed
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*
|
*
|
||||||
* @throw exception\feed_exception
|
* @throw exception\feed_exception
|
||||||
*/
|
*/
|
||||||
protected function send_feed_do(base $feed)
|
protected function send_feed_do(feed_interface $feed)
|
||||||
{
|
{
|
||||||
$feed_updated_time = 0;
|
$feed_updated_time = 0;
|
||||||
$item_vars = array();
|
$item_vars = array();
|
||||||
|
|
67
phpBB/phpbb/feed/feed_interface.php
Normal file
67
phpBB/phpbb/feed/feed_interface.php
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\feed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface implemented by all feeds types
|
||||||
|
*/
|
||||||
|
interface feed_interface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Set keys.
|
||||||
|
*/
|
||||||
|
public function set_keys();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open feed
|
||||||
|
*/
|
||||||
|
public function open();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close feed
|
||||||
|
*/
|
||||||
|
public function close();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set key
|
||||||
|
*
|
||||||
|
* @param string $key Key
|
||||||
|
* @param mixed $value Value
|
||||||
|
*/
|
||||||
|
public function set($key, $value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get key
|
||||||
|
*
|
||||||
|
* @param string $key Key
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function get($key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the next post in the feed
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_item();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjust a feed entry
|
||||||
|
*
|
||||||
|
* @param $item_row
|
||||||
|
* @param $row
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function adjust_item(&$item_row, &$row);
|
||||||
|
}
|
|
@ -1,15 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\feed;
|
namespace phpbb\feed;
|
||||||
|
|
||||||
|
@ -18,15 +18,15 @@ use phpbb\feed\exception\no_forum_exception;
|
||||||
use phpbb\feed\exception\unauthorized_forum_exception;
|
use phpbb\feed\exception\unauthorized_forum_exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forum feed
|
* Forum feed
|
||||||
*
|
*
|
||||||
* This will give you the last {$this->num_items} posts made
|
* This will give you the last {$this->num_items} posts made
|
||||||
* within a specific forum.
|
* within a specific forum.
|
||||||
*/
|
*/
|
||||||
class forum extends \phpbb\feed\post_base
|
class forum extends post_base
|
||||||
{
|
{
|
||||||
var $forum_id = 0;
|
protected $forum_id = 0;
|
||||||
var $forum_data = array();
|
protected $forum_data = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Forum ID
|
* Set the Forum ID
|
||||||
|
@ -41,7 +41,10 @@ class forum extends \phpbb\feed\post_base
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function open()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function open()
|
||||||
{
|
{
|
||||||
// Check if forum exists
|
// Check if forum exists
|
||||||
$sql = 'SELECT forum_id, forum_name, forum_password, forum_type, forum_options
|
$sql = 'SELECT forum_id, forum_name, forum_password, forum_type, forum_options
|
||||||
|
@ -90,7 +93,10 @@ class forum extends \phpbb\feed\post_base
|
||||||
parent::open();
|
parent::open();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_sql()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function get_sql()
|
||||||
{
|
{
|
||||||
// Determine topics with recent activity
|
// Determine topics with recent activity
|
||||||
$sql = 'SELECT topic_id, topic_last_post_time
|
$sql = 'SELECT topic_id, topic_last_post_time
|
||||||
|
@ -133,7 +139,10 @@ class forum extends \phpbb\feed\post_base
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjust_item(&$item_row, &$row)
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function adjust_item(&$item_row, &$row)
|
||||||
{
|
{
|
||||||
parent::adjust_item($item_row, $row);
|
parent::adjust_item($item_row, $row);
|
||||||
|
|
||||||
|
@ -141,7 +150,10 @@ class forum extends \phpbb\feed\post_base
|
||||||
$item_row['forum_id'] = $this->forum_id;
|
$item_row['forum_id'] = $this->forum_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_item()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function get_item()
|
||||||
{
|
{
|
||||||
return ($row = parent::get_item()) ? array_merge($this->forum_data, $row) : $row;
|
return ($row = parent::get_item()) ? array_merge($this->forum_data, $row) : $row;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,32 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\feed;
|
namespace phpbb\feed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 'All Forums' feed
|
* 'All Forums' feed
|
||||||
*
|
*
|
||||||
* This will give you a list of all postable forums where feeds are enabled
|
* This will give you a list of all postable forums where feeds are enabled
|
||||||
* including forum description, topic stats and post stats
|
* including forum description, topic stats and post stats
|
||||||
*/
|
*/
|
||||||
class forums extends \phpbb\feed\base
|
class forums extends base
|
||||||
{
|
{
|
||||||
var $num_items = 0;
|
protected $num_items = 0;
|
||||||
|
|
||||||
function set_keys()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function set_keys()
|
||||||
{
|
{
|
||||||
$this->set('title', 'forum_name');
|
$this->set('title', 'forum_name');
|
||||||
$this->set('text', 'forum_desc');
|
$this->set('text', 'forum_desc');
|
||||||
|
@ -33,7 +36,10 @@ class forums extends \phpbb\feed\base
|
||||||
$this->set('options', 'forum_desc_options');
|
$this->set('options', 'forum_desc_options');
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_sql()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function get_sql()
|
||||||
{
|
{
|
||||||
$in_fid_ary = array_diff($this->get_readable_forums(), $this->get_excluded_forums());
|
$in_fid_ary = array_diff($this->get_readable_forums(), $this->get_excluded_forums());
|
||||||
if (empty($in_fid_ary))
|
if (empty($in_fid_ary))
|
||||||
|
@ -55,7 +61,10 @@ class forums extends \phpbb\feed\base
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjust_item(&$item_row, &$row)
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public 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']);
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\feed;
|
namespace phpbb\feed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class with some helpful functions used in feeds
|
* Class with some helpful functions used in feeds
|
||||||
*/
|
*/
|
||||||
class helper
|
class helper
|
||||||
{
|
{
|
||||||
/** @var \phpbb\config\config */
|
/** @var \phpbb\config\config */
|
||||||
|
|
|
@ -1,27 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\feed;
|
namespace phpbb\feed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* News feed
|
* News feed
|
||||||
*
|
*
|
||||||
* This will give you {$this->num_items} first posts
|
* This will give you {$this->num_items} first posts
|
||||||
* of all topics in the selected news forums.
|
* of all topics in the selected news forums.
|
||||||
*/
|
*/
|
||||||
class news extends \phpbb\feed\topic_base
|
class news extends topic_base
|
||||||
{
|
{
|
||||||
function get_news_forums()
|
/**
|
||||||
|
* Returns the ids of the 'news forums'
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
private function get_news_forums()
|
||||||
{
|
{
|
||||||
static $forum_ids;
|
static $forum_ids;
|
||||||
|
|
||||||
|
@ -48,7 +52,10 @@ class news extends \phpbb\feed\topic_base
|
||||||
return $forum_ids;
|
return $forum_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_sql()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function get_sql()
|
||||||
{
|
{
|
||||||
// Determine forum ids
|
// Determine forum ids
|
||||||
$in_fid_ary = array_intersect($this->get_news_forums(), $this->get_readable_forums());
|
$in_fid_ary = array_intersect($this->get_news_forums(), $this->get_readable_forums());
|
||||||
|
|
|
@ -1,27 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\feed;
|
namespace phpbb\feed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Board wide feed (aka overall feed)
|
* Board wide feed (aka overall feed)
|
||||||
*
|
*
|
||||||
* This will give you the newest {$this->num_items} posts
|
* This will give you the newest {$this->num_items} posts
|
||||||
* from the whole board.
|
* from the whole board.
|
||||||
*/
|
*/
|
||||||
class overall extends \phpbb\feed\post_base
|
class overall extends post_base
|
||||||
{
|
{
|
||||||
function get_sql()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function get_sql()
|
||||||
{
|
{
|
||||||
$forum_ids = array_diff($this->get_readable_forums(), $this->get_excluded_forums(), $this->get_passworded_forums());
|
$forum_ids = array_diff($this->get_readable_forums(), $this->get_excluded_forums(), $this->get_passworded_forums());
|
||||||
if (empty($forum_ids))
|
if (empty($forum_ids))
|
||||||
|
@ -77,7 +80,10 @@ class overall extends \phpbb\feed\post_base
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjust_item(&$item_row, &$row)
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function adjust_item(&$item_row, &$row)
|
||||||
{
|
{
|
||||||
parent::adjust_item($item_row, $row);
|
parent::adjust_item($item_row, $row);
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\feed;
|
namespace phpbb\feed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for post based feeds
|
* Abstract class for post based feeds
|
||||||
*/
|
*/
|
||||||
abstract class post_base extends \phpbb\feed\attachments_base
|
abstract class post_base extends attachments_base
|
||||||
{
|
{
|
||||||
var $num_items = 'feed_limit_post';
|
protected $num_items = 'feed_limit_post';
|
||||||
var $attachments = array();
|
|
||||||
|
|
||||||
function set_keys()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function set_keys()
|
||||||
{
|
{
|
||||||
$this->set('title', 'post_subject');
|
$this->set('title', 'post_subject');
|
||||||
$this->set('title2', 'topic_title');
|
$this->set('title2', 'topic_title');
|
||||||
|
@ -40,7 +42,10 @@ abstract class post_base extends \phpbb\feed\attachments_base
|
||||||
$this->set('enable_magic_url', 'enable_magic_url');
|
$this->set('enable_magic_url', 'enable_magic_url');
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjust_item(&$item_row, &$row)
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function adjust_item(&$item_row, &$row)
|
||||||
{
|
{
|
||||||
$item_row['link'] = $this->helper->append_sid('viewtopic.' . $this->phpEx, "t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}");
|
$item_row['link'] = $this->helper->append_sid('viewtopic.' . $this->phpEx, "t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}");
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\feed;
|
namespace phpbb\feed;
|
||||||
|
|
||||||
|
@ -19,15 +19,15 @@ use phpbb\feed\exception\unauthorized_forum_exception;
|
||||||
use phpbb\feed\exception\unauthorized_topic_exception;
|
use phpbb\feed\exception\unauthorized_topic_exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Topic feed for a specific topic
|
* Topic feed for a specific topic
|
||||||
*
|
*
|
||||||
* This will give you the last {$this->num_items} posts made within this topic.
|
* This will give you the last {$this->num_items} posts made within this topic.
|
||||||
*/
|
*/
|
||||||
class topic extends \phpbb\feed\post_base
|
class topic extends post_base
|
||||||
{
|
{
|
||||||
var $topic_id = 0;
|
protected $topic_id = 0;
|
||||||
var $forum_id = 0;
|
protected $forum_id = 0;
|
||||||
var $topic_data = array();
|
protected $topic_data = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Topic ID
|
* Set the Topic ID
|
||||||
|
@ -42,7 +42,10 @@ class topic extends \phpbb\feed\post_base
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function open()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function open()
|
||||||
{
|
{
|
||||||
$sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_visibility, t.topic_title, t.topic_time, t.topic_views, t.topic_posts_approved, t.topic_type
|
$sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_visibility, t.topic_title, t.topic_time, t.topic_views, t.topic_posts_approved, t.topic_type
|
||||||
FROM ' . TOPICS_TABLE . ' t
|
FROM ' . TOPICS_TABLE . ' t
|
||||||
|
@ -94,7 +97,10 @@ class topic extends \phpbb\feed\post_base
|
||||||
parent::open();
|
parent::open();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_sql()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function get_sql()
|
||||||
{
|
{
|
||||||
$this->sql = array(
|
$this->sql = array(
|
||||||
'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' .
|
'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' .
|
||||||
|
@ -112,14 +118,20 @@ class topic extends \phpbb\feed\post_base
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjust_item(&$item_row, &$row)
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function adjust_item(&$item_row, &$row)
|
||||||
{
|
{
|
||||||
parent::adjust_item($item_row, $row);
|
parent::adjust_item($item_row, $row);
|
||||||
|
|
||||||
$item_row['forum_id'] = $this->forum_id;
|
$item_row['forum_id'] = $this->forum_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_item()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function get_item()
|
||||||
{
|
{
|
||||||
return ($row = parent::get_item()) ? array_merge($this->topic_data, $row) : $row;
|
return ($row = parent::get_item()) ? array_merge($this->topic_data, $row) : $row;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\feed;
|
namespace phpbb\feed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for topic based feeds
|
* Abstract class for topic based feeds
|
||||||
*/
|
*/
|
||||||
abstract class topic_base extends \phpbb\feed\attachments_base
|
abstract class topic_base extends attachments_base
|
||||||
{
|
{
|
||||||
var $num_items = 'feed_limit_topic';
|
protected $num_items = 'feed_limit_topic';
|
||||||
|
|
||||||
function set_keys()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function set_keys()
|
||||||
{
|
{
|
||||||
$this->set('title', 'topic_title');
|
$this->set('title', 'topic_title');
|
||||||
$this->set('title2', 'forum_name');
|
$this->set('title2', 'forum_name');
|
||||||
|
@ -39,7 +42,10 @@ abstract class topic_base extends \phpbb\feed\attachments_base
|
||||||
$this->set('enable_magic_url', 'enable_magic_url');
|
$this->set('enable_magic_url', 'enable_magic_url');
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjust_item(&$item_row, &$row)
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function adjust_item(&$item_row, &$row)
|
||||||
{
|
{
|
||||||
$item_row['link'] = $this->helper->append_sid('viewtopic.' . $this->phpEx, 't=' . $row['topic_id'] . '&p=' . $row['post_id'] . '#p' . $row['post_id']);
|
$item_row['link'] = $this->helper->append_sid('viewtopic.' . $this->phpEx, 't=' . $row['topic_id'] . '&p=' . $row['post_id'] . '#p' . $row['post_id']);
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\feed;
|
namespace phpbb\feed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New Topics feed
|
* New Topics feed
|
||||||
*
|
*
|
||||||
* This will give you the last {$this->num_items} created topics
|
* This will give you the last {$this->num_items} created topics
|
||||||
* including the first post.
|
* including the first post.
|
||||||
*/
|
*/
|
||||||
class topics extends \phpbb\feed\topic_base
|
class topics extends topic_base
|
||||||
{
|
{
|
||||||
function get_sql()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function get_sql()
|
||||||
{
|
{
|
||||||
$forum_ids_read = $this->get_readable_forums();
|
$forum_ids_read = $this->get_readable_forums();
|
||||||
if (empty($forum_ids_read))
|
if (empty($forum_ids_read))
|
||||||
|
@ -77,7 +80,10 @@ class topics extends \phpbb\feed\topic_base
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjust_item(&$item_row, &$row)
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function adjust_item(&$item_row, &$row)
|
||||||
{
|
{
|
||||||
parent::adjust_item($item_row, $row);
|
parent::adjust_item($item_row, $row);
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,33 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* This file is part of the phpBB Forum Software package.
|
* This file is part of the phpBB Forum Software package.
|
||||||
*
|
*
|
||||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
*
|
*
|
||||||
* For full copyright and license information, please see
|
* For full copyright and license information, please see
|
||||||
* the docs/CREDITS.txt file.
|
* the docs/CREDITS.txt file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpbb\feed;
|
namespace phpbb\feed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Active Topics feed
|
* Active Topics feed
|
||||||
*
|
*
|
||||||
* This will give you the last {$this->num_items} topics
|
* This will give you the last {$this->num_items} topics
|
||||||
* with replies made withing the last {$this->sort_days} days
|
* with replies made withing the last {$this->sort_days} days
|
||||||
* including the last post.
|
* including the last post.
|
||||||
*/
|
*/
|
||||||
class topics_active extends \phpbb\feed\topic_base
|
class topics_active extends topic_base
|
||||||
{
|
{
|
||||||
var $sort_days = 7;
|
protected $sort_days = 7;
|
||||||
|
|
||||||
function set_keys()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function set_keys()
|
||||||
{
|
{
|
||||||
parent::set_keys();
|
parent::set_keys();
|
||||||
|
|
||||||
|
@ -32,7 +35,10 @@ class topics_active extends \phpbb\feed\topic_base
|
||||||
$this->set('creator', 'topic_last_poster_name');
|
$this->set('creator', 'topic_last_poster_name');
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_sql()
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function get_sql()
|
||||||
{
|
{
|
||||||
$forum_ids_read = $this->get_readable_forums();
|
$forum_ids_read = $this->get_readable_forums();
|
||||||
if (empty($forum_ids_read))
|
if (empty($forum_ids_read))
|
||||||
|
@ -94,7 +100,12 @@ class topics_active extends \phpbb\feed\topic_base
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_forum_ids()
|
/**
|
||||||
|
* Returns the ids of the forums not excluded from the active list
|
||||||
|
*
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
private function get_forum_ids()
|
||||||
{
|
{
|
||||||
static $forum_ids;
|
static $forum_ids;
|
||||||
|
|
||||||
|
@ -122,7 +133,10 @@ class topics_active extends \phpbb\feed\topic_base
|
||||||
return $forum_ids;
|
return $forum_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjust_item(&$item_row, &$row)
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function adjust_item(&$item_row, &$row)
|
||||||
{
|
{
|
||||||
parent::adjust_item($item_row, $row);
|
parent::adjust_item($item_row, $row);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue