Changeset View
Changeset View
Standalone View
Standalone View
src/applications/ponder/controller/PonderQuestionViewController.php
Show First 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | final class PonderQuestionViewController extends PonderController { | ||||
* answers) is tricky business. | * answers) is tricky business. | ||||
* | * | ||||
* TODO - re-factor this to ajax in one answer panel at a time in a more | * TODO - re-factor this to ajax in one answer panel at a time in a more | ||||
* standard fashion. This is necessary to scale this application. | * standard fashion. This is necessary to scale this application. | ||||
*/ | */ | ||||
private function buildAnswers(array $answers) { | private function buildAnswers(array $answers) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$xactions = id(new PonderAnswerTransactionQuery()) | |||||
->setViewer($viewer) | |||||
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT)) | |||||
->withObjectPHIDs(mpull($answers, 'getPHID')) | |||||
->execute(); | |||||
$engine = id(new PhabricatorMarkupEngine()) | |||||
->setViewer($viewer); | |||||
foreach ($xactions as $xaction) { | |||||
if ($xaction->getComment()) { | |||||
$engine->addObject( | |||||
$xaction->getComment(), | |||||
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); | |||||
} | |||||
} | |||||
$engine->process(); | |||||
$xaction_groups = mgroup($xactions, 'getObjectPHID'); | |||||
$author_phids = mpull($answers, 'getAuthorPHID'); | $author_phids = mpull($answers, 'getAuthorPHID'); | ||||
$handles = $this->loadViewerHandles($author_phids); | $handles = $this->loadViewerHandles($author_phids); | ||||
$answers_sort = array_reverse(msort($answers, 'getVoteCount')); | $answers_sort = array_reverse(msort($answers, 'getVoteCount')); | ||||
$view = array(); | $view = array(); | ||||
foreach ($answers_sort as $answer) { | foreach ($answers_sort as $answer) { | ||||
$xactions = idx($xaction_groups, $answer->getPHID(), array()); | |||||
$id = $answer->getID(); | $id = $answer->getID(); | ||||
$handle = $handles[$answer->getAuthorPHID()]; | $handle = $handles[$answer->getAuthorPHID()]; | ||||
$timeline = $this->buildTransactionTimeline( | |||||
$answer, | |||||
id(new PonderAnswerTransactionQuery()) | |||||
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))); | |||||
$xactions = $timeline->getTransactions(); | |||||
$view[] = id(new PonderAnswerView()) | $view[] = id(new PonderAnswerView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setAnswer($answer) | ->setAnswer($answer) | ||||
->setTransactions($xactions) | ->setTransactions($xactions) | ||||
->setHandle($handle) | ->setTimeline($timeline) | ||||
->setMarkupEngine($engine); | ->setHandle($handle); | ||||
} | } | ||||
return $view; | return $view; | ||||
} | } | ||||
private function buildSidebar(PonderQuestion $question) { | private function buildSidebar(PonderQuestion $question) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |