Changeset View
Changeset View
Standalone View
Standalone View
src/applications/ponder/controller/PonderQuestionViewController.php
| Show All 38 Lines | if ($question->getStatus() == PonderQuestionStatus::STATUS_OPEN) { | ||||
| $question->getStatus()); | $question->getStatus()); | ||||
| $icon = PonderQuestionStatus::getQuestionStatusIcon( | $icon = PonderQuestionStatus::getQuestionStatusIcon( | ||||
| $question->getStatus()); | $question->getStatus()); | ||||
| $header->setStatus($icon, 'dark', $text); | $header->setStatus($icon, 'dark', $text); | ||||
| } | } | ||||
| $actions = $this->buildActionListView($question); | $actions = $this->buildActionListView($question); | ||||
| $properties = $this->buildPropertyListView($question, $actions); | $properties = $this->buildPropertyListView($question, $actions); | ||||
| $sidebar = $this->buildSidebar($question); | |||||
| $content_id = celerity_generate_unique_node_id(); | $content_id = celerity_generate_unique_node_id(); | ||||
| $timeline = $this->buildTransactionTimeline( | $timeline = $this->buildTransactionTimeline( | ||||
| $question, | $question, | ||||
| id(new PonderQuestionTransactionQuery()) | id(new PonderQuestionTransactionQuery()) | ||||
| ->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))); | ->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))); | ||||
| $xactions = $timeline->getTransactions(); | $xactions = $timeline->getTransactions(); | ||||
| Show All 20 Lines | $footer = id(new PonderFooterView()) | ||||
| ->setContentID($content_id) | ->setContentID($content_id) | ||||
| ->setCount(count($xactions)); | ->setCount(count($xactions)); | ||||
| $object_box = id(new PHUIObjectBoxView()) | $object_box = id(new PHUIObjectBoxView()) | ||||
| ->setHeader($header) | ->setHeader($header) | ||||
| ->addPropertyList($properties) | ->addPropertyList($properties) | ||||
| ->appendChild($footer); | ->appendChild($footer); | ||||
| if ($viewer->getPHID() == $question->getAuthorPHID()) { | |||||
| $status = $question->getStatus(); | |||||
| $answers_list = $question->getAnswers(); | |||||
| if ($answers_list && ($status == PonderQuestionStatus::STATUS_OPEN)) { | |||||
| $info_view = id(new PHUIInfoView()) | |||||
| ->setSeverity(PHUIInfoView::SEVERITY_WARNING) | |||||
| ->appendChild( | |||||
| pht( | |||||
| 'If this question has been resolved, please consider closing | |||||
| the question and marking the answer as helpful.')); | |||||
| $object_box->setInfoView($info_view); | |||||
| } | |||||
| } | |||||
| $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView()); | $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView()); | ||||
| $crumbs->addTextCrumb('Q'.$id, '/Q'.$id); | $crumbs->addTextCrumb('Q'.$id, '/Q'.$id); | ||||
| $answer_wiki = null; | $answer_wiki = null; | ||||
| if ($question->getAnswerWiki()) { | if ($question->getAnswerWiki()) { | ||||
| $answer = phutil_tag_div('mlt mlb msr msl', $question->getAnswerWiki()); | $answer = phutil_tag_div('mlt mlb msr msl', $question->getAnswerWiki()); | ||||
| $answer_wiki = id(new PHUIObjectBoxView()) | $answer_wiki = id(new PHUIObjectBoxView()) | ||||
| ->setHeaderText(pht('Answer Summary')) | ->setHeaderText(pht('Answer Summary')) | ||||
| ->setColor(PHUIObjectBoxView::COLOR_BLUE) | ->setColor(PHUIObjectBoxView::COLOR_BLUE) | ||||
| ->appendChild($answer); | ->appendChild($answer); | ||||
| } | } | ||||
| $ponder_view = id(new PHUITwoColumnView()) | return $this->buildApplicationPage( | ||||
| ->setMainColumn(array( | array( | ||||
| $crumbs, | |||||
| $object_box, | $object_box, | ||||
| $comment_view, | $comment_view, | ||||
| $answer_wiki, | $answer_wiki, | ||||
| $answers, | $answers, | ||||
| $answer_add_panel, | $answer_add_panel, | ||||
| )) | |||||
| ->setSideColumn($sidebar) | |||||
| ->addClass('ponder-question-view'); | |||||
| return $this->buildApplicationPage( | |||||
| array( | |||||
| $crumbs, | |||||
| $ponder_view, | |||||
| ), | ), | ||||
| array( | array( | ||||
| 'title' => 'Q'.$question->getID().' '.$question->getTitle(), | 'title' => 'Q'.$question->getID().' '.$question->getTitle(), | ||||
| 'pageObjects' => array_merge( | 'pageObjects' => array_merge( | ||||
| array($question->getPHID()), | array($question->getPHID()), | ||||
| mpull($question->getAnswers(), 'getPHID')), | mpull($question->getAnswers(), 'getPHID')), | ||||
| )); | )); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | foreach ($answers_sort as $answer) { | ||||
| ->setTimeline($timeline) | ->setTimeline($timeline) | ||||
| ->setHandle($handle); | ->setHandle($handle); | ||||
| } | } | ||||
| return $view; | return $view; | ||||
| } | } | ||||
| private function buildSidebar(PonderQuestion $question) { | |||||
| $viewer = $this->getViewer(); | |||||
| $status = $question->getStatus(); | |||||
| $id = $question->getID(); | |||||
| $questions = id(new PonderQuestionQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withStatuses(array($status)) | |||||
| ->withEdgeLogicPHIDs( | |||||
| PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, | |||||
| PhabricatorQueryConstraint::OPERATOR_OR, | |||||
| $question->getProjectPHIDs()) | |||||
| ->setLimit(10) | |||||
| ->execute(); | |||||
| $list = id(new PHUIObjectItemListView()) | |||||
| ->setUser($viewer) | |||||
| ->setNoDataString(pht('No similar questions found.')); | |||||
| foreach ($questions as $question) { | |||||
| if ($id == $question->getID()) { | |||||
| continue; | |||||
| } | |||||
| $item = new PHUIObjectItemView(); | |||||
| $item->setObjectName('Q'.$question->getID()); | |||||
| $item->setHeader($question->getTitle()); | |||||
| $item->setHref('/Q'.$question->getID()); | |||||
| $item->setObject($question); | |||||
| $item->addAttribute( | |||||
| pht( | |||||
| '%s Answer(s)', | |||||
| new PhutilNumber($question->getAnswerCount()))); | |||||
| $list->addItem($item); | |||||
| } | |||||
| $box = id(new PHUIObjectBoxView()) | |||||
| ->setHeaderText(pht('Similar Questions')) | |||||
| ->setObjectList($list); | |||||
| return $box; | |||||
| } | |||||
| } | } | ||||