コード例 #1
0
 public function render()
 {
     require_celerity_resource('ponder-core-view-css');
     require_celerity_resource('ponder-feed-view-css');
     $user = $this->user;
     $aoffset = $this->answeroffset;
     $answers = $this->answers;
     $uri = $this->uri;
     $aparam = $this->aparam;
     $pagesize = $this->pagesize;
     $apagebuttons = id(new AphrontPagerView())->setPageSize($pagesize)->setOffset($aoffset)->setURI($uri->setFragment('answers'), $aparam);
     $answers = $apagebuttons->sliceResults($answers);
     $view = new PhabricatorObjectItemListView();
     $view->setNoDataString(pht('No matching answers.'));
     foreach ($answers as $answer) {
         $question = $answer->getQuestion();
         $author_phid = $question->getAuthorPHID();
         $item = new PhabricatorObjectItemView();
         $href = id(new PhutilURI('/Q' . $question->getID()))->setFragment('A' . $answer->getID());
         $item->setHeader('A' . $answer->getID() . ' ' . self::abbreviate($answer->getContent()));
         $item->setHref($href);
         $item->addDetail(pht('Votes'), $answer->getVoteCount());
         $item->addDetail(pht('Question'), self::abbreviate($question->getTitle()));
         $item->addAttribute(pht('Created %s', phabricator_date($answer->getDateCreated(), $user)));
         $view->addItem($item);
     }
     $view->appendChild($apagebuttons);
     return $view->render();
 }
コード例 #2
0
 private function buildQuestionListView(array $questions)
 {
     assert_instances_of($questions, 'PonderQuestion');
     $user = $this->getRequest()->getUser();
     $view = new PhabricatorObjectItemListView();
     $view->setNoDataString(pht('No matching questions.'));
     foreach ($questions as $question) {
         $item = new PhabricatorObjectItemView();
         $item->setHeader('Q' . $question->getID() . ' ' . $question->getTitle());
         $item->setHref('/Q' . $question->getID());
         $desc = $question->getContent();
         if ($desc) {
             $item->addDetail(pht('Description'), phutil_escape_html(phutil_utf8_shorten($desc, 128)));
         }
         $item->addDetail(pht('Author'), $this->getHandle($question->getAuthorPHID())->renderLink());
         $item->addDetail(pht('Votes'), $question->getVoteCount());
         $item->addDetail(pht('Answers'), $question->getAnswerCount());
         $created = pht('Created %s', phabricator_date($question->getDateCreated(), $user));
         $item->addAttribute($created);
         $view->addItem($item);
     }
     return $view;
 }