]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/showstream.php
Maximum character limit with utf8mb4 is 191 in varchar
[quix0rs-gnu-social.git] / actions / showstream.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * User profile page
6  *
7  * PHP version 5
8  *
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.
13  *
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.
18  *
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/>.
21  *
22  * @category  Personal
23  * @package   StatusNet
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/
29  */
30
31 if (!defined('GNUSOCIAL')) { exit(1); }
32
33 /**
34  * User profile page
35  *
36  * When I created this page, "show stream" seemed like the best name for it.
37  * Now, it seems like a really bad name.
38  *
39  * It shows a stream of the user's posts, plus lots of profile info, links
40  * to subscriptions and stuff, etc.
41  *
42  * @category Personal
43  * @package  StatusNet
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/
47  */
48 class ShowstreamAction extends NoticestreamAction
49 {
50     public function getStream()
51     {
52         if (empty($this->tag)) {
53             $stream = new ProfileNoticeStream($this->target, $this->scoped);
54         } else {
55             $stream = new TaggedProfileNoticeStream($this->target, $this->tag, $this->scoped);
56         }
57
58         return $stream;
59     }
60
61
62     function title()
63     {
64         $base = $this->target->getFancyName();
65         if (!empty($this->tag)) {
66             if ($this->page == 1) {
67                 // TRANS: Page title showing tagged notices in one user's timeline.
68                 // TRANS: %1$s is the username, %2$s is the hash tag.
69                 return sprintf(_('Notices by %1$s tagged %2$s'), $base, $this->tag);
70             } else {
71                 // TRANS: Page title showing tagged notices in one user's timeline.
72                 // TRANS: %1$s is the username, %2$s is the hash tag, %3$d is the page number.
73                 return sprintf(_('Notices by %1$s tagged %2$s, page %3$d'), $base, $this->tag, $this->page);
74             }
75         } else {
76             if ($this->page == 1) {
77                 return $base;
78             } else {
79                 // TRANS: Extended page title showing tagged notices in one user's timeline.
80                 // TRANS: %1$s is the username, %2$d is the page number.
81                 return sprintf(_('Notices by %1$s, page %2$d'),
82                                $base,
83                                $this->page);
84             }
85         }
86     }
87
88     function showContent()
89     {
90         $this->showNotices();
91     }
92
93     function showProfileBlock()
94     {
95         $block = new AccountProfileBlock($this, $this->target);
96         $block->show();
97     }
98
99     function showPageNoticeBlock()
100     {
101         return;
102     }
103
104     function getFeeds()
105     {
106         if (!empty($this->tag)) {
107             return array(new Feed(Feed::RSS1,
108                                   common_local_url('userrss',
109                                                    array('nickname' => $this->target->getNickname(),
110                                                          'tag' => $this->tag)),
111                                   // TRANS: Title for link to notice feed.
112                                   // TRANS: %1$s is a user nickname, %2$s is a hashtag.
113                                   sprintf(_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
114                                           $this->target->getNickname(), $this->tag)));
115         }
116
117         return array(new Feed(Feed::JSON,
118                               common_local_url('ApiTimelineUser',
119                                                array(
120                                                     'id' => $this->target->getID(),
121                                                     'format' => 'as')),
122                               // TRANS: Title for link to notice feed.
123                               // TRANS: %s is a user nickname.
124                               sprintf(_('Notice feed for %s (Activity Streams JSON)'),
125                                       $this->target->getNickname())),
126                      new Feed(Feed::RSS1,
127                               common_local_url('userrss',
128                                                array('nickname' => $this->target->getNickname())),
129                               // TRANS: Title for link to notice feed.
130                               // TRANS: %s is a user nickname.
131                               sprintf(_('Notice feed for %s (RSS 1.0)'),
132                                       $this->target->getNickname())),
133                      new Feed(Feed::RSS2,
134                               common_local_url('ApiTimelineUser',
135                                                array(
136                                                     'id' => $this->target->getID(),
137                                                     'format' => 'rss')),
138                               // TRANS: Title for link to notice feed.
139                               // TRANS: %s is a user nickname.
140                               sprintf(_('Notice feed for %s (RSS 2.0)'),
141                                       $this->target->getNickname())),
142                      new Feed(Feed::ATOM,
143                               common_local_url('ApiTimelineUser',
144                                                array(
145                                                     'id' => $this->target->getID(),
146                                                     'format' => 'atom')),
147                               // TRANS: Title for link to notice feed.
148                               // TRANS: %s is a user nickname.
149                               sprintf(_('Notice feed for %s (Atom)'),
150                                       $this->target->getNickname())),
151                      new Feed(Feed::FOAF,
152                               common_local_url('foaf', array('nickname' =>
153                                                              $this->target->getNickname())),
154                               // TRANS: Title for link to notice feed. FOAF stands for Friend of a Friend.
155                               // TRANS: More information at http://www.foaf-project.org. %s is a user nickname.
156                               sprintf(_('FOAF for %s'), $this->target->getNickname())));
157     }
158
159     function extraHead()
160     {
161         if ($this->target->bio) {
162             $this->element('meta', array('name' => 'description',
163                                          'content' => $this->target->getDescription()));
164         }
165
166         // See https://wiki.mozilla.org/Microsummaries
167
168         $this->element('link', array('rel' => 'microsummary',
169                                      'href' => common_local_url('microsummary',
170                                                                 array('nickname' => $this->target->getNickname()))));
171
172         $rsd = common_local_url('rsd',
173                                 array('nickname' => $this->target->getNickname()));
174
175         // RSD, http://tales.phrasewise.com/rfc/rsd
176         $this->element('link', array('rel' => 'EditURI',
177                                      'type' => 'application/rsd+xml',
178                                      'href' => $rsd));
179
180         if ($this->page != 1) {
181             $this->element('link', array('rel' => 'canonical',
182                                          'href' => $this->target->getUrl()));
183         }
184     }
185
186     function showEmptyListMessage()
187     {
188         // TRANS: First sentence of empty list message for a timeline. $1%s is a user nickname.
189         $message = sprintf(_('This is the timeline for %1$s, but %1$s hasn\'t posted anything yet.'), $this->target->getNickname()) . ' ';
190
191         if ($this->scoped instanceof Profile) {
192             if ($this->target->getID() === $this->scoped->getID()) {
193                 // TRANS: Second sentence of empty list message for a stream for the user themselves.
194                 $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
195             } else {
196                 // 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.
197                 // TRANS: This message contains a Markdown link. Keep "](" together.
198                 $message .= sprintf(_('You can try to nudge %1$s or [post something to them](%%%%action.newnotice%%%%?status_textarea=%2$s).'), $this->target->getNickname(), '@' . $this->target->getNickname());
199             }
200         }
201         else {
202             // TRANS: Second sentence of empty message for anonymous users. %s is a user nickname.
203             // TRANS: This message contains a Markdown link. Keep "](" together.
204             $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->getNickname());
205         }
206
207         $this->elementStart('div', 'guide');
208         $this->raw(common_markup_to_html($message));
209         $this->elementEnd('div');
210     }
211
212     function showNotices()
213     {
214         $pnl = new NoticeList($this->notice, $this);
215         $cnt = $pnl->show();
216         if (0 == $cnt) {
217             $this->showEmptyListMessage();
218         }
219
220         $args = array('nickname' => $this->target->getNickname());
221         if (!empty($this->tag))
222         {
223             $args['tag'] = $this->tag;
224         }
225         $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
226                           'showstream', $args);
227     }
228
229     function showAnonymousMessage()
230     {
231         if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
232             // TRANS: Announcement for anonymous users showing a timeline if site registrations are open.
233             // TRANS: This message contains a Markdown link. Keep "](" together.
234             $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
235                            'based on the Free Software [StatusNet](http://status.net/) tool. ' .
236                            '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
237                          $this->target->getNickname(), $this->target->getNickname());
238         } else {
239             // TRANS: Announcement for anonymous users showing a timeline if site registrations are closed or invite only.
240             // TRANS: This message contains a Markdown link. Keep "](" together.
241             $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
242                            'based on the Free Software [StatusNet](http://status.net/) tool.'),
243                          $this->target->getNickname(), $this->target->getNickname());
244         }
245         $this->elementStart('div', array('id' => 'anon_notice'));
246         $this->raw(common_markup_to_html($m));
247         $this->elementEnd('div');
248     }
249
250     function showSections()
251     {
252         parent::showSections();
253         if (!common_config('performance', 'high')) {
254             $cloud = new PersonalTagCloudSection($this->target, $this);
255             $cloud->show();
256         }
257     }
258
259     function noticeFormOptions()
260     {
261         $options = parent::noticeFormOptions();
262
263         if (!$this->scoped instanceof Profile || !$this->scoped->sameAs($this->target)) {
264             $options['to_profile'] =  $this->target;
265         }
266
267         return $options;
268     }
269 }