diff --git a/src/applications/phame/controller/PhameHomeController.php b/src/applications/phame/controller/PhameHomeController.php --- a/src/applications/phame/controller/PhameHomeController.php +++ b/src/applications/phame/controller/PhameHomeController.php @@ -36,6 +36,7 @@ ->setViewer($viewer) ->withBlogPHIDs($blog_phids) ->withVisibility(array(PhameConstants::VISIBILITY_PUBLISHED)) + ->setOrder('datePublished') ->executeWithCursorPager($pager); if ($posts) { diff --git a/src/applications/phame/controller/blog/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php --- a/src/applications/phame/controller/blog/PhameBlogViewController.php +++ b/src/applications/phame/controller/blog/PhameBlogViewController.php @@ -20,6 +20,7 @@ $post_query = id(new PhamePostQuery()) ->setViewer($viewer) ->withBlogPHIDs(array($blog->getPHID())) + ->setOrder('datePublished') ->withVisibility(array( PhameConstants::VISIBILITY_PUBLISHED, PhameConstants::VISIBILITY_DRAFT, diff --git a/src/applications/phame/query/PhamePostQuery.php b/src/applications/phame/query/PhamePostQuery.php --- a/src/applications/phame/query/PhamePostQuery.php +++ b/src/applications/phame/query/PhamePostQuery.php @@ -122,6 +122,36 @@ 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;