3 * StatusNet, the distributed open-source microblogging tool
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @author Sarven Capadisli <csarven@status.net>
26 * @copyright 2008-2009 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/
31 if (!defined('GNUSOCIAL')) { exit(1); }
36 * When I created this page, "show stream" seemed like the best name for it.
37 * Now, it seems like a really bad name.
39 * It shows a stream of the user's posts, plus lots of profile info, links
40 * to subscriptions and stuff, etc.
44 * @author Evan Prodromou <evan@status.net>
45 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
46 * @link http://status.net/
48 class ShowstreamAction extends ProfileAction
52 protected function prepare(array $args=array())
54 parent::prepare($args);
56 if (empty($this->tag)) {
57 $stream = new ProfileNoticeStream($this->profile, $this->scoped);
59 $stream = new TaggedProfileNoticeStream($this->profile, $this->tag, $this->scoped);
62 $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
70 $base = $this->profile->getFancyName();
71 if (!empty($this->tag)) {
72 if ($this->page == 1) {
73 // TRANS: Page title showing tagged notices in one user's timeline.
74 // TRANS: %1$s is the username, %2$s is the hash tag.
75 return sprintf(_('Notices by %1$s tagged %2$s'), $base, $this->tag);
77 // TRANS: Page title showing tagged notices in one user's timeline.
78 // TRANS: %1$s is the username, %2$s is the hash tag, %3$d is the page number.
79 return sprintf(_('Notices by %1$s tagged %2$s, page %3$d'), $base, $this->tag, $this->page);
82 if ($this->page == 1) {
85 // TRANS: Extended page title showing tagged notices in one user's timeline.
86 // TRANS: %1$s is the username, %2$d is the page number.
87 return sprintf(_('Notices by %1$s, page %2$d'),
94 function showContent()
99 function showProfileBlock()
101 $block = new AccountProfileBlock($this, $this->profile);
105 function showPageNoticeBlock()
112 if (!empty($this->tag)) {
113 return array(new Feed(Feed::RSS1,
114 common_local_url('userrss',
115 array('nickname' => $this->target->nickname,
116 'tag' => $this->tag)),
117 // TRANS: Title for link to notice feed.
118 // TRANS: %1$s is a user nickname, %2$s is a hashtag.
119 sprintf(_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
120 $this->target->nickname, $this->tag)));
123 return array(new Feed(Feed::JSON,
124 common_local_url('ApiTimelineUser',
126 'id' => $this->user->id,
128 // TRANS: Title for link to notice feed.
129 // TRANS: %s is a user nickname.
130 sprintf(_('Notice feed for %s (Activity Streams JSON)'),
131 $this->target->nickname)),
133 common_local_url('userrss',
134 array('nickname' => $this->target->nickname)),
135 // TRANS: Title for link to notice feed.
136 // TRANS: %s is a user nickname.
137 sprintf(_('Notice feed for %s (RSS 1.0)'),
138 $this->target->nickname)),
140 common_local_url('ApiTimelineUser',
142 'id' => $this->user->id,
144 // TRANS: Title for link to notice feed.
145 // TRANS: %s is a user nickname.
146 sprintf(_('Notice feed for %s (RSS 2.0)'),
147 $this->target->nickname)),
149 common_local_url('ApiTimelineUser',
151 'id' => $this->user->id,
152 'format' => 'atom')),
153 // TRANS: Title for link to notice feed.
154 // TRANS: %s is a user nickname.
155 sprintf(_('Notice feed for %s (Atom)'),
156 $this->target->nickname)),
158 common_local_url('foaf', array('nickname' =>
159 $this->target->nickname)),
160 // TRANS: Title for link to notice feed. FOAF stands for Friend of a Friend.
161 // TRANS: More information at http://www.foaf-project.org. %s is a user nickname.
162 sprintf(_('FOAF for %s'), $this->target->nickname)));
167 if ($this->profile->bio) {
168 $this->element('meta', array('name' => 'description',
169 'content' => $this->profile->bio));
172 if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
173 $id = new Microid('mailto:'.$this->user->email,
175 $this->element('meta', array('name' => 'microid',
176 'content' => $id->toString()));
179 // See https://wiki.mozilla.org/Microsummaries
181 $this->element('link', array('rel' => 'microsummary',
182 'href' => common_local_url('microsummary',
183 array('nickname' => $this->profile->nickname))));
185 $rsd = common_local_url('rsd',
186 array('nickname' => $this->profile->nickname));
188 // RSD, http://tales.phrasewise.com/rfc/rsd
189 $this->element('link', array('rel' => 'EditURI',
190 'type' => 'application/rsd+xml',
193 if ($this->page != 1) {
194 $this->element('link', array('rel' => 'canonical',
195 'href' => $this->profile->profileurl));
199 function showEmptyListMessage()
201 // TRANS: First sentence of empty list message for a timeline. $1%s is a user nickname.
202 $message = sprintf(_('This is the timeline for %1$s, but %1$s hasn\'t posted anything yet.'), $this->target->nickname) . ' ';
204 if (common_logged_in()) {
205 $current_user = common_current_user();
206 if ($this->user->id === $current_user->id) {
207 // TRANS: Second sentence of empty list message for a stream for the user themselves.
208 $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
210 // TRANS: Second sentence of empty list message for a non-self timeline. %1$s is a user nickname, %2$s is a part of a URL.
211 // TRANS: This message contains a Markdown link. Keep "](" together.
212 $message .= sprintf(_('You can try to nudge %1$s or [post something to them](%%%%action.newnotice%%%%?status_textarea=%2$s).'), $this->target->nickname, '@' . $this->target->nickname);
216 // TRANS: Second sentence of empty message for anonymous users. %s is a user nickname.
217 // TRANS: This message contains a Markdown link. Keep "](" together.
218 $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->nickname);
221 $this->elementStart('div', 'guide');
222 $this->raw(common_markup_to_html($message));
223 $this->elementEnd('div');
226 function showNotices()
228 $pnl = new NoticeList($this->notice, $this);
231 $this->showEmptyListMessage();
234 $args = array('nickname' => $this->target->nickname);
235 if (!empty($this->tag))
237 $args['tag'] = $this->tag;
239 $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
240 'showstream', $args);
243 function showAnonymousMessage()
245 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
246 // TRANS: Announcement for anonymous users showing a timeline if site registrations are open.
247 // TRANS: This message contains a Markdown link. Keep "](" together.
248 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
249 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
250 '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
251 $this->target->nickname, $this->target->nickname);
253 // TRANS: Announcement for anonymous users showing a timeline if site registrations are closed or invite only.
254 // TRANS: This message contains a Markdown link. Keep "](" together.
255 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
256 'based on the Free Software [StatusNet](http://status.net/) tool.'),
257 $this->target->nickname, $this->target->nickname);
259 $this->elementStart('div', array('id' => 'anon_notice'));
260 $this->raw(common_markup_to_html($m));
261 $this->elementEnd('div');
264 function showSections()
266 parent::showSections();
267 if (!common_config('performance', 'high')) {
268 $cloud = new PersonalTagCloudSection($this, $this->user);
273 function noticeFormOptions()
275 $options = parent::noticeFormOptions();
276 $cur = common_current_user();
278 if (empty($cur) || $cur->id != $this->profile->id) {
279 $options['to_profile'] = $this->profile;