diff options
| -rw-r--r-- | phpBB/feed.php | 6 | ||||
| -rw-r--r-- | phpBB/phpbb/feed/forum.php | 2 | ||||
| -rw-r--r-- | phpBB/phpbb/feed/helper.php | 14 | ||||
| -rw-r--r-- | phpBB/phpbb/feed/news.php | 2 | ||||
| -rw-r--r-- | phpBB/phpbb/feed/overall.php | 2 | ||||
| -rw-r--r-- | phpBB/phpbb/feed/post_base.php | 40 | ||||
| -rw-r--r-- | phpBB/phpbb/feed/topic.php | 2 | ||||
| -rw-r--r-- | phpBB/phpbb/feed/topics.php | 2 | ||||
| -rw-r--r-- | phpBB/phpbb/feed/topics_active.php | 2 | 
9 files changed, 63 insertions, 9 deletions
diff --git a/phpBB/feed.php b/phpBB/feed.php index 35cd7fda3f..c31a6b6b1d 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -18,6 +18,7 @@ define('IN_PHPBB', true);  $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';  $phpEx = substr(strrchr(__FILE__, '.'), 1);  include($phpbb_root_path . 'common.' . $phpEx); +include($phpbb_root_path . 'includes/functions_display.' . $phpEx);  if (!$config['feed_enable'])  { @@ -72,6 +73,9 @@ if ($feed === false)  	trigger_error('NO_FEED');  } +// Get attachments for this feed +$feed->fetch_attachments(); +  // Open Feed  $feed->open(); @@ -107,7 +111,7 @@ while ($row = $feed->get_item())  		'title'			=> censor_text($title),  		'category'		=> ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '',  		'category_name'	=> ($config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '', -		'description'	=> censor_text($phpbb_feed_helper->generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options)), +		'description'	=> censor_text($phpbb_feed_helper->generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], (($row['post_attachment']) ? $feed->attachments[$row['post_id']] : array()))),  		'statistics'	=> '',  	); diff --git a/phpBB/phpbb/feed/forum.php b/phpBB/phpbb/feed/forum.php index 5f64d85625..541839559e 100644 --- a/phpBB/phpbb/feed/forum.php +++ b/phpBB/phpbb/feed/forum.php @@ -117,7 +117,7 @@ class forum extends \phpbb\feed\post_base  		}  		$this->sql = array( -			'SELECT'	=>	'p.post_id, p.topic_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, ' . +			'SELECT'	=>	'p.post_id, p.topic_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, ' .  							'u.username, u.user_id',  			'FROM'		=> array(  				POSTS_TABLE		=> 'p', diff --git a/phpBB/phpbb/feed/helper.php b/phpBB/phpbb/feed/helper.php index cf8328bd5e..88eb64953c 100644 --- a/phpBB/phpbb/feed/helper.php +++ b/phpBB/phpbb/feed/helper.php @@ -90,7 +90,7 @@ class helper  	/**  	* Generate text content  	*/ -	public function generate_content($content, $uid, $bitfield, $options) +	public function generate_content($content, $uid, $bitfield, $options, $forum_id, $post_attachments)  	{  		if (empty($content))  		{ @@ -137,8 +137,15 @@ class helper  		// Remove some specials html tag, because somewhere there are a mod to allow html tags ;)  		$content	= preg_replace( '#<(script|iframe)([^[]+)\1>#siU', ' <strong>$1</strong> ', $content); +		// Parse inline images to display with the feed +		if (count($post_attachments) > 0) +		{ +			$update_count = array(); +			parse_attachments($forum_id, $content, $post_attachments, $update_count); +		} +  		// Remove Comments from inline attachments [ia] -		$content	= preg_replace('#<div class="(inline-attachment|attachtitle)">(.*?)<!-- ia(.*?) -->(.*?)<!-- ia(.*?) -->(.*?)</div>#si','$4',$content); +		$content = preg_replace('#<dd>(.*?)</dd>#','',$content);  		// Replace some entities with their unicode counterpart  		$entities = array( @@ -156,6 +163,9 @@ class helper  		// Other control characters  		$content = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $content); +		// Convert attachments' relative path to absolute path +		$content = str_replace($this->phpbb_root_path . 'download', $this->get_board_url() . '/download', $content); +  		return $content;  	}  } diff --git a/phpBB/phpbb/feed/news.php b/phpBB/phpbb/feed/news.php index 20017a3248..aa0021d0c7 100644 --- a/phpBB/phpbb/feed/news.php +++ b/phpBB/phpbb/feed/news.php @@ -93,7 +93,7 @@ class news extends \phpbb\feed\topic_base  		$this->sql = array(  			'SELECT'	=> 'f.forum_id, f.forum_name,  							t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, t.topic_time, t.topic_last_post_time, -							p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', +							p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment',  			'FROM'		=> array(  				TOPICS_TABLE	=> 't',  				POSTS_TABLE		=> 'p', diff --git a/phpBB/phpbb/feed/overall.php b/phpBB/phpbb/feed/overall.php index 8ee1f092ab..830ad41e27 100644 --- a/phpBB/phpbb/feed/overall.php +++ b/phpBB/phpbb/feed/overall.php @@ -61,7 +61,7 @@ class overall extends \phpbb\feed\post_base  		// Get the actual data  		$this->sql = array(  			'SELECT'	=>	'f.forum_id, f.forum_name, ' . -							'p.post_id, p.topic_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_id, p.topic_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, ' .  							'u.username, u.user_id',  			'FROM'		=> array(  				USERS_TABLE		=> 'u', diff --git a/phpBB/phpbb/feed/post_base.php b/phpBB/phpbb/feed/post_base.php index 5588ecadb0..b126ad0e4a 100644 --- a/phpBB/phpbb/feed/post_base.php +++ b/phpBB/phpbb/feed/post_base.php @@ -25,6 +25,7 @@ if (!defined('IN_PHPBB'))  abstract class post_base extends \phpbb\feed\base  {  	var $num_items = 'feed_limit_post'; +	var $attachments = array();  	function set_keys()  	{ @@ -56,4 +57,43 @@ abstract class post_base extends \phpbb\feed\base  				. (($this->is_moderator_approve_forum($row['forum_id']) && $row['post_visibility'] !== ITEM_APPROVED) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POST_UNAPPROVED'] : '');  		}  	} + +	function fetch_attachments() +	{ +		global $db; + +		$sql_array = array( +						'SELECT'	=> 'a.*', +						'FROM'		=> array( +							ATTACHMENTS_TABLE	=>	'a' +						), +						'WHERE'		=> 'a.in_message = 0 ', +						'ORDER_BY'	=> 'a.filetime DESC, a.post_msg_id ASC' +					); + +		if (isset($this->topic_id)) +		{ +			$sql_array['WHERE'] .= 'AND a.topic_id = ' . (int) $this->topic_id; +		} +		else if (isset($this->forum_id)) +		{ +			$sql_array['LEFT_JOIN'] = array( +											array( +												'FROM'  => array(TOPICS_TABLE => 't'), +												'ON'    => 'a.topic_id = t.topic_id' +											) +										); +			$sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id; +		} + +		$sql = $db->sql_build_query('SELECT', $sql_array); +		$result = $db->sql_query($sql); + +		// Set attachments in feed items +		while ($row = $db->sql_fetchrow($result)) +		{ +			$this->attachments[$row['post_msg_id']][] = $row; +		} +		$db->sql_freeresult($result); +	}  } diff --git a/phpBB/phpbb/feed/topic.php b/phpBB/phpbb/feed/topic.php index 1eeb4fbe94..4b72d7e47a 100644 --- a/phpBB/phpbb/feed/topic.php +++ b/phpBB/phpbb/feed/topic.php @@ -96,7 +96,7 @@ class topic extends \phpbb\feed\post_base  	function get_sql()  	{  		$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, ' . +			'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, ' .  							'u.username, u.user_id',  			'FROM'		=> array(  				POSTS_TABLE		=> 'p', diff --git a/phpBB/phpbb/feed/topics.php b/phpBB/phpbb/feed/topics.php index d70195c87b..49f1253dc1 100644 --- a/phpBB/phpbb/feed/topics.php +++ b/phpBB/phpbb/feed/topics.php @@ -65,7 +65,7 @@ class topics extends \phpbb\feed\topic_base  		$this->sql = array(  			'SELECT'	=> 'f.forum_id, f.forum_name,  							t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, t.topic_time, t.topic_last_post_time, -							p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', +							p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment',  			'FROM'		=> array(  				TOPICS_TABLE	=> 't',  				POSTS_TABLE		=> 'p', diff --git a/phpBB/phpbb/feed/topics_active.php b/phpBB/phpbb/feed/topics_active.php index c6f46d67e6..b23ec8383f 100644 --- a/phpBB/phpbb/feed/topics_active.php +++ b/phpBB/phpbb/feed/topics_active.php @@ -82,7 +82,7 @@ class topics_active extends \phpbb\feed\topic_base  			'SELECT'	=> 'f.forum_id, f.forum_name,  							t.topic_id, t.topic_title, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views,  							t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_post_time, -							p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', +							p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment',  			'FROM'		=> array(  				TOPICS_TABLE	=> 't',  				POSTS_TABLE		=> 'p',  | 
