Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13977765
D14903.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D14903.id.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D14903: Rough data fetch for previous/next posts on a blog
Attached
Detach File
Event Timeline
Log In to Comment