$page = 1;
}
- $notice = $user->noticesWithFriends($page);
- # XXX: revisit constant scope
+ $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+
+ common_element_start('ul', array('id' => 'notices'));
- $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
+ $cnt = 0;
-
- if ($cnt > 0) {
- common_element_start('ul', array('id' => 'notices'));
- for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
- if ($notice->fetch()) {
- $this->show_notice($notice);
- } else {
- // shouldn't happen!
- break;
- }
+ while ($notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
+ $cnt++;
+
+ if ($cnt > NOTICES_PER_PAGE) {
+ break;
}
- common_element_end('ul');
+
+ $this->show_notice($notice);
}
+ common_element_end('ul');
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
- $page, 'all', array('nickname' => $profile->nickname));
+ $page, 'all', array('nickname' => $user->nickname));
}
}