private function buildFeedView(array $phids) { $request = $this->getRequest(); $user = $request->getUser(); $user_phid = $user->getPHID(); $feed_query = new PhabricatorFeedQuery(); if ($phids) { $feed_query->setFilterPHIDs($phids); } // TODO: All this limit stuff should probably be consolidated into the // feed query? $old_link = null; $new_link = null; $feed_query->setAfter($request->getStr('after')); $feed_query->setBefore($request->getStr('before')); $limit = 500; // Grab one more story than we intend to display so we can figure out // if we need to render an "Older Posts" link or not (with reasonable // accuracy, at least). $feed_query->setLimit($limit + 1); $feed = $feed_query->execute(); $extra_row = count($feed) == $limit + 1; $have_new = $request->getStr('before') || $request->getStr('after') && $extra_row; $have_old = $request->getStr('after') || $request->getStr('before') && $extra_row || !$request->getStr('before') && !$request->getStr('after') && $extra_row; $feed = array_slice($feed, 0, $limit, $preserve_keys = true); if ($have_old) { $old_link = phutil_render_tag('a', array('href' => '?before=' . end($feed)->getChronologicalKey(), 'class' => 'phabricator-feed-older-link'), "Older Stories »"); } if ($have_new) { $new_link = phutil_render_tag('a', array('href' => '?after=' . reset($feed)->getChronologicalKey(), 'class' => 'phabricator-feed-newer-link'), "« Newer Stories"); } $builder = new PhabricatorFeedBuilder($feed); $builder->setUser($user); $feed_view = $builder->buildView(); return '<div style="padding: 1em 3em;">' . '<div style="margin: 0 1em;">' . '<h1 style="font-size: 18px; ' . 'border-bottom: 1px solid #aaaaaa; ' . 'padding: 0;">Feed</h1>' . '</div>' . $feed_view->render() . '<div class="phabricator-feed-frame">' . $new_link . $old_link . '</div>' . '</div>'; }