Page MenuHomePhabricator

D14903.id.diff
No OneTemporary

D14903.id.diff

diff --git a/src/applications/phame/controller/post/PhamePostViewController.php b/src/applications/phame/controller/post/PhamePostViewController.php
--- a/src/applications/phame/controller/post/PhamePostViewController.php
+++ b/src/applications/phame/controller/post/PhamePostViewController.php
@@ -120,15 +120,29 @@
$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 @@
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);
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 19, 7:57 PM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6721776
Default Alt Text
D14903.id.diff (1 KB)

Event Timeline