/** * Really send the feed * * @param feed_interface $feed * * @return Response * * @throw exception\feed_exception */ protected function send_feed_do(feed_interface $feed) { $feed_updated_time = 0; $item_vars = array(); $board_url = $this->feed_helper->get_board_url(); // Open Feed $feed->open(); // Iterate through items while ($row = $feed->get_item()) { /** * Event to modify the feed row * * @event core.feed_modify_feed_row * @var int forum_id Forum ID * @var string mode Feeds mode (forums|topics|topics_new|topics_active|news) * @var array row Array with feed data * @var int topic_id Topic ID * * @since 3.1.10-RC1 */ $vars = array('forum_id', 'mode', 'row', 'topic_id'); extract($this->phpbb_dispatcher->trigger_event('core.feed_modify_feed_row', compact($vars))); // BBCode options to correctly disable urls, smilies, bbcode... if ($feed->get('options') === null) { // Allow all combinations $options = 7; if ($feed->get('enable_bbcode') !== null && $feed->get('enable_smilies') !== null && $feed->get('enable_magic_url') !== null) { $options = ($row[$feed->get('enable_bbcode')] ? OPTION_FLAG_BBCODE : 0) + ($row[$feed->get('enable_smilies')] ? OPTION_FLAG_SMILIES : 0) + ($row[$feed->get('enable_magic_url')] ? OPTION_FLAG_LINKS : 0); } } else { $options = $row[$feed->get('options')]; } $title = isset($row[$feed->get('title')]) && $row[$feed->get('title')] !== '' ? $row[$feed->get('title')] : (isset($row[$feed->get('title2')]) ? $row[$feed->get('title2')] : ''); $published = $feed->get('published') !== null ? (int) $row[$feed->get('published')] : 0; $updated = $feed->get('updated') !== null ? (int) $row[$feed->get('updated')] : 0; $display_attachments = $this->auth->acl_get('u_download') && $this->auth->acl_get('f_download', $row['forum_id']) && isset($row['post_attachment']) && $row['post_attachment'] ? true : false; $item_row = array('author' => $feed->get('creator') !== null ? $row[$feed->get('creator')] : '', 'published' => $published > 0 ? $this->feed_helper->format_date($published) : '', 'updated' => $updated > 0 ? $this->feed_helper->format_date($updated) : '', 'link' => '', 'title' => censor_text($title), 'category' => $this->config['feed_item_statistics'] && !empty($row['forum_id']) ? $board_url . '/viewforum.' . $this->php_ext . '?f=' . $row['forum_id'] : '', 'category_name' => $this->config['feed_item_statistics'] && isset($row['forum_name']) ? $row['forum_name'] : '', 'description' => censor_text($this->feed_helper->generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], $display_attachments ? $feed->get_attachments($row['post_id']) : array())), 'statistics' => ''); // Adjust items, fill link, etc. $feed->adjust_item($item_row, $row); $item_vars[] = $item_row; $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. if (!$feed_updated_time) { $feed_updated_time = time(); } $feed->close(); $content = $this->template->render('feed.xml.twig', array('FEED_IMAGE' => '', 'SELF_LINK' => $this->controller_helper->route($this->request->attributes->get('_route'), $this->request->attributes->get('_route_params'), true, '', UrlGeneratorInterface::ABSOLUTE_URL), 'FEED_LINK' => $board_url . '/index.' . $this->php_ext, 'FEED_TITLE' => $this->config['sitename'], 'FEED_SUBTITLE' => $this->config['site_desc'], 'FEED_UPDATED' => $this->feed_helper->format_date($feed_updated_time), 'FEED_LANG' => $this->user->lang['USER_LANG'], 'FEED_AUTHOR' => $this->config['sitename'], 'FEED_ROWS' => $item_vars)); $response = new Response($content); $response->headers->set('Content-Type', 'application/atom+xml'); $response->setCharset('UTF-8'); $response->setLastModified(new \DateTime('@' . $feed_updated_time)); if (!empty($this->user->data['is_bot'])) { // Let reverse proxies know we detected a bot. $response->headers->set('X-PHPBB-IS-BOT', 'yes'); } return $response; }
function user_viewprofile($row) { $author_id = (int) $row[$this->get('author_id')]; if ($author_id == ANONYMOUS) { // Since we cannot link to a profile, we just return GUEST // instead of $row['username'] return $this->user->lang['GUEST']; } return '<a href="' . $this->helper->append_sid('memberlist.' . $this->phpEx, 'mode=viewprofile&u=' . $author_id) . '">' . $row[$this->get('creator')] . '</a>'; }