diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Controller/FeedController.php | 57 | ||||
-rw-r--r-- | app/Template/feed/project.php | 23 | ||||
-rw-r--r-- | app/Template/feed/user.php | 23 |
3 files changed, 54 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, + ])); } } diff --git a/app/Template/feed/project.php b/app/Template/feed/project.php new file mode 100644 index 00000000..5bf4264e --- /dev/null +++ b/app/Template/feed/project.php @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <title><?= e("%s's activity", $project['name']) ?></title> + <updated><?= date(DATE_ATOM) ?></updated> + <link rel="alternate" type="text/html" href="<?= $this->url->base() ?>"/> + <link rel="self" type="application/atom+xml" href="<?= $this->url->href('FeedController', 'project', ['token' => $project['token']], false, '', true) ?>"/> + <id><?= $this->url->href('FeedController', 'project', ['token' => $project['token']], false, '', true) ?></id> + + <?php foreach ($events as $event): ?> + <entry> + <id><?= $this->url->href('TaskViewController', 'show', ['task_id' => $event['task_id']], false, 'event-'.$event['id'], true) ?></id> + <link rel="alternate" type="text/html" href="<?= $this->url->href('TaskViewController', 'show', ['task_id' => $event['task_id']], false, 'event-'.$event['id'], true) ?>"/> + <updated><?= date(DATE_ATOM, $event['date_creation']) ?></updated> + <published><?= date(DATE_ATOM, $event['date_creation']) ?></published> + <author> + <name><?= $event['author'] ?></name> + </author> + <title><?= $event['event_title'] ?></title> + <content type="html"><![CDATA[<?= $event['event_content'] ?>]]></content> + </entry> + <?php endforeach ?> + +</feed>
\ No newline at end of file diff --git a/app/Template/feed/user.php b/app/Template/feed/user.php new file mode 100644 index 00000000..7d3c596a --- /dev/null +++ b/app/Template/feed/user.php @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <title><?= e('Project activities for %s', $this->user->getFullname($user)) ?></title> + <updated><?= date(DATE_ATOM) ?></updated> + <link rel="alternate" type="text/html" href="<?= $this->url->base() ?>"/> + <link rel="self" type="application/atom+xml" href="<?= $this->url->href('FeedController', 'user', ['token' => $user['token']], false, '', true) ?>"/> + <id><?= $this->url->href('FeedController', 'user', ['token' => $user['token']], false, '', true) ?></id> + + <?php foreach ($events as $event): ?> + <entry> + <id><?= $this->url->href('TaskViewController', 'show', ['task_id' => $event['task_id']], false, 'event-'.$event['id'], true) ?></id> + <link rel="alternate" type="text/html" href="<?= $this->url->href('TaskViewController', 'show', ['task_id' => $event['task_id']], false, 'event-'.$event['id'], true) ?>"/> + <updated><?= date(DATE_ATOM, $event['date_creation']) ?></updated> + <published><?= date(DATE_ATOM, $event['date_creation']) ?></published> + <author> + <name><?= $event['author'] ?></name> + </author> + <title><?= $event['event_title'] ?></title> + <content type="html"><![CDATA[<?= $event['event_content'] ?>]]></content> + </entry> + <?php endforeach ?> + +</feed>
\ No newline at end of file |