summaryrefslogtreecommitdiff
path: root/app/Controller/FeedController.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2018-02-02 15:39:47 -0800
committerFrédéric Guillot <fred@kanboard.net>2018-02-02 15:39:47 -0800
commitbab2fb3899cc243e2f67ccf787f3657b250f6e61 (patch)
tree07ddb755330b320fbd2e2803fdb978cfff3bd452 /app/Controller/FeedController.php
parent5c4d06d26b808ea50d08f83ae02ac82373fd2208 (diff)
Remove dependency on PicoFeed
Diffstat (limited to 'app/Controller/FeedController.php')
-rw-r--r--app/Controller/FeedController.php57
1 files changed, 8 insertions, 49 deletions
diff --git a/app/Controller/FeedController.php b/app/Controller/FeedController.php
index f9b0ed7c..f494ab1f 100644
--- a/app/Controller/FeedController.php
+++ b/app/Controller/FeedController.php
@@ -2,11 +2,7 @@
namespace Kanboard\Controller;
-use DateTime;
use Kanboard\Core\Controller\AccessForbiddenException;
-use PicoFeed\Syndication\AtomFeedBuilder;
-use PicoFeed\Syndication\AtomItemBuilder;
-use PicoFeed\Syndication\FeedBuilder;
/**
* Atom/RSS Feed controller
@@ -26,20 +22,16 @@ class FeedController extends BaseController
$token = $this->request->getStringParam('token');
$user = $this->userModel->getByToken($token);
- // Token verification
if (empty($user)) {
throw AccessForbiddenException::getInstance()->withoutLayout();
}
$events = $this->helper->projectActivity->getProjectsEvents($this->projectPermissionModel->getActiveProjectIds($user['id']));
- $feedBuilder = AtomFeedBuilder::create()
- ->withTitle(e('Project activities for %s', $this->helper->user->getFullname($user)))
- ->withFeedUrl($this->helper->url->to('FeedController', 'user', array('token' => $user['token']), '', true))
- ->withSiteUrl($this->helper->url->base())
- ->withDate(new DateTime());
-
- $this->response->xml($this->buildFeedItems($events, $feedBuilder)->build());
+ $this->response->xml($this->template->render('feed/user', [
+ 'user' => $user,
+ 'events' => $events,
+ ]));
}
/**
@@ -58,42 +50,9 @@ class FeedController extends BaseController
$events = $this->helper->projectActivity->getProjectEvents($project['id']);
- $feedBuilder = AtomFeedBuilder::create()
- ->withTitle(e('%s\'s activity', $project['name']))
- ->withFeedUrl($this->helper->url->to('FeedController', 'project', array('token' => $project['token']), '', true))
- ->withSiteUrl($this->helper->url->base())
- ->withDate(new DateTime());
-
- $this->response->xml($this->buildFeedItems($events, $feedBuilder)->build());
- }
-
- /**
- * Build feed items
- *
- * @access protected
- * @param array $events
- * @param FeedBuilder $feedBuilder
- * @return FeedBuilder
- */
- protected function buildFeedItems(array $events, FeedBuilder $feedBuilder)
- {
- foreach ($events as $event) {
- $itemDate = new DateTime();
- $itemDate->setTimestamp($event['date_creation']);
-
- $itemUrl = $this->helper->url->to('TaskViewController', 'show', array('task_id' => $event['task_id']), '', true);
-
- $feedBuilder
- ->withItem(AtomItemBuilder::create($feedBuilder)
- ->withTitle($event['event_title'])
- ->withUrl($itemUrl.'#event-'.$event['id'])
- ->withAuthor($event['author'])
- ->withPublishedDate($itemDate)
- ->withUpdatedDate($itemDate)
- ->withContent($event['event_content'])
- );
- }
-
- return $feedBuilder;
+ $this->response->xml($this->template->render('feed/project', [
+ 'project' => $project,
+ 'events' => $events,
+ ]));
}
}