123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- require_once INSTALLDIR . '/lib/ui/widget.php';
- class GroupList extends Widget
- {
-
- var $group = null;
-
- var $owner = null;
-
- var $action = null;
- function __construct($group, $owner=null, $action=null)
- {
- parent::__construct($action);
- $this->group = $group;
- $this->owner = $owner;
- $this->action = $action;
- }
- function show()
- {
- $this->out->elementStart('ul', 'profiles groups xoxo');
- $cnt = 0;
- while ($this->group->fetch()) {
- $cnt++;
- if($cnt > GROUPS_PER_PAGE) {
- break;
- }
- $this->showgroup();
- }
- $this->out->elementEnd('ul');
- return $cnt;
- }
- function showGroup()
- {
- $this->out->elementStart('li', array('class' => 'profile h-card',
- 'id' => 'group-' . $this->group->id));
- $user = common_current_user();
- $this->out->elementStart('div', 'entity_profile');
- $logo = $this->group->stream_logo ?: User_group::defaultLogo(AVATAR_STREAM_SIZE);
- $this->out->elementStart('a', array('href' => $this->group->homeUrl(),
- 'class' => 'u-url p-nickname',
- 'rel' => 'contact group'));
- $this->out->element('img', array('src' => $logo,
- 'class' => 'avatar u-photo',
- 'width' => AVATAR_STREAM_SIZE,
- 'height' => AVATAR_STREAM_SIZE,
- 'alt' => $this->group->getBestName()));
- $this->out->text($this->group->getNickname());
- $this->out->elementEnd('a');
- if ($this->group->fullname) {
- $this->out->text(' ');
- $this->out->elementStart('span', 'p-name');
- $this->out->raw($this->highlight($this->group->fullname));
- $this->out->elementEnd('span');
- }
- if ($this->group->location) {
- $this->out->text(' ');
- $this->out->elementStart('span', 'label');
- $this->out->raw($this->highlight($this->group->location));
- $this->out->elementEnd('span');
- }
- if ($this->group->homepage) {
- $this->out->text(' ');
- $this->out->elementStart('a', array('href' => $this->group->homepage,
- 'class' => 'u-url'));
- $this->out->raw($this->highlight($this->group->homepage));
- $this->out->elementEnd('a');
- }
- if ($this->group->description) {
- $this->out->elementStart('p', 'note');
- $this->out->raw($this->highlight($this->group->description));
- $this->out->elementEnd('p');
- }
-
- if (!empty($user) && !empty($this->owner) && $user->id == $this->owner->id) {
- $this->showOwnerControls();
- }
- $this->out->elementEnd('div');
- if ($user) {
- $this->out->elementStart('div', 'entity_actions');
- $this->out->elementStart('ul');
- $this->out->elementStart('li', 'entity_subscribe');
-
-
- if ($user->isMember($this->group)) {
- $lf = new LeaveForm($this->out, $this->group);
- $lf->show();
- } else if (!Group_block::isBlocked($this->group, $user->getProfile())) {
- $jf = new JoinForm($this->out, $this->group);
- $jf->show();
- }
- $this->out->elementEnd('li');
- $this->out->elementEnd('ul');
- $this->out->elementEnd('div');
- }
- $this->out->elementEnd('li');
- }
-
- function showOwnerControls()
- {
- return;
- }
- function highlight($text)
- {
- return htmlspecialchars($text);
- }
- }
|