peopletagsubscriptions.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * People tags subscribed to by a user
  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 Shashi Gowda <connect2shashi@gmail.com>
  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('STATUSNET') && !defined('LACONICA')) {
  30. exit(1);
  31. }
  32. require_once INSTALLDIR.'/lib/peopletaglist.php';
  33. class PeopletagsubscriptionsAction extends Action
  34. {
  35. var $page = null;
  36. var $profile = null;
  37. function isReadOnly($args)
  38. {
  39. return true;
  40. }
  41. function title()
  42. {
  43. if ($this->page == 1) {
  44. // TRANS: Title for page that displays lists subscribed to by a user.
  45. // TRANS: %s is a profile nickname.
  46. return sprintf(_('Lists subscribed to by %s'), $this->profile->nickname);
  47. } else {
  48. // TRANS: Title for page that displays lists subscribed to by a user.
  49. // TRANS: %1$s is a profile nickname, %2$d is a page number.
  50. return sprintf(_('Lists subscribed to by %1$s, page %2$d'), $this->profile->nickname, $this->page);
  51. }
  52. }
  53. function prepare($args)
  54. {
  55. parent::prepare($args);
  56. if (common_config('singleuser', 'enabled')) {
  57. $nickname_arg = User::singleUserNickname();
  58. } else {
  59. $nickname_arg = $this->arg('nickname');
  60. }
  61. $nickname = common_canonical_nickname($nickname_arg);
  62. // Permanent redirect on non-canonical nickname
  63. if ($nickname_arg != $nickname) {
  64. $args = array('nickname' => $nickname);
  65. if ($this->arg('page') && $this->arg('page') != 1) {
  66. $args['page'] = $this->arg['page'];
  67. }
  68. common_redirect(common_local_url('peopletagsbyuser', $args), 301);
  69. }
  70. $user = User::getKV('nickname', $nickname);
  71. if (!$user) {
  72. // TRANS: Client error displayed trying to perform an action related to a non-existing user.
  73. $this->clientError(_('No such user.'), 404);
  74. }
  75. $this->profile = $user->getProfile();
  76. if (!$this->profile) {
  77. // TRANS: Error message displayed when referring to a user without a profile.
  78. $this->serverError(_('User has no profile.'));
  79. }
  80. $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
  81. return true;
  82. }
  83. function handle($args)
  84. {
  85. parent::handle($args);
  86. $this->showPage();
  87. }
  88. function showAnonymousMessage()
  89. {
  90. $notice =
  91. // TRANS: Message displayed for anonymous users on page that displays lists subscribed to by a user.
  92. // TRANS: This message contains Markdown links in the form [description](links).
  93. // TRANS: %s is a profile nickname.
  94. sprintf(_('These are lists subscribed to by **%s**. ' .
  95. 'Lists are how you sort similar ' .
  96. 'people on %%%%site.name%%%%, a [micro-blogging]' .
  97. '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
  98. 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
  99. 'You can easily keep track of what they ' .
  100. 'are doing by subscribing to the list\'s timeline.' ), $this->profile->nickname);
  101. $this->elementStart('div', array('id' => 'anon_notice'));
  102. $this->raw(common_markup_to_html($notice));
  103. $this->elementEnd('div');
  104. }
  105. function showContent()
  106. {
  107. $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
  108. $limit = PEOPLETAGS_PER_PAGE + 1;
  109. $ptags = $this->profile->getTagSubscriptions($offset, $limit);
  110. $pl = new PeopletagList($ptags, $this);
  111. $cnt = $pl->show();
  112. $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
  113. $this->page, 'peopletagsubscriptions', array('nickname' => $this->profile->id));
  114. }
  115. function showObjectNav()
  116. {
  117. $nav = new PeopletagNav($this, $this->profile);
  118. $nav->show();
  119. }
  120. function showProfileBlock()
  121. {
  122. $block = new AccountProfileBlock($this, $this->profile);
  123. $block->show();
  124. }
  125. function showSections()
  126. {
  127. #TODO: tags with most subscribers
  128. #TODO: tags with most "members"
  129. }
  130. }