all.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. /**
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2008-2011, StatusNet, Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 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 Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * @category Actions
  20. * @package Actions
  21. * @author Adrian Lang <mail@adrianlang.de>
  22. * @author Brenda Wallace <shiny@cpan.org>
  23. * @author Brion Vibber <brion@pobox.com>
  24. * @author Craig Andrews <candrews@integralblue.com>
  25. * @author Evan Prodromou <evan@status.net>
  26. * @author Jeffery To <jeffery.to@gmail.com>
  27. * @author Meitar Moscovitz <meitarm@gmail.com>
  28. * @author Mike Cochrane <mikec@mikenz.geek.nz>
  29. * @author Robin Millette <millette@status.net>
  30. * @author Sarven Capadisli <csarven@status.net>
  31. * @author Siebrand Mazeland <s.mazeland@xs4all.nl>
  32. * @author Zach Copley <zach@status.net>
  33. * @copyright 2009-2014 Free Software Foundation, Inc http://www.fsf.org
  34. * @license GNU Affero General Public License http://www.gnu.org/licenses/
  35. * @link http://status.net
  36. */
  37. if (!defined('GNUSOCIAL')) { exit(1); }
  38. class AllAction extends ShowstreamAction
  39. {
  40. public function getStream()
  41. {
  42. if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
  43. $stream = new InboxNoticeStream($this->target, $this->scoped);
  44. } else {
  45. $stream = new ThreadingInboxNoticeStream($this->target, $this->scoped);
  46. }
  47. return $stream;
  48. }
  49. function title()
  50. {
  51. if (!empty($this->scoped) && $this->scoped->sameAs($this->target)) {
  52. // TRANS: Title of a user's own start page.
  53. return _('Home timeline');
  54. } else {
  55. // TRANS: Title of another user's start page.
  56. // TRANS: %s is the other user's name.
  57. return sprintf(_("%s's home timeline"), $this->target->getBestName());
  58. }
  59. }
  60. function getFeeds()
  61. {
  62. return array(
  63. new Feed(Feed::JSON,
  64. common_local_url(
  65. 'ApiTimelineFriends', array(
  66. 'format' => 'as',
  67. 'id' => $this->target->getNickname()
  68. )
  69. ),
  70. // TRANS: %s is user nickname.
  71. sprintf(_('Feed for friends of %s (Activity Streams JSON)'), $this->target->getNickname())),
  72. new Feed(Feed::RSS1,
  73. common_local_url(
  74. 'allrss', array(
  75. 'nickname' =>
  76. $this->target->getNickname())
  77. ),
  78. // TRANS: %s is user nickname.
  79. sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->target->getNickname())),
  80. new Feed(Feed::RSS2,
  81. common_local_url(
  82. 'ApiTimelineFriends', array(
  83. 'format' => 'rss',
  84. 'id' => $this->target->getNickname()
  85. )
  86. ),
  87. // TRANS: %s is user nickname.
  88. sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->target->getNickname())),
  89. new Feed(Feed::ATOM,
  90. common_local_url(
  91. 'ApiTimelineFriends', array(
  92. 'format' => 'atom',
  93. 'id' => $this->target->getNickname()
  94. )
  95. ),
  96. // TRANS: %s is user nickname.
  97. sprintf(_('Feed for friends of %s (Atom)'), $this->target->getNickname()))
  98. );
  99. }
  100. function showEmptyListMessage()
  101. {
  102. // TRANS: Empty list message. %s is a user nickname.
  103. $message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->target->getNickname()) . ' ';
  104. if (common_logged_in()) {
  105. if ($this->target->id === $this->scoped->id) {
  106. // TRANS: Encouragement displayed on logged in user's empty timeline.
  107. // TRANS: This message contains Markdown links. Keep "](" together.
  108. $message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.');
  109. } else {
  110. // TRANS: %1$s is user nickname, %2$s is user nickname, %2$s is user nickname prefixed with "@".
  111. // TRANS: This message contains Markdown links. Keep "](" together.
  112. $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) from their profile or [post something to them](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->target->getNickname(), $this->target->getNickname(), '@' . $this->target->getNickname());
  113. }
  114. } else {
  115. // TRANS: Encouragement displayed on empty timeline user pages for anonymous users.
  116. // TRANS: %s is a user nickname. This message contains Markdown links. Keep "](" together.
  117. $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->getNickname());
  118. }
  119. $this->elementStart('div', 'guide');
  120. $this->raw(common_markup_to_html($message));
  121. $this->elementEnd('div');
  122. }
  123. function showContent()
  124. {
  125. if (Event::handle('StartShowAllContent', array($this))) {
  126. if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
  127. $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
  128. } else {
  129. $nl = new ThreadedNoticeList($this->notice, $this, $this->scoped);
  130. }
  131. $cnt = $nl->show();
  132. if (0 == $cnt) {
  133. $this->showEmptyListMessage();
  134. }
  135. $this->pagination(
  136. $this->page > 1, $cnt > NOTICES_PER_PAGE,
  137. $this->page, 'all', array('nickname' => $this->target->getNickname())
  138. );
  139. Event::handle('EndShowAllContent', array($this));
  140. }
  141. }
  142. function showSections()
  143. {
  144. // Show invite button, as long as site isn't closed, and
  145. // we have a logged in user.
  146. if (common_config('invite', 'enabled') && !common_config('site', 'closed') && common_logged_in()) {
  147. if (!common_config('site', 'private')) {
  148. $ibs = new InviteButtonSection(
  149. $this,
  150. // TRANS: Button text for inviting more users to the StatusNet instance.
  151. // TRANS: Less business/enterprise-oriented language for public sites.
  152. _m('BUTTON', 'Send invite')
  153. );
  154. } else {
  155. $ibs = new InviteButtonSection($this);
  156. }
  157. $ibs->show();
  158. }
  159. }
  160. }
  161. class ThreadingInboxNoticeStream extends ThreadingNoticeStream
  162. {
  163. function __construct(Profile $target, Profile $scoped=null)
  164. {
  165. parent::__construct(new InboxNoticeStream($target, $scoped));
  166. }
  167. }