diff --git a/lib/groupminilist.php b/lib/groupminilist.php new file mode 100644 index 0000000000..e4d4c68fd1 --- /dev/null +++ b/lib/groupminilist.php @@ -0,0 +1,92 @@ +. + * + * @category Public + * @package Laconica + * @author Evan Prodromou + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/grouplist.php'; + +define('GROUPS_PER_MINILIST', 80); + +/** + * Widget to show a list of groups, good for sidebar + * + * @category Public + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class GroupMiniList extends GroupList +{ + function show() + { + $this->out->elementStart('ul', 'groups'); + + $cnt = 0; + + while ($this->group->fetch()) { + $cnt++; + if($cnt > GROUPS_PER_MINILIST) { + break; + } + $this->showGroup(); + } + + $this->out->elementEnd('ul'); + + return $cnt; + } + + function showGroup() + { + $this->out->elementStart('li', 'vcard'); + $this->out->elementStart('a', array('title' => ($this->group->fullname) ? + $this->group->fullname : + $this->group->nickname, + 'href' => $this->group->homeUrl(), + 'rel' => 'contact', + 'class' => 'url')); + $logo = ($this->group->stream_logo) ? + $this->group->stream_logo : User_group::defaultLogo(AVATAR_STREAM_SIZE); + + $this->out->element('img', array('src' => $logo, + 'width' => AVATAR_MINI_SIZE, + 'height' => AVATAR_MINI_SIZE, + 'class' => 'avatar photo', + 'alt' => ($this->group->fullname) ? + $this->group->fullname : + $this->group->nickname)); + $this->out->element('span', 'fn nickname', $this->group->nickname); + $this->out->elementEnd('a'); + $this->out->elementEnd('li'); + } +}