mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
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:
parent
1049feb0ed
commit
b94b16df49
3 changed files with 32 additions and 0 deletions
|
@ -36,6 +36,7 @@ final class PhameHomeController extends PhamePostController {
|
|||
->setViewer($viewer)
|
||||
->withBlogPHIDs($blog_phids)
|
||||
->withVisibility(array(PhameConstants::VISIBILITY_PUBLISHED))
|
||||
->setOrder('datePublished')
|
||||
->executeWithCursorPager($pager);
|
||||
|
||||
if ($posts) {
|
||||
|
|
|
@ -20,6 +20,7 @@ final class PhameBlogViewController extends PhameLiveController {
|
|||
$post_query = id(new PhamePostQuery())
|
||||
->setViewer($viewer)
|
||||
->withBlogPHIDs(array($blog->getPHID()))
|
||||
->setOrder('datePublished')
|
||||
->withVisibility(array(
|
||||
PhameConstants::VISIBILITY_PUBLISHED,
|
||||
PhameConstants::VISIBILITY_DRAFT,
|
||||
|
|
|
@ -122,6 +122,36 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
|||
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() {
|
||||
// TODO: Does setting this break public blogs?
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue