]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Directory/lib/sortablesubscriptionlist.php
don't use fetchAll() when you've done a query()
[quix0rs-gnu-social.git] / plugins / Directory / lib / sortablesubscriptionlist.php
index 7685c86a6a160780068a1d3d4afe65fbccb517b9..750a0f2491e96ad82c58724f6d65b6dbb8eed175 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * StatusNet, the distributed open-source microblogging tool
  *
@@ -43,7 +42,6 @@ require_once INSTALLDIR . '/lib/subscriptionlist.php';
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
-
 class SortableSubscriptionList extends SubscriptionList
 {
     /** Owner of this list */
@@ -63,7 +61,9 @@ class SortableSubscriptionList extends SubscriptionList
         $this->out->elementStart('tr');
 
         $tableHeaders = array(
+            // TRANS: Column header in table for user nickname.
             'nickname'    => _m('Nickname'),
+            // TRANS: Column header in table for timestamp when user was created.
             'created'     => _m('Created')
         );
 
@@ -110,8 +110,10 @@ class SortableSubscriptionList extends SubscriptionList
             $this->out->elementEnd('th');
         }
 
-        $this->out->element('th', array('id' => 'subscriptions'), 'Subscriptions');
-        $this->out->element('th', array('id' => 'notices'), 'Notices');
+        // TRANS: Column header for number of subscriptions.
+        $this->out->element('th', array('id' => 'subscriptions'), _m('Subscriptions'));
+        // TRANS: Column header for number of notices.
+        $this->out->element('th', array('id' => 'notices'), _m('Notices'));
         $this->out->element('th', array('id' => 'controls'), null);
 
         $this->out->elementEnd('tr');
@@ -128,17 +130,21 @@ class SortableSubscriptionList extends SubscriptionList
 
     function showProfiles()
     {
-        $cnt = 0;
+        // Note: we don't use fetchAll() because it's borked with query()
+
+        $profiles = array();
 
         while ($this->profile->fetch()) {
-            $cnt++;
-            if($cnt > PROFILES_PER_PAGE) {
-                break;
-            }
+            $profiles[] = clone($this->profile);
+        }
+
+        $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();
         }
 
@@ -280,5 +286,4 @@ class SortableSubscriptionListItem extends SubscriptionListItem
         }
 
     }
-
 }