Allow Phame Posts to be ordered by datePublished
Summary: Adds some ordering options to PhamePost queries. Works on search, PhameHome, BlogHome Test Plan: Try searching with Order By set to Date Published in application search, get correct order. Check a blog home page, check PhameHome. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9897 Differential Revision: https://secure.phabricator.com/D16125
This commit is contained in:
@@ -36,6 +36,7 @@ final class PhameHomeController extends PhamePostController {
|
|||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withBlogPHIDs($blog_phids)
|
->withBlogPHIDs($blog_phids)
|
||||||
->withVisibility(array(PhameConstants::VISIBILITY_PUBLISHED))
|
->withVisibility(array(PhameConstants::VISIBILITY_PUBLISHED))
|
||||||
|
->setOrder('datePublished')
|
||||||
->executeWithCursorPager($pager);
|
->executeWithCursorPager($pager);
|
||||||
|
|
||||||
if ($posts) {
|
if ($posts) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ final class PhameBlogViewController extends PhameLiveController {
|
|||||||
$post_query = id(new PhamePostQuery())
|
$post_query = id(new PhamePostQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withBlogPHIDs(array($blog->getPHID()))
|
->withBlogPHIDs(array($blog->getPHID()))
|
||||||
|
->setOrder('datePublished')
|
||||||
->withVisibility(array(
|
->withVisibility(array(
|
||||||
PhameConstants::VISIBILITY_PUBLISHED,
|
PhameConstants::VISIBILITY_PUBLISHED,
|
||||||
PhameConstants::VISIBILITY_DRAFT,
|
PhameConstants::VISIBILITY_DRAFT,
|
||||||
|
|||||||
@@ -122,6 +122,36 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
|||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBuiltinOrders() {
|
||||||
|
return array(
|
||||||
|
'datePublished' => array(
|
||||||
|
'vector' => array('datePublished', 'id'),
|
||||||
|
'name' => pht('Publish Date'),
|
||||||
|
),
|
||||||
|
) + parent::getBuiltinOrders();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrderableColumns() {
|
||||||
|
return parent::getOrderableColumns() + array(
|
||||||
|
'datePublished' => array(
|
||||||
|
'column' => 'datePublished',
|
||||||
|
'type' => 'int',
|
||||||
|
'reverse' => false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPagingValueMap($cursor, array $keys) {
|
||||||
|
$post = $this->loadCursorObject($cursor);
|
||||||
|
|
||||||
|
$map = array(
|
||||||
|
'datePublished' => $post->getDatePublished(),
|
||||||
|
'id' => $post->getID(),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $map;
|
||||||
|
}
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
// TODO: Does setting this break public blogs?
|
// TODO: Does setting this break public blogs?
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user