showgroup.php 7.3 KB

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