replies.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * List of replies
  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. * @copyright 2008-2011 StatusNet, Inc.
  26. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  27. * @link http://status.net/
  28. */
  29. if (!defined('GNUSOCIAL')) { exit(1); }
  30. /**
  31. * List of replies
  32. *
  33. * @category Personal
  34. * @package StatusNet
  35. * @author Evan Prodromou <evan@status.net>
  36. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  37. * @link http://status.net/
  38. */
  39. class RepliesAction extends ShowstreamAction
  40. {
  41. public function getStream()
  42. {
  43. return new ReplyNoticeStream($this->target->getID(), $this->scoped);
  44. }
  45. /**
  46. * Title of the page
  47. *
  48. * Includes name of user and page number.
  49. *
  50. * @return string title of page
  51. */
  52. function title()
  53. {
  54. if ($this->page == 1) {
  55. // TRANS: Title for first page of replies for a user.
  56. // TRANS: %s is a user nickname.
  57. return sprintf(_("Replies to %s"), $this->target->getNickname());
  58. } else {
  59. // TRANS: Title for all but the first page of replies for a user.
  60. // TRANS: %1$s is a user nickname, %2$d is a page number.
  61. return sprintf(_('Replies to %1$s, page %2$d'),
  62. $this->target->getNickname(),
  63. $this->page);
  64. }
  65. }
  66. /**
  67. * Feeds for the <head> section
  68. *
  69. * @return void
  70. */
  71. function getFeeds()
  72. {
  73. return array(new Feed(Feed::JSON,
  74. common_local_url('ApiTimelineMentions',
  75. array(
  76. 'id' => $this->target->getNickname(),
  77. 'format' => 'as')),
  78. // TRANS: Link for feed with replies for a user.
  79. // TRANS: %s is a user nickname.
  80. sprintf(_('Replies feed for %s (Activity Streams JSON)'),
  81. $this->target->getNickname())),
  82. new Feed(Feed::RSS1,
  83. common_local_url('repliesrss',
  84. array('nickname' => $this->target->getNickname())),
  85. // TRANS: Link for feed with replies for a user.
  86. // TRANS: %s is a user nickname.
  87. sprintf(_('Replies feed for %s (RSS 1.0)'),
  88. $this->target->getNickname())),
  89. new Feed(Feed::RSS2,
  90. common_local_url('ApiTimelineMentions',
  91. array(
  92. 'id' => $this->target->getNickname(),
  93. 'format' => 'rss')),
  94. // TRANS: Link for feed with replies for a user.
  95. // TRANS: %s is a user nickname.
  96. sprintf(_('Replies feed for %s (RSS 2.0)'),
  97. $this->target->getNickname())),
  98. new Feed(Feed::ATOM,
  99. common_local_url('ApiTimelineMentions',
  100. array(
  101. 'id' => $this->target->getNickname(),
  102. 'format' => 'atom')),
  103. // TRANS: Link for feed with replies for a user.
  104. // TRANS: %s is a user nickname.
  105. sprintf(_('Replies feed for %s (Atom)'),
  106. $this->target->getNickname())));
  107. }
  108. function showContent()
  109. {
  110. $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
  111. $cnt = $nl->show();
  112. if (0 === $cnt) {
  113. $this->showEmptyListMessage();
  114. }
  115. $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
  116. $this->page, 'replies',
  117. array('nickname' => $this->target->getNickname()));
  118. }
  119. function showEmptyListMessage()
  120. {
  121. // TRANS: Empty list message for page with replies for a user.
  122. // TRANS: %1$s is the user nickname.
  123. $message = sprintf(_('This is the timeline showing replies to %1$s but no notices have arrived yet.'), $this->target->getNickname());
  124. $message .= ' '; // Spacing between this sentence and the next.
  125. if (common_logged_in()) {
  126. if ($this->target->getID() === $this->scoped->getID()) {
  127. // TRANS: Empty list message for page with replies for a user for the logged in user.
  128. // TRANS: This message contains a Markdown link in the form [link text](link).
  129. $message .= _('You can engage other users in a conversation, subscribe to more people or [join groups](%%action.groups%%).');
  130. } else {
  131. // TRANS: Empty list message for page with replies for a user for all logged in users but the user themselves.
  132. // TRANS: %1$s is a user nickname and %2$s is the same but with a prepended '@' character. This message contains a Markdown link in the form [link text](link).
  133. $message .= sprintf(_('You can try to [nudge %1$s](../%1$s) or [post something to them](%%%%action.newnotice%%%%?content=%2$s).'), $this->target->getNickname(), '@' . $this->target->getNickname());
  134. }
  135. } else {
  136. // TRANS: Empty list message for page with replies for a user for not logged in users.
  137. // TRANS: %1$s is a user nickname. This message contains a Markdown link in the form [link text](link).
  138. $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->getNickname());
  139. }
  140. $this->elementStart('div', 'guide');
  141. $this->raw(common_markup_to_html($message));
  142. $this->elementEnd('div');
  143. }
  144. public function isReadOnly($args)
  145. {
  146. return true;
  147. }
  148. }