public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $this->answerOffset = $request->getInt('aoff');
     $pages = array('feed' => 'All Questions', 'questions' => 'Your Questions', 'answers' => 'Your Answers');
     $side_nav = $this->buildSideNavView();
     $this->page = $side_nav->selectFilter($this->page, 'feed');
     $title = $pages[$this->page];
     switch ($this->page) {
         case 'feed':
         case 'questions':
             $pager = new AphrontPagerView();
             $pager->setOffset($request->getStr('offset'));
             $pager->setURI($request->getRequestURI(), 'offset');
             $query = new PonderQuestionQuery();
             if ($this->page == 'feed') {
                 $query->setOrder(PonderQuestionQuery::ORDER_HOTTEST);
             } else {
                 $query->setOrder(PonderQuestionQuery::ORDER_CREATED)->withAuthorPHIDs(array($user->getPHID()));
             }
             $questions = $query->executeWithOffsetPager($pager);
             $this->loadHandles(mpull($questions, 'getAuthorPHID'));
             $view = $this->buildQuestionListView($questions);
             $view->setPager($pager);
             $side_nav->appendChild(id(new PhabricatorHeaderView())->setHeader($title));
             $side_nav->appendChild($view);
             break;
         case 'answers':
             $answers = PonderAnswerQuery::loadByAuthorWithQuestions($user, $user->getPHID(), $this->answerOffset, self::PROFILE_ANSWER_PAGE_SIZE + 1);
             $side_nav->appendChild(id(new PonderUserProfileView())->setUser($user)->setAnswers($answers)->setAnswerOffset($this->answerOffset)->setPageSize(self::PROFILE_ANSWER_PAGE_SIZE)->setURI(new PhutilURI("/ponder/profile/"), "aoff"));
             break;
     }
     return $this->buildApplicationPage($side_nav, array('device' => true, 'title' => $title));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $newvote = $request->getInt("vote");
     $phid = $request->getStr("phid");
     if (1 < $newvote || $newvote < -1) {
         return new Aphront400Response();
     }
     $target = null;
     if ($this->kind == "question") {
         $target = PonderQuestionQuery::loadSingleByPHID($user, $phid);
     } else {
         if ($this->kind == "answer") {
             $target = PonderAnswerQuery::loadSingleByPHID($user, $phid);
         }
     }
     if (!$target) {
         return new Aphront404Response();
     }
     $editor = id(new PonderVoteEditor())->setVotable($target)->setUser($user)->setVote($newvote)->saveVote();
     return id(new AphrontAjaxResponse())->setContent(".");
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $this->feedOffset = $request->getInt('off');
     $this->questionOffset = $request->getInt('qoff');
     $this->answerOffset = $request->getInt('aoff');
     $side_nav = new AphrontSideNavView();
     foreach (self::$pages as $pagename => $pagetitle) {
         $class = "";
         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);
     }
     switch ($this->page) {
         case self::PAGE_FEED:
             $data = PonderQuestionQuery::loadHottest($user, $this->feedOffset, self::FEED_PAGE_SIZE + 1);
             $phids = array();
             foreach ($data as $question) {
                 $phids[] = $question->getAuthorPHID();
             }
             $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
             $side_nav->appendChild(id(new PonderQuestionFeedView())->setUser($user)->setData($data)->setHandles($handles)->setOffset($this->feedOffset)->setPageSize(self::FEED_PAGE_SIZE)->setURI(new PhutilURI("/ponder/feed/"), "off"));
             break;
         case self::PAGE_PROFILE:
             $questions = PonderQuestionQuery::loadByAuthor($user, $user->getPHID(), $this->questionOffset, self::PROFILE_QUESTION_PAGE_SIZE + 1);
             $answers = PonderAnswerQuery::loadByAuthorWithQuestions($user, $user->getPHID(), $this->answerOffset, self::PROFILE_ANSWER_PAGE_SIZE + 1);
             $phids = array($user->getPHID());
             $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
             $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"));
             break;
     }
     return $this->buildStandardPageResponse($side_nav, array('title' => self::$pages[$this->page]));
 }