Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionRepositoryController.php
<?php | <?php | ||||
final class DiffusionRepositoryController extends DiffusionController { | final class DiffusionRepositoryController extends DiffusionController { | ||||
private $historyFuture; | |||||
private $browseFuture; | private $browseFuture; | ||||
private $branchButton = null; | private $branchButton = null; | ||||
private $branchFuture; | private $branchFuture; | ||||
public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | final class DiffusionRepositoryController extends DiffusionController { | ||||
private function buildNormalContent(DiffusionRequest $drequest) { | private function buildNormalContent(DiffusionRequest $drequest) { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
$commit = $drequest->getCommit(); | $commit = $drequest->getCommit(); | ||||
$path = $drequest->getPath(); | $path = $drequest->getPath(); | ||||
$futures = array(); | $futures = array(); | ||||
$this->historyFuture = $this->callConduitMethod( | |||||
'diffusion.historyquery', | |||||
array( | |||||
'commit' => $commit, | |||||
'path' => $path, | |||||
'offset' => 0, | |||||
'limit' => 15, | |||||
)); | |||||
$futures[] = $this->historyFuture; | |||||
$browse_pager = id(new PHUIPagerView()) | $browse_pager = id(new PHUIPagerView()) | ||||
->readFromRequest($request); | ->readFromRequest($request); | ||||
$this->browseFuture = $this->callConduitMethod( | $this->browseFuture = $this->callConduitMethod( | ||||
'diffusion.browsequery', | 'diffusion.browsequery', | ||||
array( | array( | ||||
'commit' => $commit, | 'commit' => $commit, | ||||
Show All 14 Lines | private function buildNormalContent(DiffusionRequest $drequest) { | ||||
} | } | ||||
$futures = array_filter($futures); | $futures = array_filter($futures); | ||||
$futures = new FutureIterator($futures); | $futures = new FutureIterator($futures); | ||||
foreach ($futures as $future) { | foreach ($futures as $future) { | ||||
// Just resolve all the futures before continuing. | // Just resolve all the futures before continuing. | ||||
} | } | ||||
$phids = array(); | |||||
$content = array(); | $content = array(); | ||||
try { | try { | ||||
$history_results = $this->historyFuture->resolve(); | |||||
$history = DiffusionPathChange::newFromConduit( | |||||
$history_results['pathChanges']); | |||||
foreach ($history as $item) { | |||||
$data = $item->getCommitData(); | |||||
if ($data) { | |||||
if ($data->getCommitDetail('authorPHID')) { | |||||
$phids[$data->getCommitDetail('authorPHID')] = true; | |||||
} | |||||
if ($data->getCommitDetail('committerPHID')) { | |||||
$phids[$data->getCommitDetail('committerPHID')] = true; | |||||
} | |||||
} | |||||
} | |||||
$history_exception = null; | |||||
} catch (Exception $ex) { | |||||
$history_results = null; | |||||
$history = null; | |||||
$history_exception = $ex; | |||||
} | |||||
try { | |||||
$browse_results = $this->browseFuture->resolve(); | $browse_results = $this->browseFuture->resolve(); | ||||
$browse_results = DiffusionBrowseResultSet::newFromConduit( | $browse_results = DiffusionBrowseResultSet::newFromConduit( | ||||
$browse_results); | $browse_results); | ||||
$browse_paths = $browse_results->getPaths(); | $browse_paths = $browse_results->getPaths(); | ||||
$browse_paths = $browse_pager->sliceResults($browse_paths); | $browse_paths = $browse_pager->sliceResults($browse_paths); | ||||
foreach ($browse_paths as $item) { | |||||
$data = $item->getLastCommitData(); | |||||
if ($data) { | |||||
if ($data->getCommitDetail('authorPHID')) { | |||||
$phids[$data->getCommitDetail('authorPHID')] = true; | |||||
} | |||||
if ($data->getCommitDetail('committerPHID')) { | |||||
$phids[$data->getCommitDetail('committerPHID')] = true; | |||||
} | |||||
} | |||||
} | |||||
$browse_exception = null; | $browse_exception = null; | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$browse_results = null; | $browse_results = null; | ||||
$browse_paths = null; | $browse_paths = null; | ||||
$browse_exception = $ex; | $browse_exception = $ex; | ||||
} | } | ||||
$phids = array_keys($phids); | |||||
$handles = $this->loadViewerHandles($phids); | |||||
if ($browse_results) { | if ($browse_results) { | ||||
$readme = $this->renderDirectoryReadme($browse_results); | $readme = $this->renderDirectoryReadme($browse_results); | ||||
} else { | } else { | ||||
$readme = null; | $readme = null; | ||||
} | } | ||||
$content[] = $this->buildBrowseTable( | $content[] = $this->buildBrowseTable( | ||||
$browse_results, | $browse_results, | ||||
$browse_paths, | $browse_paths, | ||||
$browse_exception, | $browse_exception, | ||||
$handles, | |||||
$browse_pager); | $browse_pager); | ||||
if ($readme) { | if ($readme) { | ||||
$content[] = $readme; | $content[] = $readme; | ||||
} | } | ||||
try { | try { | ||||
$branch_button = $this->buildBranchList($drequest); | $branch_button = $this->buildBranchList($drequest); | ||||
▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | private function buildLocateFile() { | ||||
} | } | ||||
return $form_box; | return $form_box; | ||||
} | } | ||||
private function buildBrowseTable( | private function buildBrowseTable( | ||||
$browse_results, | $browse_results, | ||||
$browse_paths, | $browse_paths, | ||||
$browse_exception, | $browse_exception, | ||||
array $handles, | |||||
PHUIPagerView $pager) { | PHUIPagerView $pager) { | ||||
require_celerity_resource('diffusion-icons-css'); | require_celerity_resource('diffusion-icons-css'); | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
$drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
$repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
if ($browse_exception) { | if ($browse_exception) { | ||||
if ($repository->isImporting()) { | if ($repository->isImporting()) { | ||||
// The history table renders a useful message. | // The history table renders a useful message. | ||||
return null; | return null; | ||||
} else { | } else { | ||||
return $this->renderStatusMessage( | return $this->renderStatusMessage( | ||||
pht('Unable to Retrieve Paths'), | pht('Unable to Retrieve Paths'), | ||||
$browse_exception->getMessage()); | $browse_exception->getMessage()); | ||||
} | } | ||||
} | } | ||||
$browse_table = id(new DiffusionBrowseTableView()) | $browse_table = id(new DiffusionBrowseTableView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setDiffusionRequest($drequest) | ->setDiffusionRequest($drequest); | ||||
->setHandles($handles); | |||||
if ($browse_paths) { | if ($browse_paths) { | ||||
$browse_table->setPaths($browse_paths); | $browse_table->setPaths($browse_paths); | ||||
} else { | } else { | ||||
$browse_table->setPaths(array()); | $browse_table->setPaths(array()); | ||||
} | } | ||||
$browse_uri = $drequest->generateURI(array('action' => 'browse')); | $browse_uri = $drequest->generateURI(array('action' => 'browse')); | ||||
$pager->setURI($browse_uri, 'offset'); | $pager->setURI($browse_uri, 'offset'); | ||||
Show All 38 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0