peopletagsforuser.php 5.5 KB

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