]> 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     public function getStream()
80     {
81         if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
82             $stream = new GroupNoticeStream($this->group, $this->scoped);
83         } else {
84             $stream = new ThreadingGroupNoticeStream($this->group, $this->scoped);
85         }
86
87         return $stream;
88     }
89
90     /**
91      * Get a list of the feeds for this page
92      *
93      * @return void
94      */
95     function getFeeds()
96     {
97         $url =
98           common_local_url('grouprss',
99                            array('nickname' => $this->group->nickname));
100
101         return array(new Feed(Feed::JSON,
102                               common_local_url('ApiTimelineGroup',
103                                                array('format' => 'as',
104                                                      'id' => $this->group->id)),
105                               // TRANS: Tooltip for feed link. %s is a group nickname.
106                               sprintf(_('Notice feed for %s group (Activity Streams JSON)'),
107                                       $this->group->nickname)),
108                     new Feed(Feed::RSS1,
109                               common_local_url('grouprss',
110                                                array('nickname' => $this->group->nickname)),
111                               // TRANS: Tooltip for feed link. %s is a group nickname.
112                               sprintf(_('Notice feed for %s group (RSS 1.0)'),
113                                       $this->group->nickname)),
114                      new Feed(Feed::RSS2,
115                               common_local_url('ApiTimelineGroup',
116                                                array('format' => 'rss',
117                                                      'id' => $this->group->id)),
118                               // TRANS: Tooltip for feed link. %s is a group nickname.
119                               sprintf(_('Notice feed for %s group (RSS 2.0)'),
120                                       $this->group->nickname)),
121                      new Feed(Feed::ATOM,
122                               common_local_url('ApiTimelineGroup',
123                                                array('format' => 'atom',
124                                                      'id' => $this->group->id)),
125                               // TRANS: Tooltip for feed link. %s is a group nickname.
126                               sprintf(_('Notice feed for %s group (Atom)'),
127                                       $this->group->nickname)),
128                      new Feed(Feed::FOAF,
129                               common_local_url('foafgroup',
130                                                array('nickname' => $this->group->nickname)),
131                               // TRANS: Tooltip for feed link. %s is a group nickname.
132                               sprintf(_('FOAF for %s group'),
133                                        $this->group->nickname)));
134     }
135
136     function showAnonymousMessage()
137     {
138         if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
139             // TRANS: Notice on group pages for anonymous users for StatusNet sites that accept new registrations.
140             // TRANS: %s is the group name, %%%%site.name%%%% is the site name,
141             // TRANS: %%%%action.register%%%% is the URL for registration, %%%%doc.help%%%% is a URL to help.
142             // TRANS: This message contains Markdown links. Ensure they are formatted correctly: [Description](link).
143             $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
144                 'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
145                 'short messages about their life and interests. '.
146                 '[Join now](%%%%action.register%%%%) to become part of this group and many more! ([Read more](%%%%doc.help%%%%))'),
147                      $this->group->getBestName());
148         } else {
149             // TRANS: Notice on group pages for anonymous users for StatusNet sites that accept no new registrations.
150             // TRANS: %s is the group name, %%%%site.name%%%% is the site name,
151             // TRANS: This message contains Markdown links. Ensure they are formatted correctly: [Description](link).
152             $m = sprintf(_('**%s** is a user group on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
153                 'based on the Free Software [StatusNet](http://status.net/) tool. Its members share ' .
154                 'short messages about their life and interests.'),
155                      $this->group->getBestName());
156         }
157         $this->elementStart('div', array('id' => 'anon_notice'));
158         $this->raw(common_markup_to_html($m));
159         $this->elementEnd('div');
160     }
161
162     function extraHead()
163     {
164         if ($this->page != 1) {
165             $this->element('link', array('rel' => 'canonical',
166                                          'href' => $this->group->homeUrl()));
167         }
168     }
169 }