public function renderView()
 {
     $data = $this->getStoryData();
     $author_phid = $data->getAuthorPHID();
     $commit_phid = $data->getValue('commitPHID');
     $view = new PhabricatorFeedStoryView();
     $action = $data->getValue('action');
     $verb = PhabricatorAuditActionConstants::getActionPastTenseVerb($action);
     $view->setTitle($this->linkTo($author_phid) . " {$verb} commit " . $this->linkTo($commit_phid) . ".");
     $view->setEpoch($data->getEpoch());
     $comments = $data->getValue('content');
     if ($comments) {
         $full_size = true;
     } else {
         $full_size = false;
     }
     if ($full_size) {
         $view->setImage($this->getHandle($author_phid)->getImageURI());
         $content = $this->renderSummary($data->getValue('content'));
         $view->appendChild($content);
     } else {
         $view->setOneLineStory(true);
     }
     return $view;
 }
 public function renderForAsanaBridge($implied_context = false)
 {
     $data = $this->getStoryData();
     $comment = $data->getValue('content');
     $author_name = $this->getHandle($this->getAuthorPHID())->getName();
     $action = $this->getValue('action');
     $verb = PhabricatorAuditActionConstants::getActionPastTenseVerb($action);
     $commit_phid = $this->getPrimaryObjectPHID();
     $commit_name = $this->getHandle($commit_phid)->getFullName();
     if ($implied_context) {
         $title = "{$author_name} {$verb} this commit.";
     } else {
         $title = "{$author_name} {$verb} commit {$commit_name}.";
     }
     if (strlen($comment)) {
         $engine = PhabricatorMarkupEngine::newMarkupEngine(array())->setConfig('viewer', new PhabricatorUser())->setMode(PhutilRemarkupEngine::MODE_TEXT);
         $comment = $engine->markupText($comment);
         $title .= "\n\n";
         $title .= $comment;
     }
     return $title;
 }
Ejemplo n.º 3
0
 private function renderActions()
 {
     $comment = $this->comment;
     $author = $this->getHandle($comment->getActorPHID());
     $author_link = $author->renderLink();
     $action = $comment->getAction();
     $verb = PhabricatorAuditActionConstants::getActionPastTenseVerb($action);
     $metadata = $comment->getMetadata();
     $added_auditors = idx($metadata, PhabricatorAuditComment::METADATA_ADDED_AUDITORS, array());
     $added_ccs = idx($metadata, PhabricatorAuditComment::METADATA_ADDED_CCS, array());
     $actions = array();
     if ($action == PhabricatorAuditActionConstants::ADD_CCS) {
         $rendered_ccs = $this->renderHandleList($added_ccs);
         $actions[] = "{$author_link} added CCs: {$rendered_ccs}.";
     } else {
         if ($action == PhabricatorAuditActionConstants::ADD_AUDITORS) {
             $rendered_auditors = $this->renderHandleList($added_auditors);
             $actions[] = "{$author_link} added auditors: " . "{$rendered_auditors}.";
         } else {
             $actions[] = "{$author_link} " . phutil_escape_html($verb) . " this commit.";
         }
     }
     foreach ($actions as $key => $action) {
         $actions[$key] = '<div>' . $action . '</div>';
     }
     return $actions;
 }
 private function renderMailBody(PhabricatorAuditComment $comment, $cname, PhabricatorObjectHandle $handle, PhabricatorMailReplyHandler $reply_handler, array $inline_comments)
 {
     assert_instances_of($inline_comments, 'PhabricatorInlineCommentInterface');
     $commit = $this->commit;
     $user = $this->user;
     $name = $user->getUsername();
     $verb = PhabricatorAuditActionConstants::getActionPastTenseVerb($comment->getAction());
     $body = array();
     $body[] = "{$name} {$verb} commit {$cname}.";
     if ($comment->getContent()) {
         $body[] = $comment->getContent();
     }
     if ($inline_comments) {
         $block = array();
         $path_map = id(new DiffusionPathQuery())->withPathIDs(mpull($inline_comments, 'getPathID'))->execute();
         $path_map = ipull($path_map, 'path', 'id');
         foreach ($inline_comments as $inline) {
             $path = idx($path_map, $inline->getPathID());
             if ($path === null) {
                 continue;
             }
             $start = $inline->getLineNumber();
             $len = $inline->getLineLength();
             if ($len) {
                 $range = $start . '-' . ($start + $len);
             } else {
                 $range = $start;
             }
             $content = $inline->getContent();
             $block[] = "{$path}:{$range} {$content}";
         }
         $body[] = "INLINE COMMENTS\n  " . implode("\n  ", $block);
     }
     $body[] = "COMMIT\n  " . PhabricatorEnv::getProductionURI($handle->getURI());
     $reply_instructions = $reply_handler->getReplyHandlerInstructions();
     if ($reply_instructions) {
         $body[] = "REPLY HANDLER ACTIONS\n  " . $reply_instructions;
     }
     return implode("\n\n", $body) . "\n";
 }
Ejemplo n.º 5
0
 private function renderActions()
 {
     $comment = $this->comment;
     $author = $this->getHandle($comment->getActorPHID());
     $author_link = $author->renderLink();
     $action = $comment->getAction();
     $verb = PhabricatorAuditActionConstants::getActionPastTenseVerb($action);
     $actions = array();
     $actions[] = "{$author_link} " . phutil_escape_html($verb) . " this commit.";
     foreach ($actions as $key => $action) {
         $actions[$key] = '<div>' . $action . '</div>';
     }
     return $actions;
 }