diff --git a/src/applications/diffusion/controller/DiffusionBrowseFileController.php b/src/applications/diffusion/controller/DiffusionBrowseFileController.php index a6d4582234..63d3a39caf 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseFileController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseFileController.php @@ -210,6 +210,38 @@ final class DiffusionBrowseFileController extends DiffusionController { $rows = $this->buildDisplayRows($text_list, $rev_list, $blame_dict, $needs_blame, $drequest, $file_query, $selected); + $id = celerity_generate_unique_node_id(); + + $projects = $drequest->loadArcanistProjects(); + $langs = array(); + foreach ($projects as $project) { + $ls = $project->getSymbolIndexLanguages(); + if (!$ls) { + continue; + } + $dep_projects = $project->getSymbolIndexProjects(); + $dep_projects = mpull($dep_projects, 'getPHID'); + $dep_projects[] = $project->getPHID(); + foreach ($ls as $lang) { + if (!isset($langs[$lang])) { + $langs[$lang] = array(); + } + $langs[$lang] += $dep_projects + array($project); + } + } + + $lang = last(explode('.', $drequest->getPath())); + + if (isset($langs[$lang])) { + Javelin::initBehavior( + 'repository-crossreference', + array( + 'container' => $id, + 'lang' => $lang, + 'projects' => $langs[$lang], + )); + } + $corpus_table = phutil_render_tag( 'table', array( @@ -220,6 +252,7 @@ final class DiffusionBrowseFileController extends DiffusionController { 'div', array( 'style' => 'padding: 0 2em;', + 'id' => $id, ), $corpus_table); diff --git a/src/applications/diffusion/request/DiffusionRequest.php b/src/applications/diffusion/request/DiffusionRequest.php index 5a02a88fb8..a9c92cb457 100644 --- a/src/applications/diffusion/request/DiffusionRequest.php +++ b/src/applications/diffusion/request/DiffusionRequest.php @@ -41,6 +41,7 @@ abstract class DiffusionRequest { protected $repositoryCommit; protected $repositoryCommitData; protected $stableCommitName; + protected $arcanistProjects; abstract protected function getSupportsBranches(); abstract protected function didInitialize(); @@ -235,6 +236,16 @@ abstract class DiffusionRequest { return $this->repositoryCommit; } + public function loadArcanistProjects() { + if (empty($this->arcanistProjects)) { + $projects = id(new PhabricatorRepositoryArcanistProject())->loadAllWhere( + 'repositoryID = %d', + $this->getRepository()->getID()); + $this->arcanistProjects = $projects; + } + return $this->arcanistProjects; + } + public function loadCommitData() { if (empty($this->repositoryCommitData)) { $commit = $this->loadCommit();