Path: blob/master/src/applications/diffusion/controller/DiffusionHistoryController.php
12242 views
<?php12final class DiffusionHistoryController extends DiffusionController {34public function shouldAllowPublic() {5return true;6}78public function handleRequest(AphrontRequest $request) {9$response = $this->loadDiffusionContext();10if ($response) {11return $response;12}13require_celerity_resource('diffusion-css');1415$viewer = $this->getViewer();16$drequest = $this->getDiffusionRequest();17$repository = $drequest->getRepository();1819$pager = id(new PHUIPagerView())20->readFromRequest($request);2122$params = array(23'commit' => $drequest->getCommit(),24'path' => $drequest->getPath(),25'offset' => $pager->getOffset(),26'limit' => $pager->getPageSize() + 1,27);2829$history_results = $this->callConduitWithDiffusionRequest(30'diffusion.historyquery',31$params);32$history = DiffusionPathChange::newFromConduit(33$history_results['pathChanges']);3435$history = $pager->sliceResults($history);3637$history_list = id(new DiffusionCommitGraphView())38->setViewer($viewer)39->setDiffusionRequest($drequest)40->setHistory($history);4142// NOTE: If we have a path (like "src/"), many nodes in the graph are43// likely to be missing (since the path wasn't touched by those commits).4445// If we draw the graph, commits will often appear to be unrelated because46// intermediate nodes are omitted. Just drop the graph.4748// The ideal behavior would be to load the entire graph and then connect49// ancestors appropriately, but this would currrently be prohibitively50// expensive in the general case.5152$show_graph = ($drequest->getPath() === null53|| !strlen($drequest->getPath()));54if ($show_graph) {55$history_list56->setParents($history_results['parents'])57->setIsHead(!$pager->getOffset())58->setIsTail(!$pager->getHasMorePages());59}6061$header = $this->buildHeader($drequest);6263$crumbs = $this->buildCrumbs(64array(65'branch' => true,66'path' => true,67'view' => 'history',68));69$crumbs->setBorder(true);7071$title = array(72pht('History'),73$repository->getDisplayName(),74);7576$pager = id(new PHUIBoxView())77->addClass('mlb')78->appendChild($pager);7980$tabs = $this->buildTabsView('history');8182$view = id(new PHUITwoColumnView())83->setHeader($header)84->setTabs($tabs)85->setFooter(array(86$history_list,87$pager,88));8990return $this->newPage()91->setTitle($title)92->setCrumbs($crumbs)93->appendChild($view)94->addClass('diffusion-history-view');95}9697private function buildHeader(DiffusionRequest $drequest) {98$viewer = $this->getViewer();99$repository = $drequest->getRepository();100101$no_path = $drequest->getPath() === null || !strlen($drequest->getPath());102if ($no_path) {103$header_text = pht('History');104} else {105$header_text = $this->renderPathLinks($drequest, $mode = 'history');106}107108$header = id(new PHUIHeaderView())109->setUser($viewer)110->setHeader($header_text)111->setHeaderIcon('fa-clock-o');112113if (!$repository->isSVN()) {114$branch_tag = $this->renderBranchTag($drequest);115$header->addTag($branch_tag);116}117118if ($drequest->getSymbolicCommit()) {119$symbolic_tag = $this->renderSymbolicCommit($drequest);120$header->addTag($symbolic_tag);121}122123return $header;124125}126127}128129130