subscribers.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * List a user's subscribers
  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('STATUSNET') && !defined('LACONICA')) {
  31. exit(1);
  32. }
  33. /**
  34. * List a user's subscribers
  35. *
  36. * @category Social
  37. * @package StatusNet
  38. * @author Evan Prodromou <evan@status.net>
  39. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  40. * @link http://status.net/
  41. */
  42. class SubscribersAction extends GalleryAction
  43. {
  44. function title()
  45. {
  46. if ($this->page == 1) {
  47. // TRANS: Header for list of subscribers for a user (first page).
  48. // TRANS: %s is the user's nickname.
  49. return sprintf(_('%s subscribers'), $this->target->getNickname());
  50. } else {
  51. // TRANS: Header for list of subscribers for a user (not first page).
  52. // TRANS: %1$s is the user's nickname, $2$d is the page number.
  53. return sprintf(_('%1$s subscribers, page %2$d'),
  54. $this->target->getNickname(),
  55. $this->page);
  56. }
  57. }
  58. function showPageNotice()
  59. {
  60. if ($this->scoped instanceof Profile && $this->scoped->id === $this->target->id) {
  61. $this->element('p', null,
  62. // TRANS: Page notice for page with an overview of all subscribers
  63. // TRANS: of the logged in user's own profile.
  64. _('These are the people who listen to '.
  65. 'your notices.'));
  66. } else {
  67. $this->element('p', null,
  68. // TRANS: Page notice for page with an overview of all subscribers of a user other
  69. // TRANS: than the logged in user. %s is the user nickname.
  70. sprintf(_('These are the people who '.
  71. 'listen to %s\'s notices.'),
  72. $this->target->getNickname()));
  73. }
  74. }
  75. function showContent()
  76. {
  77. parent::showContent();
  78. $offset = ($this->page-1) * PROFILES_PER_PAGE;
  79. $limit = PROFILES_PER_PAGE + 1;
  80. $cnt = 0;
  81. if ($this->tag) {
  82. $subscribers = $this->target->getTaggedSubscribers($this->tag, $offset, $limit);
  83. } else {
  84. $subscribers = $this->target->getSubscribers($offset, $limit);
  85. }
  86. if ($subscribers) {
  87. $subscribers_list = new SubscribersList($subscribers, $this->target, $this);
  88. $cnt = $subscribers_list->show();
  89. if (0 == $cnt) {
  90. $this->showEmptyListMessage();
  91. }
  92. }
  93. $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
  94. $this->page, 'subscribers',
  95. array('nickname' => $this->target->getNickname()));
  96. }
  97. function showEmptyListMessage()
  98. {
  99. if ($this->scoped instanceof Profile && $this->target->id === $this->scoped->id) {
  100. // TRANS: Subscriber list text when the logged in user has no subscribers.
  101. $message = _('You have no subscribers. Try subscribing to people you know and they might return the favor.');
  102. } elseif ($this->scoped instanceof Profile) {
  103. // TRANS: Subscriber list text when looking at the subscribers for a of a user other
  104. // TRANS: than the logged in user that has no subscribers. %s is the user nickname.
  105. $message = sprintf(_('%s has no subscribers. Want to be the first?'), $this->target->getNickname());
  106. } else {
  107. // TRANS: Subscriber list text when looking at the subscribers for a of a user that has none
  108. // TRANS: as an anonymous user. %s is the user nickname.
  109. // TRANS: This message contains a Markdown URL. The link description is between
  110. // TRANS: square brackets, and the link between parentheses. Do not separate "]("
  111. // TRANS: and do not change the URL part.
  112. $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.register%%%%) and be the first?'), $this->target->getNickname());
  113. }
  114. $this->elementStart('div', 'guide');
  115. $this->raw(common_markup_to_html($message));
  116. $this->elementEnd('div');
  117. }
  118. function showSections()
  119. {
  120. parent::showSections();
  121. }
  122. }