1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-25 22:18:19 +01:00

Move Ponder to AphrontSideNavFilterView

Summary: AphrontSideNavView is oldschool and I want to kill it.

Test Plan: Viewed Ponder, clicked both nav options.

Reviewers: pieter, vrana, btrahan

Reviewed By: pieter

CC: aran

Differential Revision: https://secure.phabricator.com/D3430
This commit is contained in:
epriestley 2012-09-05 11:41:19 -07:00
parent dbc8218f06
commit 9afb186c77

View file

@ -22,31 +22,13 @@ final class PonderFeedController extends PonderController {
private $questionOffset; private $questionOffset;
private $answerOffset; private $answerOffset;
const PAGE_FEED = "feed";
const PAGE_PROFILE = "profile";
const FEED_PAGE_SIZE = 20; const FEED_PAGE_SIZE = 20;
const PROFILE_QUESTION_PAGE_SIZE = 10; const PROFILE_QUESTION_PAGE_SIZE = 10;
const PROFILE_ANSWER_PAGE_SIZE = 10; const PROFILE_ANSWER_PAGE_SIZE = 10;
static $pages = array(
self::PAGE_FEED => "Popular Questions",
self::PAGE_PROFILE => "User Profile"
);
public function willProcessRequest(array $data) { public function willProcessRequest(array $data) {
if (isset($data['page'])) { $this->page = idx($data, 'page');
$this->page = $data['page']; $this->feedOffset = idx($data, 'feedoffset');
}
if (!isset(self::$pages[$this->page])) {
$this->page = self::PAGE_FEED;
}
$this->feedOffset = 0;
if (isset($data['feedoffset'])) {
$this->feedOffset = $data['feedoffset'];
}
} }
public function processRequest() { public function processRequest() {
@ -56,27 +38,21 @@ final class PonderFeedController extends PonderController {
$this->questionOffset = $request->getInt('qoff'); $this->questionOffset = $request->getInt('qoff');
$this->answerOffset = $request->getInt('aoff'); $this->answerOffset = $request->getInt('aoff');
$side_nav = new AphrontSideNavView(); $pages = array(
foreach (self::$pages as $pagename => $pagetitle) { 'feed' => 'Popular Questions',
$class = ""; 'profile' => 'User Profile',
if ($pagename == $this->page) {
$class = 'aphront-side-nav-selected';
}
$linky = phutil_render_tag(
'a',
array(
'href' => '/ponder/'.$pagename .'/',
'class' => $class
),
phutil_escape_html($pagetitle)
); );
$side_nav->addNavItem($linky); $side_nav = new AphrontSideNavFilterView();
$side_nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
foreach ($pages as $name => $title) {
$side_nav->addFilter($name, $title);
} }
$this->page = $side_nav->selectFilter($this->page, 'feed');
switch ($this->page) { switch ($this->page) {
case self::PAGE_FEED: case 'feed':
$data = PonderQuestionQuery::loadHottest( $data = PonderQuestionQuery::loadHottest(
$user, $user,
$this->feedOffset, $this->feedOffset,
@ -98,7 +74,7 @@ final class PonderFeedController extends PonderController {
->setURI(new PhutilURI("/ponder/feed/"), "off") ->setURI(new PhutilURI("/ponder/feed/"), "off")
); );
break; break;
case self::PAGE_PROFILE: case 'profile':
$questions = PonderQuestionQuery::loadByAuthor( $questions = PonderQuestionQuery::loadByAuthor(
$user, $user,
$user->getPHID(), $user->getPHID(),
@ -134,7 +110,7 @@ final class PonderFeedController extends PonderController {
return $this->buildStandardPageResponse( return $this->buildStandardPageResponse(
$side_nav, $side_nav,
array( array(
'title' => self::$pages[$this->page] 'title' => $pages[$this->page]
)); ));
} }