]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/profilelist.php
use an array of profiles rather than a looping cursor for profile lists
[quix0rs-gnu-social.git] / lib / profilelist.php
index 90e1c743a5e063da7cfea5fa3d633f0852967fa2..9039d1b6d87cdced07fe4eaaed98a7b3c6e3113e 100644 (file)
@@ -85,14 +85,14 @@ class ProfileList extends Widget
 
     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();
         }
 
@@ -101,7 +101,17 @@ class ProfileList extends Widget
 
     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;
     }
 }
 
@@ -186,7 +196,7 @@ class ProfileListItem extends Widget
         $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,