Change NoticeList::prefill() to a static function

This commit is contained in:
Evan Prodromou 2011-08-02 12:01:41 -04:00
parent 06e2422517
commit 58d798b607
2 changed files with 18 additions and 13 deletions

View File

@ -87,7 +87,7 @@ class NoticeList extends Widget
$total = count($notices); $total = count($notices);
$notices = array_slice($notices, 0, NOTICES_PER_PAGE); $notices = array_slice($notices, 0, NOTICES_PER_PAGE);
$this->prefill($notices); self::prefill($notices);
foreach ($notices as $notice) { foreach ($notices as $notice) {
@ -122,10 +122,23 @@ class NoticeList extends Widget
return new NoticeListItem($notice, $this->out); return new NoticeListItem($notice, $this->out);
} }
function prefill(&$notices) static function prefill(&$notices, $avatarSize=AVATAR_STREAM_SIZE)
{ {
// Prefill the profiles // Prefill the profiles
$profiles = Notice::fillProfiles($notices); $profiles = Notice::fillProfiles($notices);
Profile::fillAvatars($profiles, AVATAR_STREAM_SIZE); // Prefill the avatars
Profile::fillAvatars($profiles, $avatarSize);
$p = Profile::current();
$ids = array();
foreach ($notices as $notice) {
$ids[] = $notice->id;
}
if (!empty($p)) {
Memcached_DataObject::pivotGet('Fave', 'notice_id', $ids, array('user_id' => $p->id));
}
} }
} }

View File

@ -80,7 +80,7 @@ class ThreadedNoticeList extends NoticeList
$total = count($notices); $total = count($notices);
$notices = array_slice($notices, 0, NOTICES_PER_PAGE); $notices = array_slice($notices, 0, NOTICES_PER_PAGE);
$this->prefill($notices); self::prefill($notices);
$conversations = array(); $conversations = array();
@ -224,8 +224,7 @@ class ThreadedNoticeListItem extends NoticeListItem
$item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out, count($notices)); $item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out, count($notices));
$item->show(); $item->show();
} }
// XXX: replicating NoticeList::prefill(), annoyingly NoticeList::prefill($notices, AVATAR_MINI_SIZE);
$this->prefill($notices);
foreach (array_reverse($notices) as $notice) { foreach (array_reverse($notices) as $notice) {
if (Event::handle('StartShowThreadedNoticeSub', array($this, $this->notice, $notice))) { if (Event::handle('StartShowThreadedNoticeSub', array($this, $this->notice, $notice))) {
$item = new ThreadedNoticeListSubItem($notice, $this->notice, $this->out); $item = new ThreadedNoticeListSubItem($notice, $this->notice, $this->out);
@ -250,13 +249,6 @@ class ThreadedNoticeListItem extends NoticeListItem
parent::showEnd(); parent::showEnd();
} }
function prefill(&$notices)
{
// Prefill the profiles
$profiles = Notice::fillProfiles($notices);
Profile::fillAvatars($profiles, AVATAR_MINI_SIZE);
}
} }
// @todo FIXME: needs documentation. // @todo FIXME: needs documentation.