X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fprofilelist.php;h=fdc71ab8df78f349340a3673ad967a05be5bded0;hb=0b9cda03d5c5d4dac96e862115a10bcb11c2a597;hp=ebc974d6b9b991c23ba6a8eb2f615733dc2184c7;hpb=c10a2e3fe29eb7cea1ac9bc18877b100896626e3;p=quix0rs-gnu-social.git diff --git a/lib/profilelist.php b/lib/profilelist.php index ebc974d6b9..fdc71ab8df 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -1,10 +1,13 @@ . + * + * @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); } +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/widget.php'; define('PROFILES_PER_PAGE', 20); -class ProfileList { - - var $profile = NULL; - - function __construct($profile) { - $this->profile = $profile; - } - - function show_list() { - - common_element_start('ul', array('id' => 'profiles')); - - $cnt = 0; - - while ($this->profile->fetch()) { - $cnt++; - if($cnt > PROFILES_PER_PAGE) { - break; - } - $this->show(); - } - - common_element_end('ul'); - - return $cnt; - } - - function show() { - - $this->profile = $this->profile; - - common_element_start('li', array('class' => 'profile_single', - 'id' => 'profile-' . $this->profile->id)); - $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE); - common_element_start('a', array('href' => $this->profile->profileurl)); - common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE), - 'class' => 'avatar stream', - 'width' => AVATAR_STREAM_SIZE, - 'height' => AVATAR_STREAM_SIZE, - 'alt' => - ($this->profile->fullname) ? $this->profile->fullname : - $this->profile->nickname)); - common_element_end('a'); - common_element_start('p'); - common_element_start('a', array('href' => $this->profile->profileurl, - 'class' => 'nickname')); - common_raw($this->highlight($this->profile->nickname)); - common_element_end('a'); - if ($this->profile->fullname) { - common_text(' | '); - common_element_start('span', 'fullname'); - common_raw($this->highlight($this->profile->fullname)); - common_element_end('span'); - } - if ($this->profile->location) { - common_text(' | '); - common_element_start('span', 'location'); - common_raw($this->highlight($this->profile->location)); - common_element_end('span'); - } - common_element_end('p'); - if ($this->profile->homepage) { - common_element_start('p', 'website'); - common_element_start('a', array('href' => $this->profile->homepage)); - common_raw($this->highlight($this->profile->homepage)); - common_element_end('a'); - common_element_end('p'); - } - if ($this->profile->bio) { - common_element_start('p', 'bio'); - common_raw($this->highlight($this->profile->bio)); - common_element_end('p'); - } - common_element_end('li'); - } - - function highlight($text) { - return htmlspecialchars($text); - } +/** + * Widget to show a list of profiles + * + * @category Public + * @package Laconica + * @author Zach Copley + * @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 ProfileList extends Widget +{ + /** Current profile, profile query. */ + var $profile = null; + /** Owner of this list */ + var $owner = null; + /** Action object using us. */ + var $action = null; + + function __construct($profile, $owner=null, $action=null) + { + parent::__construct($action); + + $this->profile = $profile; + $this->owner = $owner; + $this->action = $action; + } + + function show() + { + + $this->out->elementStart('ul', array('id' => 'profiles', 'class' => 'profile_list')); + + $cnt = 0; + + while ($this->profile->fetch()) { + $cnt++; + if($cnt > PROFILES_PER_PAGE) { + break; + } + $this->showProfile(); + } + + $this->out->elementEnd('ul'); + + return $cnt; + } + + function showProfile() + { + $this->out->elementStart('li', array('class' => 'profile_single', + 'id' => 'profile-' . $this->profile->id)); + + $user = common_current_user(); + + if ($user && $user->id != $this->profile->id) { + # XXX: special-case for user looking at own + # subscriptions page + if ($user->isSubscribed($this->profile)) { + $usf = new UnsubscribeForm($this->out, $this->profile); + $usf->show(); + } else { + $sf = new SubscribeForm($this->out, $this->profile); + $sf->show(); + } + } + + $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE); + $this->out->elementStart('a', array('href' => $this->profile->profileurl)); + $this->out->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE), + 'class' => 'avatar stream', + 'width' => AVATAR_STREAM_SIZE, + 'height' => AVATAR_STREAM_SIZE, + 'alt' => + ($this->profile->fullname) ? $this->profile->fullname : + $this->profile->nickname)); + $this->out->elementEnd('a'); + $this->out->elementStart('p'); + $this->out->elementStart('a', array('href' => $this->profile->profileurl, + 'class' => 'nickname')); + $this->out->raw($this->highlight($this->profile->nickname)); + $this->out->elementEnd('a'); + if ($this->profile->fullname) { + $this->out->text(' | '); + $this->out->elementStart('span', 'fullname'); + $this->out->raw($this->highlight($this->profile->fullname)); + $this->out->elementEnd('span'); + } + if ($this->profile->location) { + $this->out->text(' | '); + $this->out->elementStart('span', 'location'); + $this->out->raw($this->highlight($this->profile->location)); + $this->out->elementEnd('span'); + } + $this->out->elementEnd('p'); + if ($this->profile->homepage) { + $this->out->elementStart('p', 'website'); + $this->out->elementStart('a', array('href' => $this->profile->homepage)); + $this->out->raw($this->highlight($this->profile->homepage)); + $this->out->elementEnd('a'); + $this->out->elementEnd('p'); + } + if ($this->profile->bio) { + $this->out->elementStart('p', 'bio'); + $this->out->raw($this->highlight($this->profile->bio)); + $this->out->elementEnd('p'); + } + + # If we're on a list with an owner (subscriptions or subscribers)... + + if ($this->owner) { + # Get tags + $tags = Profile_tag::getTags($this->owner->id, $this->profile->id); + + $this->out->elementStart('div', 'tags_user'); + $this->out->elementStart('dl'); + $this->out->elementStart('dt'); + if ($user->id == $this->owner->id) { + $this->out->element('a', array('href' => common_local_url('tagother', + array('id' => $this->profile->id))), + _('Tags')); + } else { + $this->out->text(_('Tags')); + } + $this->out->text(":"); + $this->out->elementEnd('dt'); + $this->out->elementStart('dd'); + if ($tags) { + $this->out->elementStart('ul', 'tags xoxo'); + foreach ($tags as $tag) { + $this->out->elementStart('li'); + $this->out->element('a', array('rel' => 'tag', + 'href' => common_local_url($this->action, + array('nickname' => $this->owner->nickname, + 'tag' => $tag))), + $tag); + $this->out->elementEnd('li'); + } + $this->out->elementEnd('ul'); + } else { + $this->out->text(_('(none)')); + } + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); + $this->out->elementEnd('div'); + } + + if ($user && $user->id == $this->owner->id) { + $this->showOwnerControls($this->profile); + } + + $this->out->elementEnd('li'); + } + + /* Override this in subclasses. */ + + function showOwnerControls($profile) + { + return; + } + + function highlight($text) + { + return htmlspecialchars($text); + } } \ No newline at end of file