peopletaggroupnav.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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/ui/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 and check when PeopletagGroupNav is actually loaded etc.
  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. && $tag instanceof Profile_list && $user_profile instanceof Profile) {
  96. // People tag timeline
  97. $this->out->menuItem(common_local_url('showprofiletag', array('nickname' => $user_profile->nickname,
  98. 'tag' => $tag->tag)),
  99. // TRANS: Menu item in list navigation panel.
  100. _m('MENU','List'),
  101. // TRANS: Menu item title in list navigation panel.
  102. // TRANS: %1$s is a list, %2$s is a nickname.
  103. sprintf(_('%1$s list by %2$s.'), $tag->tag,
  104. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  105. $action == 'showprofiletag', 'nav_timeline_peopletag');
  106. // Tagged
  107. $this->out->menuItem(common_local_url('peopletagged', array('tagger' => $user->nickname,
  108. 'tag' => $tag->tag)),
  109. // TRANS: Menu item in list navigation panel.
  110. _m('MENU','Listed'),
  111. // TRANS: Menu item title in list navigation panel.
  112. // TRANS: %1$s is a list, %2$s is a nickname.
  113. sprintf(_('%1$s list by %2$s.'), $tag->tag,
  114. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  115. $action == 'peopletagged', 'nav_peopletag_tagged');
  116. // Subscribers
  117. $this->out->menuItem(common_local_url('peopletagsubscribers', array('tagger' => $user->nickname,
  118. 'tag' => $tag->tag)),
  119. // TRANS: Menu item in list navigation panel.
  120. _m('MENU','Subscribers'),
  121. // TRANS: Menu item title in list navigation panel.
  122. // TRANS: %1$s is a list, %2$s is a nickname.
  123. sprintf(_('Subscribers to %1$s list by %2$s.'), $tag->tag,
  124. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  125. $action == 'peopletagsubscribers', 'nav_peopletag_subscribers');
  126. $cur = common_current_user();
  127. if (!empty($cur) && $user_profile->id == $cur->id) {
  128. // Edit
  129. $this->out->menuItem(common_local_url('editpeopletag', array('tagger' => $user->nickname,
  130. 'tag' => $tag->tag)),
  131. // TRANS: Menu item in list navigation panel.
  132. _m('MENU','Edit'),
  133. // TRANS: Menu item title in list navigation panel.
  134. // TRANS: %s is a list.
  135. sprintf(_('Edit %s list by you.'), $tag->tag,
  136. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  137. $action == 'editpeopletag', 'nav_peopletag_edit');
  138. }
  139. Event::handle('EndPeopletagGroupNav', array($this));
  140. }
  141. $this->out->elementEnd('ul');
  142. }
  143. }