peopletaggroupnav.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Base class for all actions (~views)
  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 Action
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @author Sarven Capadisli <csarven@status.net>
  26. * @copyright 2008 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. require_once INSTALLDIR.'/lib/widget.php';
  34. /**
  35. * Base class for all actions
  36. *
  37. * This is the base class for all actions in the package. An action is
  38. * more or less a "view" in an MVC framework.
  39. *
  40. * Actions are responsible for extracting and validating parameters; using
  41. * model classes to read and write to the database; and doing ouput.
  42. *
  43. * @category Output
  44. * @package StatusNet
  45. * @author Evan Prodromou <evan@status.net>
  46. * @author Sarven Capadisli <csarven@status.net>
  47. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  48. * @link http://status.net/
  49. *
  50. * @see HTMLOutputter
  51. */
  52. class PeopletagGroupNav extends Widget
  53. {
  54. var $action = null;
  55. /**
  56. * Construction
  57. *
  58. * @param Action $action current action, used for output
  59. */
  60. function __construct(Action $action=null)
  61. {
  62. parent::__construct($action);
  63. $this->action = $action;
  64. }
  65. /**
  66. * Show the menu
  67. *
  68. * @return void
  69. */
  70. function show()
  71. {
  72. $user = null;
  73. // FIXME: we should probably pass this in
  74. $action = $this->action->trimmed('action');
  75. if (common_config('singleuser', 'enabled')) {
  76. $nickname = User::singleUserNickname();
  77. } else {
  78. $nickname = $this->action->arg('tagger');
  79. }
  80. $tag = $this->action->trimmed('tag');
  81. if ($nickname) {
  82. $user = User::getKV('nickname', $nickname);
  83. $user_profile = $user->getProfile();
  84. if ($tag) {
  85. $tag = Profile_list::pkeyGet(array('tagger' => $user->id,
  86. 'tag' => $tag));
  87. } else {
  88. $tag = false;
  89. }
  90. } else {
  91. $user_profile = false;
  92. }
  93. $this->out->elementStart('ul', array('class' => 'nav'));
  94. if (Event::handle('StartPeopletagGroupNav', array($this))) {
  95. // People tag timeline
  96. $this->out->menuItem(common_local_url('showprofiletag', array('tagger' => $user_profile->nickname,
  97. 'tag' => $tag->tag)),
  98. // TRANS: Menu item in list navigation panel.
  99. _m('MENU','List'),
  100. // TRANS: Menu item title in list navigation panel.
  101. // TRANS: %1$s is a list, %2$s is a nickname.
  102. sprintf(_('%1$s list by %2$s.'), $tag->tag,
  103. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  104. $action == 'showprofiletag', 'nav_timeline_peopletag');
  105. // Tagged
  106. $this->out->menuItem(common_local_url('peopletagged', array('tagger' => $user->nickname,
  107. 'tag' => $tag->tag)),
  108. // TRANS: Menu item in list navigation panel.
  109. _m('MENU','Listed'),
  110. // TRANS: Menu item title in list navigation panel.
  111. // TRANS: %1$s is a list, %2$s is a nickname.
  112. sprintf(_('%1$s list by %2$s.'), $tag->tag,
  113. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  114. $action == 'peopletagged', 'nav_peopletag_tagged');
  115. // Subscribers
  116. $this->out->menuItem(common_local_url('peopletagsubscribers', array('tagger' => $user->nickname,
  117. 'tag' => $tag->tag)),
  118. // TRANS: Menu item in list navigation panel.
  119. _m('MENU','Subscribers'),
  120. // TRANS: Menu item title in list navigation panel.
  121. // TRANS: %1$s is a list, %2$s is a nickname.
  122. sprintf(_('Subscribers to %1$s list by %2$s.'), $tag->tag,
  123. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  124. $action == 'peopletagsubscribers', 'nav_peopletag_subscribers');
  125. $cur = common_current_user();
  126. if (!empty($cur) && $user_profile->id == $cur->id) {
  127. // Edit
  128. $this->out->menuItem(common_local_url('editpeopletag', array('tagger' => $user->nickname,
  129. 'tag' => $tag->tag)),
  130. // TRANS: Menu item in list navigation panel.
  131. _m('MENU','Edit'),
  132. // TRANS: Menu item title in list navigation panel.
  133. // TRANS: %s is a list.
  134. sprintf(_('Edit %s list by you.'), $tag->tag,
  135. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  136. $action == 'editpeopletag', 'nav_peopletag_edit');
  137. }
  138. Event::handle('EndPeopletagGroupNav', array($this));
  139. }
  140. $this->out->elementEnd('ul');
  141. }
  142. }