1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 05:12:41 +01:00

Rough data fetch for previous/next posts on a blog

Summary: Ref T9897. Not pretty, but pulls data.

Test Plan: {F1046464}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9897

Differential Revision: https://secure.phabricator.com/D14903
This commit is contained in:
epriestley 2015-12-28 06:30:25 -08:00
parent e0a97c88db
commit abd60eeee0

View file

@ -120,15 +120,29 @@ final class PhamePostViewController
$add_comment = phutil_tag_div('mlb mlt', $add_comment);
}
list($prev, $next) = $this->loadAdjacentPosts($post);
$properties = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($post);
if ($next) {
$properties->addProperty(
pht('Later Posts'),
$viewer->renderHandleList(mpull($next, 'getPHID')));
}
if ($prev) {
$properties->addProperty(
pht('Earlier Posts'),
$viewer->renderHandleList(mpull($prev, 'getPHID')));
}
$properties->invokeWillRenderEvent();
$crumbs = $this->buildApplicationCrumbs();
$page = $this->newPage()
$page = $this->newPage()
->setTitle($post->getTitle())
->setPageObjectPHIDs(array($post->getPHID()))
->setCrumbs($crumbs)
@ -236,4 +250,24 @@ final class PhamePostViewController
return phutil_tag_div('phui-document-view-pro-box', $box);
}
private function loadAdjacentPosts(PhamePost $post) {
$viewer = $this->getViewer();
$query = id(new PhamePostQuery())
->setViewer($viewer)
->withVisibility(PhameConstants::VISIBILITY_PUBLISHED)
->withBlogPHIDs(array($post->getBlog()->getPHID()))
->setLimit(2);
$prev = id(clone $query)
->setAfterID($post->getID())
->execute();
$next = id(clone $query)
->setBeforeID($post->getID())
->execute();
return array($prev, $next);
}
}