diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-11-20 07:31:46 -0500 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-11-20 07:31:46 -0500 |
commit | c10a2e3fe29eb7cea1ac9bc18877b100896626e3 (patch) | |
tree | 009a4328b06122c310d4bf8d420fe3e2574e35e0 | |
parent | c7dbb1d53a7f1c8559e06d1c69c2817a12c5d411 (diff) |
stop trying to get count from query
darcs-hash:20081120123146-84dde-299808e2ed7a793a8240ab1c54e71b27f51307c4.gz
-rw-r--r-- | lib/gallery.php | 49 | ||||
-rw-r--r-- | lib/profilelist.php | 2 |
2 files changed, 32 insertions, 19 deletions
diff --git a/lib/gallery.php b/lib/gallery.php index 5914745f7..f9d0b31fa 100644 --- a/lib/gallery.php +++ b/lib/gallery.php @@ -97,41 +97,50 @@ class GalleryAction extends Action { # XXX: memcached results - $cnt = $other->query('SELECT profile.* ' . - 'FROM profile JOIN subscription ' . - 'ON profile.id = subscription.' . $lst . ' ' . - 'WHERE ' . $usr . ' = ' . $profile->id . ' ' . - 'AND subscriber != subscribed ' . - 'ORDER BY subscription.created DESC ' . - $lim); + $other->query('SELECT profile.* ' . + 'FROM profile JOIN subscription ' . + 'ON profile.id = subscription.' . $lst . ' ' . + 'WHERE ' . $usr . ' = ' . $profile->id . ' ' . + 'AND subscriber != subscribed ' . + 'ORDER BY subscription.created DESC ' . + $lim); - if ($cnt == 0) { - common_element('p', 'error', _('Nobody to show!')); - return; - } - if ($display == 'list') { $profile_list = new ProfileList($other); - $profile_list->show_list(); + $cnt = $profile_list->show_list(); } else { - $this->icon_list($profile, $cnt); + $cnt = $this->icon_list($other); + } + + # For building the pagination URLs + + $args = array('nickname' => $profile->nickname); + + if ($display != 'list') { + $args['display'] = $display; } common_pagination($page > 1, $cnt > $per_page, $page, $this->trimmed('action'), - array('nickname' => $profile->nickname)); + $args); } - function icon_list($other, $subs_count) { + function icon_list($other) { common_element_start('ul', $this->div_class()); - - for ($idx = 0; $idx < min($subs_count, AVATARS_PER_PAGE); $idx++) { - $other->fetch(); + $cnt = 0; + + while ($other->fetch()) { + $cnt++; + + if ($cnt > AVATARS_PER_PAGE) { + break; + } + common_element_start('li'); common_element_start('a', array('title' => ($other->fullname) ? @@ -158,6 +167,8 @@ class GalleryAction extends Action { } common_element_end('ul'); + + return $cnt; } function gallery_type() { diff --git a/lib/profilelist.php b/lib/profilelist.php index 15ac2a6da..ebc974d6b 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -45,6 +45,8 @@ class ProfileList { } common_element_end('ul'); + + return $cnt; } function show() { |