peopletaggroupnav.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. public $widgetOpts;
  55. public $scoped;
  56. var $action = null;
  57. /**
  58. * Construction
  59. *
  60. * @param Action $action current action, used for output
  61. */
  62. function __construct(Action $action=null)
  63. {
  64. parent::__construct($action);
  65. $this->action = $action;
  66. }
  67. /**
  68. * Show the menu
  69. *
  70. * @return void
  71. */
  72. function show()
  73. {
  74. $user = null;
  75. // FIXME: we should probably pass this in and check when PeopletagGroupNav is actually loaded etc.
  76. $action = $this->action->trimmed('action');
  77. if (common_config('singleuser', 'enabled')) {
  78. $nickname = User::singleUserNickname();
  79. } else {
  80. $nickname = $this->action->arg('tagger');
  81. }
  82. $tag = $this->action->trimmed('tag');
  83. if ($nickname) {
  84. $user = User::getKV('nickname', $nickname);
  85. $user_profile = $user->getProfile();
  86. if ($tag) {
  87. $tag = Profile_list::pkeyGet(array('tagger' => $user->id,
  88. 'tag' => $tag));
  89. } else {
  90. $tag = false;
  91. }
  92. } else {
  93. $user_profile = false;
  94. }
  95. $this->out->elementStart('ul', array('class' => 'nav'));
  96. if (Event::handle('StartPeopletagGroupNav', array($this))
  97. && $tag instanceof Profile_list && $user_profile instanceof Profile) {
  98. // People tag timeline
  99. $this->out->menuItem(common_local_url('showprofiletag', array('nickname' => $user_profile->nickname,
  100. 'tag' => $tag->tag)),
  101. // TRANS: Menu item in list navigation panel.
  102. _m('MENU','List'),
  103. // TRANS: Menu item title in list navigation panel.
  104. // TRANS: %1$s is a list, %2$s is a nickname.
  105. sprintf(_('%1$s list by %2$s.'), $tag->tag,
  106. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  107. $action == 'showprofiletag', 'nav_timeline_peopletag');
  108. // Tagged
  109. $this->out->menuItem(common_local_url('peopletagged', array('tagger' => $user->nickname,
  110. 'tag' => $tag->tag)),
  111. // TRANS: Menu item in list navigation panel.
  112. _m('MENU','Listed'),
  113. // TRANS: Menu item title in list navigation panel.
  114. // TRANS: %1$s is a list, %2$s is a nickname.
  115. sprintf(_('%1$s list by %2$s.'), $tag->tag,
  116. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  117. $action == 'peopletagged', 'nav_peopletag_tagged');
  118. // Subscribers
  119. $this->out->menuItem(common_local_url('peopletagsubscribers', array('tagger' => $user->nickname,
  120. 'tag' => $tag->tag)),
  121. // TRANS: Menu item in list navigation panel.
  122. _m('MENU','Subscribers'),
  123. // TRANS: Menu item title in list navigation panel.
  124. // TRANS: %1$s is a list, %2$s is a nickname.
  125. sprintf(_('Subscribers to %1$s list by %2$s.'), $tag->tag,
  126. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  127. $action == 'peopletagsubscribers', 'nav_peopletag_subscribers');
  128. $cur = common_current_user();
  129. if (!empty($cur) && $user_profile->id == $cur->id) {
  130. // Edit
  131. $this->out->menuItem(common_local_url('editpeopletag', array('tagger' => $user->nickname,
  132. 'tag' => $tag->tag)),
  133. // TRANS: Menu item in list navigation panel.
  134. _m('MENU','Edit'),
  135. // TRANS: Menu item title in list navigation panel.
  136. // TRANS: %s is a list.
  137. sprintf(_('Edit %s list by you.'), $tag->tag,
  138. (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
  139. $action == 'editpeopletag', 'nav_peopletag_edit');
  140. }
  141. Event::handle('EndPeopletagGroupNav', array($this));
  142. }
  143. $this->out->elementEnd('ul');
  144. }
  145. }