subscriptions.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * List of a user's subscriptions
  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 Social
  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. if (!defined('GNUSOCIAL')) { exit(1); }
  31. /**
  32. * A list of the user's subscriptions
  33. *
  34. * @category Social
  35. * @package StatusNet
  36. * @author Evan Prodromou <evan@status.net>
  37. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  38. * @link http://status.net/
  39. */
  40. class SubscriptionsAction extends GalleryAction
  41. {
  42. function title()
  43. {
  44. if ($this->page == 1) {
  45. // TRANS: Header for subscriptions overview for a user (first page).
  46. // TRANS: %s is a user nickname.
  47. return sprintf(_('%s subscriptions'), $this->target->getNickname());
  48. } else {
  49. // TRANS: Header for subscriptions overview for a user (not first page).
  50. // TRANS: %1$s is a user nickname, %2$d is the page number.
  51. return sprintf(_('%1$s subscriptions, page %2$d'),
  52. $this->target->getNickname(),
  53. $this->page);
  54. }
  55. }
  56. function showPageNotice()
  57. {
  58. if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
  59. $this->element('p', null,
  60. // TRANS: Page notice for page with an overview of all subscriptions
  61. // TRANS: of the logged in user's own profile.
  62. _('These are the people whose notices '.
  63. 'you listen to.'));
  64. } else {
  65. $this->element('p', null,
  66. // TRANS: Page notice for page with an overview of all subscriptions of a user other
  67. // TRANS: than the logged in user. %s is the user nickname.
  68. sprintf(_('These are the people whose '.
  69. 'notices %s listens to.'),
  70. $this->target->getNickname()));
  71. }
  72. }
  73. function getAllTags()
  74. {
  75. return $this->getTags('subscribed', 'subscriber');
  76. }
  77. function showContent()
  78. {
  79. if (Event::handle('StartShowSubscriptionsContent', array($this))) {
  80. parent::showContent();
  81. $offset = ($this->page-1) * PROFILES_PER_PAGE;
  82. $limit = PROFILES_PER_PAGE + 1;
  83. $cnt = 0;
  84. if ($this->tag) {
  85. $subscriptions = $this->target->getTaggedSubscriptions($this->tag, $offset, $limit);
  86. } else {
  87. $subscriptions = $this->target->getSubscribed($offset, $limit);
  88. }
  89. if ($subscriptions) {
  90. $subscriptions_list = new SubscriptionsList($subscriptions, $this->target->getUser(), $this);
  91. $cnt = $subscriptions_list->show();
  92. if (0 == $cnt) {
  93. $this->showEmptyListMessage();
  94. }
  95. }
  96. $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
  97. $this->page, 'subscriptions',
  98. array('nickname' => $this->target->getNickname()));
  99. Event::handle('EndShowSubscriptionsContent', array($this));
  100. }
  101. }
  102. function showScripts()
  103. {
  104. parent::showScripts();
  105. $this->autofocus('tag');
  106. }
  107. function showEmptyListMessage()
  108. {
  109. if ($this->scoped instanceof Profile && $this->target->id === $this->scoped->id) {
  110. // TRANS: Subscription list text when the logged in user has no subscriptions.
  111. // TRANS: This message contains Markdown URLs. The link description is between
  112. // TRANS: square brackets, and the link between parentheses. Do not separate "]("
  113. // TRANS: and do not change the URL part.
  114. $message = _('You\'re not listening to anyone\'s notices right now, try subscribing to people you know. '.
  115. 'Try [people search](%%action.peoplesearch%%), look for members in groups you\'re interested '.
  116. 'in and in our [featured users](%%action.featured%%).');
  117. } else {
  118. // TRANS: Subscription list text when looking at the subscriptions for a of a user that has none
  119. // TRANS: as an anonymous user. %s is the user nickname.
  120. $message = sprintf(_('%s is not listening to anyone.'), $this->target->getNickname());
  121. }
  122. $this->elementStart('div', 'guide');
  123. $this->raw(common_markup_to_html($message));
  124. $this->elementEnd('div');
  125. }
  126. /**
  127. * Link to feeds of subscriptions
  128. *
  129. * @return array of Feed objects
  130. */
  131. function getFeeds()
  132. {
  133. return array(new Feed(Feed::ATOM,
  134. common_local_url('AtomPubSubscriptionFeed',
  135. array('subscriber' => $this->target->id)),
  136. // TRANS: Atom feed title. %s is a profile nickname.
  137. sprintf(_('Subscription feed for %s (Atom)'),
  138. $this->target->getNickname())));
  139. }
  140. }