diff --git a/src/applications/ponder/application/PhabricatorApplicationPonder.php b/src/applications/ponder/application/PhabricatorApplicationPonder.php index 843ce14feb..d04d2748be 100644 --- a/src/applications/ponder/application/PhabricatorApplicationPonder.php +++ b/src/applications/ponder/application/PhabricatorApplicationPonder.php @@ -48,7 +48,8 @@ final class PhabricatorApplicationPonder extends PhabricatorApplication { '/Q(?P\d+)' => 'PonderQuestionViewController', '/ponder/' => array( '(?Pfeed/)?' => 'PonderFeedController', - '(?Pprofile)/' => 'PonderFeedController', + '(?Pquestions)/' => 'PonderFeedController', + '(?Panswers)/' => 'PonderFeedController', 'answer/add/' => 'PonderAnswerSaveController', 'answer/preview/' => 'PonderAnswerPreviewController', 'question/ask/' => 'PonderQuestionAskController', diff --git a/src/applications/ponder/controller/PonderController.php b/src/applications/ponder/controller/PonderController.php index 91def1f133..b93c38d416 100644 --- a/src/applications/ponder/controller/PonderController.php +++ b/src/applications/ponder/controller/PonderController.php @@ -46,8 +46,9 @@ abstract class PonderController extends PhabricatorController { $side_nav->addSpacer(); - $side_nav->addLabel('Profile'); - $side_nav->addFilter('profile', 'User Profile'); + $side_nav->addLabel('User'); + $side_nav->addFilter('questions', 'Your Questions'); + $side_nav->addFilter('answers', 'Your Answers'); return $side_nav; } diff --git a/src/applications/ponder/controller/PonderFeedController.php b/src/applications/ponder/controller/PonderFeedController.php index 2fe4cb2d30..40f73ffb35 100644 --- a/src/applications/ponder/controller/PonderFeedController.php +++ b/src/applications/ponder/controller/PonderFeedController.php @@ -39,8 +39,9 @@ final class PonderFeedController extends PonderController { $this->answerOffset = $request->getInt('aoff'); $pages = array( - 'feed' => 'All Questions', - 'profile' => 'User Profile', + 'feed' => 'All Questions', + 'questions' => 'Your Questions', + 'answers' => 'Your Answers', ); $side_nav = $this->buildSideNavView(); @@ -51,10 +52,21 @@ final class PonderFeedController extends PonderController { switch ($this->page) { case 'feed': - $questions = PonderQuestionQuery::loadHottest( - $user, - $this->feedOffset, - self::FEED_PAGE_SIZE + 1); + case 'questions': + + if ($this->page == 'feed') { + $questions = PonderQuestionQuery::loadHottest( + $user, + $this->feedOffset, + self::FEED_PAGE_SIZE + 1); + } else { + $questions = PonderQuestionQuery::loadByAuthor( + $user, + $user->getPHID(), + $this->questionOffset, + self::PROFILE_QUESTION_PAGE_SIZE + 1 + ); + } $this->loadHandles(mpull($questions, 'getAuthorPHID')); @@ -63,14 +75,7 @@ final class PonderFeedController extends PonderController { id(new PhabricatorHeaderView())->setHeader($title)); $side_nav->appendChild($view); break; - case 'profile': - $questions = PonderQuestionQuery::loadByAuthor( - $user, - $user->getPHID(), - $this->questionOffset, - self::PROFILE_QUESTION_PAGE_SIZE + 1 - ); - + case 'answers': $answers = PonderAnswerQuery::loadByAuthorWithQuestions( $user, $user->getPHID(), @@ -84,13 +89,11 @@ final class PonderFeedController extends PonderController { $side_nav->appendChild( id(new PonderUserProfileView()) ->setUser($user) - ->setQuestions($questions) ->setAnswers($answers) ->setHandles($handles) - ->setQuestionOffset($this->questionOffset) ->setAnswerOffset($this->answerOffset) ->setPageSize(self::PROFILE_QUESTION_PAGE_SIZE) - ->setURI(new PhutilURI("/ponder/profile/"), "qoff", "aoff") + ->setURI(new PhutilURI("/ponder/profile/"), "aoff") ); break; } diff --git a/src/applications/ponder/view/PonderUserProfileView.php b/src/applications/ponder/view/PonderUserProfileView.php index ab9e815868..fac3b86871 100644 --- a/src/applications/ponder/view/PonderUserProfileView.php +++ b/src/applications/ponder/view/PonderUserProfileView.php @@ -20,11 +20,9 @@ final class PonderUserProfileView extends AphrontView { private $user; private $questionoffset; private $answeroffset; - private $questions; private $answers; private $pagesize; private $uri; - private $qparam; private $aparam; public function setUser(PhabricatorUser $user) { @@ -42,11 +40,6 @@ final class PonderUserProfileView extends AphrontView { return $this; } - public function setQuestions($data) { - $this->questions = $data; - return $this; - } - public function setAnswers($data) { $this->answers = $data; return $this; @@ -62,9 +55,8 @@ final class PonderUserProfileView extends AphrontView { return $this; } - public function setURI($uri, $qparam, $aparam) { + public function setURI($uri, $aparam) { $this->uri = $uri; - $this->qparam = $qparam; $this->aparam = $aparam; return $this; } @@ -74,52 +66,13 @@ final class PonderUserProfileView extends AphrontView { require_celerity_resource('ponder-feed-view-css'); $user = $this->user; - $qoffset = $this->questionoffset; $aoffset = $this->answeroffset; - $questions = $this->questions; $answers = $this->answers; $handles = $this->handles; $uri = $this->uri; - $qparam = $this->qparam; $aparam = $this->aparam; $pagesize = $this->pagesize; - - // display questions - $question_panel = id(new AphrontPanelView()) - ->setHeader("Your Questions") - ->addClass("ponder-panel"); - - $question_panel->addButton( - phutil_render_tag( - 'a', - array( - 'href' => "/ponder/question/ask/", - 'class' => 'green button', - ), - "Ask a question")); - - $qpagebuttons = id(new AphrontPagerView()) - ->setPageSize($pagesize) - ->setOffset($qoffset) - ->setURI( - $uri->alter( - $aparam, - $aoffset), - $qparam); - - $questions = $qpagebuttons->sliceResults($questions); - - foreach ($questions as $question) { - $cur = id(new PonderQuestionSummaryView()) - ->setUser($user) - ->setQuestion($question) - ->setHandles($handles); - $question_panel->appendChild($cur); - } - - $question_panel->appendChild($qpagebuttons); - // display answers $answer_panel = id(new AphrontPanelView()) ->setHeader("Your Answers") @@ -136,9 +89,6 @@ final class PonderUserProfileView extends AphrontView { ->setOffset($aoffset) ->setURI( $uri - ->alter( - $qparam, - $qoffset) ->setFragment("answers"), $aparam); @@ -154,6 +104,6 @@ final class PonderUserProfileView extends AphrontView { $answer_panel->appendChild($apagebuttons); - return $question_panel->render() . $answer_panel->render(); + return $answer_panel->render(); } }