The official, canonical postActiv repository. http://www.postactiv.com

replies.php 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. // !TODO: I WRITE HTML, REFACTOR FOR SMARTY
  3. /* ============================================================================
  4. * Title: Replies
  5. * List of replies
  6. *
  7. * postActiv:
  8. * the micro-blogging software
  9. *
  10. * Copyright:
  11. * Copyright (C) 2016-2018, Maiyannah Bishop
  12. *
  13. * Derived from code copyright various sources:
  14. * o GNU Social (C) 2013-2016, Free Software Foundation, Inc
  15. * o StatusNet (C) 2008-2012, StatusNet, Inc
  16. * ----------------------------------------------------------------------------
  17. * License:
  18. * This program is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License as published by
  20. * the Free Software Foundation, either version 3 of the License, or
  21. * (at your option) any later version.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU Affero General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU Affero General Public License
  29. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. *
  31. * <https://www.gnu.org/licenses/agpl.html>
  32. * ----------------------------------------------------------------------------
  33. * About:
  34. * List of replies
  35. *
  36. * PHP version:
  37. * Tested with PHP 7.0
  38. * ----------------------------------------------------------------------------
  39. * File Authors:
  40. * o Matthew Gregg <matthew.gregg@gmail.com>
  41. * o Evan Prodromou
  42. * o Mike Cochrane <mikec@mikenz.geek.nz>
  43. * o Sarven Capadisli
  44. * o Robin Millette <robin@millette.info>
  45. * o Zach Copley
  46. * o Meitar Moscovitz <meitarm@gmail.com>
  47. * o Adrian Lang <mail@adrianlang.de>
  48. * o Jeffery To <jeffery.to@gmail.com>
  49. * o Craig Andrews <candrews@integralblue.com>
  50. * o Siebrand Mazeland <s.mazeland@xs4all.nl>
  51. * o Eric Helgeson <erichelgeson@gmail.com>
  52. * o Mikael Nordfeldth <mmn@hethane.se>
  53. * o Maiyannah Bishop <maiyannah.bishop@postactiv.com>
  54. *
  55. * Web:
  56. * o postActiv <http://www.postactiv.com>
  57. * o GNU social <https://www.gnu.org/s/social/>
  58. * ============================================================================
  59. */
  60. // This file is formatted so that it provides useful documentation output in
  61. // NaturalDocs. Please be considerate of this before changing formatting.
  62. if (!defined('POSTACTIV')) { exit(1); }
  63. /**
  64. * List of replies
  65. */
  66. class RepliesAction extends ShowstreamAction
  67. {
  68. public function getStream()
  69. {
  70. return new ReplyNoticeStream($this->target->getID(), $this->scoped);
  71. }
  72. /**
  73. * Title of the page
  74. *
  75. * Includes name of user and page number.
  76. *
  77. * @return string title of page
  78. */
  79. function title()
  80. {
  81. if ($this->page == 1) {
  82. // TRANS: Title for first page of replies for a user.
  83. // TRANS: %s is a user nickname.
  84. return sprintf(_("Replies to %s"), $this->target->getNickname());
  85. } else {
  86. // TRANS: Title for all but the first page of replies for a user.
  87. // TRANS: %1$s is a user nickname, %2$d is a page number.
  88. return sprintf(_('Replies to %1$s, page %2$d'),
  89. $this->target->getNickname(),
  90. $this->page);
  91. }
  92. }
  93. /**
  94. * Feeds for the <head> section
  95. *
  96. * @return void
  97. */
  98. function getFeeds()
  99. {
  100. return array(new Feed(Feed::JSON,
  101. common_local_url('ApiTimelineMentions',
  102. array(
  103. 'id' => $this->target->getNickname(),
  104. 'format' => 'as')),
  105. // TRANS: Link for feed with replies for a user.
  106. // TRANS: %s is a user nickname.
  107. sprintf(_('Replies feed for %s (Activity Streams JSON)'),
  108. $this->target->getNickname())),
  109. new Feed(Feed::RSS1,
  110. common_local_url('repliesrss',
  111. array('nickname' => $this->target->getNickname())),
  112. // TRANS: Link for feed with replies for a user.
  113. // TRANS: %s is a user nickname.
  114. sprintf(_('Replies feed for %s (RSS 1.0)'),
  115. $this->target->getNickname())),
  116. new Feed(Feed::RSS2,
  117. common_local_url('ApiTimelineMentions',
  118. array(
  119. 'id' => $this->target->getNickname(),
  120. 'format' => 'rss')),
  121. // TRANS: Link for feed with replies for a user.
  122. // TRANS: %s is a user nickname.
  123. sprintf(_('Replies feed for %s (RSS 2.0)'),
  124. $this->target->getNickname())),
  125. new Feed(Feed::ATOM,
  126. common_local_url('ApiTimelineMentions',
  127. array(
  128. 'id' => $this->target->getNickname(),
  129. 'format' => 'atom')),
  130. // TRANS: Link for feed with replies for a user.
  131. // TRANS: %s is a user nickname.
  132. sprintf(_('Replies feed for %s (Atom)'),
  133. $this->target->getNickname())));
  134. }
  135. function showContent()
  136. {
  137. $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
  138. $cnt = $nl->show();
  139. if (0 === $cnt) {
  140. $this->showEmptyListMessage();
  141. }
  142. $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
  143. $this->page, 'replies',
  144. array('nickname' => $this->target->getNickname()));
  145. }
  146. function showEmptyListMessage()
  147. {
  148. // TRANS: Empty list message for page with replies for a user.
  149. // TRANS: %1$s is the user nickname.
  150. $message = sprintf(_('This is the timeline showing replies to %1$s but no notices have arrived yet.'), $this->target->getNickname());
  151. $message .= ' '; // Spacing between this sentence and the next.
  152. if (common_logged_in()) {
  153. if ($this->target->getID() === $this->scoped->getID()) {
  154. // TRANS: Empty list message for page with replies for a user for the logged in user.
  155. // TRANS: This message contains a Markdown link in the form [link text](link).
  156. $message .= _('You can engage other users in a conversation, subscribe to more people or [join groups](%%action.groups%%).');
  157. } else {
  158. // TRANS: Empty list message for page with replies for a user for all logged in users but the user themselves.
  159. // 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).
  160. $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());
  161. }
  162. } else {
  163. // TRANS: Empty list message for page with replies for a user for not logged in users.
  164. // TRANS: %1$s is a user nickname. This message contains a Markdown link in the form [link text](link).
  165. $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->getNickname());
  166. }
  167. $this->elementStart('div', 'guide');
  168. $this->raw(common_markup_to_html($message));
  169. $this->elementEnd('div');
  170. }
  171. public function isReadOnly($args)
  172. {
  173. return true;
  174. }
  175. }
  176. // END OF FILE
  177. // =============================================================================
  178. ?>