Commit | Line | Data |
---|---|---|
4e9a7a6d FB |
1 | <?php |
2 | /*************************************************************************** | |
3 | * Copyright (C) 2003-2008 Polytechnique.org * | |
4 | * http://opensource.polytechnique.org/ * | |
5 | * * | |
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. * | |
10 | * * | |
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. * | |
15 | * * | |
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 * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
22 | require_once 'notifs.inc.php'; | |
23 | ||
24 | class CarnetFeedIterator implements PlIterator | |
25 | { | |
26 | private $notifs; | |
4018f0b3 | 27 | private $it; |
4e9a7a6d FB |
28 | |
29 | public function __construct(Notifs& $notifs) | |
30 | { | |
31 | $this->notifs =& $notifs; | |
20661fd0 | 32 | $this->it = PlIteratorUtils::fromArray($notifs->_data, 3); |
4e9a7a6d FB |
33 | } |
34 | ||
35 | public function next() | |
36 | { | |
4018f0b3 FB |
37 | $data = $this->it->next(); |
38 | if (is_null($data)) { | |
4e9a7a6d FB |
39 | return null; |
40 | } | |
4018f0b3 FB |
41 | $cid = $data['keys'][0]; |
42 | $x = $data['value']; | |
4e9a7a6d FB |
43 | |
44 | global $globals; | |
4e9a7a6d FB |
45 | @require_once 'Date.php'; |
46 | @$date = new Date($x['date']); | |
47 | @$date = $date->format('%e %B %Y'); | |
4018f0b3 | 48 | $author = $x['prenom'] . ' ' . $x['nom'] . ' (X' . $x['promo'] . ')'; |
4e9a7a6d FB |
49 | return array_merge($x, |
50 | array('author' => $author, | |
51 | 'publication' => $x['known'], | |
52 | 'id' => 'carnet' . $x['known'] . $cid . $x['bestalias'], | |
53 | 'link' => $globals->baseurl . '/profile/private/' | |
54 | . $x['bestalias'], | |
55 | 'title' => '[' . $this->notifs->_cats[$cid]['short'] . '] ' | |
56 | . $author . ' - le ' . $date)); | |
57 | } | |
58 | ||
59 | public function total() | |
60 | { | |
4018f0b3 | 61 | return $this->it->total(); |
4e9a7a6d FB |
62 | } |
63 | ||
64 | public function first() | |
65 | { | |
4018f0b3 | 66 | return $this->it->first(); |
4e9a7a6d FB |
67 | } |
68 | ||
69 | public function last() | |
70 | { | |
4018f0b3 | 71 | return $this->it->last(); |
4e9a7a6d FB |
72 | } |
73 | } | |
74 | ||
75 | class CarnetFeed extends PlFeed | |
76 | { | |
77 | public function __construct() | |
78 | { | |
79 | global $globals; | |
80 | parent::__construct($globals->core->sitename . ' :: Carnet', | |
81 | $globals->baseurl . '/carnet/panel', | |
82 | 'Ton carnet polytechnicien', | |
83 | $globals->baseurl . '/images/logo.png', | |
84 | 'carnet/rss.tpl'); | |
85 | } | |
86 | ||
87 | protected function fetch($user) | |
88 | { | |
89 | return new CarnetFeedIterator(new Notifs($user, false)); | |
90 | } | |
91 | } | |
92 | ||
93 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: | |
94 | ?> |