コード例 #1
0
 private function buildSubheaderView(PonderQuestion $question)
 {
     $viewer = $this->getViewer();
     $asker = $viewer->renderHandle($question->getAuthorPHID())->render();
     $date = phabricator_datetime($question->getDateCreated(), $viewer);
     $asker = phutil_tag('strong', array(), $asker);
     $author = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withPHIDs(array($question->getAuthorPHID()))->needProfileImage(true)->executeOne();
     $image_uri = $author->getProfileImageURI();
     $image_href = '/p/' . $author->getUsername();
     $content = pht('Asked by %s on %s.', $asker, $date);
     return id(new PHUIHeadThingView())->setImage($image_uri)->setImageHref($image_href)->setContent($content);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 private function buildPropertyListView(PonderQuestion $question, array $subscribers)
 {
     $viewer = $this->getRequest()->getUser();
     $view = new PhabricatorPropertyListView();
     $view->addProperty(pht('Author'), $this->getHandle($question->getAuthorPHID())->renderLink());
     $view->addProperty(pht('Created'), phabricator_datetime($question->getDateCreated(), $viewer));
     if ($subscribers) {
         foreach ($subscribers as $key => $subscriber) {
             $subscribers[$key] = $this->getHandle($subscriber)->renderLink();
         }
         $subscribers = implode(', ', $subscribers);
     }
     $view->addProperty(pht('Subscribers'), nonempty($subscribers, '<em>' . pht('None') . '</em>'));
     return $view;
 }
コード例 #4
0
 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);
 }