3 * StatusNet, the distributed open-source microblogging tool
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.
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.
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/>.
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/
31 if (!defined('GNUSOCIAL')) { exit(1); }
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/
42 class ShowgroupAction extends GroupAction
44 /** page we're viewing. */
49 * Is this page read-only?
51 * @return boolean true
53 function isReadOnly($args)
61 * @return string page title, with page number
65 $base = $this->group->getFancyName();
67 if ($this->page == 1) {
68 // TRANS: Page title for first group page. %s is a group name.
69 return sprintf(_('%s group'), $base);
71 // TRANS: Page title for any but first group page.
72 // TRANS: %1$s is a group name, $2$s is a page number.
73 return sprintf(_('%1$s group, page %2$d'),
82 * Reads and validates arguments and instantiates the attributes.
84 * @param array $args $_REQUEST args
86 * @return boolean success flag
88 protected function prepare(array $args=array())
90 parent::prepare($args);
92 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
94 if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
95 $stream = new GroupNoticeStream($this->group, $this->scoped);
97 $stream = new ThreadingGroupNoticeStream($this->group, $this->scoped);
100 $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
101 NOTICES_PER_PAGE + 1);
103 common_set_returnto($this->selfUrl());
111 * Shows a profile for the group, some controls, and a list of
116 protected function handle()
123 * Show the page content
125 * Shows a group profile and a list of group notices
127 function showContent()
129 $this->showGroupNotices();
133 * Show the group notices
137 function showGroupNotices()
139 if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
140 $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
142 $nl = new ThreadedNoticeList($this->notice, $this, $this->scoped);
147 $this->pagination($this->page > 1,
148 $cnt > NOTICES_PER_PAGE,
151 array('nickname' => $this->group->nickname));
155 * Get a list of the feeds for this page
162 common_local_url('grouprss',
163 array('nickname' => $this->group->nickname));
165 return array(new Feed(Feed::JSON,
166 common_local_url('ApiTimelineGroup',
167 array('format' => 'as',
168 'id' => $this->group->id)),
169 // TRANS: Tooltip for feed link. %s is a group nickname.
170 sprintf(_('Notice feed for %s group (Activity Streams JSON)'),
171 $this->group->nickname)),
173 common_local_url('grouprss',
174 array('nickname' => $this->group->nickname)),
175 // TRANS: Tooltip for feed link. %s is a group nickname.
176 sprintf(_('Notice feed for %s group (RSS 1.0)'),
177 $this->group->nickname)),
179 common_local_url('ApiTimelineGroup',
180 array('format' => 'rss',
181 'id' => $this->group->id)),
182 // TRANS: Tooltip for feed link. %s is a group nickname.
183 sprintf(_('Notice feed for %s group (RSS 2.0)'),
184 $this->group->nickname)),
186 common_local_url('ApiTimelineGroup',
187 array('format' => 'atom',
188 'id' => $this->group->id)),
189 // TRANS: Tooltip for feed link. %s is a group nickname.
190 sprintf(_('Notice feed for %s group (Atom)'),
191 $this->group->nickname)),
193 common_local_url('foafgroup',
194 array('nickname' => $this->group->nickname)),
195 // TRANS: Tooltip for feed link. %s is a group nickname.
196 sprintf(_('FOAF for %s group'),
197 $this->group->nickname)));
200 function showAnonymousMessage()
202 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
203 // TRANS: Notice on group pages for anonymous users for StatusNet sites that accept new registrations.
204 // TRANS: %s is the group name, %%%%site.name%%%% is the site name,
205 // TRANS: %%%%action.register%%%% is the URL for registration, %%%%doc.help%%%% is a URL to help.
206 // TRANS: This message contains Markdown links. Ensure they are formatted correctly: [Description](link).
207 $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
208 'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
209 'short messages about their life and interests. '.
210 '[Join now](%%%%action.register%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
211 $this->group->getBestName());
213 // TRANS: Notice on group pages for anonymous users for StatusNet sites that accept no new registrations.
214 // TRANS: %s is the group name, %%%%site.name%%%% is the site name,
215 // TRANS: This message contains Markdown links. Ensure they are formatted correctly: [Description](link).
216 $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
217 'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
218 'short messages about their life and interests.'),
219 $this->group->getBestName());
221 $this->elementStart('div', array('id' => 'anon_notice'));
222 $this->raw(common_markup_to_html($m));
223 $this->elementEnd('div');
228 if ($this->page != 1) {
229 $this->element('link', array('rel' => 'canonical',
230 'href' => $this->group->homeUrl()));