diff options
Diffstat (limited to 'phpBB/phpbb')
| -rw-r--r-- | phpBB/phpbb/feed/forum.php | 2 | ||||
| -rw-r--r-- | phpBB/phpbb/feed/helper.php | 31 | ||||
| -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 | 38 | ||||
| -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 | 
8 files changed, 72 insertions, 9 deletions
| diff --git a/phpBB/phpbb/feed/forum.php b/phpBB/phpbb/feed/forum.php index 8026824ab7..85ecb60f7e 100644 --- a/phpBB/phpbb/feed/forum.php +++ b/phpBB/phpbb/feed/forum.php @@ -109,7 +109,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 3f2759b85e..12acf997ac 100644 --- a/phpBB/phpbb/feed/helper.php +++ b/phpBB/phpbb/feed/helper.php @@ -24,6 +24,9 @@ class helper  	/** @var string */  	protected $phpbb_root_path; +	/** @var string */ +	protected $phpEx; +  	/**  	* Constructor  	* @@ -32,11 +35,12 @@ class helper  	* @param	string	$phpbb_root_path	Root path  	* @return	null  	*/ -	public function __construct(\phpbb\config\config $config, \phpbb\user $user, $phpbb_root_path) +	public function __construct(\phpbb\config\config $config, \phpbb\user $user, $phpbb_root_path, $phpEx)  	{  		$this->config = $config;  		$this->user = $user;  		$this->phpbb_root_path = $phpbb_root_path; +		$this->phpEx = $phpEx;  	}  	/** @@ -81,8 +85,16 @@ class helper  	/**  	* Generate text content +	* +	* @param string $content is feed text content +	* @param string $uid is bbcode_uid +	* @param string $bitfield is bbcode bitfield +	* @param int $options bbcode flag options +	* @param int $forum_id is the forum id +	* @param array $post_attachments is an array containing the attachments and their respective info +	* @return string the html content to be printed for the feed  	*/ -	public function generate_content($content, $uid, $bitfield, $options) +	public function generate_content($content, $uid, $bitfield, $options, $forum_id, $post_attachments)  	{  		if (empty($content))  		{ @@ -129,8 +141,21 @@ 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 (!empty($post_attachments)) +		{ +			$update_count = array(); +			parse_attachments($forum_id, $content, $post_attachments, $update_count); +			$post_attachments = implode('<br />', $post_attachments); + +			// Convert attachments' relative path to absolute path +			$post_attachments = str_replace($this->phpbb_root_path . 'download/file.' . $this->phpEx, $this->get_board_url() . '/download/file.' . $this->phpEx, $post_attachments); + +			$content .= $post_attachments; +		} +  		// 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( diff --git a/phpBB/phpbb/feed/news.php b/phpBB/phpbb/feed/news.php index 7888e73239..1b7c452a92 100644 --- a/phpBB/phpbb/feed/news.php +++ b/phpBB/phpbb/feed/news.php @@ -85,7 +85,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 4545ba5c64..d99200475e 100644 --- a/phpBB/phpbb/feed/overall.php +++ b/phpBB/phpbb/feed/overall.php @@ -53,7 +53,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 42c5eea9e3..c797d6a8ca 100644 --- a/phpBB/phpbb/feed/post_base.php +++ b/phpBB/phpbb/feed/post_base.php @@ -17,6 +17,7 @@ namespace phpbb\feed;  abstract class post_base extends \phpbb\feed\base  {  	var $num_items = 'feed_limit_post'; +	var $attachments = array();  	function set_keys()  	{ @@ -48,4 +49,41 @@ 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() +	{ +		$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 = $this->db->sql_build_query('SELECT', $sql_array); +		$result = $this->db->sql_query($sql); + +		// Set attachments in feed items +		while ($row = $this->db->sql_fetchrow($result)) +		{ +			$this->attachments[$row['post_msg_id']][] = $row; +		} +		$this->db->sql_freeresult($result); +	}  } diff --git a/phpBB/phpbb/feed/topic.php b/phpBB/phpbb/feed/topic.php index 09f377dd10..a7acfb502f 100644 --- a/phpBB/phpbb/feed/topic.php +++ b/phpBB/phpbb/feed/topic.php @@ -88,7 +88,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 bdc858e947..e8b9f6de6c 100644 --- a/phpBB/phpbb/feed/topics.php +++ b/phpBB/phpbb/feed/topics.php @@ -57,7 +57,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 cc0adac2eb..809a536c2a 100644 --- a/phpBB/phpbb/feed/topics_active.php +++ b/phpBB/phpbb/feed/topics_active.php @@ -74,7 +74,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', | 
