public static function indexQuestion(PonderQuestion $question) { // note: we assume someone's already called attachrelated on $question $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($question->getPHID()); $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_QUES); $doc->setDocumentTitle($question->getTitle()); $doc->setDocumentCreated($question->getDateCreated()); $doc->setDocumentModified($question->getDateModified()); $doc->addField(PhabricatorSearchField::FIELD_BODY, $question->getContent()); $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $question->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_USER, $question->getDateCreated()); $comments = $question->getComments(); foreach ($comments as $curcomment) { $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $curcomment->getContent()); } $answers = $question->getAnswers(); foreach ($answers as $curanswer) { if (strlen($curanswer->getContent())) { $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $curanswer->getContent()); } $answer_comments = $curanswer->getComments(); foreach ($answer_comments as $curcomment) { $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $curcomment->getContent()); } } self::reindexAbstractDocument($doc); }
private function buildQuestionTransactions(PonderQuestion $question) { $viewer = $this->getRequest()->getUser(); $id = $question->getID(); $xactions = id(new PonderQuestionTransactionQuery())->setViewer($viewer)->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))->withObjectPHIDs(array($question->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(); $timeline = id(new PhabricatorApplicationTransactionView())->setUser($viewer)->setObjectPHID($question->getPHID())->setTransactions($xactions)->setMarkupEngine($engine); $add_comment = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($question->getPHID())->setShowPreview(false)->setHeaderText(pht('Question Comment'))->setAction($this->getApplicationURI("/question/comment/{$id}/"))->setSubmitButtonName(pht('Comment')); return $this->wrapComments(count($xactions), array($timeline, $add_comment)); }
public static function indexQuestion(PonderQuestion $question) { $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($question->getPHID()); $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_QUES); $doc->setDocumentTitle($question->getTitle()); $doc->setDocumentCreated($question->getDateCreated()); $doc->setDocumentModified($question->getDateModified()); $doc->addField(PhabricatorSearchField::FIELD_BODY, $question->getContent()); $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $question->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_USER, $question->getDateCreated()); $answers = $question->getAnswers(); $touches = array(); foreach ($answers as $comment) { if (strlen($comment->getContent())) { $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $comment->getContent()); } $author = $comment->getAuthorPHID(); $touches[$author] = $comment->getDateCreated(); } self::reindexAbstractDocument($doc); }