1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 11:22:40 +01:00
phorge-phorge/src/applications/diffusion/controller/DiffusionPathCompleteController.php

48 lines
1.3 KiB
PHP
Raw Normal View History

2011-04-04 04:20:47 +02:00
<?php
final class DiffusionPathCompleteController extends DiffusionController {
2011-04-04 04:20:47 +02:00
protected function getRepositoryIdentifierFromRequest(
AphrontRequest $request) {
return $request->getStr('repositoryPHID');
2011-04-04 04:20:47 +02:00
}
public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContext();
if ($response) {
return $response;
2011-04-04 04:20:47 +02:00
}
$viewer = $this->getViewer();
$drequest = $this->getDiffusionRequest();
2011-04-04 04:20:47 +02:00
$query_path = $request->getStr('q');
if (preg_match('@/$@', $query_path)) {
$query_dir = $query_path;
} else {
$query_dir = dirname($query_path).'/';
2011-04-04 04:20:47 +02:00
}
$query_dir = ltrim($query_dir, '/');
2011-04-04 04:20:47 +02:00
$browse_results = DiffusionBrowseResultSet::newFromConduit(
$this->callConduitWithDiffusionRequest(
'diffusion.browsequery',
array(
'path' => $query_dir,
'commit' => $drequest->getCommit(),
)));
$paths = $browse_results->getPaths();
2011-04-04 04:20:47 +02:00
$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);
}
}