From 74a1d8b64a59492dccad14edc939266ed8dd4e3d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 21 Jan 2009 13:32:43 -0500 Subject: [PATCH] minilist for groups --- lib/groupminilist.php | 92 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 lib/groupminilist.php 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'); + } +}