4 * StatusNet, the distributed open-source microblogging tool
6 * Widget to show a list of groups
10 * LICENCE: This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Evan Prodromou <evan@status.net>
26 * @copyright 2008-2009 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('STATUSNET') && !defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/widget.php';
38 * Widget to show a list of groups
42 * @author Evan Prodromou <evan@status.net>
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44 * @link http://status.net/
47 class GroupList extends Widget
49 /** Current group, group query. */
51 /** Owner of this list */
53 /** Action object using us. */
56 function __construct($group, $owner=null, $action=null)
58 parent::__construct($action);
60 $this->group = $group;
61 $this->owner = $owner;
62 $this->action = $action;
67 $this->out->elementStart('ul', 'profiles groups xoxo');
71 while ($this->group->fetch()) {
73 if($cnt > GROUPS_PER_PAGE) {
79 $this->out->elementEnd('ul');
86 $this->out->elementStart('li', array('class' => 'profile h-card',
87 'id' => 'group-' . $this->group->id));
89 $user = common_current_user();
91 $this->out->elementStart('div', 'entity_profile');
93 $logo = $this->group->stream_logo ?: User_group::defaultLogo(AVATAR_STREAM_SIZE);
95 $this->out->elementStart('a', array('href' => $this->group->homeUrl(),
96 'class' => 'u-url p-nickname',
97 'rel' => 'contact group'));
98 $this->out->element('img', array('src' => $logo,
99 'class' => 'avatar u-photo',
100 'width' => AVATAR_STREAM_SIZE,
101 'height' => AVATAR_STREAM_SIZE,
102 'alt' => $this->group->getBestName()));
103 $this->out->text($this->group->getNickname());
104 $this->out->elementEnd('a');
106 if ($this->group->fullname) {
107 $this->out->text(' ');
108 $this->out->elementStart('span', 'p-name');
109 $this->out->raw($this->highlight($this->group->fullname));
110 $this->out->elementEnd('span');
112 if ($this->group->location) {
113 $this->out->text(' ');
114 $this->out->elementStart('span', 'label');
115 $this->out->raw($this->highlight($this->group->location));
116 $this->out->elementEnd('span');
118 if ($this->group->homepage) {
119 $this->out->text(' ');
120 $this->out->elementStart('a', array('href' => $this->group->homepage,
121 'class' => 'u-url'));
122 $this->out->raw($this->highlight($this->group->homepage));
123 $this->out->elementEnd('a');
125 if ($this->group->description) {
126 $this->out->elementStart('p', 'note');
127 $this->out->raw($this->highlight($this->group->description));
128 $this->out->elementEnd('p');
131 // If we're on a list with an owner (subscriptions or subscribers)...
133 if (!empty($user) && !empty($this->owner) && $user->id == $this->owner->id) {
134 $this->showOwnerControls();
137 $this->out->elementEnd('div');
140 $this->out->elementStart('div', 'entity_actions');
141 $this->out->elementStart('ul');
142 $this->out->elementStart('li', 'entity_subscribe');
143 // XXX: special-case for user looking at own
144 // subscriptions page
145 if ($user->isMember($this->group)) {
146 $lf = new LeaveForm($this->out, $this->group);
148 } else if (!Group_block::isBlocked($this->group, $user->getProfile())) {
149 $jf = new JoinForm($this->out, $this->group);
152 $this->out->elementEnd('li');
153 $this->out->elementEnd('ul');
154 $this->out->elementEnd('div');
157 $this->out->elementEnd('li');
160 /* Override this in subclasses. */
162 function showOwnerControls()
167 function highlight($text)
169 return htmlspecialchars($text);