From 24520f26ad5aaf812cfffbedc4ccafd5d47e14f7 Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Fri, 21 Jan 2011 15:45:10 -0700 Subject: [PATCH 1/5] [ticket/10009] Differentiate published from updated in Atom feed Change the handling of dates to differentiate between the date when an entry was published and the date on which it was last updated. Incorporate this information into the Atom feed by using and appropriately according to sections 4.2.9 and 4.2.15 of the spec. PHPBB3-10009 --- phpBB/feed.php | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index c4b71f3a26..36655d694f 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -95,11 +95,13 @@ while ($row = $feed->get_item()) $title = (isset($row[$feed->get('title')]) && $row[$feed->get('title')] !== '') ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : ''); - $item_time = (int) $row[$feed->get('date')]; + $published = ($feed->get('published') !== NULL) ? (int) $row[$feed->get('published')] : 0; + $updated = ($feed->get('updated') !== NULL) ? (int) $row[$feed->get('updated')] : 0; $item_row = array( 'author' => ($feed->get('creator') !== NULL) ? $row[$feed->get('creator')] : '', - 'pubdate' => feed_format_date($item_time), + 'published' => ($published > 0) ? feed_format_date($published) : '', + 'updated' => ($updated > 0) ? feed_format_date($updated) : '', 'link' => '', 'title' => censor_text($title), 'category' => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '', @@ -113,7 +115,7 @@ while ($row = $feed->get_item()) $item_vars[] = $item_row; - $feed_updated_time = max($feed_updated_time, $item_time); + $feed_updated_time = max($feed_updated_time, $published, $updated); } // If we do not have any items at all, sending the current time is better than sending no time. @@ -192,7 +194,16 @@ foreach ($item_vars as $row) echo '' . "\n"; } - echo '' . $row['pubdate'] . '' . "\n"; + if (!empty($row['published'])) + { + echo '' . $row['published'] . '' . "\n"; + } + + if (!empty($row['updated'])) + { + echo '' . $row['updated'] . '' . "\n"; + } + echo '' . $row['link'] . '' . "\n"; echo '' . "\n"; echo '<![CDATA[' . $row['title'] . ']]>' . "\n\n"; @@ -675,7 +686,8 @@ class phpbb_feed_post_base extends phpbb_feed_base $this->set('author_id', 'user_id'); $this->set('creator', 'username'); - $this->set('date', 'post_time'); + $this->set('published', 'post_time'); + $this->set('updated', 'post_edit_time'); $this->set('text', 'post_text'); $this->set('bitfield', 'bbcode_bitfield'); @@ -717,7 +729,8 @@ class phpbb_feed_topic_base extends phpbb_feed_base $this->set('author_id', 'topic_poster'); $this->set('creator', 'topic_first_poster_name'); - $this->set('date', 'topic_time'); + $this->set('published', 'topic_time'); + $this->set('updated', 'topic_last_post_time'); $this->set('text', 'post_text'); $this->set('bitfield', 'bbcode_bitfield'); @@ -737,7 +750,7 @@ class phpbb_feed_topic_base extends phpbb_feed_base if ($config['feed_item_statistics']) { $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) - . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('date')]) + . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('updated')]) . ' ' . $this->separator_stats . ' ' . $user->lang['REPLIES'] . ' ' . (($this->is_moderator_approve_forum($row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies']) . ' ' . $this->separator_stats . ' ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'] . (($this->is_moderator_approve_forum($row['forum_id']) && ($row['topic_replies_real'] != $row['topic_replies'])) ? ' ' . $this->separator_stats . ' ' . $user->lang['POSTS_UNAPPROVED'] : ''); @@ -800,7 +813,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_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_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', @@ -932,7 +945,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_approved, 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_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', @@ -1097,7 +1110,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_approved, 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_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', @@ -1136,7 +1149,7 @@ class phpbb_feed_forums extends phpbb_feed_base $this->set('text', 'forum_desc'); $this->set('bitfield', 'forum_desc_bitfield'); $this->set('bbcode_uid','forum_desc_uid'); - $this->set('date', 'forum_last_post_time'); + $this->set('updated', 'forum_last_post_time'); $this->set('options', 'forum_desc_options'); } @@ -1261,7 +1274,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_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_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', 'FROM' => array( TOPICS_TABLE => 't', @@ -1334,7 +1347,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_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_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', 'FROM' => array( TOPICS_TABLE => 't', @@ -1381,7 +1394,7 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base $this->set('author_id', 'topic_last_poster_id'); $this->set('creator', 'topic_last_poster_name'); - $this->set('date', 'topic_last_post_time'); + $this->set('updated', 'topic_last_post_time'); $this->set('text', 'post_text'); } From df93856ac45690fa1c84bc383d7a70a1225be8cc Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Fri, 28 Jan 2011 21:11:55 -0700 Subject: [PATCH 2/5] [ticket/10009] Send atom:updated whenever possible For posts/topics which have not been edited/updated, use the creation date to populate atom:updated, as suggested by bantu. This should increase compatibility with user agents which expect an atom:updated element. PHPBB3-10009 --- phpBB/feed.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/feed.php b/phpBB/feed.php index 36655d694f..a95b3abf9a 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -203,6 +203,10 @@ foreach ($item_vars as $row) { echo '' . $row['updated'] . '' . "\n"; } + else if (!empty($row['published'])) + { + echo '' . $row['published'] . '' . "\n"; + } echo '' . $row['link'] . '' . "\n"; echo '' . "\n"; From 361f6fc16c98f8e083337481277e81c0cb060f38 Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Mon, 31 Jan 2011 06:52:41 -0700 Subject: [PATCH 3/5] [ticket/10009] Make atom:update output unconditional and before atom:published PHPBB3-10009 --- phpBB/feed.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index a95b3abf9a..a69a24d062 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -194,20 +194,13 @@ foreach ($item_vars as $row) echo '' . "\n"; } + echo '' . ((!empty($row['updated'])) ? $row['updated'] : $row['published']) . '' . "\n"; + if (!empty($row['published'])) { echo '' . $row['published'] . '' . "\n"; } - if (!empty($row['updated'])) - { - echo '' . $row['updated'] . '' . "\n"; - } - else if (!empty($row['published'])) - { - echo '' . $row['published'] . '' . "\n"; - } - echo '' . $row['link'] . '' . "\n"; echo '' . "\n"; echo '<![CDATA[' . $row['title'] . ']]>' . "\n\n"; From 366107a54ca38afbe5635a1bf8b8c54758a8df4a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 21 Feb 2011 19:50:11 +0100 Subject: [PATCH 4/5] [ticket/10009] Always show 'published' data in feed item statistics. PHPBB3-10009 --- phpBB/feed.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index a69a24d062..75a47630ca 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -704,7 +704,7 @@ class phpbb_feed_post_base extends phpbb_feed_base if ($config['feed_item_statistics']) { $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) - . ' ' . $this->separator_stats . ' ' . $user->format_date($row['post_time']) + . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('published')]) . (($this->is_moderator_approve_forum($row['forum_id']) && !$row['post_approved']) ? ' ' . $this->separator_stats . ' ' . $user->lang['POST_UNAPPROVED'] : ''); } } @@ -747,7 +747,7 @@ class phpbb_feed_topic_base extends phpbb_feed_base if ($config['feed_item_statistics']) { $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) - . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('updated')]) + . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('published')]) . ' ' . $this->separator_stats . ' ' . $user->lang['REPLIES'] . ' ' . (($this->is_moderator_approve_forum($row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies']) . ' ' . $this->separator_stats . ' ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'] . (($this->is_moderator_approve_forum($row['forum_id']) && ($row['topic_replies_real'] != $row['topic_replies'])) ? ' ' . $this->separator_stats . ' ' . $user->lang['POSTS_UNAPPROVED'] : ''); From d11a0097d0a0a7b69ee644bd9c9d5e35d124bed0 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 21 Feb 2011 19:56:54 +0100 Subject: [PATCH 5/5] [ticket/10009] Entries are always posts, update fields accordingly. PHPBB3-10009 --- phpBB/feed.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index 75a47630ca..d737b8e10c 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -726,8 +726,8 @@ class phpbb_feed_topic_base extends phpbb_feed_base $this->set('author_id', 'topic_poster'); $this->set('creator', 'topic_first_poster_name'); - $this->set('published', 'topic_time'); - $this->set('updated', 'topic_last_post_time'); + $this->set('published', 'post_time'); + $this->set('updated', 'post_edit_time'); $this->set('text', 'post_text'); $this->set('bitfield', 'bbcode_bitfield'); @@ -1272,7 +1272,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_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', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', @@ -1345,7 +1345,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_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', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', @@ -1391,8 +1391,6 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base $this->set('author_id', 'topic_last_poster_id'); $this->set('creator', 'topic_last_poster_name'); - $this->set('updated', 'topic_last_post_time'); - $this->set('text', 'post_text'); } function get_sql() @@ -1444,7 +1442,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_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', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p',