showgroup.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Group main page
  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 Group
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @author Sarven Capadisli <csarven@status.net>
  26. * @copyright 2008-2011 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('GNUSOCIAL')) { exit(1); }
  31. /**
  32. * Group main page
  33. *
  34. * @category Group
  35. * @package StatusNet
  36. * @author Evan Prodromou <evan@status.net>
  37. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  38. * @link http://status.net/
  39. */
  40. class ShowgroupAction extends GroupAction
  41. {
  42. /** page we're viewing. */
  43. var $page = null;
  44. var $notice = null;
  45. /**
  46. * Is this page read-only?
  47. *
  48. * @return boolean true
  49. */
  50. function isReadOnly($args)
  51. {
  52. return true;
  53. }
  54. /**
  55. * Title of the page
  56. *
  57. * @return string page title, with page number
  58. */
  59. function title()
  60. {
  61. $base = $this->group->getFancyName();
  62. if ($this->page == 1) {
  63. // TRANS: Page title for first group page. %s is a group name.
  64. return sprintf(_('%s group'), $base);
  65. } else {
  66. // TRANS: Page title for any but first group page.
  67. // TRANS: %1$s is a group name, $2$s is a page number.
  68. return sprintf(_('%1$s group, page %2$d'),
  69. $base,
  70. $this->page);
  71. }
  72. }
  73. public function getStream()
  74. {
  75. if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
  76. $stream = new GroupNoticeStream($this->group, $this->scoped);
  77. } else {
  78. $stream = new ThreadingGroupNoticeStream($this->group, $this->scoped);
  79. }
  80. return $stream;
  81. }
  82. /**
  83. * Get a list of the feeds for this page
  84. *
  85. * @return void
  86. */
  87. function getFeeds()
  88. {
  89. $url =
  90. common_local_url('grouprss',
  91. array('nickname' => $this->group->nickname));
  92. return array(new Feed(Feed::JSON,
  93. common_local_url('ApiTimelineGroup',
  94. array('format' => 'as',
  95. 'id' => $this->group->id)),
  96. // TRANS: Tooltip for feed link. %s is a group nickname.
  97. sprintf(_('Notice feed for %s group (Activity Streams JSON)'),
  98. $this->group->nickname)),
  99. new Feed(Feed::RSS1,
  100. common_local_url('grouprss',
  101. array('nickname' => $this->group->nickname)),
  102. // TRANS: Tooltip for feed link. %s is a group nickname.
  103. sprintf(_('Notice feed for %s group (RSS 1.0)'),
  104. $this->group->nickname)),
  105. new Feed(Feed::RSS2,
  106. common_local_url('ApiTimelineGroup',
  107. array('format' => 'rss',
  108. 'id' => $this->group->id)),
  109. // TRANS: Tooltip for feed link. %s is a group nickname.
  110. sprintf(_('Notice feed for %s group (RSS 2.0)'),
  111. $this->group->nickname)),
  112. new Feed(Feed::ATOM,
  113. common_local_url('ApiTimelineGroup',
  114. array('format' => 'atom',
  115. 'id' => $this->group->id)),
  116. // TRANS: Tooltip for feed link. %s is a group nickname.
  117. sprintf(_('Notice feed for %s group (Atom)'),
  118. $this->group->nickname)),
  119. new Feed(Feed::FOAF,
  120. common_local_url('foafgroup',
  121. array('nickname' => $this->group->nickname)),
  122. // TRANS: Tooltip for feed link. %s is a group nickname.
  123. sprintf(_('FOAF for %s group'),
  124. $this->group->nickname)));
  125. }
  126. function showAnonymousMessage()
  127. {
  128. if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
  129. // TRANS: Notice on group pages for anonymous users for StatusNet sites that accept new registrations.
  130. // TRANS: %s is the group name, %%%%site.name%%%% is the site name,
  131. // TRANS: %%%%action.register%%%% is the URL for registration, %%%%doc.help%%%% is a URL to help.
  132. // TRANS: This message contains Markdown links. Ensure they are formatted correctly: [Description](link).
  133. $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
  134. 'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
  135. 'short messages about their life and interests. '.
  136. '[Join now](%%%%action.register%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
  137. $this->group->getBestName());
  138. } else {
  139. // TRANS: Notice on group pages for anonymous users for StatusNet sites that accept no new registrations.
  140. // TRANS: %s is the group name, %%%%site.name%%%% is the site name,
  141. // TRANS: This message contains Markdown links. Ensure they are formatted correctly: [Description](link).
  142. $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
  143. 'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
  144. 'short messages about their life and interests.'),
  145. $this->group->getBestName());
  146. }
  147. $this->elementStart('div', array('id' => 'anon_notice'));
  148. $this->raw(common_markup_to_html($m));
  149. $this->elementEnd('div');
  150. }
  151. function extraHead()
  152. {
  153. if ($this->page != 1) {
  154. $this->element('link', array('rel' => 'canonical',
  155. 'href' => $this->group->homeUrl()));
  156. }
  157. }
  158. }