return $this->_user;
}
- protected $_avatars = array();
+ protected $_avatars;
function getAvatar($width, $height=null)
{
$height = $width;
}
+ if (!isset($this->_avatars)) {
+ $this->_avatars = array();
+ }
+
if (array_key_exists($width, $this->_avatars)) {
return $this->_avatars[$width];
}
function showProfiles()
{
- $cnt = 0;
+ $profiles = $this->profile->fetchAll();
- while ($this->profile->fetch()) {
- $cnt++;
- if($cnt > PROFILES_PER_PAGE) {
- break;
- }
- $pli = $this->newListItem($this->profile);
+ $cnt = count($profiles);
+
+ $max = min($cnt, $this->maxProfiles());
+
+ for ($i = 0; $i < $max; $i++) {
+ $pli = $this->newListItem($profiles[$i]);
$pli->show();
}
function newListItem($profile)
{
- return new ProfileListItem($this->profile, $this->action);
+ return new ProfileListItem($profile, $this->action);
+ }
+
+ function maxProfiles()
+ {
+ return PROFILES_PER_PAGE;
+ }
+
+ function avatarSize()
+ {
+ return AVATAR_STREAM_SIZE;
}
}
$avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
$aAttrs = $this->linkAttributes();
$this->out->elementStart('a', $aAttrs);
- $this->out->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE),
+ $this->out->element('img', array('src' => (!empty($avatar)) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE),
'class' => 'photo avatar',
'width' => AVATAR_STREAM_SIZE,
'height' => AVATAR_STREAM_SIZE,
return new ProfileMiniListItem($profile, $this->action);
}
- function showProfiles()
+ function maxProfiles()
{
- $cnt = 0;
-
- while ($this->profile->fetch()) {
- $cnt++;
- if ($cnt > PROFILES_PER_MINILIST) {
- break;
- }
- $pli = $this->newListItem($this->profile);
- $pli->show();
- }
-
- return $cnt;
+ return PROFILES_PER_MINILIST;
}
+ function avatarSize()
+ {
+ return AVATAR_MINI_SIZE;
+ }
}
class ProfileMiniListItem extends ProfileListItem
function showProfiles()
{
- $cnt = 0;
+ $profiles = $this->profile->fetchAll();
- while ($this->profile->fetch()) {
- $cnt++;
- if($cnt > PROFILES_PER_PAGE) {
- break;
- }
+ $cnt = count($profiles);
- $odd = ($cnt % 2 == 0); // for zebra striping
+ $max = min($cnt, $this->maxProfiles());
- $pli = $this->newListItem($this->profile, $odd);
+ for ($i = 0; $i < $max; $i++) {
+ $odd = ($i % 2 == 0); // for zebra striping
+ $pli = $this->newListItem($profiles[$i], $odd);
$pli->show();
}