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

peopletagsforuser.php 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?php
  2. // !TODO: I WRITE HTML, REFACTOR FOR SMARTY
  3. /* ============================================================================
  4. * Title: PeopleTagsForUser
  5. * People tags for a user
  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. * People tags for a user
  35. *
  36. * PHP version:
  37. * Tested with PHP 7.0
  38. * ----------------------------------------------------------------------------
  39. * File Authors:
  40. * o Shashi Gowda <connect2shashi@gmail.com>
  41. * o Siebrand Mazeland <s.mazeland@xs4all.nl>
  42. * o Zach Copley
  43. * o Evan Prodromou
  44. * o Mikael Nordfeldth <mmn@hethane.se>
  45. * o Maiyannah Bishop <maiyannah.bishop@postactiv.com>
  46. *
  47. * Web:
  48. * o postActiv <http://www.postactiv.com>
  49. * o GNU social <https://www.gnu.org/s/social/>
  50. * ============================================================================
  51. */
  52. // This file is formatted so that it provides useful documentation output in
  53. // NaturalDocs. Please be considerate of this before changing formatting.
  54. if (!defined('POSTACTIV')) { exit(1); }
  55. require_once INSTALLDIR.'/lib/peopletaglist.php';
  56. class PeopletagsforuserAction extends Action
  57. {
  58. var $page = null;
  59. var $tagged = null;
  60. function isReadOnly($args)
  61. {
  62. return true;
  63. }
  64. function title()
  65. {
  66. if ($this->page == 1) {
  67. // TRANS: Page title. %s is a tagged user's nickname.
  68. return sprintf(_('Lists with %s in them'), $this->tagged->nickname);
  69. } else {
  70. // TRANS: Page title. %1$s is a tagged user's nickname, %2$s is a page number.
  71. return sprintf(_('Lists with %1$s, page %2$d'), $this->tagged->nickname, $this->page);
  72. }
  73. }
  74. function prepare(array $args = array())
  75. {
  76. parent::prepare($args);
  77. if (common_config('singleuser', 'enabled')) {
  78. $nickname_arg = User::singleUserNickname();
  79. } else {
  80. $nickname_arg = $this->arg('nickname');
  81. }
  82. $nickname = common_canonical_nickname($nickname_arg);
  83. // Permanent redirect on non-canonical nickname
  84. if ($nickname_arg != $nickname) {
  85. $args = array('nickname' => $nickname);
  86. if ($this->arg('page') && $this->arg('page') != 1) {
  87. $args['page'] = $this->arg['page'];
  88. }
  89. common_redirect(common_local_url('peopletagsforuser', $args), 301);
  90. }
  91. $this->user = User::getKV('nickname', $nickname);
  92. if (!$this->user) {
  93. // TRANS: Client error displayed trying to perform an action related to a non-existing user.
  94. $this->clientError(_('No such user.'), 404);
  95. }
  96. $this->tagged = $this->user->getProfile();
  97. if (!$this->tagged) {
  98. // TRANS: Error message displayed when referring to a user without a profile.
  99. $this->serverError(_('User has no profile.'));
  100. }
  101. $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
  102. return true;
  103. }
  104. function handle()
  105. {
  106. parent::handle();
  107. $this->showPage();
  108. }
  109. function showAnonymousMessage()
  110. {
  111. $notice =
  112. // TRANS: Message displayed for anonymous users on page that displays lists for a user.
  113. // TRANS: This message contains Markdown links in the form [description](links).
  114. // TRANS: %s is a tagger nickname.
  115. sprintf(_('These are lists for **%s**. ' .
  116. 'lists are how you sort similar ' .
  117. 'people on %%%%site.name%%%%, a [micro-blogging]' .
  118. '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
  119. 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
  120. 'You can easily keep track of what they ' .
  121. 'are doing by subscribing to the list\'s timeline.' ), $this->tagged->nickname);
  122. $this->elementStart('div', array('id' => 'anon_notice'));
  123. $this->raw(common_markup_to_html($notice));
  124. $this->elementEnd('div');
  125. }
  126. function showContent()
  127. {
  128. #TODO: controls here.
  129. $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
  130. $limit = PEOPLETAGS_PER_PAGE + 1;
  131. $ptags = $this->tagged->getOtherTags($this->scoped, $offset, $limit);
  132. $pl = new PeopletagList($ptags, $this);
  133. $cnt = $pl->show();
  134. if ($cnt == 0) {
  135. $this->showEmptyListMessage();
  136. }
  137. $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
  138. $this->page, 'peopletagsforuser', array('nickname' => $this->tagged->id));
  139. }
  140. function showEmptyListMessage()
  141. {
  142. // TRANS: Message displayed on page that displays lists a user was added to when there are none.
  143. // TRANS: This message contains Markdown links in the form [description](links).
  144. // TRANS: %s is a user nickname.
  145. $message = sprintf(_('%s has not been [listed](%%%%doc.lists%%%%) by anyone yet.'), $this->tagged->nickname);
  146. $this->elementStart('div', 'guide');
  147. $this->raw(common_markup_to_html($message));
  148. $this->elementEnd('div');
  149. }
  150. function showObjectNav()
  151. {
  152. $nav = new PeopletagNav($this, $this->tagged);
  153. $nav->show();
  154. }
  155. function showProfileBlock()
  156. {
  157. $block = new AccountProfileBlock($this, $this->tagged);
  158. $block->show();
  159. }
  160. function showSections()
  161. {
  162. #TODO: tags with most subscribers
  163. #TODO: tags with most "members"
  164. }
  165. }
  166. // END OF FILE
  167. // ============================================================================
  168. ?>