]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/atomlistnoticefeed.php
Merge branch 'master' into social-master
[quix0rs-gnu-social.git] / lib / atomlistnoticefeed.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Class for building an in-memory Atom feed for a particular list's
6  * timeline.
7  *
8  * PHP version 5
9  *
10  * LICENCE: This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * @category  Feed
24  * @package   StatusNet
25  * @author    Zach Copley <zach@status.net>
26  * @copyright 2010 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET'))
32 {
33     exit(1);
34 }
35
36 /**
37  * Class for list notice feeds.  May contain a reference to the list.
38  *
39  * @category Feed
40  * @package  StatusNet
41  * @author   Zach Copley <zach@status.net>
42  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43  * @link     http://status.net/
44  */
45 class AtomListNoticeFeed extends AtomNoticeFeed
46 {
47     private $list;
48     private $tagger;
49
50     /**
51      * Constructor
52      *
53      * @param List    $list    the list for the feed
54      * @param User    $cur     the current authenticated user, if any
55      * @param boolean $indent  flag to turn indenting on or off
56      *
57      * @return void
58      */
59     function __construct($list, $cur = null, $indent = true) {
60         parent::__construct($cur, $indent);
61         $this->list = $list;
62         $this->tagger = Profile::getKV('id', $list->tagger);
63
64         // TRANS: Title in atom list notice feed. %1$s is a list name, %2$s is a tagger's nickname.
65         $title = sprintf(_('Timeline for people in list %1$s by %2$s'), $list->tag, $this->tagger->nickname);
66         $this->setTitle($title);
67
68         $sitename   = common_config('site', 'name');
69         $subtitle   = sprintf(
70             // TRANS: Message is used as a subtitle in atom list notice feed.
71             // TRANS: %1$s is a tagger's nickname, %2$s is a list name, %3$s is a site name.
72             _('Updates from %1$s\'s list %2$s on %3$s!'),
73             $this->tagger->nickname,
74             $list->tag,
75             $sitename
76         );
77         $this->setSubtitle($subtitle);
78
79         $avatar = $this->tagger->avatarUrl(AVATAR_PROFILE_SIZE);
80         $this->setLogo($avatar);
81
82         $this->setUpdated('now');
83
84         $self = common_local_url('ApiTimelineList',
85                                  array('user' => $this->tagger->nickname,
86                                        'id' => $list->tag,
87                                        'format' => 'atom'));
88         $this->setId($self);
89         $this->setSelfLink($self);
90
91         $ao = ActivityObject::fromPeopletag($this->list);
92
93         $this->addAuthorRaw($ao->asString('author'));
94
95         $this->addLink($this->list->getUri());
96     }
97
98     function getList()
99     {
100         return $this->list;
101     }
102 }