]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/showgroup.php
Merge branch 'master' of git.gnu.io:gnu/gnu-social into mmn_fixes
[quix0rs-gnu-social.git] / actions / showgroup.php
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
31 if (!defined('GNUSOCIAL')) { 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     var $page = null;
46     var $notice = null;
47
48     /**
49      * Is this page read-only?
50      *
51      * @return boolean true
52      */
53     function isReadOnly($args)
54     {
55         return true;
56     }
57
58     /**
59      * Title of the page
60      *
61      * @return string page title, with page number
62      */
63     function title()
64     {
65         $base = $this->group->getFancyName();
66
67         if ($this->page == 1) {
68             // TRANS: Page title for first group page. %s is a group name.
69             return sprintf(_('%s group'), $base);
70         } else {
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'),
74                            $base,
75                            $this->page);
76         }
77     }
78
79     /**
80      * Prepare the action
81      *
82      * Reads and validates arguments and instantiates the attributes.
83      *
84      * @param array $args $_REQUEST args
85      *
86      * @return boolean success flag
87      */
88     protected function prepare(array $args=array())
89     {
90         parent::prepare($args);
91
92         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
93
94         if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
95             $stream = new GroupNoticeStream($this->group, $this->scoped);
96         } else {
97             $stream = new ThreadingGroupNoticeStream($this->group, $this->scoped);
98         }
99
100         $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
101                                             NOTICES_PER_PAGE + 1);
102
103         common_set_returnto($this->selfUrl());
104
105         return true;
106     }
107
108     /**
109      * Handle the request
110      *
111      * Shows a profile for the group, some controls, and a list of
112      * group notices.
113      *
114      * @return void
115      */
116     protected function handle()
117     {
118         parent::handle();
119         $this->showPage();
120     }
121
122     /**
123      * Show the page content
124      *
125      * Shows a group profile and a list of group notices
126      */
127     function showContent()
128     {
129         $this->showGroupNotices();
130     }
131
132     /**
133      * Show the group notices
134      *
135      * @return void
136      */
137     function showGroupNotices()
138     {
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));
141         } else {
142             $nl = new ThreadedNoticeList($this->notice, $this, $this->scoped);
143         } 
144
145         $cnt = $nl->show();
146
147         $this->pagination($this->page > 1,
148                           $cnt > NOTICES_PER_PAGE,
149                           $this->page,
150                           'showgroup',
151                           array('nickname' => $this->group->nickname));
152     }
153
154     /**
155      * Get a list of the feeds for this page
156      *
157      * @return void
158      */
159     function getFeeds()
160     {
161         $url =
162           common_local_url('grouprss',
163                            array('nickname' => $this->group->nickname));
164
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)),
172                     new Feed(Feed::RSS1,
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)),
178                      new Feed(Feed::RSS2,
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)),
185                      new Feed(Feed::ATOM,
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)),
192                      new Feed(Feed::FOAF,
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)));
198     }
199
200     function showAnonymousMessage()
201     {
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());
212         } else {
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());
220         }
221         $this->elementStart('div', array('id' => 'anon_notice'));
222         $this->raw(common_markup_to_html($m));
223         $this->elementEnd('div');
224     }
225
226     function extraHead()
227     {
228         if ($this->page != 1) {
229             $this->element('link', array('rel' => 'canonical',
230                                          'href' => $this->group->homeUrl()));
231         }
232     }
233 }