2 /***************************************************************************
3 * Copyright (C) 2003-2008 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
32 public $last_modification;
39 public function __construct($tpl, array& $data)
41 $this->template
= $tpl;
42 foreach ($data as $key => $value) {
48 /** An abstract feed. A feed is nothing more than a set of article.
50 abstract class PlFeed
implements PlIterator
61 public function __construct($title, $link, $desc, $img_link,
63 $this->title
= $title;
65 $this->description
= $desc;
66 $this->img_link
= $img_link;
67 $this->article_tpl
= $article_tpl;
70 /** Fetch the feed for the given user.
72 abstract protected function fetch($user);
74 public function next()
76 $data = $this->iterator
->next();
78 return new PlFeedArticle($this->article_tpl
, $data);
83 public function total()
85 return $this->iterator
->total();
88 public function first()
90 return $this->iterator
->first();
93 public function last()
95 return $this->iterator
->last();
98 public function run(PlPage
& $page, $login, $token, $require_auth = true
, $type = 'rss2')
100 $user = Platal
::session()->tokenAuth($login, $token);
109 $page->assign('rss_hash', $token);
110 header('Content-Type: application/rss+xml; charset=utf8');
111 $this->iterator
= $this->fetch($user);
112 $page->coreTpl('feed.' . $type . '.tpl', NO_SKIN
);
113 $page->assign_by_ref('feed', $this);
118 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: