[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DiffusionDiffController extends DiffusionController { 4 5 public function shouldAllowPublic() { 6 return true; 7 } 8 9 public function willProcessRequest(array $data) { 10 $data = $data + array( 11 'dblob' => $this->getRequest()->getStr('ref'), 12 ); 13 $drequest = DiffusionRequest::newFromAphrontRequestDictionary( 14 $data, 15 $this->getRequest()); 16 17 $this->diffusionRequest = $drequest; 18 } 19 20 public function processRequest() { 21 $drequest = $this->getDiffusionRequest(); 22 $request = $this->getRequest(); 23 $user = $request->getUser(); 24 25 if (!$request->isAjax()) { 26 27 // This request came out of the dropdown menu, either "View Standalone" 28 // or "View Raw File". 29 30 $view = $request->getStr('view'); 31 if ($view == 'r') { 32 $uri = $drequest->generateURI( 33 array( 34 'action' => 'browse', 35 'params' => array( 36 'view' => 'raw', 37 ), 38 )); 39 } else { 40 $uri = $drequest->generateURI( 41 array( 42 'action' => 'change', 43 )); 44 } 45 46 return id(new AphrontRedirectResponse())->setURI($uri); 47 } 48 49 $data = $this->callConduitWithDiffusionRequest( 50 'diffusion.diffquery', 51 array( 52 'commit' => $drequest->getCommit(), 53 'path' => $drequest->getPath(), 54 )); 55 $drequest->updateSymbolicCommit($data['effectiveCommit']); 56 $raw_changes = ArcanistDiffChange::newFromConduit($data['changes']); 57 $diff = DifferentialDiff::newFromRawChanges( 58 $user, 59 $raw_changes); 60 $changesets = $diff->getChangesets(); 61 $changeset = reset($changesets); 62 63 if (!$changeset) { 64 return new Aphront404Response(); 65 } 66 67 $parser = new DifferentialChangesetParser(); 68 $parser->setUser($user); 69 $parser->setChangeset($changeset); 70 $parser->setRenderingReference($drequest->generateURI( 71 array( 72 'action' => 'rendering-ref', 73 ))); 74 75 $parser->setCharacterEncoding($request->getStr('encoding')); 76 $parser->setHighlightAs($request->getStr('highlight')); 77 78 $coverage = $drequest->loadCoverage(); 79 if ($coverage) { 80 $parser->setCoverage($coverage); 81 } 82 83 $pquery = new DiffusionPathIDQuery(array($changeset->getFilename())); 84 $ids = $pquery->loadPathIDs(); 85 $path_id = $ids[$changeset->getFilename()]; 86 87 $parser->setLeftSideCommentMapping($path_id, false); 88 $parser->setRightSideCommentMapping($path_id, true); 89 90 $parser->setWhitespaceMode( 91 DifferentialChangesetParser::WHITESPACE_SHOW_ALL); 92 93 $inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments( 94 $user, 95 $drequest->loadCommit()->getPHID(), 96 $path_id); 97 98 if ($inlines) { 99 foreach ($inlines as $inline) { 100 $parser->parseInlineComment($inline); 101 } 102 103 $phids = mpull($inlines, 'getAuthorPHID'); 104 $handles = $this->loadViewerHandles($phids); 105 $parser->setHandles($handles); 106 } 107 108 $engine = new PhabricatorMarkupEngine(); 109 $engine->setViewer($user); 110 111 foreach ($inlines as $inline) { 112 $engine->addObject( 113 $inline, 114 PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY); 115 } 116 117 $engine->process(); 118 119 $parser->setMarkupEngine($engine); 120 121 $spec = $request->getStr('range'); 122 list($range_s, $range_e, $mask) = 123 DifferentialChangesetParser::parseRangeSpecification($spec); 124 $output = $parser->render($range_s, $range_e, $mask); 125 126 return id(new PhabricatorChangesetResponse()) 127 ->setRenderedChangeset($output); 128 } 129 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |