diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-06-12 15:26:50 -0400 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-06-12 15:26:50 -0400 |
commit | 4449ff2051ce7ec09ca8b4371890767cd5ece88f (patch) | |
tree | 1060953e2e20208a34e77eb837b159886a687c42 | |
parent | e13e58a9cfc6783291d88ac3106fa14e42829a1e (diff) |
only show "more subscriptions" link if there really are more subscriptions
darcs-hash:20080612192650-84dde-3bab08162d9e1e6def8712070c509306227ee645.gz
-rw-r--r-- | actions/showstream.php | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/actions/showstream.php b/actions/showstream.php index 56572a8e1..6ff7e41d9 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -203,13 +203,12 @@ class ShowstreamAction extends StreamAction { function show_subscriptions($profile) { global $config; - # XXX: add a limit $subs = DB_DataObject::factory('subscription'); $subs->subscriber = $profile->id; # We ask for an extra one to know if we need to do another page - $subs->limit(0, SUBSCRIPTIONS); + $subs->limit(0, SUBSCRIPTIONS + 1); $subs_count = $subs->find(); @@ -221,7 +220,12 @@ class ShowstreamAction extends StreamAction { common_element_start('ul', array('id' => 'subscriptions_avatars')); - while ($subs->fetch()) { + for ($i = 0; $i < min($subs_count, SUBSCRIPTIONS); $i++) { + + if (!$subs->fetch()) { + common_debug('Weirdly, broke out of subscriptions loop early', __FILE__); + break; + } $other = Profile::staticGet($subs->subscribed); @@ -242,17 +246,19 @@ class ShowstreamAction extends StreamAction { common_element_end('a'); common_element_end('li'); } + common_element_end('ul'); } - common_element_start('p', array('id' => 'subscriptions_viewall')); - - common_element('a', array('href' => common_local_url('subscriptions', - array('nickname' => $profile->nickname)), - 'class' => 'moresubscriptions'), - _t('All subscriptions')); - - common_element_end('p'); + if ($subs_count > SUBSCRIPTIONS) { + common_element_start('p', array('id' => 'subscriptions_viewall')); + + common_element('a', array('href' => common_local_url('subscriptions', + array('nickname' => $profile->nickname)), + 'class' => 'moresubscriptions'), + _t('All subscriptions')); + common_element_end('p'); + } common_element_end('div'); } |