From f9cdec90fc184ce939c8b7ef6fc755e459456947 Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@gmx.de> Date: Tue, 22 Apr 2014 18:55:17 +0200 Subject: [PATCH] [ticket/12413] Revert e65a6dd8f45d0ce4c8700fb68c19ac6268162aa0 "Merge remote-tracking branch 'dhruvgoel92/ticket/11271' into develop-olympus" This reverts commit e65a6dd8f45d0ce4c8700fb68c19ac6268162aa0, reversing changes made to 214f515e9ccc71e368882384fb38bd7135b0e40f. PHPBB3-12413 --- phpBB/feed.php | 79 ++++++-------------------------------------------- 1 file changed, 9 insertions(+), 70 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index 04bb0f40ea..9816f0f303 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -71,9 +71,6 @@ if ($feed === false) trigger_error('NO_FEED'); } -// Get attachments for this feed -$feed->fetch_attachments(); - // Open Feed $feed->open(); @@ -109,7 +106,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(feed_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()))), + 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options)), 'statistics' => '', ); @@ -275,16 +272,8 @@ function feed_format_date($time) /** * 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 **/ -function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $post_attachments) +function feed_generate_content($content, $uid, $bitfield, $options) { global $user, $config, $phpbb_root_path, $phpEx, $board_url; @@ -333,15 +322,8 @@ function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $ // 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); - } - // Remove Comments from inline attachments [ia] - $content = preg_replace('#<dd>(.*?)</dd>#','',$content); + $content = preg_replace('#<div class="(inline-attachment|attachtitle)">(.*?)<!-- ia(.*?) -->(.*?)<!-- ia(.*?) -->(.*?)</div>#si','$4',$content); // Replace some entities with their unicode counterpart $entities = array( @@ -359,9 +341,6 @@ function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $ // Other control characters $content = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $content); - // Convert attachments' relative path to absolute path - $content = str_replace($phpbb_root_path . 'download/file.' . $phpEx, $board_url . '/download/file.' . $phpEx, $content); - return $content; } @@ -681,7 +660,6 @@ class phpbb_feed_base class phpbb_feed_post_base extends phpbb_feed_base { var $num_items = 'feed_limit_post'; - var $attachments = array(); function set_keys() { @@ -715,45 +693,6 @@ class phpbb_feed_post_base extends phpbb_feed_base . (($this->is_moderator_approve_forum($row['forum_id']) && !$row['post_approved']) ? ' ' . $this->separator_stats . ' ' . $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); - } } /** @@ -856,7 +795,7 @@ class phpbb_feed_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_approved, 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, ' . + 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( USERS_TABLE => 'u', @@ -988,7 +927,7 @@ class phpbb_feed_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_approved, 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.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( POSTS_TABLE => 'p', @@ -1153,7 +1092,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base global $auth, $db; $this->sql = array( - 'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_approved, 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_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( POSTS_TABLE => 'p', @@ -1318,7 +1257,7 @@ class phpbb_feed_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_replies, t.topic_replies_real, 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_attachment', + 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', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', @@ -1391,7 +1330,7 @@ class phpbb_feed_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_replies, t.topic_replies_real, 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_attachment', + 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', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', @@ -1488,7 +1427,7 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_replies, t.topic_replies_real, 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_attachment', + 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', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p',