mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 03:12:41 +01:00
3cbc239bc6
Summary: Ref T4245. This gets everything else except serving HTTP requests (complicated) and lint (quite weird). Test Plan: - Viewed a diff. - Viewed externals. - Viewed history table to see last modified. - Did path completion and validation in Owners. - Did tree path search in Diffusion. - Viewed a repository. - Created a new repository. - Looked up symbols. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4245 Differential Revision: https://secure.phabricator.com/D14947
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class DiffusionPathCompleteController extends DiffusionController {
|
|
|
|
protected function getRepositoryIdentifierFromRequest(
|
|
AphrontRequest $request) {
|
|
return $request->getStr('repositoryPHID');
|
|
}
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$response = $this->loadDiffusionContext();
|
|
if ($response) {
|
|
return $response;
|
|
}
|
|
|
|
$viewer = $this->getViewer();
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$query_path = $request->getStr('q');
|
|
if (preg_match('@/$@', $query_path)) {
|
|
$query_dir = $query_path;
|
|
} else {
|
|
$query_dir = dirname($query_path).'/';
|
|
}
|
|
$query_dir = ltrim($query_dir, '/');
|
|
|
|
$browse_results = DiffusionBrowseResultSet::newFromConduit(
|
|
$this->callConduitWithDiffusionRequest(
|
|
'diffusion.browsequery',
|
|
array(
|
|
'path' => $query_dir,
|
|
'commit' => $drequest->getCommit(),
|
|
)));
|
|
$paths = $browse_results->getPaths();
|
|
|
|
$output = array();
|
|
foreach ($paths as $path) {
|
|
$full_path = $query_dir.$path->getPath();
|
|
if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
|
|
$full_path .= '/';
|
|
}
|
|
$output[] = array('/'.$full_path, null, substr(md5($full_path), 0, 7));
|
|
}
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($output);
|
|
}
|
|
}
|