aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/feed
diff options
context:
space:
mode:
authorDhruv <dhruv.goel92@gmail.com>2013-10-05 16:54:09 +0530
committerDhruv <dhruv.goel92@gmail.com>2013-10-05 16:54:09 +0530
commit7a971f896d9a09037959d26794b8efe09aa1258e (patch)
tree6ffccdcc3270368b8b56982c4f50beb7e4b9596d /phpBB/phpbb/feed
parente8c7f8134df38708e1af27325d2c8a7b9f28052e (diff)
parentc73801242d5c1abc3efb4ac75b4cc1a5d01ce514 (diff)
downloadforums-7a971f896d9a09037959d26794b8efe09aa1258e.tar
forums-7a971f896d9a09037959d26794b8efe09aa1258e.tar.gz
forums-7a971f896d9a09037959d26794b8efe09aa1258e.tar.bz2
forums-7a971f896d9a09037959d26794b8efe09aa1258e.tar.xz
forums-7a971f896d9a09037959d26794b8efe09aa1258e.zip
Merge branch 'ticket/11271' into ticket/11271-develop
# By erangamapa (7) and Dhruv (2) * ticket/11271: [ticket/11271] Typecast forum and topic id to integer [ticket/11271] Use absolute path for displaying inline attachments in feeds [ticket/11271] Changed executable bit. [ticket/11271] Formatting code and removing null assignment. [ticket/11271] Removing unnecessary database object [ticket/11271] Separated attachment fetching query [ticket/11271] Fetched feed attachments before loop. [ticket/11271] Removed in-line attachment comments properly. [ticket/11271] Displaying in-line attached images in ATOM feed. Conflicts: phpBB/feed.php
Diffstat (limited to 'phpBB/phpbb/feed')
-rw-r--r--phpBB/phpbb/feed/forum.php2
-rw-r--r--phpBB/phpbb/feed/helper.php14
-rw-r--r--phpBB/phpbb/feed/news.php2
-rw-r--r--phpBB/phpbb/feed/overall.php2
-rw-r--r--phpBB/phpbb/feed/post_base.php40
-rw-r--r--phpBB/phpbb/feed/topic.php2
-rw-r--r--phpBB/phpbb/feed/topics.php2
-rw-r--r--phpBB/phpbb/feed/topics_active.php2
8 files changed, 58 insertions, 8 deletions
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',